31 #include "llvm/ADT/StringExtras.h" 32 #include "llvm/Support/ErrorHandling.h" 33 #include "llvm/Support/raw_ostream.h" 35 using namespace clang;
51 = dyn_cast_or_null<ParmVarDecl>(RD->getLambdaContextDecl()))
52 return ContextParam->getDeclContext();
56 if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
58 = dyn_cast_or_null<ParmVarDecl>(BD->getBlockManglingContextDecl()))
59 return ContextParam->getDeclContext();
63 if (isa<CapturedDecl>(DC) || isa<OMPDeclareReductionDecl>(DC) ||
64 isa<OMPDeclareMapperDecl>(DC)) {
65 return getEffectiveDeclContext(cast<Decl>(DC));
68 if (
const auto *VD = dyn_cast<VarDecl>(D))
70 return VD->getASTContext().getTranslationUnitDecl();
72 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
74 return FD->getASTContext().getTranslationUnitDecl();
80 return getEffectiveDeclContext(cast<Decl>(DC));
83 static bool isLocalContainerContext(
const DeclContext *DC) {
84 return isa<FunctionDecl>(DC) || isa<ObjCMethodDecl>(DC) || isa<BlockDecl>(DC);
90 if (isLocalContainerContext(DC))
91 return dyn_cast<RecordDecl>(D);
93 DC = getEffectiveDeclContext(D);
100 return ftd->getTemplatedDecl();
107 return (fn ? getStructor(fn) :
decl);
110 static bool isLambda(
const NamedDecl *ND) {
118 static const unsigned UnknownArity = ~0U;
121 typedef std::pair<const DeclContext*, IdentifierInfo*> DiscriminatorKeyTy;
122 llvm::DenseMap<DiscriminatorKeyTy, unsigned> Discriminator;
123 llvm::DenseMap<const NamedDecl*, unsigned> Uniquifier;
126 explicit ItaniumMangleContextImpl(
ASTContext &Context,
133 bool shouldMangleCXXName(
const NamedDecl *D)
override;
134 bool shouldMangleStringLiteral(
const StringLiteral *)
override {
137 void mangleCXXName(
const NamedDecl *D, raw_ostream &)
override;
139 raw_ostream &)
override;
142 raw_ostream &)
override;
143 void mangleReferenceTemporary(
const VarDecl *D,
unsigned ManglingNumber,
144 raw_ostream &)
override;
145 void mangleCXXVTable(
const CXXRecordDecl *RD, raw_ostream &)
override;
146 void mangleCXXVTT(
const CXXRecordDecl *RD, raw_ostream &)
override;
149 void mangleCXXRTTI(
QualType T, raw_ostream &)
override;
150 void mangleCXXRTTIName(
QualType T, raw_ostream &)
override;
151 void mangleTypeName(
QualType T, raw_ostream &)
override;
153 raw_ostream &)
override;
155 raw_ostream &)
override;
159 void mangleStaticGuardVariable(
const VarDecl *D, raw_ostream &)
override;
160 void mangleDynamicInitializer(
const VarDecl *D, raw_ostream &Out)
override;
161 void mangleDynamicAtExitDestructor(
const VarDecl *D,
162 raw_ostream &Out)
override;
163 void mangleSEHFilterExpression(
const NamedDecl *EnclosingDecl,
164 raw_ostream &Out)
override;
165 void mangleSEHFinallyBlock(
const NamedDecl *EnclosingDecl,
166 raw_ostream &Out)
override;
167 void mangleItaniumThreadLocalInit(
const VarDecl *D, raw_ostream &)
override;
168 void mangleItaniumThreadLocalWrapper(
const VarDecl *D,
169 raw_ostream &)
override;
171 void mangleStringLiteral(
const StringLiteral *, raw_ostream &)
override;
173 bool getNextDiscriminator(
const NamedDecl *ND,
unsigned &disc) {
179 if (
const TagDecl *Tag = dyn_cast<TagDecl>(ND)) {
180 if (Tag->getName().empty() && !Tag->getTypedefNameForAnonDecl())
186 unsigned discriminator = getASTContext().getManglingNumber(ND);
187 if (discriminator == 1)
189 disc = discriminator - 2;
194 unsigned &discriminator = Uniquifier[ND];
195 if (!discriminator) {
196 const DeclContext *DC = getEffectiveDeclContext(ND);
197 discriminator = ++Discriminator[std::make_pair(DC, ND->
getIdentifier())];
199 if (discriminator == 1)
201 disc = discriminator-2;
208 class CXXNameMangler {
209 ItaniumMangleContextImpl &Context;
211 bool NullOut =
false;
216 bool DisableDerivedAbiTags =
false;
222 unsigned StructorType;
227 class FunctionTypeDepthState {
230 enum { InResultTypeMask = 1 };
233 FunctionTypeDepthState() : Bits(0) {}
236 unsigned getDepth()
const {
241 bool isInResultType()
const {
242 return Bits & InResultTypeMask;
245 FunctionTypeDepthState push() {
246 FunctionTypeDepthState
tmp = *
this;
247 Bits = (Bits & ~InResultTypeMask) + 2;
251 void enterResultType() {
252 Bits |= InResultTypeMask;
255 void leaveResultType() {
256 Bits &= ~InResultTypeMask;
259 void pop(FunctionTypeDepthState saved) {
260 assert(getDepth() == saved.getDepth() + 1);
275 class AbiTagState final {
277 explicit AbiTagState(AbiTagState *&Head) : LinkHead(Head) {
283 AbiTagState(
const AbiTagState &) =
delete;
284 AbiTagState &operator=(
const AbiTagState &) =
delete;
286 ~AbiTagState() { pop(); }
288 void write(raw_ostream &Out,
const NamedDecl *ND,
289 const AbiTagList *AdditionalAbiTags) {
291 if (!isa<FunctionDecl>(ND) && !isa<VarDecl>(ND)) {
293 !AdditionalAbiTags &&
294 "only function and variables need a list of additional abi tags");
295 if (
const auto *NS = dyn_cast<NamespaceDecl>(ND)) {
296 if (
const auto *AbiTag = NS->getAttr<AbiTagAttr>()) {
297 UsedAbiTags.insert(UsedAbiTags.end(), AbiTag->tags().begin(),
298 AbiTag->tags().end());
306 if (
const auto *AbiTag = ND->
getAttr<AbiTagAttr>()) {
307 UsedAbiTags.insert(UsedAbiTags.end(), AbiTag->tags().begin(),
308 AbiTag->tags().end());
309 TagList.insert(TagList.end(), AbiTag->tags().begin(),
310 AbiTag->tags().end());
313 if (AdditionalAbiTags) {
314 UsedAbiTags.insert(UsedAbiTags.end(), AdditionalAbiTags->begin(),
315 AdditionalAbiTags->end());
316 TagList.insert(TagList.end(), AdditionalAbiTags->begin(),
317 AdditionalAbiTags->end());
321 TagList.erase(std::unique(TagList.begin(), TagList.end()), TagList.end());
323 writeSortedUniqueAbiTags(Out, TagList);
326 const AbiTagList &getUsedAbiTags()
const {
return UsedAbiTags; }
327 void setUsedAbiTags(
const AbiTagList &AbiTags) {
328 UsedAbiTags = AbiTags;
331 const AbiTagList &getEmittedAbiTags()
const {
332 return EmittedAbiTags;
335 const AbiTagList &getSortedUniqueUsedAbiTags() {
336 llvm::sort(UsedAbiTags);
337 UsedAbiTags.erase(std::unique(UsedAbiTags.begin(), UsedAbiTags.end()),
344 AbiTagList UsedAbiTags;
346 AbiTagList EmittedAbiTags;
348 AbiTagState *&LinkHead;
349 AbiTagState *
Parent =
nullptr;
352 assert(LinkHead ==
this &&
353 "abi tag link head must point to us on destruction");
355 Parent->UsedAbiTags.insert(Parent->UsedAbiTags.end(),
356 UsedAbiTags.begin(), UsedAbiTags.end());
357 Parent->EmittedAbiTags.insert(Parent->EmittedAbiTags.end(),
358 EmittedAbiTags.begin(),
359 EmittedAbiTags.end());
364 void writeSortedUniqueAbiTags(raw_ostream &Out,
const AbiTagList &AbiTags) {
365 for (
const auto &Tag : AbiTags) {
366 EmittedAbiTags.push_back(Tag);
374 AbiTagState *AbiTags =
nullptr;
375 AbiTagState AbiTagsRoot;
377 llvm::DenseMap<uintptr_t, unsigned> Substitutions;
378 llvm::DenseMap<StringRef, unsigned> ModuleSubstitutions;
380 ASTContext &getASTContext()
const {
return Context.getASTContext(); }
383 CXXNameMangler(ItaniumMangleContextImpl &
C, raw_ostream &Out_,
384 const NamedDecl *D =
nullptr,
bool NullOut_ =
false)
385 : Context(C), Out(Out_), NullOut(NullOut_), Structor(getStructor(D)),
386 StructorType(0), SeqID(0), AbiTagsRoot(AbiTags) {
388 assert(!D || (!isa<CXXDestructorDecl>(D) &&
389 !isa<CXXConstructorDecl>(D)));
391 CXXNameMangler(ItaniumMangleContextImpl &C, raw_ostream &Out_,
393 : Context(C), Out(Out_), Structor(getStructor(D)), StructorType(Type),
394 SeqID(0), AbiTagsRoot(AbiTags) { }
395 CXXNameMangler(ItaniumMangleContextImpl &C, raw_ostream &Out_,
397 : Context(C), Out(Out_), Structor(getStructor(D)), StructorType(Type),
398 SeqID(0), AbiTagsRoot(AbiTags) { }
400 CXXNameMangler(CXXNameMangler &Outer, raw_ostream &Out_)
401 : Context(Outer.Context), Out(Out_), NullOut(
false),
402 Structor(Outer.Structor), StructorType(Outer.StructorType),
403 SeqID(Outer.SeqID), FunctionTypeDepth(Outer.FunctionTypeDepth),
404 AbiTagsRoot(AbiTags), Substitutions(Outer.Substitutions) {}
406 CXXNameMangler(CXXNameMangler &Outer, llvm::raw_null_ostream &Out_)
407 : Context(Outer.Context), Out(Out_), NullOut(
true),
408 Structor(Outer.Structor), StructorType(Outer.StructorType),
409 SeqID(Outer.SeqID), FunctionTypeDepth(Outer.FunctionTypeDepth),
410 AbiTagsRoot(AbiTags), Substitutions(Outer.Substitutions) {}
412 raw_ostream &getStream() {
return Out; }
414 void disableDerivedAbiTags() { DisableDerivedAbiTags =
true; }
415 static bool shouldHaveAbiTags(ItaniumMangleContextImpl &C,
const VarDecl *VD);
418 void mangleCallOffset(int64_t NonVirtual, int64_t Virtual);
419 void mangleNumber(
const llvm::APSInt &I);
420 void mangleNumber(int64_t Number);
421 void mangleFloat(
const llvm::APFloat &F);
423 void mangleSeqID(
unsigned SeqID);
426 void mangleNameOrStandardSubstitution(
const NamedDecl *ND);
430 bool mangleSubstitution(
const NamedDecl *ND);
431 bool mangleSubstitution(
QualType T);
437 bool mangleStandardSubstitution(
const NamedDecl *ND);
439 void addSubstitution(
const NamedDecl *ND) {
442 addSubstitution(reinterpret_cast<uintptr_t>(ND));
448 void extendSubstitutions(CXXNameMangler* Other);
451 bool recursive =
false);
455 unsigned NumTemplateArgs,
456 unsigned KnownArity = UnknownArity);
458 void mangleFunctionEncodingBareType(
const FunctionDecl *FD);
460 void mangleNameWithAbiTags(
const NamedDecl *ND,
461 const AbiTagList *AdditionalAbiTags);
462 void mangleModuleName(
const Module *M);
463 void mangleModuleNamePrefix(StringRef Name);
466 unsigned NumTemplateArgs);
467 void mangleUnqualifiedName(
const NamedDecl *ND,
468 const AbiTagList *AdditionalAbiTags) {
469 mangleUnqualifiedName(ND, ND->
getDeclName(), UnknownArity,
474 const AbiTagList *AdditionalAbiTags);
475 void mangleUnscopedName(
const NamedDecl *ND,
476 const AbiTagList *AdditionalAbiTags);
478 const AbiTagList *AdditionalAbiTags);
480 const AbiTagList *AdditionalAbiTags);
483 void mangleSourceNameWithAbiTags(
484 const NamedDecl *ND,
const AbiTagList *AdditionalAbiTags =
nullptr);
485 void mangleLocalName(
const Decl *D,
486 const AbiTagList *AdditionalAbiTags);
487 void mangleBlockForPrefix(
const BlockDecl *Block);
488 void mangleUnqualifiedBlock(
const BlockDecl *Block);
492 const AbiTagList *AdditionalAbiTags,
493 bool NoFunction=
false);
496 unsigned NumTemplateArgs);
498 void manglePrefix(
const DeclContext *DC,
bool NoFunction=
false);
500 void mangleTemplatePrefix(
const TemplateDecl *ND,
bool NoFunction=
false);
502 bool mangleUnresolvedTypeOrSimpleId(
QualType DestroyedType,
503 StringRef Prefix =
"");
506 void mangleVendorQualifier(StringRef qualifier);
513 #define ABSTRACT_TYPE(CLASS, PARENT) 514 #define NON_CANONICAL_TYPE(CLASS, PARENT) 515 #define TYPE(CLASS, PARENT) void mangleType(const CLASS##Type *T); 516 #include "clang/AST/TypeNodes.def" 518 void mangleType(
const TagType*);
520 static StringRef getCallingConvQualifierName(
CallingConv CC);
521 void mangleExtParameterInfo(FunctionProtoType::ExtParameterInfo info);
525 void mangleNeonVectorType(
const VectorType *T);
527 void mangleAArch64NeonVectorType(
const VectorType *T);
530 void mangleIntegerLiteral(
QualType T,
const llvm::APSInt &
Value);
531 void mangleMemberExprBase(
const Expr *base,
bool isArrow);
532 void mangleMemberExpr(
const Expr *base,
bool isArrow,
537 unsigned NumTemplateArgs,
538 unsigned knownArity);
539 void mangleCastExpression(
const Expr *E, StringRef CastEncoding);
540 void mangleInitListElements(
const InitListExpr *InitList);
541 void mangleDeclRefExpr(
const NamedDecl *D);
542 void mangleExpression(
const Expr *E,
unsigned Arity = UnknownArity);
547 unsigned NumTemplateArgs);
549 unsigned NumTemplateArgs);
553 void mangleTemplateParameter(
unsigned Index);
558 const AbiTagList *AdditionalAbiTags);
561 AbiTagList makeFunctionReturnTypeTags(
const FunctionDecl *FD);
563 AbiTagList makeVariableTypeTags(
const VarDecl *VD);
568 bool ItaniumMangleContextImpl::shouldMangleCXXName(
const NamedDecl *D) {
573 if (FD->
hasAttr<OverloadableAttr>())
603 if (!getASTContext().getLangOpts().CPlusPlus)
607 if (VD && !isa<DecompositionDecl>(D)) {
613 const DeclContext *DC = getEffectiveDeclContext(D);
617 DC = getEffectiveParentContext(DC);
619 !CXXNameMangler::shouldHaveAbiTags(*
this, VD) &&
620 !isa<VarTemplateSpecializationDecl>(D))
627 void CXXNameMangler::writeAbiTags(
const NamedDecl *ND,
628 const AbiTagList *AdditionalAbiTags) {
629 assert(AbiTags &&
"require AbiTagState");
630 AbiTags->write(Out, ND, DisableDerivedAbiTags ?
nullptr : AdditionalAbiTags);
633 void CXXNameMangler::mangleSourceNameWithAbiTags(
634 const NamedDecl *ND,
const AbiTagList *AdditionalAbiTags) {
636 writeAbiTags(ND, AdditionalAbiTags);
639 void CXXNameMangler::mangle(
const NamedDecl *D) {
645 mangleFunctionEncoding(FD);
646 else if (
const VarDecl *VD = dyn_cast<VarDecl>(D))
649 mangleName(IFD->getAnonField());
651 mangleName(cast<FieldDecl>(D));
654 void CXXNameMangler::mangleFunctionEncoding(
const FunctionDecl *FD) {
658 if (!Context.shouldMangleDeclName(FD)) {
663 AbiTagList ReturnTypeAbiTags = makeFunctionReturnTypeTags(FD);
664 if (ReturnTypeAbiTags.empty()) {
667 mangleFunctionEncodingBareType(FD);
675 llvm::raw_svector_ostream FunctionEncodingStream(FunctionEncodingBuf);
676 CXXNameMangler FunctionEncodingMangler(*
this, FunctionEncodingStream);
678 FunctionEncodingMangler.disableDerivedAbiTags();
679 FunctionEncodingMangler.mangleNameWithAbiTags(FD,
nullptr);
682 size_t EncodingPositionStart = FunctionEncodingStream.str().size();
683 FunctionEncodingMangler.mangleFunctionEncodingBareType(FD);
687 const AbiTagList &UsedAbiTags =
688 FunctionEncodingMangler.AbiTagsRoot.getSortedUniqueUsedAbiTags();
689 AbiTagList AdditionalAbiTags(ReturnTypeAbiTags.size());
690 AdditionalAbiTags.erase(
691 std::set_difference(ReturnTypeAbiTags.begin(), ReturnTypeAbiTags.end(),
692 UsedAbiTags.begin(), UsedAbiTags.end(),
693 AdditionalAbiTags.begin()),
694 AdditionalAbiTags.end());
697 mangleNameWithAbiTags(FD, &AdditionalAbiTags);
698 Out << FunctionEncodingStream.str().substr(EncodingPositionStart);
702 extendSubstitutions(&FunctionEncodingMangler);
705 void CXXNameMangler::mangleFunctionEncodingBareType(
const FunctionDecl *FD) {
706 if (FD->
hasAttr<EnableIfAttr>()) {
707 FunctionTypeDepthState Saved = FunctionTypeDepth.push();
708 Out <<
"Ua9enable_ifI";
709 for (AttrVec::const_iterator I = FD->
getAttrs().begin(),
712 EnableIfAttr *EIA = dyn_cast<EnableIfAttr>(*I);
716 mangleExpression(EIA->getCond());
720 FunctionTypeDepth.pop(Saved);
725 if (
auto *CD = dyn_cast<CXXConstructorDecl>(FD))
726 if (
auto Inherited = CD->getInheritedConstructor())
727 FD = Inherited.getConstructor();
745 bool MangleReturnType =
false;
747 if (!(isa<CXXConstructorDecl>(FD) || isa<CXXDestructorDecl>(FD) ||
748 isa<CXXConversionDecl>(FD)))
749 MangleReturnType =
true;
752 FD = PrimaryTemplate->getTemplatedDecl();
756 MangleReturnType, FD);
760 while (isa<LinkageSpecDecl>(DC)) {
761 DC = getEffectiveParentContext(DC);
770 ->isTranslationUnit())
774 return II && II->
isStr(
"std");
783 return isStd(cast<NamespaceDecl>(DC));
789 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
798 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
799 TemplateArgs = &Spec->getTemplateArgs();
800 return Spec->getSpecializedTemplate();
805 dyn_cast<VarTemplateSpecializationDecl>(ND)) {
806 TemplateArgs = &Spec->getTemplateArgs();
807 return Spec->getSpecializedTemplate();
813 void CXXNameMangler::mangleName(
const NamedDecl *ND) {
814 if (
const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
816 AbiTagList VariableTypeAbiTags = makeVariableTypeTags(VD);
817 if (VariableTypeAbiTags.empty()) {
819 mangleNameWithAbiTags(VD,
nullptr);
824 llvm::raw_null_ostream NullOutStream;
825 CXXNameMangler VariableNameMangler(*
this, NullOutStream);
826 VariableNameMangler.disableDerivedAbiTags();
827 VariableNameMangler.mangleNameWithAbiTags(VD,
nullptr);
830 const AbiTagList &UsedAbiTags =
831 VariableNameMangler.AbiTagsRoot.getSortedUniqueUsedAbiTags();
832 AbiTagList AdditionalAbiTags(VariableTypeAbiTags.size());
833 AdditionalAbiTags.erase(
834 std::set_difference(VariableTypeAbiTags.begin(),
835 VariableTypeAbiTags.end(), UsedAbiTags.begin(),
836 UsedAbiTags.end(), AdditionalAbiTags.begin()),
837 AdditionalAbiTags.end());
840 mangleNameWithAbiTags(VD, &AdditionalAbiTags);
842 mangleNameWithAbiTags(ND,
nullptr);
846 void CXXNameMangler::mangleNameWithAbiTags(
const NamedDecl *ND,
847 const AbiTagList *AdditionalAbiTags) {
853 const DeclContext *DC = getEffectiveDeclContext(ND);
859 if (isLocalContainerContext(DC) && ND->
hasLinkage() && !isLambda(ND))
861 DC = getEffectiveParentContext(DC);
862 else if (GetLocalClassDecl(ND)) {
863 mangleLocalName(ND, AdditionalAbiTags);
869 if (isLocalContainerContext(DC)) {
870 mangleLocalName(ND, AdditionalAbiTags);
886 mangleUnscopedTemplateName(TD, AdditionalAbiTags);
887 mangleTemplateArgs(*TemplateArgs);
891 mangleUnscopedName(ND, AdditionalAbiTags);
895 mangleNestedName(ND, DC, AdditionalAbiTags);
898 void CXXNameMangler::mangleModuleName(
const Module *M) {
905 mangleModuleNamePrefix(M->
Name);
909 void CXXNameMangler::mangleModuleNamePrefix(StringRef Name) {
912 auto It = ModuleSubstitutions.find(Name);
913 if (It != ModuleSubstitutions.end()) {
915 Out << '_' << static_cast<char>(
'0' + It->second);
917 Out <<
'W' << (It->second - 10) <<
'_';
923 auto Parts = Name.rsplit(
'.');
924 if (Parts.second.empty())
925 Parts.second = Parts.first;
927 mangleModuleNamePrefix(Parts.first);
929 Out << Parts.second.size() << Parts.second;
930 ModuleSubstitutions.insert({Name, ModuleSubstitutions.size()});
933 void CXXNameMangler::mangleTemplateName(
const TemplateDecl *TD,
935 unsigned NumTemplateArgs) {
939 mangleUnscopedTemplateName(TD,
nullptr);
940 mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
942 mangleNestedName(TD, TemplateArgs, NumTemplateArgs);
946 void CXXNameMangler::mangleUnscopedName(
const NamedDecl *ND,
947 const AbiTagList *AdditionalAbiTags) {
954 mangleUnqualifiedName(ND, AdditionalAbiTags);
957 void CXXNameMangler::mangleUnscopedTemplateName(
958 const TemplateDecl *ND,
const AbiTagList *AdditionalAbiTags) {
961 if (mangleSubstitution(ND))
965 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND)) {
966 assert(!AdditionalAbiTags &&
967 "template template param cannot have abi tags");
968 mangleTemplateParameter(TTP->getIndex());
969 }
else if (isa<BuiltinTemplateDecl>(ND)) {
970 mangleUnscopedName(ND, AdditionalAbiTags);
978 void CXXNameMangler::mangleUnscopedTemplateName(
979 TemplateName Template,
const AbiTagList *AdditionalAbiTags) {
983 return mangleUnscopedTemplateName(TD, AdditionalAbiTags);
985 if (mangleSubstitution(Template))
988 assert(!AdditionalAbiTags &&
989 "dependent template name cannot have abi tags");
992 assert(Dependent &&
"Not a dependent template name?");
994 mangleSourceName(
Id);
996 mangleOperatorName(Dependent->
getOperator(), UnknownArity);
998 addSubstitution(Template);
1001 void CXXNameMangler::mangleFloat(
const llvm::APFloat &f) {
1015 llvm::APInt valueBits = f.bitcastToAPInt();
1016 unsigned numCharacters = (valueBits.getBitWidth() + 3) / 4;
1017 assert(numCharacters != 0);
1023 for (
unsigned stringIndex = 0; stringIndex != numCharacters; ++stringIndex) {
1025 unsigned digitBitIndex = 4 * (numCharacters - stringIndex - 1);
1028 uint64_t hexDigit = valueBits.getRawData()[digitBitIndex / 64];
1029 hexDigit >>= (digitBitIndex % 64);
1033 static const char charForHex[16] = {
1034 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
1035 '8',
'9',
'a',
'b',
'c',
'd',
'e',
'f' 1037 buffer[stringIndex] = charForHex[hexDigit];
1040 Out.write(buffer.data(), numCharacters);
1043 void CXXNameMangler::mangleNumber(
const llvm::APSInt &
Value) {
1044 if (Value.isSigned() && Value.isNegative()) {
1046 Value.abs().print(Out,
false);
1048 Value.print(Out,
false);
1052 void CXXNameMangler::mangleNumber(int64_t Number) {
1062 void CXXNameMangler::mangleCallOffset(int64_t NonVirtual, int64_t Virtual) {
1070 mangleNumber(NonVirtual);
1076 mangleNumber(NonVirtual);
1078 mangleNumber(Virtual);
1084 if (!mangleSubstitution(
QualType(TST, 0))) {
1085 mangleTemplatePrefix(TST->getTemplateName());
1090 mangleTemplateArgs(TST->getArgs(), TST->getNumArgs());
1093 }
else if (
const auto *DTST =
1095 if (!mangleSubstitution(
QualType(DTST, 0))) {
1096 TemplateName Template = getASTContext().getDependentTemplateName(
1097 DTST->getQualifier(), DTST->getIdentifier());
1098 mangleTemplatePrefix(Template);
1103 mangleTemplateArgs(DTST->getArgs(), DTST->getNumArgs());
1104 addSubstitution(
QualType(DTST, 0));
1134 switch (qualifier->
getKind()) {
1146 llvm_unreachable(
"Can't mangle __super specifier");
1150 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1158 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1175 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1182 if (mangleUnresolvedTypeOrSimpleId(
QualType(type, 0), recursive ?
"N" :
""))
1191 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1209 void CXXNameMangler::mangleUnresolvedName(
1212 unsigned knownArity) {
1213 if (qualifier) mangleUnresolvedPrefix(qualifier);
1229 mangleOperatorName(name, knownArity);
1232 llvm_unreachable(
"Can't mangle a constructor name!");
1234 llvm_unreachable(
"Can't mangle a using directive name!");
1236 llvm_unreachable(
"Can't mangle a deduction guide name!");
1240 llvm_unreachable(
"Can't mangle Objective-C selector names here!");
1246 mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
1249 void CXXNameMangler::mangleUnqualifiedName(
const NamedDecl *ND,
1251 unsigned KnownArity,
1252 const AbiTagList *AdditionalAbiTags) {
1253 unsigned Arity = KnownArity;
1262 if (
auto *DD = dyn_cast<DecompositionDecl>(ND)) {
1271 for (
auto *BD : DD->bindings())
1272 mangleSourceName(BD->getDeclName().getAsIdentifierInfo());
1274 writeAbiTags(ND, AdditionalAbiTags);
1294 getEffectiveDeclContext(ND)->isFileContext() &&
1299 bool IsRegCall = FD &&
1303 mangleRegCallName(II);
1305 mangleSourceName(II);
1307 writeAbiTags(ND, AdditionalAbiTags);
1312 assert(ND &&
"mangling empty name without declaration");
1314 if (
const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) {
1315 if (NS->isAnonymousNamespace()) {
1317 Out <<
"12_GLOBAL__N_1";
1322 if (
const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
1336 &&
"Expected anonymous struct or union!");
1343 assert(FD->getIdentifier() &&
"Data member name isn't an identifier!");
1345 mangleSourceName(FD->getIdentifier());
1356 if (isa<ObjCContainerDecl>(ND))
1360 const TagDecl *TD = cast<TagDecl>(ND);
1363 "Typedef should not be in another decl context!");
1365 "Typedef was not named!");
1367 assert(!AdditionalAbiTags &&
"Type cannot have additional abi tags");
1370 writeAbiTags(TD,
nullptr);
1379 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(TD)) {
1381 assert(!AdditionalAbiTags &&
1382 "Lambda type cannot have additional abi tags");
1383 mangleLambda(Record);
1389 unsigned UnnamedMangle = getASTContext().getManglingNumber(TD);
1391 if (UnnamedMangle > 1)
1392 Out << UnnamedMangle - 2;
1394 writeAbiTags(TD, AdditionalAbiTags);
1400 unsigned AnonStructId = NullOut ? 0 : Context.getAnonymousStructId(TD);
1407 Str += llvm::utostr(AnonStructId);
1417 llvm_unreachable(
"Can't mangle Objective-C selector names here!");
1422 if (
auto Inherited =
1423 cast<CXXConstructorDecl>(ND)->getInheritedConstructor()) {
1424 InheritedFrom = Inherited.getConstructor()->
getParent();
1425 InheritedTemplateArgs =
1426 Inherited.getConstructor()->getTemplateSpecializationArgs();
1432 mangleCXXCtorType(static_cast<CXXCtorType>(StructorType), InheritedFrom);
1440 if (InheritedTemplateArgs)
1441 mangleTemplateArgs(*InheritedTemplateArgs);
1443 writeAbiTags(ND, AdditionalAbiTags);
1451 mangleCXXDtorType(static_cast<CXXDtorType>(StructorType));
1456 writeAbiTags(ND, AdditionalAbiTags);
1460 if (ND && Arity == UnknownArity) {
1461 Arity = cast<FunctionDecl>(ND)->getNumParams();
1464 if (
const auto *MD = dyn_cast<CXXMethodDecl>(ND))
1465 if (!MD->isStatic())
1471 mangleOperatorName(Name, Arity);
1472 writeAbiTags(ND, AdditionalAbiTags);
1476 llvm_unreachable(
"Can't mangle a deduction guide name!");
1479 llvm_unreachable(
"Can't mangle a using directive name!");
1483 void CXXNameMangler::mangleRegCallName(
const IdentifierInfo *II) {
1487 Out << II->
getLength() +
sizeof(
"__regcall3__") - 1 <<
"__regcall3__" 1491 void CXXNameMangler::mangleSourceName(
const IdentifierInfo *II) {
1498 void CXXNameMangler::mangleNestedName(
const NamedDecl *ND,
1500 const AbiTagList *AdditionalAbiTags,
1508 if (
const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(ND)) {
1509 Qualifiers MethodQuals = Method->getMethodQualifiers();
1513 mangleQualifiers(MethodQuals);
1514 mangleRefQualifier(Method->getRefQualifier());
1520 mangleTemplatePrefix(TD, NoFunction);
1521 mangleTemplateArgs(*TemplateArgs);
1524 manglePrefix(DC, NoFunction);
1525 mangleUnqualifiedName(ND, AdditionalAbiTags);
1530 void CXXNameMangler::mangleNestedName(
const TemplateDecl *TD,
1532 unsigned NumTemplateArgs) {
1537 mangleTemplatePrefix(TD);
1538 mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
1543 void CXXNameMangler::mangleLocalName(
const Decl *D,
1544 const AbiTagList *AdditionalAbiTags) {
1550 assert(isa<NamedDecl>(D) || isa<BlockDecl>(D));
1552 const DeclContext *DC = getEffectiveDeclContext(RD ? RD : D);
1557 AbiTagState LocalAbiTags(AbiTags);
1560 mangleObjCMethodName(MD);
1561 else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(DC))
1562 mangleBlockForPrefix(BD);
1564 mangleFunctionEncoding(cast<FunctionDecl>(DC));
1568 LocalAbiTags.setUsedAbiTags(LocalAbiTags.getEmittedAbiTags());
1587 = dyn_cast<FunctionDecl>(Parm->getDeclContext())) {
1589 unsigned Num = Func->getNumParams() - Parm->getFunctionScopeIndex();
1591 mangleNumber(Num - 2);
1600 mangleUnqualifiedName(RD, AdditionalAbiTags);
1601 }
else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
1602 manglePrefix(getEffectiveDeclContext(BD),
true );
1603 assert(!AdditionalAbiTags &&
"Block cannot have additional abi tags");
1604 mangleUnqualifiedBlock(BD);
1606 const NamedDecl *ND = cast<NamedDecl>(D);
1607 mangleNestedName(ND, getEffectiveDeclContext(ND), AdditionalAbiTags,
1610 }
else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
1614 = dyn_cast_or_null<ParmVarDecl>(BD->getBlockManglingContextDecl())) {
1616 = dyn_cast<FunctionDecl>(Parm->getDeclContext())) {
1618 unsigned Num = Func->getNumParams() - Parm->getFunctionScopeIndex();
1620 mangleNumber(Num - 2);
1625 assert(!AdditionalAbiTags &&
"Block cannot have additional abi tags");
1626 mangleUnqualifiedBlock(BD);
1628 mangleUnqualifiedName(cast<NamedDecl>(D), AdditionalAbiTags);
1631 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(RD ? RD : D)) {
1633 if (Context.getNextDiscriminator(ND, disc)) {
1637 Out <<
"__" << disc <<
'_';
1642 void CXXNameMangler::mangleBlockForPrefix(
const BlockDecl *Block) {
1643 if (GetLocalClassDecl(Block)) {
1644 mangleLocalName(Block,
nullptr);
1647 const DeclContext *DC = getEffectiveDeclContext(Block);
1648 if (isLocalContainerContext(DC)) {
1649 mangleLocalName(Block,
nullptr);
1652 manglePrefix(getEffectiveDeclContext(Block));
1653 mangleUnqualifiedBlock(Block);
1656 void CXXNameMangler::mangleUnqualifiedBlock(
const BlockDecl *Block) {
1658 if ((isa<VarDecl>(Context) || isa<FieldDecl>(Context)) &&
1659 Context->getDeclContext()->isRecord()) {
1660 const auto *ND = cast<NamedDecl>(Context);
1662 mangleSourceNameWithAbiTags(ND);
1673 Number = Context.getBlockId(Block,
false);
1688 void CXXNameMangler::mangleTemplateParamDecl(
const NamedDecl *
Decl) {
1689 if (isa<TemplateTypeParmDecl>(Decl)) {
1691 }
else if (
auto *Tn = dyn_cast<NonTypeTemplateParmDecl>(Decl)) {
1693 mangleType(Tn->getType());
1694 }
else if (
auto *Tt = dyn_cast<TemplateTemplateParmDecl>(Decl)) {
1696 for (
auto *Param : *Tt->getTemplateParameters())
1697 mangleTemplateParamDecl(Param);
1702 void CXXNameMangler::mangleLambda(
const CXXRecordDecl *Lambda) {
1713 if ((isa<VarDecl>(Context) || isa<FieldDecl>(Context)) &&
1714 !isa<ParmVarDecl>(Context)) {
1718 = cast<NamedDecl>(Context)->getIdentifier()) {
1719 mangleSourceName(Name);
1721 if (
isTemplate(cast<NamedDecl>(Context), TemplateArgs))
1722 mangleTemplateArgs(*TemplateArgs);
1730 mangleTemplateParamDecl(D);
1732 getAs<FunctionProtoType>();
1733 mangleBareFunctionType(Proto,
false,
1743 assert(Number > 0 &&
"Lambda should be mangled as an unnamed class");
1745 mangleNumber(Number - 2);
1750 switch (qualifier->
getKind()) {
1756 llvm_unreachable(
"Can't mangle __super specifier");
1781 llvm_unreachable(
"unexpected nested name specifier");
1784 void CXXNameMangler::manglePrefix(
const DeclContext *DC,
bool NoFunction) {
1796 if (NoFunction && isLocalContainerContext(DC))
1799 assert(!isLocalContainerContext(DC));
1801 const NamedDecl *ND = cast<NamedDecl>(DC);
1802 if (mangleSubstitution(ND))
1808 mangleTemplatePrefix(TD);
1809 mangleTemplateArgs(*TemplateArgs);
1811 manglePrefix(getEffectiveDeclContext(ND), NoFunction);
1812 mangleUnqualifiedName(ND,
nullptr);
1815 addSubstitution(ND);
1818 void CXXNameMangler::mangleTemplatePrefix(
TemplateName Template) {
1823 return mangleTemplatePrefix(TD);
1826 manglePrefix(Qualified->getQualifier());
1830 mangleUnqualifiedName(
nullptr, (*Overloaded->begin())->getDeclName(),
1831 UnknownArity,
nullptr);
1836 assert(Dependent &&
"Unknown template name kind?");
1838 manglePrefix(Qualifier);
1839 mangleUnscopedTemplateName(Template,
nullptr);
1842 void CXXNameMangler::mangleTemplatePrefix(
const TemplateDecl *ND,
1850 if (mangleSubstitution(ND))
1854 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND)) {
1855 mangleTemplateParameter(TTP->getIndex());
1857 manglePrefix(getEffectiveDeclContext(ND), NoFunction);
1858 if (isa<BuiltinTemplateDecl>(ND))
1859 mangleUnqualifiedName(ND,
nullptr);
1864 addSubstitution(ND);
1873 if (mangleSubstitution(TN))
1888 if (isa<TemplateTemplateParmDecl>(TD))
1889 mangleTemplateParameter(cast<TemplateTemplateParmDecl>(TD)->getIndex());
1896 llvm_unreachable(
"can't mangle an overloaded template name as a <type>");
1925 Out <<
"_SUBSTPACK_";
1930 addSubstitution(TN);
1933 bool CXXNameMangler::mangleUnresolvedTypeOrSimpleId(
QualType Ty,
1939 case Type::Adjusted:
1942 case Type::BlockPointer:
1943 case Type::LValueReference:
1944 case Type::RValueReference:
1945 case Type::MemberPointer:
1946 case Type::ConstantArray:
1947 case Type::IncompleteArray:
1948 case Type::VariableArray:
1949 case Type::DependentSizedArray:
1950 case Type::DependentAddressSpace:
1951 case Type::DependentVector:
1952 case Type::DependentSizedExtVector:
1954 case Type::ExtVector:
1955 case Type::FunctionProto:
1956 case Type::FunctionNoProto:
1958 case Type::Attributed:
1960 case Type::DeducedTemplateSpecialization:
1961 case Type::PackExpansion:
1962 case Type::ObjCObject:
1963 case Type::ObjCInterface:
1964 case Type::ObjCObjectPointer:
1965 case Type::ObjCTypeParam:
1968 case Type::MacroQualified:
1969 llvm_unreachable(
"type is illegal as a nested name specifier");
1971 case Type::SubstTemplateTypeParmPack:
1976 Out <<
"_SUBSTPACK_";
1983 case Type::TypeOfExpr:
1985 case Type::Decltype:
1986 case Type::TemplateTypeParm:
1987 case Type::UnaryTransform:
1988 case Type::SubstTemplateTypeParm:
2002 mangleSourceNameWithAbiTags(cast<TypedefType>(Ty)->getDecl());
2005 case Type::UnresolvedUsing:
2006 mangleSourceNameWithAbiTags(
2007 cast<UnresolvedUsingType>(Ty)->getDecl());
2012 mangleSourceNameWithAbiTags(cast<TagType>(Ty)->getDecl());
2015 case Type::TemplateSpecialization: {
2017 cast<TemplateSpecializationType>(Ty);
2019 switch (TN.getKind()) {
2026 assert(TD &&
"no template for template specialization type");
2027 if (isa<TemplateTemplateParmDecl>(TD))
2028 goto unresolvedType;
2030 mangleSourceNameWithAbiTags(TD);
2037 llvm_unreachable(
"invalid base for a template specialization type");
2051 Out <<
"_SUBSTPACK_";
2060 case Type::InjectedClassName:
2061 mangleSourceNameWithAbiTags(
2062 cast<InjectedClassNameType>(Ty)->getDecl());
2065 case Type::DependentName:
2066 mangleSourceName(cast<DependentNameType>(Ty)->
getIdentifier());
2069 case Type::DependentTemplateSpecialization: {
2071 cast<DependentTemplateSpecializationType>(Ty);
2077 case Type::Elaborated:
2078 return mangleUnresolvedTypeOrSimpleId(
2079 cast<ElaboratedType>(Ty)->getNamedType(), Prefix);
2085 void CXXNameMangler::mangleOperatorName(
DeclarationName Name,
unsigned Arity) {
2095 llvm_unreachable(
"Not an operator name");
2118 case OO_New: Out <<
"nw";
break;
2120 case OO_Array_New: Out <<
"na";
break;
2122 case OO_Delete: Out <<
"dl";
break;
2124 case OO_Array_Delete: Out <<
"da";
break;
2128 Out << (Arity == 1?
"ps" :
"pl");
break;
2132 Out << (Arity == 1?
"ng" :
"mi");
break;
2136 Out << (Arity == 1?
"ad" :
"an");
break;
2141 Out << (Arity == 1?
"de" :
"ml");
break;
2143 case OO_Tilde: Out <<
"co";
break;
2145 case OO_Slash: Out <<
"dv";
break;
2147 case OO_Percent: Out <<
"rm";
break;
2149 case OO_Pipe: Out <<
"or";
break;
2151 case OO_Caret: Out <<
"eo";
break;
2153 case OO_Equal: Out <<
"aS";
break;
2155 case OO_PlusEqual: Out <<
"pL";
break;
2157 case OO_MinusEqual: Out <<
"mI";
break;
2159 case OO_StarEqual: Out <<
"mL";
break;
2161 case OO_SlashEqual: Out <<
"dV";
break;
2163 case OO_PercentEqual: Out <<
"rM";
break;
2165 case OO_AmpEqual: Out <<
"aN";
break;
2167 case OO_PipeEqual: Out <<
"oR";
break;
2169 case OO_CaretEqual: Out <<
"eO";
break;
2171 case OO_LessLess: Out <<
"ls";
break;
2173 case OO_GreaterGreater: Out <<
"rs";
break;
2175 case OO_LessLessEqual: Out <<
"lS";
break;
2177 case OO_GreaterGreaterEqual: Out <<
"rS";
break;
2179 case OO_EqualEqual: Out <<
"eq";
break;
2181 case OO_ExclaimEqual: Out <<
"ne";
break;
2183 case OO_Less: Out <<
"lt";
break;
2185 case OO_Greater: Out <<
"gt";
break;
2187 case OO_LessEqual: Out <<
"le";
break;
2189 case OO_GreaterEqual: Out <<
"ge";
break;
2191 case OO_Exclaim: Out <<
"nt";
break;
2193 case OO_AmpAmp: Out <<
"aa";
break;
2195 case OO_PipePipe: Out <<
"oo";
break;
2197 case OO_PlusPlus: Out <<
"pp";
break;
2199 case OO_MinusMinus: Out <<
"mm";
break;
2201 case OO_Comma: Out <<
"cm";
break;
2203 case OO_ArrowStar: Out <<
"pm";
break;
2205 case OO_Arrow: Out <<
"pt";
break;
2207 case OO_Call: Out <<
"cl";
break;
2209 case OO_Subscript: Out <<
"ix";
break;
2214 case OO_Conditional: Out <<
"qu";
break;
2217 case OO_Coawait: Out <<
"aw";
break;
2220 case OO_Spaceship: Out <<
"ss";
break;
2224 llvm_unreachable(
"Not an overloaded operator");
2250 if (Context.getASTContext().addressSpaceMapManglingFor(AS)) {
2252 unsigned TargetAS = Context.getASTContext().getTargetAddressSpace(AS);
2254 ASString =
"AS" + llvm::utostr(TargetAS);
2257 default: llvm_unreachable(
"Not a language specific address space");
2271 if (!ASString.empty())
2272 mangleVendorQualifier(ASString);
2285 mangleVendorQualifier(
"__weak");
2289 mangleVendorQualifier(
"__unaligned");
2301 mangleVendorQualifier(
"__strong");
2305 mangleVendorQualifier(
"__autoreleasing");
2328 void CXXNameMangler::mangleVendorQualifier(StringRef name) {
2329 Out <<
'U' << name.size() <<
name;
2335 switch (RefQualifier) {
2349 void CXXNameMangler::mangleObjCMethodName(
const ObjCMethodDecl *MD) {
2350 Context.mangleObjCMethodName(MD, Out);
2371 void CXXNameMangler::mangleType(
QualType T) {
2412 = dyn_cast<TemplateSpecializationType>(T))
2413 if (!TST->isTypeAlias())
2426 const Type *ty = split.
Ty;
2428 bool isSubstitutable =
2430 if (isSubstitutable && mangleSubstitution(T))
2435 if (quals && isa<ArrayType>(T)) {
2436 ty = Context.getASTContext().getAsArrayType(T);
2445 dyn_cast<DependentAddressSpaceType>(ty)) {
2447 mangleQualifiers(splitDAST.
Quals, DAST);
2450 mangleQualifiers(quals);
2458 #define ABSTRACT_TYPE(CLASS, PARENT) 2459 #define NON_CANONICAL_TYPE(CLASS, PARENT) \ 2461 llvm_unreachable("can't mangle non-canonical type " #CLASS "Type"); \ 2463 #define TYPE(CLASS, PARENT) \ 2465 mangleType(static_cast<const CLASS##Type*>(ty)); \ 2467 #include "clang/AST/TypeNodes.def" 2472 if (isSubstitutable)
2476 void CXXNameMangler::mangleNameOrStandardSubstitution(
const NamedDecl *ND) {
2477 if (!mangleStandardSubstitution(ND))
2481 void CXXNameMangler::mangleType(
const BuiltinType *T) {
2512 std::string type_name;
2514 case BuiltinType::Void:
2517 case BuiltinType::Bool:
2520 case BuiltinType::Char_U:
2521 case BuiltinType::Char_S:
2524 case BuiltinType::UChar:
2527 case BuiltinType::UShort:
2530 case BuiltinType::UInt:
2533 case BuiltinType::ULong:
2536 case BuiltinType::ULongLong:
2539 case BuiltinType::UInt128:
2542 case BuiltinType::SChar:
2545 case BuiltinType::WChar_S:
2546 case BuiltinType::WChar_U:
2549 case BuiltinType::Char8:
2552 case BuiltinType::Char16:
2555 case BuiltinType::Char32:
2558 case BuiltinType::Short:
2561 case BuiltinType::Int:
2564 case BuiltinType::Long:
2567 case BuiltinType::LongLong:
2570 case BuiltinType::Int128:
2573 case BuiltinType::Float16:
2576 case BuiltinType::ShortAccum:
2577 case BuiltinType::Accum:
2578 case BuiltinType::LongAccum:
2579 case BuiltinType::UShortAccum:
2580 case BuiltinType::UAccum:
2581 case BuiltinType::ULongAccum:
2582 case BuiltinType::ShortFract:
2583 case BuiltinType::Fract:
2584 case BuiltinType::LongFract:
2585 case BuiltinType::UShortFract:
2586 case BuiltinType::UFract:
2587 case BuiltinType::ULongFract:
2588 case BuiltinType::SatShortAccum:
2589 case BuiltinType::SatAccum:
2590 case BuiltinType::SatLongAccum:
2591 case BuiltinType::SatUShortAccum:
2592 case BuiltinType::SatUAccum:
2593 case BuiltinType::SatULongAccum:
2594 case BuiltinType::SatShortFract:
2595 case BuiltinType::SatFract:
2596 case BuiltinType::SatLongFract:
2597 case BuiltinType::SatUShortFract:
2598 case BuiltinType::SatUFract:
2599 case BuiltinType::SatULongFract:
2600 llvm_unreachable(
"Fixed point types are disabled for c++");
2601 case BuiltinType::Half:
2604 case BuiltinType::Float:
2607 case BuiltinType::Double:
2610 case BuiltinType::LongDouble: {
2611 const TargetInfo *TI = getASTContext().getLangOpts().OpenMP &&
2612 getASTContext().getLangOpts().OpenMPIsDevice
2613 ? getASTContext().getAuxTargetInfo()
2614 : &getASTContext().getTargetInfo();
2618 case BuiltinType::Float128: {
2619 const TargetInfo *TI = getASTContext().getLangOpts().OpenMP &&
2620 getASTContext().getLangOpts().OpenMPIsDevice
2621 ? getASTContext().getAuxTargetInfo()
2622 : &getASTContext().getTargetInfo();
2626 case BuiltinType::NullPtr:
2630 #define BUILTIN_TYPE(Id, SingletonId) 2631 #define PLACEHOLDER_TYPE(Id, SingletonId) \ 2632 case BuiltinType::Id: 2633 #include "clang/AST/BuiltinTypes.def" 2634 case BuiltinType::Dependent:
2636 llvm_unreachable(
"mangling a placeholder type");
2638 case BuiltinType::ObjCId:
2639 Out <<
"11objc_object";
2641 case BuiltinType::ObjCClass:
2642 Out <<
"10objc_class";
2644 case BuiltinType::ObjCSel:
2645 Out <<
"13objc_selector";
2647 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 2648 case BuiltinType::Id: \ 2649 type_name = "ocl_" #ImgType "_" #Suffix; \ 2650 Out << type_name.size() << type_name; \ 2652 #include "clang/Basic/OpenCLImageTypes.def" 2653 case BuiltinType::OCLSampler:
2654 Out <<
"11ocl_sampler";
2656 case BuiltinType::OCLEvent:
2657 Out <<
"9ocl_event";
2659 case BuiltinType::OCLClkEvent:
2660 Out <<
"12ocl_clkevent";
2662 case BuiltinType::OCLQueue:
2663 Out <<
"9ocl_queue";
2665 case BuiltinType::OCLReserveID:
2666 Out <<
"13ocl_reserveid";
2668 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 2669 case BuiltinType::Id: \ 2670 type_name = "ocl_" #ExtType; \ 2671 Out << type_name.size() << type_name; \ 2673 #include "clang/Basic/OpenCLExtensionTypes.def" 2677 StringRef CXXNameMangler::getCallingConvQualifierName(
CallingConv CC) {
2715 llvm_unreachable(
"bad calling convention");
2718 void CXXNameMangler::mangleExtFunctionInfo(
const FunctionType *T) {
2727 StringRef CCQualifier = getCallingConvQualifierName(T->
getExtInfo().
getCC());
2728 if (!CCQualifier.empty())
2729 mangleVendorQualifier(CCQualifier);
2736 CXXNameMangler::mangleExtParameterInfo(FunctionProtoType::ExtParameterInfo PI) {
2742 switch (PI.getABI()) {
2754 if (PI.isConsumed())
2755 mangleVendorQualifier(
"ns_consumed");
2757 if (PI.isNoEscape())
2758 mangleVendorQualifier(
"noescape");
2765 mangleExtFunctionInfo(T);
2782 mangleType(ExceptTy);
2793 mangleBareFunctionType(T,
true);
2807 FunctionTypeDepthState saved = FunctionTypeDepth.push();
2809 FunctionTypeDepth.enterResultType();
2811 FunctionTypeDepth.leaveResultType();
2813 FunctionTypeDepth.pop(saved);
2818 bool MangleReturnType,
2822 FunctionTypeDepthState saved = FunctionTypeDepth.push();
2825 if (MangleReturnType) {
2826 FunctionTypeDepth.enterResultType();
2830 mangleVendorQualifier(
"ns_returns_retained");
2835 auto SplitReturnTy = ReturnTy.
split();
2837 ReturnTy = getASTContext().getQualifiedType(SplitReturnTy);
2839 mangleType(ReturnTy);
2841 FunctionTypeDepth.leaveResultType();
2848 FunctionTypeDepth.pop(saved);
2853 for (
unsigned I = 0, E = Proto->
getNumParams(); I != E; ++I) {
2861 mangleType(Context.getASTContext().getSignatureParameterType(ParamTy));
2866 assert(
Attr->getType() <= 9 &&
Attr->getType() >= 0);
2867 if (
Attr->isDynamic())
2868 Out <<
"U25pass_dynamic_object_size" <<
Attr->getType();
2870 Out <<
"U17pass_object_size" <<
Attr->getType();
2875 FunctionTypeDepth.pop(saved);
2890 void CXXNameMangler::mangleType(
const EnumType *T) {
2891 mangleType(static_cast<const TagType*>(T));
2893 void CXXNameMangler::mangleType(
const RecordType *T) {
2894 mangleType(static_cast<const TagType*>(T));
2896 void CXXNameMangler::mangleType(
const TagType *T) {
2904 Out <<
'A' << T->
getSize() <<
'_';
2953 mangleType(PointeeType);
2958 mangleTemplateParameter(T->
getIndex());
2967 Out <<
"_SUBSTPACK_";
2971 void CXXNameMangler::mangleType(
const PointerType *T) {
2993 void CXXNameMangler::mangleType(
const ComplexType *T) {
3001 void CXXNameMangler::mangleNeonVectorType(
const VectorType *T) {
3003 assert(EltType->
isBuiltinType() &&
"Neon vector element not a BuiltinType");
3004 const char *EltName =
nullptr;
3006 switch (cast<BuiltinType>(EltType)->getKind()) {
3007 case BuiltinType::SChar:
3008 case BuiltinType::UChar:
3009 EltName =
"poly8_t";
3011 case BuiltinType::Short:
3012 case BuiltinType::UShort:
3013 EltName =
"poly16_t";
3015 case BuiltinType::ULongLong:
3016 EltName =
"poly64_t";
3018 default: llvm_unreachable(
"unexpected Neon polynomial vector element type");
3021 switch (cast<BuiltinType>(EltType)->
getKind()) {
3022 case BuiltinType::SChar: EltName =
"int8_t";
break;
3023 case BuiltinType::UChar: EltName =
"uint8_t";
break;
3024 case BuiltinType::Short: EltName =
"int16_t";
break;
3025 case BuiltinType::UShort: EltName =
"uint16_t";
break;
3026 case BuiltinType::Int: EltName =
"int32_t";
break;
3027 case BuiltinType::UInt: EltName =
"uint32_t";
break;
3028 case BuiltinType::LongLong: EltName =
"int64_t";
break;
3029 case BuiltinType::ULongLong: EltName =
"uint64_t";
break;
3030 case BuiltinType::Double: EltName =
"float64_t";
break;
3031 case BuiltinType::Float: EltName =
"float32_t";
break;
3032 case BuiltinType::Half: EltName =
"float16_t";
break;
3034 llvm_unreachable(
"unexpected Neon vector element type");
3037 const char *BaseName =
nullptr;
3039 getASTContext().getTypeSize(EltType));
3041 BaseName =
"__simd64_";
3043 assert(BitSize == 128 &&
"Neon vector type not 64 or 128 bits");
3044 BaseName =
"__simd128_";
3046 Out << strlen(BaseName) + strlen(EltName);
3047 Out << BaseName << EltName;
3054 "cannot mangle this dependent neon vector type yet");
3060 case BuiltinType::SChar:
3062 case BuiltinType::Short:
3064 case BuiltinType::Int:
3066 case BuiltinType::Long:
3067 case BuiltinType::LongLong:
3069 case BuiltinType::UChar:
3071 case BuiltinType::UShort:
3073 case BuiltinType::UInt:
3075 case BuiltinType::ULong:
3076 case BuiltinType::ULongLong:
3078 case BuiltinType::Half:
3080 case BuiltinType::Float:
3082 case BuiltinType::Double:
3085 llvm_unreachable(
"Unexpected vector element base type");
3092 void CXXNameMangler::mangleAArch64NeonVectorType(
const VectorType *T) {
3094 assert(EltType->
isBuiltinType() &&
"Neon vector element not a BuiltinType");
3099 assert((BitSize == 64 || BitSize == 128) &&
3100 "Neon vector type not 64 or 128 bits");
3104 switch (cast<BuiltinType>(EltType)->getKind()) {
3105 case BuiltinType::UChar:
3108 case BuiltinType::UShort:
3111 case BuiltinType::ULong:
3112 case BuiltinType::ULongLong:
3116 llvm_unreachable(
"unexpected Neon polynomial vector element type");
3121 std::string TypeName =
3122 (
"__" + EltName +
"x" + Twine(T->
getNumElements()) +
"_t").str();
3123 Out << TypeName.length() << TypeName;
3129 "cannot mangle this dependent neon vector type yet");
3141 void CXXNameMangler::mangleType(
const VectorType *T) {
3144 llvm::Triple
Target = getASTContext().getTargetInfo().getTriple();
3145 llvm::Triple::ArchType Arch =
3146 getASTContext().getTargetInfo().getTriple().getArch();
3147 if ((Arch == llvm::Triple::aarch64 ||
3148 Arch == llvm::Triple::aarch64_be) && !Target.isOSDarwin())
3149 mangleAArch64NeonVectorType(T);
3151 mangleNeonVectorType(T);
3166 llvm::Triple
Target = getASTContext().getTargetInfo().getTriple();
3167 llvm::Triple::ArchType Arch =
3168 getASTContext().getTargetInfo().getTriple().getArch();
3169 if ((Arch == llvm::Triple::aarch64 || Arch == llvm::Triple::aarch64_be) &&
3170 !Target.isOSDarwin())
3171 mangleAArch64NeonVectorType(T);
3173 mangleNeonVectorType(T);
3189 mangleType(static_cast<const VectorType*>(T));
3200 mangleQualifiers(split.
Quals, T);
3217 Out <<
"U8__kindof";
3222 llvm::raw_svector_ostream QualOS(QualStr);
3223 QualOS <<
"objcproto";
3224 for (
const auto *I : T->
quals()) {
3225 StringRef name = I->getName();
3226 QualOS << name.size() <<
name;
3228 Out <<
'U' << QualStr.size() << QualStr;
3237 mangleType(typeArg);
3243 Out <<
"U13block_pointer";
3258 if (mangleSubstitution(
QualType(T, 0)))
3311 getASTContext().getDependentTemplateName(T->
getQualifier(),
3313 mangleTemplatePrefix(Prefix);
3322 void CXXNameMangler::mangleType(
const TypeOfType *T) {
3334 void CXXNameMangler::mangleType(
const DecltypeType *T) {
3345 if (isa<DeclRefExpr>(E) ||
3346 isa<MemberExpr>(E) ||
3347 isa<UnresolvedLookupExpr>(E) ||
3348 isa<DependentScopeDeclRefExpr>(E) ||
3349 isa<CXXDependentScopeMemberExpr>(E) ||
3350 isa<UnresolvedMemberExpr>(E))
3354 mangleExpression(E);
3374 void CXXNameMangler::mangleType(
const AutoType *T) {
3376 "Deduced AutoType shouldn't be handled here!");
3378 "shouldn't need to mangle __auto_type!");
3394 void CXXNameMangler::mangleType(
const AtomicType *T) {
3401 void CXXNameMangler::mangleType(
const PipeType *T) {
3408 void CXXNameMangler::mangleIntegerLiteral(
QualType T,
3409 const llvm::APSInt &Value) {
3416 Out << (Value.getBoolValue() ?
'1' :
'0');
3418 mangleNumber(Value);
3424 void CXXNameMangler::mangleMemberExprBase(
const Expr *
Base,
bool IsArrow) {
3427 if (!RT->getDecl()->isAnonymousStructOrUnion())
3432 Base = ME->getBase();
3433 IsArrow = ME->isArrow();
3442 Out << (IsArrow ?
"pt" :
"dt");
3443 mangleExpression(Base);
3448 void CXXNameMangler::mangleMemberExpr(
const Expr *base,
3454 unsigned NumTemplateArgs,
3459 mangleMemberExprBase(base, isArrow);
3460 mangleUnresolvedName(qualifier, member, TemplateArgs, NumTemplateArgs, arity);
3473 if (callee == fn)
return false;
3477 if (!lookup)
return false;
3494 void CXXNameMangler::mangleCastExpression(
const Expr *E, StringRef CastEncoding) {
3496 Out << CastEncoding;
3501 void CXXNameMangler::mangleInitListElements(
const InitListExpr *InitList) {
3503 InitList = Syntactic;
3505 mangleExpression(InitList->
getInit(
i));
3508 void CXXNameMangler::mangleDeclRefExpr(
const NamedDecl *D) {
3518 mangleFunctionParam(cast<ParmVarDecl>(D));
3521 case Decl::EnumConstant: {
3527 case Decl::NonTypeTemplateParm:
3529 mangleTemplateParameter(PD->
getIndex());
3534 void CXXNameMangler::mangleExpression(
const Expr *E,
unsigned Arity) {
3558 QualType ImplicitlyConvertedToType;
3563 #define ABSTRACT_STMT(Type) 3564 #define EXPR(Type, Base) 3565 #define STMT(Type, Base) \ 3566 case Expr::Type##Class: 3567 #include "clang/AST/StmtNodes.inc" 3572 case Expr::AddrLabelExprClass:
3573 case Expr::DesignatedInitUpdateExprClass:
3574 case Expr::ImplicitValueInitExprClass:
3575 case Expr::ArrayInitLoopExprClass:
3576 case Expr::ArrayInitIndexExprClass:
3577 case Expr::NoInitExprClass:
3578 case Expr::ParenListExprClass:
3579 case Expr::LambdaExprClass:
3580 case Expr::MSPropertyRefExprClass:
3581 case Expr::MSPropertySubscriptExprClass:
3582 case Expr::TypoExprClass:
3583 case Expr::OMPArraySectionExprClass:
3584 case Expr::CXXInheritedCtorInitExprClass:
3585 llvm_unreachable(
"unexpected statement kind");
3587 case Expr::ConstantExprClass:
3588 E = cast<ConstantExpr>(E)->getSubExpr();
3592 case Expr::BlockExprClass:
3593 case Expr::ChooseExprClass:
3594 case Expr::CompoundLiteralExprClass:
3595 case Expr::ExtVectorElementExprClass:
3596 case Expr::GenericSelectionExprClass:
3597 case Expr::ObjCEncodeExprClass:
3598 case Expr::ObjCIsaExprClass:
3599 case Expr::ObjCIvarRefExprClass:
3600 case Expr::ObjCMessageExprClass:
3601 case Expr::ObjCPropertyRefExprClass:
3602 case Expr::ObjCProtocolExprClass:
3603 case Expr::ObjCSelectorExprClass:
3604 case Expr::ObjCStringLiteralClass:
3605 case Expr::ObjCBoxedExprClass:
3606 case Expr::ObjCArrayLiteralClass:
3607 case Expr::ObjCDictionaryLiteralClass:
3608 case Expr::ObjCSubscriptRefExprClass:
3609 case Expr::ObjCIndirectCopyRestoreExprClass:
3610 case Expr::ObjCAvailabilityCheckExprClass:
3611 case Expr::OffsetOfExprClass:
3612 case Expr::PredefinedExprClass:
3613 case Expr::ShuffleVectorExprClass:
3614 case Expr::ConvertVectorExprClass:
3615 case Expr::StmtExprClass:
3616 case Expr::TypeTraitExprClass:
3617 case Expr::ArrayTypeTraitExprClass:
3618 case Expr::ExpressionTraitExprClass:
3619 case Expr::VAArgExprClass:
3620 case Expr::CUDAKernelCallExprClass:
3621 case Expr::AsTypeExprClass:
3622 case Expr::PseudoObjectExprClass:
3623 case Expr::AtomicExprClass:
3624 case Expr::SourceLocExprClass:
3625 case Expr::FixedPointLiteralClass:
3626 case Expr::BuiltinBitCastExprClass:
3632 "cannot yet mangle expression type %0");
3639 case Expr::CXXUuidofExprClass: {
3643 Out <<
"u8__uuidoft";
3647 Out <<
"u8__uuidofz";
3648 mangleExpression(UuidExp, Arity);
3654 case Expr::BinaryConditionalOperatorClass: {
3658 "?: operator with omitted middle operand cannot be mangled");
3665 case Expr::OpaqueValueExprClass:
3666 llvm_unreachable(
"cannot mangle opaque value; mangling wrong thing?");
3668 case Expr::InitListExprClass: {
3670 mangleInitListElements(cast<InitListExpr>(E));
3675 case Expr::DesignatedInitExprClass: {
3676 auto *DIE = cast<DesignatedInitExpr>(E);
3677 for (
const auto &
Designator : DIE->designators()) {
3683 mangleExpression(DIE->getArrayIndex(
Designator));
3686 "unknown designator kind");
3688 mangleExpression(DIE->getArrayRangeStart(
Designator));
3689 mangleExpression(DIE->getArrayRangeEnd(
Designator));
3692 mangleExpression(DIE->getInit());
3696 case Expr::CXXDefaultArgExprClass:
3697 mangleExpression(cast<CXXDefaultArgExpr>(E)->getExpr(), Arity);
3700 case Expr::CXXDefaultInitExprClass:
3701 mangleExpression(cast<CXXDefaultInitExpr>(E)->getExpr(), Arity);
3704 case Expr::CXXStdInitializerListExprClass:
3705 mangleExpression(cast<CXXStdInitializerListExpr>(E)->getSubExpr(), Arity);
3708 case Expr::SubstNonTypeTemplateParmExprClass:
3709 mangleExpression(cast<SubstNonTypeTemplateParmExpr>(E)->getReplacement(),
3713 case Expr::UserDefinedLiteralClass:
3716 case Expr::CXXMemberCallExprClass:
3717 case Expr::CallExprClass: {
3718 const CallExpr *CE = cast<CallExpr>(E);
3737 if (isa<PackExpansionExpr>(Arg))
3738 CallArity = UnknownArity;
3740 mangleExpression(CE->
getCallee(), CallArity);
3742 mangleExpression(Arg);
3747 case Expr::CXXNewExprClass: {
3750 Out << (New->
isArray() ?
"na" :
"nw");
3753 mangleExpression(*I);
3767 mangleExpression(*I);
3768 }
else if (
const ParenListExpr *PLE = dyn_cast<ParenListExpr>(Init)) {
3769 for (
unsigned i = 0, e = PLE->getNumExprs();
i != e; ++
i)
3770 mangleExpression(PLE->getExpr(
i));
3772 isa<InitListExpr>(Init)) {
3774 mangleInitListElements(cast<InitListExpr>(Init));
3776 mangleExpression(Init);
3782 case Expr::CXXPseudoDestructorExprClass: {
3783 const auto *PDE = cast<CXXPseudoDestructorExpr>(E);
3784 if (
const Expr *Base = PDE->getBase())
3785 mangleMemberExprBase(Base, PDE->isArrow());
3789 mangleUnresolvedPrefix(Qualifier,
3791 mangleUnresolvedTypeOrSimpleId(ScopeInfo->getType());
3795 if (!mangleUnresolvedTypeOrSimpleId(ScopeInfo->getType()))
3798 }
else if (Qualifier) {
3799 mangleUnresolvedPrefix(Qualifier);
3803 QualType DestroyedType = PDE->getDestroyedType();
3804 mangleUnresolvedTypeOrSimpleId(DestroyedType);
3808 case Expr::MemberExprClass: {
3818 case Expr::UnresolvedMemberExprClass: {
3828 case Expr::CXXDependentScopeMemberExprClass: {
3830 = cast<CXXDependentScopeMemberExpr>(E);
3840 case Expr::UnresolvedLookupExprClass: {
3848 case Expr::CXXUnresolvedConstructExprClass: {
3853 assert(N == 1 &&
"unexpected form for list initialization");
3854 auto *IL = cast<InitListExpr>(CE->
getArg(0));
3857 mangleInitListElements(IL);
3864 if (N != 1) Out <<
'_';
3865 for (
unsigned I = 0; I != N; ++I) mangleExpression(CE->
getArg(I));
3866 if (N != 1) Out <<
'E';
3870 case Expr::CXXConstructExprClass: {
3871 const auto *CE = cast<CXXConstructExpr>(E);
3872 if (!CE->isListInitialization() || CE->isStdInitListInitialization()) {
3874 CE->getNumArgs() >= 1 &&
3875 (CE->getNumArgs() == 1 || isa<CXXDefaultArgExpr>(CE->getArg(1))) &&
3876 "implicit CXXConstructExpr must have one argument");
3877 return mangleExpression(cast<CXXConstructExpr>(E)->getArg(0));
3880 for (
auto *E : CE->arguments())
3881 mangleExpression(E);
3886 case Expr::CXXTemporaryObjectExprClass: {
3887 const auto *CE = cast<CXXTemporaryObjectExpr>(E);
3888 unsigned N = CE->getNumArgs();
3889 bool List = CE->isListInitialization();
3895 mangleType(CE->getType());
3896 if (!List && N != 1)
3898 if (CE->isStdInitListInitialization()) {
3903 cast<CXXStdInitializerListExpr>(CE->getArg(0)->IgnoreImplicit());
3904 auto *ILE = cast<InitListExpr>(SILE->getSubExpr()->IgnoreImplicit());
3905 mangleInitListElements(ILE);
3907 for (
auto *E : CE->arguments())
3908 mangleExpression(E);
3915 case Expr::CXXScalarValueInitExprClass:
3921 case Expr::CXXNoexceptExprClass:
3923 mangleExpression(cast<CXXNoexceptExpr>(E)->getOperand());
3926 case Expr::UnaryExprOrTypeTraitExprClass: {
3940 : ImplicitlyConvertedToType;
3942 mangleIntegerLiteral(T, V);
3957 "cannot yet mangle vec_step expression");
3965 "cannot yet mangle __builtin_omp_required_simd_align expression");
3980 case Expr::CXXThrowExprClass: {
3993 case Expr::CXXTypeidExprClass: {
4007 case Expr::CXXDeleteExprClass: {
4017 case Expr::UnaryOperatorClass: {
4025 case Expr::ArraySubscriptExprClass: {
4031 mangleExpression(AE->
getLHS());
4032 mangleExpression(AE->
getRHS());
4036 case Expr::CompoundAssignOperatorClass:
4037 case Expr::BinaryOperatorClass: {
4044 mangleExpression(BO->
getLHS());
4045 mangleExpression(BO->
getRHS());
4049 case Expr::ConditionalOperatorClass: {
4051 mangleOperatorName(OO_Conditional, 3);
4052 mangleExpression(CO->
getCond());
4053 mangleExpression(CO->
getLHS(), Arity);
4054 mangleExpression(CO->
getRHS(), Arity);
4058 case Expr::ImplicitCastExprClass: {
4059 ImplicitlyConvertedToType = E->
getType();
4060 E = cast<ImplicitCastExpr>(E)->getSubExpr();
4064 case Expr::ObjCBridgedCastExprClass: {
4067 StringRef
Kind = cast<ObjCBridgedCastExpr>(E)->getBridgeKindName();
4068 Out <<
"v1U" << Kind.size() <<
Kind;
4073 case Expr::CStyleCastExprClass:
4074 mangleCastExpression(E,
"cv");
4077 case Expr::CXXFunctionalCastExprClass: {
4078 auto *Sub = cast<ExplicitCastExpr>(E)->getSubExpr()->IgnoreImplicit();
4080 if (
auto *CCE = dyn_cast<CXXConstructExpr>(Sub))
4081 if (CCE->getParenOrBraceRange().isInvalid())
4082 Sub = CCE->getArg(0)->IgnoreImplicit();
4083 if (
auto *StdInitList = dyn_cast<CXXStdInitializerListExpr>(Sub))
4084 Sub = StdInitList->getSubExpr()->IgnoreImplicit();
4085 if (
auto *IL = dyn_cast<InitListExpr>(Sub)) {
4088 mangleInitListElements(IL);
4091 mangleCastExpression(E,
"cv");
4096 case Expr::CXXStaticCastExprClass:
4097 mangleCastExpression(E,
"sc");
4099 case Expr::CXXDynamicCastExprClass:
4100 mangleCastExpression(E,
"dc");
4102 case Expr::CXXReinterpretCastExprClass:
4103 mangleCastExpression(E,
"rc");
4105 case Expr::CXXConstCastExprClass:
4106 mangleCastExpression(E,
"cc");
4109 case Expr::CXXOperatorCallExprClass: {
4117 for (
unsigned i = 0;
i != NumArgs; ++
i)
4118 mangleExpression(CE->
getArg(
i));
4122 case Expr::ParenExprClass:
4123 mangleExpression(cast<ParenExpr>(E)->getSubExpr(), Arity);
4126 case Expr::DeclRefExprClass:
4127 mangleDeclRefExpr(cast<DeclRefExpr>(E)->getDecl());
4130 case Expr::SubstNonTypeTemplateParmPackExprClass:
4135 Out <<
"_SUBSTPACK_";
4138 case Expr::FunctionParmPackExprClass: {
4141 Out <<
"v110_SUBSTPACK";
4146 case Expr::DependentScopeDeclRefExprClass: {
4154 case Expr::CXXBindTemporaryExprClass:
4155 mangleExpression(cast<CXXBindTemporaryExpr>(E)->getSubExpr());
4158 case Expr::ExprWithCleanupsClass:
4159 mangleExpression(cast<ExprWithCleanups>(E)->getSubExpr(), Arity);
4162 case Expr::FloatingLiteralClass: {
4171 case Expr::CharacterLiteralClass:
4174 Out << cast<CharacterLiteral>(E)->
getValue();
4179 case Expr::ObjCBoolLiteralExprClass:
4181 Out << (cast<ObjCBoolLiteralExpr>(E)->
getValue() ?
'1' :
'0');
4185 case Expr::CXXBoolLiteralExprClass:
4187 Out << (cast<CXXBoolLiteralExpr>(E)->
getValue() ?
'1' :
'0');
4191 case Expr::IntegerLiteralClass: {
4194 Value.setIsSigned(
true);
4199 case Expr::ImaginaryLiteralClass: {
4206 dyn_cast<FloatingLiteral>(IE->
getSubExpr())) {
4208 mangleFloat(llvm::APFloat(Imag->getValue().getSemantics()));
4210 mangleFloat(Imag->getValue());
4215 Value.setIsSigned(
true);
4216 mangleNumber(Value);
4222 case Expr::StringLiteralClass: {
4225 assert(isa<ConstantArrayType>(E->
getType()));
4231 case Expr::GNUNullExprClass:
4235 case Expr::CXXNullPtrLiteralExprClass: {
4240 case Expr::PackExpansionExprClass:
4242 mangleExpression(cast<PackExpansionExpr>(E)->getPattern());
4245 case Expr::SizeOfPackExprClass: {
4246 auto *SPE = cast<SizeOfPackExpr>(E);
4247 if (SPE->isPartiallySubstituted()) {
4249 for (
const auto &A : SPE->getPartialArguments())
4250 mangleTemplateArg(A);
4258 mangleTemplateParameter(TTP->getIndex());
4260 = dyn_cast<NonTypeTemplateParmDecl>(Pack))
4261 mangleTemplateParameter(NTTP->getIndex());
4263 = dyn_cast<TemplateTemplateParmDecl>(Pack))
4264 mangleTemplateParameter(TempTP->getIndex());
4266 mangleFunctionParam(cast<ParmVarDecl>(Pack));
4270 case Expr::MaterializeTemporaryExprClass: {
4271 mangleExpression(cast<MaterializeTemporaryExpr>(E)->GetTemporaryExpr());
4275 case Expr::CXXFoldExprClass: {
4276 auto *FE = cast<CXXFoldExpr>(E);
4277 if (FE->isLeftFold())
4278 Out << (FE->getInit() ?
"fL" :
"fl");
4280 Out << (FE->getInit() ?
"fR" :
"fr");
4282 if (FE->getOperator() == BO_PtrMemD)
4290 mangleExpression(FE->getLHS());
4292 mangleExpression(FE->getRHS());
4296 case Expr::CXXThisExprClass:
4300 case Expr::CoawaitExprClass:
4302 Out <<
"v18co_await";
4303 mangleExpression(cast<CoawaitExpr>(E)->getOperand());
4306 case Expr::DependentCoawaitExprClass:
4308 Out <<
"v18co_await";
4309 mangleExpression(cast<DependentCoawaitExpr>(E)->getOperand());
4312 case Expr::CoyieldExprClass:
4314 Out <<
"v18co_yield";
4315 mangleExpression(cast<CoawaitExpr>(E)->getOperand());
4348 void CXXNameMangler::mangleFunctionParam(
const ParmVarDecl *parm) {
4355 assert(parmDepth < FunctionTypeDepth.getDepth());
4356 unsigned nestingDepth = FunctionTypeDepth.getDepth() - parmDepth;
4357 if (FunctionTypeDepth.isInResultType())
4360 if (nestingDepth == 0) {
4363 Out <<
"fL" << (nestingDepth - 1) <<
'p';
4371 &&
"parameter's type is still an array type?");
4374 dyn_cast<DependentAddressSpaceType>(parm->
getType())) {
4381 if (parmIndex != 0) {
4382 Out << (parmIndex - 1);
4387 void CXXNameMangler::mangleCXXCtorType(
CXXCtorType T,
4410 llvm_unreachable(
"closure constructors don't exist for the Itanium ABI!");
4413 mangleName(InheritedFrom);
4416 void CXXNameMangler::mangleCXXDtorType(
CXXDtorType T) {
4439 unsigned NumTemplateArgs) {
4442 for (
unsigned i = 0;
i != NumTemplateArgs; ++
i)
4450 for (
unsigned i = 0, e = AL.
size();
i != e; ++
i)
4451 mangleTemplateArg(AL[
i]);
4455 void CXXNameMangler::mangleTemplateArgs(
const TemplateArgument *TemplateArgs,
4456 unsigned NumTemplateArgs) {
4459 for (
unsigned i = 0;
i != NumTemplateArgs; ++
i)
4460 mangleTemplateArg(TemplateArgs[
i]);
4470 A = Context.getASTContext().getCanonicalTemplateArgument(A);
4474 llvm_unreachable(
"Cannot mangle NULL template argument");
4493 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
4495 if (isa<VarDecl>(D) || isa<FunctionDecl>(D)) {
4504 mangleExpression(E);
4518 if (compensateMangling) {
4520 mangleOperatorName(OO_Amp, 1);
4529 if (compensateMangling)
4545 mangleTemplateArg(
P);
4551 void CXXNameMangler::mangleTemplateParameter(
unsigned Index) {
4557 Out <<
'T' << (Index - 1) <<
'_';
4560 void CXXNameMangler::mangleSeqID(
unsigned SeqID) {
4563 else if (SeqID > 1) {
4571 for (; SeqID != 0; SeqID /= 36) {
4572 unsigned C = SeqID % 36;
4573 *I++ = (C < 10 ?
'0' +
C :
'A' + C - 10);
4576 Out.write(I.base(), I - BufferRef.rbegin());
4581 void CXXNameMangler::mangleExistingSubstitution(
TemplateName tname) {
4582 bool result = mangleSubstitution(tname);
4583 assert(result &&
"no existing substitution for template name");
4589 bool CXXNameMangler::mangleSubstitution(
const NamedDecl *ND) {
4591 if (mangleStandardSubstitution(ND))
4595 return mangleSubstitution(reinterpret_cast<uintptr_t>(ND));
4605 bool CXXNameMangler::mangleSubstitution(
QualType T) {
4608 return mangleSubstitution(RT->getDecl());
4613 return mangleSubstitution(TypePtr);
4616 bool CXXNameMangler::mangleSubstitution(
TemplateName Template) {
4618 return mangleSubstitution(TD);
4620 Template = Context.getASTContext().getCanonicalTemplateName(Template);
4621 return mangleSubstitution(
4625 bool CXXNameMangler::mangleSubstitution(
uintptr_t Ptr) {
4626 llvm::DenseMap<uintptr_t, unsigned>::iterator I = Substitutions.find(Ptr);
4627 if (I == Substitutions.end())
4630 unsigned SeqID = I->second;
4664 if (TemplateArgs.
size() != 1)
4667 if (!
isCharType(TemplateArgs[0].getAsType()))
4673 template <std::
size_t StrLen>
4675 const char (&Str)[StrLen]) {
4680 if (TemplateArgs.
size() != 2)
4683 if (!
isCharType(TemplateArgs[0].getAsType()))
4692 bool CXXNameMangler::mangleStandardSubstitution(
const NamedDecl *ND) {
4694 if (
const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) {
4719 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
4729 if (TemplateArgs.
size() != 3)
4732 if (!
isCharType(TemplateArgs[0].getAsType()))
4769 void CXXNameMangler::addSubstitution(
QualType T) {
4772 addSubstitution(RT->getDecl());
4778 addSubstitution(TypePtr);
4781 void CXXNameMangler::addSubstitution(
TemplateName Template) {
4783 return addSubstitution(TD);
4785 Template = Context.getASTContext().getCanonicalTemplateName(Template);
4789 void CXXNameMangler::addSubstitution(
uintptr_t Ptr) {
4790 assert(!Substitutions.count(Ptr) &&
"Substitution already exists!");
4791 Substitutions[Ptr] = SeqID++;
4794 void CXXNameMangler::extendSubstitutions(CXXNameMangler* Other) {
4795 assert(Other->SeqID >= SeqID &&
"Must be superset of substitutions!");
4796 if (Other->SeqID > SeqID) {
4797 Substitutions.swap(Other->Substitutions);
4798 SeqID = Other->SeqID;
4802 CXXNameMangler::AbiTagList
4803 CXXNameMangler::makeFunctionReturnTypeTags(
const FunctionDecl *FD) {
4805 if (DisableDerivedAbiTags)
4806 return AbiTagList();
4808 llvm::raw_null_ostream NullOutStream;
4809 CXXNameMangler TrackReturnTypeTags(*
this, NullOutStream);
4810 TrackReturnTypeTags.disableDerivedAbiTags();
4814 FunctionTypeDepthState saved = TrackReturnTypeTags.FunctionTypeDepth.push();
4815 TrackReturnTypeTags.FunctionTypeDepth.enterResultType();
4817 TrackReturnTypeTags.FunctionTypeDepth.leaveResultType();
4818 TrackReturnTypeTags.FunctionTypeDepth.pop(saved);
4820 return TrackReturnTypeTags.AbiTagsRoot.getSortedUniqueUsedAbiTags();
4823 CXXNameMangler::AbiTagList
4824 CXXNameMangler::makeVariableTypeTags(
const VarDecl *VD) {
4826 if (DisableDerivedAbiTags)
4827 return AbiTagList();
4829 llvm::raw_null_ostream NullOutStream;
4830 CXXNameMangler TrackVariableType(*
this, NullOutStream);
4831 TrackVariableType.disableDerivedAbiTags();
4833 TrackVariableType.mangleType(VD->
getType());
4835 return TrackVariableType.AbiTagsRoot.getSortedUniqueUsedAbiTags();
4838 bool CXXNameMangler::shouldHaveAbiTags(ItaniumMangleContextImpl &C,
4840 llvm::raw_null_ostream NullOutStream;
4841 CXXNameMangler TrackAbiTags(C, NullOutStream,
nullptr,
true);
4842 TrackAbiTags.mangle(VD);
4843 return TrackAbiTags.AbiTagsRoot.getUsedAbiTags().size();
4856 void ItaniumMangleContextImpl::mangleCXXName(
const NamedDecl *D,
4858 assert((isa<FunctionDecl>(D) || isa<VarDecl>(D)) &&
4859 "Invalid mangleName() call, argument is not a variable or function!");
4860 assert(!isa<CXXConstructorDecl>(D) && !isa<CXXDestructorDecl>(D) &&
4861 "Invalid mangleName() call on 'structor decl!");
4864 getASTContext().getSourceManager(),
4865 "Mangling declaration");
4867 CXXNameMangler Mangler(*
this, Out, D);
4874 CXXNameMangler Mangler(*
this, Out, D, Type);
4881 CXXNameMangler Mangler(*
this, Out, D, Type);
4887 CXXNameMangler Mangler(*
this, Out, D,
Ctor_Comdat);
4893 CXXNameMangler Mangler(*
this, Out, D,
Dtor_Comdat);
4897 void ItaniumMangleContextImpl::mangleThunk(
const CXXMethodDecl *MD,
4907 assert(!isa<CXXDestructorDecl>(MD) &&
4908 "Use mangleCXXDtor for destructor decls!");
4909 CXXNameMangler Mangler(*
this, Out);
4910 Mangler.getStream() <<
"_ZT";
4912 Mangler.getStream() <<
'c';
4923 Mangler.mangleFunctionEncoding(MD);
4926 void ItaniumMangleContextImpl::mangleCXXDtorThunk(
4931 CXXNameMangler Mangler(*
this, Out, DD, Type);
4932 Mangler.getStream() <<
"_ZT";
4935 Mangler.mangleCallOffset(ThisAdjustment.
NonVirtual,
4938 Mangler.mangleFunctionEncoding(DD);
4942 void ItaniumMangleContextImpl::mangleStaticGuardVariable(
const VarDecl *D,
4946 CXXNameMangler Mangler(*
this, Out);
4949 Mangler.getStream() <<
"_ZGV";
4950 Mangler.mangleName(D);
4953 void ItaniumMangleContextImpl::mangleDynamicInitializer(
const VarDecl *MD,
4958 Out <<
"__cxx_global_var_init";
4961 void ItaniumMangleContextImpl::mangleDynamicAtExitDestructor(
const VarDecl *D,
4964 CXXNameMangler Mangler(*
this, Out);
4965 Mangler.getStream() <<
"__dtor_";
4966 if (shouldMangleDeclName(D))
4969 Mangler.getStream() << D->
getName();
4972 void ItaniumMangleContextImpl::mangleSEHFilterExpression(
4973 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
4974 CXXNameMangler Mangler(*
this, Out);
4975 Mangler.getStream() <<
"__filt_";
4976 if (shouldMangleDeclName(EnclosingDecl))
4977 Mangler.mangle(EnclosingDecl);
4979 Mangler.getStream() << EnclosingDecl->
getName();
4982 void ItaniumMangleContextImpl::mangleSEHFinallyBlock(
4983 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
4984 CXXNameMangler Mangler(*
this, Out);
4985 Mangler.getStream() <<
"__fin_";
4986 if (shouldMangleDeclName(EnclosingDecl))
4987 Mangler.mangle(EnclosingDecl);
4989 Mangler.getStream() << EnclosingDecl->
getName();
4992 void ItaniumMangleContextImpl::mangleItaniumThreadLocalInit(
const VarDecl *D,
4995 CXXNameMangler Mangler(*
this, Out);
4996 Mangler.getStream() <<
"_ZTH";
4997 Mangler.mangleName(D);
5001 ItaniumMangleContextImpl::mangleItaniumThreadLocalWrapper(
const VarDecl *D,
5004 CXXNameMangler Mangler(*
this, Out);
5005 Mangler.getStream() <<
"_ZTW";
5006 Mangler.mangleName(D);
5009 void ItaniumMangleContextImpl::mangleReferenceTemporary(
const VarDecl *D,
5010 unsigned ManglingNumber,
5014 CXXNameMangler Mangler(*
this, Out);
5015 Mangler.getStream() <<
"_ZGR";
5016 Mangler.mangleName(D);
5017 assert(ManglingNumber > 0 &&
"Reference temporary mangling number is zero!");
5018 Mangler.mangleSeqID(ManglingNumber - 1);
5021 void ItaniumMangleContextImpl::mangleCXXVTable(
const CXXRecordDecl *RD,
5024 CXXNameMangler Mangler(*
this, Out);
5025 Mangler.getStream() <<
"_ZTV";
5026 Mangler.mangleNameOrStandardSubstitution(RD);
5029 void ItaniumMangleContextImpl::mangleCXXVTT(
const CXXRecordDecl *RD,
5032 CXXNameMangler Mangler(*
this, Out);
5033 Mangler.getStream() <<
"_ZTT";
5034 Mangler.mangleNameOrStandardSubstitution(RD);
5037 void ItaniumMangleContextImpl::mangleCXXCtorVTable(
const CXXRecordDecl *RD,
5042 CXXNameMangler Mangler(*
this, Out);
5043 Mangler.getStream() <<
"_ZTC";
5044 Mangler.mangleNameOrStandardSubstitution(RD);
5045 Mangler.getStream() <<
Offset;
5046 Mangler.getStream() <<
'_';
5047 Mangler.mangleNameOrStandardSubstitution(Type);
5050 void ItaniumMangleContextImpl::mangleCXXRTTI(
QualType Ty, raw_ostream &Out) {
5052 assert(!Ty.
hasQualifiers() &&
"RTTI info cannot have top-level qualifiers");
5053 CXXNameMangler Mangler(*
this, Out);
5054 Mangler.getStream() <<
"_ZTI";
5055 Mangler.mangleType(Ty);
5058 void ItaniumMangleContextImpl::mangleCXXRTTIName(
QualType Ty,
5061 CXXNameMangler Mangler(*
this, Out);
5062 Mangler.getStream() <<
"_ZTS";
5063 Mangler.mangleType(Ty);
5066 void ItaniumMangleContextImpl::mangleTypeName(
QualType Ty, raw_ostream &Out) {
5067 mangleCXXRTTIName(Ty, Out);
5070 void ItaniumMangleContextImpl::mangleStringLiteral(
const StringLiteral *, raw_ostream &) {
5071 llvm_unreachable(
"Can't mangle string literals");
5076 return new ItaniumMangleContextImpl(Context, Diags);
A call to an overloaded operator written using operator syntax.
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
Defines the clang::ASTContext interface.
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it's either not been deduced or was deduce...
const Type * Ty
The locally-unqualified type.
unsigned getNumDecls() const
Gets the number of declarations in the unresolved set.
Represents a function declaration or definition.
std::string Name
The name of this module.
The "enum" keyword introduces the elaborated-type-specifier.
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this __uuidof() expression after various required adjustments (removing...
PointerType - C99 6.7.5.1 - Pointer Declarators.
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
void * getAsVoidPointer() const
Retrieve the template name as a void pointer.
QualType getPointeeType() const
Represents the dependent type named by a dependently-scoped typename using declaration, e.g.
A (possibly-)qualified type.
OverloadedOperatorKind getOperator() const
Return the overloaded operator to which this template name refers.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
Attempt to be ABI-compatible with code generated by Clang 6.0.x (SVN r321711).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
static const TemplateArgument & getArgument(const TemplateArgument &A)
QualType getInjectedSpecializationType() const
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
const Expr * getSubExpr() const
__auto_type (GNU extension)
VarDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
The COMDAT used for ctors.
const Expr * getInit(unsigned Init) const
bool isListInitialization() const
Determine whether this expression models list-initialization.
Expr * getUnderlyingExpr() const
bool isDependent() const
Whether this template argument is dependent on a template parameter such that its result can change f...
Module * getOwningModuleForLinkage(bool IgnoreLinkage=false) const
Get the module that owns this declaration for linkage purposes.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
FunctionType - C99 6.7.5.3 - Function Declarators.
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program...
bool hasExtParameterInfos() const
Is there any interesting extra information for any of the parameters of this function type...
TemplateArgumentLoc const * getTemplateArgs() const
An instance of this object exists for each enum constant that is defined.
Defines the SourceManager interface.
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
Represents a qualified type name for which the type name is dependent.
The template argument is an expression, and we've not resolved it to one of the other forms yet...
unsigned size() const
Retrieve the number of template arguments in this template argument list.
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
bool isDecltypeAuto() const
Decl - This represents one declaration (or definition), e.g.
bool isVariadic() const
Whether this function prototype is variadic.
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.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
Represents a C++11 auto or C++14 decltype(auto) type.
unsigned getBlockManglingNumber() const
The base class of the type hierarchy.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies this declaration.
int64_t NonVirtual
The non-virtual adjustment from the derived object to its nearest virtual base.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
Represent a C++ namespace.
bool isArrayRangeDesignator() const
Represents a call to a C++ constructor.
static bool isParenthesizedADLCallee(const CallExpr *call)
Look at the callee of the given call expression and determine if it's a parenthesized id-expression w...
ArrayRef< NamedDecl * > getLambdaExplicitTemplateParameters() const
Retrieve the lambda template parameters that were specified explicitly.
A container of type source information.
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
SourceLocation getAttributeLoc() const
Represents a C++ constructor within a class.
A template template parameter that has been substituted for some other template name.
Default closure variant of a ctor.
QualType getElementType() const
const Expr * getSubExpr() const
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
TemplateName getTemplateName() const
Retrieve the name of the template that we are deducing.
An identifier, stored as an IdentifierInfo*.
Represents a variable declaration or definition.
void removeObjCLifetime()
unsigned getNumParams() const
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.
struct clang::ThisAdjustment::VirtualAdjustment::@135 Itanium
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
A C++ throw-expression (C++ [except.throw]).
Expr * getExprOperand() const
Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
QualType getIntegralType() const
Retrieve the type of the integral value.
static const TemplateDecl * isTemplate(const NamedDecl *ND, const TemplateArgumentList *&TemplateArgs)
The collection of all-type qualifiers we support.
Expr * getExprOperand() const
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
const char * getStmtClassName() const
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Represents a struct/union/class.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
bool isNothrow(bool ResultIfDependent=false) const
Determine whether this function type has a non-throwing exception specification.
bool isInAnonymousNamespace() const
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Represents a class type in Objective C.
QualType getPointeeType() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Represents a dependent template name that cannot be resolved prior to template instantiation.
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
Used for GCC's __alignof.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
NameKind getNameKind() const
Determine what kind of name this is.
Represents a member of a struct/union/class.
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
const llvm::APSInt & getInitVal() const
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm()
bool isReferenceType() const
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.
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
An unqualified-id that has been assumed to name a function template that will be found by ADL...
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.
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.
virtual const char * getLongDoubleMangling() const
Return the mangled code of long double.
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
Expr * getSizeExpr() const
unsigned getLength() const
Efficiently return the length of this identifier info.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
bool isTypeOperand() const
Expr * getSizeExpr() const
QualType getElementType() const
arg_iterator placement_arg_end()
This parameter (which must have pointer-to-pointer type) uses the special Swift error-result ABI trea...
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
Represents an extended vector type where either the type or size is dependent.
This object can be modified without requiring retains or releases.
NamedDecl * getFirstQualifierFoundInScope() const
Retrieve the first part of the nested-name-specifier that was found in the scope of the member access...
DeclarationName getMemberName() const
Retrieve the name of the member that this expression refers to.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
Represents a K&R-style 'int foo()' function, which has no information available about its arguments...
Expr * getAddrSpaceExpr() const
bool isExternC() const
Determines whether this variable is a variable with external, C linkage.
llvm::StringRef getParameterABISpelling(ParameterABI kind)
unsigned getLambdaManglingNumber() const
If this is the closure type of a lambda expression, retrieve the number to be used for name mangling ...
ConditionalOperator - The ?: ternary operator.
QualType getBaseType() const
Gets the base type of this object type.
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).
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.
bool isImplicitAccess() const
True if this is an implicit access, i.e.
Exposes information about the current target.
Represents an array type in C++ whose size is a value-dependent expression.
CXXDtorType
C++ destructor types.
QualType getElementType() const
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function)...
unsigned getNumArgs() const
Retrieve the number of template arguments.
unsigned getFunctionScopeDepth() const
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.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
static const DeclContext * IgnoreLinkageSpecDecls(const DeclContext *DC)
QualType getPointeeType() const
TemplateDecl * getTemplateDecl() const
The template declaration to which this qualified name refers.
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
TemplateArgumentLoc const * getTemplateArgs() const
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '...
Declaration of a template type parameter.
unsigned getIndex() const
bool isImplicitAccess() const
True if this is an implicit access, i.e., one in which the member being accessed was not written in t...
const T * castAs() const
Member-template castAs<specific type>.
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
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
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
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
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
static StringRef mangleAArch64VectorBase(const BuiltinType *EltType)
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char, signed char, short, int, long..], or an enum decl which has a signed representation.
bool isFunctionOrMethod() const
bool isIdentifier() const
Predicate functions for querying what type of name this is.
Qualifiers Quals
The local qualifiers.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool hasInitializer() const
Whether this new-expression has any initializer at all.
bool hasInstantiationDependentExceptionSpec() const
Return whether this function has an instantiation-dependent exception spec.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Represents a GCC generic vector type.
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this typeid() expression after various required adjustments (removing r...
An lvalue reference type, per C++11 [dcl.ref].
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
A type, stored as a Type*.
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
The COMDAT used for dtors.
static StringRef getIdentifier(const Token &Tok)
CallingConv
CallingConv - Specifies the calling convention that a function uses.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1...
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
RecordDecl * getDecl() const
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the member name.
int64_t NonVirtual
The non-virtual adjustment from the derived object to its nearest virtual base.
static bool hasMangledSubstitutionQualifiers(QualType T)
Determine whether the given type has any qualifiers that are relevant for substitutions.
A template template parameter pack that has been substituted for a template template argument pack...
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
There is no lifetime qualification on this type.
struct clang::ReturnAdjustment::VirtualAdjustment::@133 Itanium
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template declarations that this template name refers to...
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
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.
virtual const char * getFloat128Mangling() const
Return the mangled code of __float128.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
Represents the declaration of a struct/union/class/enum.
LanguageLinkage
Describes the different kinds of language linkage (C++ [dcl.link]) that an entity may have...
CallingConv getCC() const
QualType getElementType() const
Represents a vector type where either the type or size is dependent.
bool isFieldDesignator() const
Represents a static or instance method of a struct/union/class.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
No ref-qualifier was provided.
QualType getAllocatedType() const
const ParmVarDecl * getParamDecl(unsigned i) const
This file defines OpenMP nodes for declarative directives.
Qualifiers getMethodQuals() const
Expr * getNoexceptExpr() const
Return the expression inside noexcept(expression), or a null pointer if there is none (because the ex...
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
Used for C's _Alignof and C++'s alignof.
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 or init-capture pack that has been substituted bu...
Represents a template argument.
Represents a template name that was expressed as a qualified name.
bool isTypeOperand() const
Dataflow Directional Tag Classes.
ThisAdjustment This
The this pointer adjustment.
ExtInfo getExtInfo() const
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
NestedNameSpecifier * getQualifier() const
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
The base class of all kinds of template declarations (e.g., class, function, etc.).
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
The template argument is a pack expansion of a template name that was provided for a template templat...
const TemplateArgument * getArgs() const
Retrieve the template arguments.
Represents a field injected from an anonymous union/struct into the parent scope. ...
bool isDependentAddressSpaceType() const
NamespaceDecl * getOriginalNamespace()
Get the original (first) namespace declaration.
DeclarationName getMember() const
Retrieve the name of the member that this expression refers to.
The name of a declaration.
StmtClass getStmtClass() const
VectorKind getVectorKind() const
ArrayRef< QualType > exceptions() const
The "union" keyword introduces the elaborated-type-specifier.
bool isBooleanType() const
bool isMSVCRTEntryPoint() const
Determines whether this function is a MSVCRT user defined entry point.
The "class" keyword introduces the elaborated-type-specifier.
bool isKindOfType() const
Whether this ia a "__kindof" type (semantically).
int64_t VBaseOffsetOffset
The offset (in bytes), relative to the address point of the virtual base class offset.
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
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
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.
Iterator for iterating over Stmt * arrays that contain only T *.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const llvm::APInt & getSize() const
ExtVectorType - Extended vector type.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
ReturnAdjustment Return
The return adjustment.
The template argument is a type.
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
The template argument is actually a parameter pack.
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '...
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
arg_iterator placement_arg_begin()
CXXMethodDecl * getLambdaStaticInvoker() const
Retrieve the lambda static invoker, the address of which is returned by the conversion operator...
unsigned arg_size() const
Retrieve the number of arguments.
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
A template argument list.
VectorType::VectorKind getVectorKind() const
Reading or writing from this object requires a barrier call.
ArgKind getKind() const
Return the kind of stored template argument.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
QualType getParamType(unsigned i) const
static bool isTypeSubstitutable(Qualifiers Quals, const Type *Ty, ASTContext &Ctx)
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
TypedefNameDecl * getTypedefNameForAnonDecl() const
bool hasUnaligned() const
Represents a C++ struct/union/class.
Represents a template specialization type whose template cannot be resolved, e.g. ...
The template argument is a template name that was provided for a template template parameter...
Represents a C array with an unspecified size.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
A structure for storing the information associated with an overloaded template name.
Declaration of a class template.
This class is used for builtin types like 'int'.
Decl * getLambdaContextDecl() const
Retrieve the declaration that provides additional context for a lambda, when the normal declaration c...
static bool isCharSpecialization(QualType T, const char *Name)
Returns whether a given type is a template specialization of a given name with a single argument of t...
static bool isCharType(QualType T)
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
bool isGlobalDelete() const
bool isImplicitCXXThis() const
Whether this expression is an implicit reference to 'this' in C++.
Copying closure variant of a ctor.
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
unsigned getCVRQualifiers() const
static Decl::Kind getKind(const Decl *D)
unsigned getNumElements() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
QualType getAsType() const
Retrieve the type for a type template argument.
A reference to a declared variable, function, enum, etc.
Represents an extended address space qualifier where the input address space value is dependent...
Represents a type template specialization; the template must be a class template, a type alias templa...
Designator - A designator in a C99 designated initializer.
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
IdentifierInfo * getCXXLiteralIdentifier() const
If this name is the name of a literal operator, retrieve the identifier associated with it...
A set of overloaded template declarations.
This represents a decl that may have a name.
bool isTranslationUnit() const
bool isOpenCLSpecificType() const
Represents a C array with a specified size that is not an integer-constant-expression.
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
No keyword precedes the qualified type name.
static bool isStd(const NamespaceDecl *NS)
Return whether a given namespace is the 'std' namespace.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
unsigned getNumTemplateArgs() const
QualType getElementType() const
The global specifier '::'. There is no stored value.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion, return the pattern as a template name.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
const LangOptions & getLangOpts() const
The "__interface" keyword introduces the elaborated-type-specifier.
Represents the canonical version of C arrays with a specified constant size.
InitListExpr * getSyntacticForm() const
Declaration of a template function.
A class which abstracts out some details necessary for making a call.
bool hasLinkage() const
Determine whether this declaration has linkage.
Attr - This represents one attribute.
QualType getPointeeType() const
bool isExternallyVisible() const
QualType getType() const
Return the type wrapped by this type source info.
A single template declaration.
This parameter (which must have pointer type) is a Swift indirect result parameter.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point...
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.