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;
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);
491 const AbiTagList *AdditionalAbiTags,
492 bool NoFunction=
false);
495 unsigned NumTemplateArgs);
497 void manglePrefix(
const DeclContext *DC,
bool NoFunction=
false);
499 void mangleTemplatePrefix(
const TemplateDecl *ND,
bool NoFunction=
false);
501 bool mangleUnresolvedTypeOrSimpleId(
QualType DestroyedType,
502 StringRef Prefix =
"");
505 void mangleVendorQualifier(StringRef qualifier);
512 #define ABSTRACT_TYPE(CLASS, PARENT) 513 #define NON_CANONICAL_TYPE(CLASS, PARENT) 514 #define TYPE(CLASS, PARENT) void mangleType(const CLASS##Type *T); 515 #include "clang/AST/TypeNodes.def" 517 void mangleType(
const TagType*);
519 static StringRef getCallingConvQualifierName(
CallingConv CC);
520 void mangleExtParameterInfo(FunctionProtoType::ExtParameterInfo info);
524 void mangleNeonVectorType(
const VectorType *T);
526 void mangleAArch64NeonVectorType(
const VectorType *T);
529 void mangleIntegerLiteral(
QualType T,
const llvm::APSInt &
Value);
530 void mangleMemberExprBase(
const Expr *base,
bool isArrow);
531 void mangleMemberExpr(
const Expr *base,
bool isArrow,
536 unsigned NumTemplateArgs,
537 unsigned knownArity);
538 void mangleCastExpression(
const Expr *E, StringRef CastEncoding);
539 void mangleInitListElements(
const InitListExpr *InitList);
540 void mangleExpression(
const Expr *E,
unsigned Arity = UnknownArity);
545 unsigned NumTemplateArgs);
547 unsigned NumTemplateArgs);
551 void mangleTemplateParameter(
unsigned Index);
556 const AbiTagList *AdditionalAbiTags);
559 AbiTagList makeFunctionReturnTypeTags(
const FunctionDecl *FD);
561 AbiTagList makeVariableTypeTags(
const VarDecl *VD);
566 bool ItaniumMangleContextImpl::shouldMangleCXXName(
const NamedDecl *D) {
571 if (FD->
hasAttr<OverloadableAttr>())
601 if (!getASTContext().getLangOpts().CPlusPlus)
605 if (VD && !isa<DecompositionDecl>(D)) {
611 const DeclContext *DC = getEffectiveDeclContext(D);
615 DC = getEffectiveParentContext(DC);
617 !CXXNameMangler::shouldHaveAbiTags(*
this, VD) &&
618 !isa<VarTemplateSpecializationDecl>(D))
625 void CXXNameMangler::writeAbiTags(
const NamedDecl *ND,
626 const AbiTagList *AdditionalAbiTags) {
627 assert(AbiTags &&
"require AbiTagState");
628 AbiTags->write(Out, ND, DisableDerivedAbiTags ?
nullptr : AdditionalAbiTags);
631 void CXXNameMangler::mangleSourceNameWithAbiTags(
632 const NamedDecl *ND,
const AbiTagList *AdditionalAbiTags) {
634 writeAbiTags(ND, AdditionalAbiTags);
637 void CXXNameMangler::mangle(
const NamedDecl *D) {
643 mangleFunctionEncoding(FD);
644 else if (
const VarDecl *VD = dyn_cast<VarDecl>(D))
647 mangleName(IFD->getAnonField());
649 mangleName(cast<FieldDecl>(D));
652 void CXXNameMangler::mangleFunctionEncoding(
const FunctionDecl *FD) {
656 if (!Context.shouldMangleDeclName(FD)) {
661 AbiTagList ReturnTypeAbiTags = makeFunctionReturnTypeTags(FD);
662 if (ReturnTypeAbiTags.empty()) {
665 mangleFunctionEncodingBareType(FD);
673 llvm::raw_svector_ostream FunctionEncodingStream(FunctionEncodingBuf);
674 CXXNameMangler FunctionEncodingMangler(*
this, FunctionEncodingStream);
676 FunctionEncodingMangler.disableDerivedAbiTags();
677 FunctionEncodingMangler.mangleNameWithAbiTags(FD,
nullptr);
680 size_t EncodingPositionStart = FunctionEncodingStream.str().size();
681 FunctionEncodingMangler.mangleFunctionEncodingBareType(FD);
685 const AbiTagList &UsedAbiTags =
686 FunctionEncodingMangler.AbiTagsRoot.getSortedUniqueUsedAbiTags();
687 AbiTagList AdditionalAbiTags(ReturnTypeAbiTags.size());
688 AdditionalAbiTags.erase(
689 std::set_difference(ReturnTypeAbiTags.begin(), ReturnTypeAbiTags.end(),
690 UsedAbiTags.begin(), UsedAbiTags.end(),
691 AdditionalAbiTags.begin()),
692 AdditionalAbiTags.end());
695 mangleNameWithAbiTags(FD, &AdditionalAbiTags);
696 Out << FunctionEncodingStream.str().substr(EncodingPositionStart);
700 extendSubstitutions(&FunctionEncodingMangler);
703 void CXXNameMangler::mangleFunctionEncodingBareType(
const FunctionDecl *FD) {
704 if (FD->
hasAttr<EnableIfAttr>()) {
705 FunctionTypeDepthState Saved = FunctionTypeDepth.push();
706 Out <<
"Ua9enable_ifI";
707 for (AttrVec::const_iterator I = FD->
getAttrs().begin(),
710 EnableIfAttr *EIA = dyn_cast<EnableIfAttr>(*I);
714 mangleExpression(EIA->getCond());
718 FunctionTypeDepth.pop(Saved);
723 if (
auto *CD = dyn_cast<CXXConstructorDecl>(FD))
724 if (
auto Inherited = CD->getInheritedConstructor())
725 FD = Inherited.getConstructor();
743 bool MangleReturnType =
false;
745 if (!(isa<CXXConstructorDecl>(FD) || isa<CXXDestructorDecl>(FD) ||
746 isa<CXXConversionDecl>(FD)))
747 MangleReturnType =
true;
750 FD = PrimaryTemplate->getTemplatedDecl();
754 MangleReturnType, FD);
758 while (isa<LinkageSpecDecl>(DC)) {
759 DC = getEffectiveParentContext(DC);
768 ->isTranslationUnit())
772 return II && II->
isStr(
"std");
781 return isStd(cast<NamespaceDecl>(DC));
787 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
796 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
797 TemplateArgs = &Spec->getTemplateArgs();
798 return Spec->getSpecializedTemplate();
803 dyn_cast<VarTemplateSpecializationDecl>(ND)) {
804 TemplateArgs = &Spec->getTemplateArgs();
805 return Spec->getSpecializedTemplate();
811 void CXXNameMangler::mangleName(
const NamedDecl *ND) {
812 if (
const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
814 AbiTagList VariableTypeAbiTags = makeVariableTypeTags(VD);
815 if (VariableTypeAbiTags.empty()) {
817 mangleNameWithAbiTags(VD,
nullptr);
822 llvm::raw_null_ostream NullOutStream;
823 CXXNameMangler VariableNameMangler(*
this, NullOutStream);
824 VariableNameMangler.disableDerivedAbiTags();
825 VariableNameMangler.mangleNameWithAbiTags(VD,
nullptr);
828 const AbiTagList &UsedAbiTags =
829 VariableNameMangler.AbiTagsRoot.getSortedUniqueUsedAbiTags();
830 AbiTagList AdditionalAbiTags(VariableTypeAbiTags.size());
831 AdditionalAbiTags.erase(
832 std::set_difference(VariableTypeAbiTags.begin(),
833 VariableTypeAbiTags.end(), UsedAbiTags.begin(),
834 UsedAbiTags.end(), AdditionalAbiTags.begin()),
835 AdditionalAbiTags.end());
838 mangleNameWithAbiTags(VD, &AdditionalAbiTags);
840 mangleNameWithAbiTags(ND,
nullptr);
844 void CXXNameMangler::mangleNameWithAbiTags(
const NamedDecl *ND,
845 const AbiTagList *AdditionalAbiTags) {
851 const DeclContext *DC = getEffectiveDeclContext(ND);
857 if (isLocalContainerContext(DC) && ND->
hasLinkage() && !isLambda(ND))
859 DC = getEffectiveParentContext(DC);
860 else if (GetLocalClassDecl(ND)) {
861 mangleLocalName(ND, AdditionalAbiTags);
867 if (isLocalContainerContext(DC)) {
868 mangleLocalName(ND, AdditionalAbiTags);
884 mangleUnscopedTemplateName(TD, AdditionalAbiTags);
885 mangleTemplateArgs(*TemplateArgs);
889 mangleUnscopedName(ND, AdditionalAbiTags);
893 mangleNestedName(ND, DC, AdditionalAbiTags);
896 void CXXNameMangler::mangleModuleName(
const Module *M) {
903 mangleModuleNamePrefix(M->
Name);
907 void CXXNameMangler::mangleModuleNamePrefix(StringRef Name) {
910 auto It = ModuleSubstitutions.find(Name);
911 if (It != ModuleSubstitutions.end()) {
913 Out << '_' << static_cast<char>(
'0' + It->second);
915 Out <<
'W' << (It->second - 10) <<
'_';
921 auto Parts = Name.rsplit(
'.');
922 if (Parts.second.empty())
923 Parts.second = Parts.first;
925 mangleModuleNamePrefix(Parts.first);
927 Out << Parts.second.size() << Parts.second;
928 ModuleSubstitutions.insert({Name, ModuleSubstitutions.size()});
931 void CXXNameMangler::mangleTemplateName(
const TemplateDecl *TD,
933 unsigned NumTemplateArgs) {
937 mangleUnscopedTemplateName(TD,
nullptr);
938 mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
940 mangleNestedName(TD, TemplateArgs, NumTemplateArgs);
944 void CXXNameMangler::mangleUnscopedName(
const NamedDecl *ND,
945 const AbiTagList *AdditionalAbiTags) {
952 mangleUnqualifiedName(ND, AdditionalAbiTags);
955 void CXXNameMangler::mangleUnscopedTemplateName(
956 const TemplateDecl *ND,
const AbiTagList *AdditionalAbiTags) {
959 if (mangleSubstitution(ND))
963 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND)) {
964 assert(!AdditionalAbiTags &&
965 "template template param cannot have abi tags");
966 mangleTemplateParameter(TTP->getIndex());
967 }
else if (isa<BuiltinTemplateDecl>(ND)) {
968 mangleUnscopedName(ND, AdditionalAbiTags);
976 void CXXNameMangler::mangleUnscopedTemplateName(
977 TemplateName Template,
const AbiTagList *AdditionalAbiTags) {
981 return mangleUnscopedTemplateName(TD, AdditionalAbiTags);
983 if (mangleSubstitution(Template))
986 assert(!AdditionalAbiTags &&
987 "dependent template name cannot have abi tags");
990 assert(Dependent &&
"Not a dependent template name?");
992 mangleSourceName(
Id);
994 mangleOperatorName(Dependent->
getOperator(), UnknownArity);
996 addSubstitution(Template);
999 void CXXNameMangler::mangleFloat(
const llvm::APFloat &f) {
1013 llvm::APInt valueBits = f.bitcastToAPInt();
1014 unsigned numCharacters = (valueBits.getBitWidth() + 3) / 4;
1015 assert(numCharacters != 0);
1021 for (
unsigned stringIndex = 0; stringIndex != numCharacters; ++stringIndex) {
1023 unsigned digitBitIndex = 4 * (numCharacters - stringIndex - 1);
1026 uint64_t hexDigit = valueBits.getRawData()[digitBitIndex / 64];
1027 hexDigit >>= (digitBitIndex % 64);
1031 static const char charForHex[16] = {
1032 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
1033 '8',
'9',
'a',
'b',
'c',
'd',
'e',
'f' 1035 buffer[stringIndex] = charForHex[hexDigit];
1038 Out.write(buffer.data(), numCharacters);
1041 void CXXNameMangler::mangleNumber(
const llvm::APSInt &
Value) {
1042 if (Value.isSigned() && Value.isNegative()) {
1044 Value.abs().print(Out,
false);
1046 Value.print(Out,
false);
1050 void CXXNameMangler::mangleNumber(int64_t Number) {
1060 void CXXNameMangler::mangleCallOffset(int64_t NonVirtual, int64_t Virtual) {
1068 mangleNumber(NonVirtual);
1074 mangleNumber(NonVirtual);
1076 mangleNumber(Virtual);
1082 if (!mangleSubstitution(
QualType(TST, 0))) {
1083 mangleTemplatePrefix(TST->getTemplateName());
1088 mangleTemplateArgs(TST->getArgs(), TST->getNumArgs());
1091 }
else if (
const auto *DTST =
1093 if (!mangleSubstitution(
QualType(DTST, 0))) {
1094 TemplateName Template = getASTContext().getDependentTemplateName(
1095 DTST->getQualifier(), DTST->getIdentifier());
1096 mangleTemplatePrefix(Template);
1101 mangleTemplateArgs(DTST->getArgs(), DTST->getNumArgs());
1102 addSubstitution(
QualType(DTST, 0));
1132 switch (qualifier->
getKind()) {
1144 llvm_unreachable(
"Can't mangle __super specifier");
1148 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1156 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1173 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1180 if (mangleUnresolvedTypeOrSimpleId(
QualType(type, 0), recursive ?
"N" :
""))
1189 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1207 void CXXNameMangler::mangleUnresolvedName(
1210 unsigned knownArity) {
1211 if (qualifier) mangleUnresolvedPrefix(qualifier);
1227 mangleOperatorName(name, knownArity);
1230 llvm_unreachable(
"Can't mangle a constructor name!");
1232 llvm_unreachable(
"Can't mangle a using directive name!");
1234 llvm_unreachable(
"Can't mangle a deduction guide name!");
1238 llvm_unreachable(
"Can't mangle Objective-C selector names here!");
1244 mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
1247 void CXXNameMangler::mangleUnqualifiedName(
const NamedDecl *ND,
1249 unsigned KnownArity,
1250 const AbiTagList *AdditionalAbiTags) {
1251 unsigned Arity = KnownArity;
1260 if (
auto *DD = dyn_cast<DecompositionDecl>(ND)) {
1269 for (
auto *BD : DD->bindings())
1270 mangleSourceName(BD->getDeclName().getAsIdentifierInfo());
1272 writeAbiTags(ND, AdditionalAbiTags);
1292 getEffectiveDeclContext(ND)->isFileContext() &&
1297 bool IsRegCall = FD &&
1301 mangleRegCallName(II);
1303 mangleSourceName(II);
1305 writeAbiTags(ND, AdditionalAbiTags);
1310 assert(ND &&
"mangling empty name without declaration");
1312 if (
const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) {
1313 if (NS->isAnonymousNamespace()) {
1315 Out <<
"12_GLOBAL__N_1";
1320 if (
const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
1334 &&
"Expected anonymous struct or union!");
1341 assert(FD->getIdentifier() &&
"Data member name isn't an identifier!");
1343 mangleSourceName(FD->getIdentifier());
1354 if (isa<ObjCContainerDecl>(ND))
1358 const TagDecl *TD = cast<TagDecl>(ND);
1361 "Typedef should not be in another decl context!");
1363 "Typedef was not named!");
1365 assert(!AdditionalAbiTags &&
"Type cannot have additional abi tags");
1368 writeAbiTags(TD,
nullptr);
1376 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(TD)) {
1378 assert(!AdditionalAbiTags &&
1379 "Lambda type cannot have additional abi tags");
1380 mangleLambda(Record);
1386 unsigned UnnamedMangle = getASTContext().getManglingNumber(TD);
1388 if (UnnamedMangle > 1)
1389 Out << UnnamedMangle - 2;
1391 writeAbiTags(TD, AdditionalAbiTags);
1397 unsigned AnonStructId = NullOut ? 0 : Context.getAnonymousStructId(TD);
1404 Str += llvm::utostr(AnonStructId);
1414 llvm_unreachable(
"Can't mangle Objective-C selector names here!");
1419 if (
auto Inherited =
1420 cast<CXXConstructorDecl>(ND)->getInheritedConstructor()) {
1421 InheritedFrom = Inherited.getConstructor()->
getParent();
1422 InheritedTemplateArgs =
1423 Inherited.getConstructor()->getTemplateSpecializationArgs();
1429 mangleCXXCtorType(static_cast<CXXCtorType>(StructorType), InheritedFrom);
1437 if (InheritedTemplateArgs)
1438 mangleTemplateArgs(*InheritedTemplateArgs);
1440 writeAbiTags(ND, AdditionalAbiTags);
1448 mangleCXXDtorType(static_cast<CXXDtorType>(StructorType));
1453 writeAbiTags(ND, AdditionalAbiTags);
1457 if (ND && Arity == UnknownArity) {
1458 Arity = cast<FunctionDecl>(ND)->getNumParams();
1461 if (
const auto *MD = dyn_cast<CXXMethodDecl>(ND))
1462 if (!MD->isStatic())
1468 mangleOperatorName(Name, Arity);
1469 writeAbiTags(ND, AdditionalAbiTags);
1473 llvm_unreachable(
"Can't mangle a deduction guide name!");
1476 llvm_unreachable(
"Can't mangle a using directive name!");
1480 void CXXNameMangler::mangleRegCallName(
const IdentifierInfo *II) {
1484 Out << II->
getLength() +
sizeof(
"__regcall3__") - 1 <<
"__regcall3__" 1488 void CXXNameMangler::mangleSourceName(
const IdentifierInfo *II) {
1495 void CXXNameMangler::mangleNestedName(
const NamedDecl *ND,
1497 const AbiTagList *AdditionalAbiTags,
1505 if (
const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(ND)) {
1506 Qualifiers MethodQuals = Method->getMethodQualifiers();
1510 mangleQualifiers(MethodQuals);
1511 mangleRefQualifier(Method->getRefQualifier());
1517 mangleTemplatePrefix(TD, NoFunction);
1518 mangleTemplateArgs(*TemplateArgs);
1521 manglePrefix(DC, NoFunction);
1522 mangleUnqualifiedName(ND, AdditionalAbiTags);
1527 void CXXNameMangler::mangleNestedName(
const TemplateDecl *TD,
1529 unsigned NumTemplateArgs) {
1534 mangleTemplatePrefix(TD);
1535 mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
1540 void CXXNameMangler::mangleLocalName(
const Decl *D,
1541 const AbiTagList *AdditionalAbiTags) {
1547 assert(isa<NamedDecl>(D) || isa<BlockDecl>(D));
1549 const DeclContext *DC = getEffectiveDeclContext(RD ? RD : D);
1554 AbiTagState LocalAbiTags(AbiTags);
1557 mangleObjCMethodName(MD);
1558 else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(DC))
1559 mangleBlockForPrefix(BD);
1561 mangleFunctionEncoding(cast<FunctionDecl>(DC));
1565 LocalAbiTags.setUsedAbiTags(LocalAbiTags.getEmittedAbiTags());
1584 = dyn_cast<FunctionDecl>(Parm->getDeclContext())) {
1586 unsigned Num = Func->getNumParams() - Parm->getFunctionScopeIndex();
1588 mangleNumber(Num - 2);
1597 mangleUnqualifiedName(RD, AdditionalAbiTags);
1598 }
else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
1599 manglePrefix(getEffectiveDeclContext(BD),
true );
1600 assert(!AdditionalAbiTags &&
"Block cannot have additional abi tags");
1601 mangleUnqualifiedBlock(BD);
1603 const NamedDecl *ND = cast<NamedDecl>(D);
1604 mangleNestedName(ND, getEffectiveDeclContext(ND), AdditionalAbiTags,
1607 }
else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
1611 = dyn_cast_or_null<ParmVarDecl>(BD->getBlockManglingContextDecl())) {
1613 = dyn_cast<FunctionDecl>(Parm->getDeclContext())) {
1615 unsigned Num = Func->getNumParams() - Parm->getFunctionScopeIndex();
1617 mangleNumber(Num - 2);
1622 assert(!AdditionalAbiTags &&
"Block cannot have additional abi tags");
1623 mangleUnqualifiedBlock(BD);
1625 mangleUnqualifiedName(cast<NamedDecl>(D), AdditionalAbiTags);
1628 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(RD ? RD : D)) {
1630 if (Context.getNextDiscriminator(ND, disc)) {
1634 Out <<
"__" << disc <<
'_';
1639 void CXXNameMangler::mangleBlockForPrefix(
const BlockDecl *Block) {
1640 if (GetLocalClassDecl(Block)) {
1641 mangleLocalName(Block,
nullptr);
1644 const DeclContext *DC = getEffectiveDeclContext(Block);
1645 if (isLocalContainerContext(DC)) {
1646 mangleLocalName(Block,
nullptr);
1649 manglePrefix(getEffectiveDeclContext(Block));
1650 mangleUnqualifiedBlock(Block);
1653 void CXXNameMangler::mangleUnqualifiedBlock(
const BlockDecl *Block) {
1655 if ((isa<VarDecl>(Context) || isa<FieldDecl>(Context)) &&
1656 Context->getDeclContext()->isRecord()) {
1657 const auto *ND = cast<NamedDecl>(Context);
1659 mangleSourceNameWithAbiTags(ND);
1670 Number = Context.getBlockId(Block,
false);
1681 void CXXNameMangler::mangleLambda(
const CXXRecordDecl *Lambda) {
1692 if ((isa<VarDecl>(Context) || isa<FieldDecl>(Context)) &&
1693 !isa<ParmVarDecl>(Context)) {
1697 = cast<NamedDecl>(Context)->getIdentifier()) {
1698 mangleSourceName(Name);
1700 if (
isTemplate(cast<NamedDecl>(Context), TemplateArgs))
1701 mangleTemplateArgs(*TemplateArgs);
1709 getAs<FunctionProtoType>();
1710 mangleBareFunctionType(Proto,
false,
1720 assert(Number > 0 &&
"Lambda should be mangled as an unnamed class");
1722 mangleNumber(Number - 2);
1727 switch (qualifier->
getKind()) {
1733 llvm_unreachable(
"Can't mangle __super specifier");
1758 llvm_unreachable(
"unexpected nested name specifier");
1761 void CXXNameMangler::manglePrefix(
const DeclContext *DC,
bool NoFunction) {
1773 if (NoFunction && isLocalContainerContext(DC))
1776 assert(!isLocalContainerContext(DC));
1778 const NamedDecl *ND = cast<NamedDecl>(DC);
1779 if (mangleSubstitution(ND))
1785 mangleTemplatePrefix(TD);
1786 mangleTemplateArgs(*TemplateArgs);
1788 manglePrefix(getEffectiveDeclContext(ND), NoFunction);
1789 mangleUnqualifiedName(ND,
nullptr);
1792 addSubstitution(ND);
1795 void CXXNameMangler::mangleTemplatePrefix(
TemplateName Template) {
1800 return mangleTemplatePrefix(TD);
1803 manglePrefix(Qualified->getQualifier());
1807 mangleUnqualifiedName(
nullptr, (*Overloaded->begin())->getDeclName(),
1808 UnknownArity,
nullptr);
1813 assert(Dependent &&
"Unknown template name kind?");
1815 manglePrefix(Qualifier);
1816 mangleUnscopedTemplateName(Template,
nullptr);
1819 void CXXNameMangler::mangleTemplatePrefix(
const TemplateDecl *ND,
1827 if (mangleSubstitution(ND))
1831 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND)) {
1832 mangleTemplateParameter(TTP->getIndex());
1834 manglePrefix(getEffectiveDeclContext(ND), NoFunction);
1835 if (isa<BuiltinTemplateDecl>(ND))
1836 mangleUnqualifiedName(ND,
nullptr);
1841 addSubstitution(ND);
1850 if (mangleSubstitution(TN))
1865 if (isa<TemplateTemplateParmDecl>(TD))
1866 mangleTemplateParameter(cast<TemplateTemplateParmDecl>(TD)->getIndex());
1872 llvm_unreachable(
"can't mangle an overloaded template name as a <type>");
1901 Out <<
"_SUBSTPACK_";
1906 addSubstitution(TN);
1909 bool CXXNameMangler::mangleUnresolvedTypeOrSimpleId(
QualType Ty,
1915 case Type::Adjusted:
1918 case Type::BlockPointer:
1919 case Type::LValueReference:
1920 case Type::RValueReference:
1921 case Type::MemberPointer:
1922 case Type::ConstantArray:
1923 case Type::IncompleteArray:
1924 case Type::VariableArray:
1925 case Type::DependentSizedArray:
1926 case Type::DependentAddressSpace:
1927 case Type::DependentVector:
1928 case Type::DependentSizedExtVector:
1930 case Type::ExtVector:
1931 case Type::FunctionProto:
1932 case Type::FunctionNoProto:
1934 case Type::Attributed:
1936 case Type::DeducedTemplateSpecialization:
1937 case Type::PackExpansion:
1938 case Type::ObjCObject:
1939 case Type::ObjCInterface:
1940 case Type::ObjCObjectPointer:
1941 case Type::ObjCTypeParam:
1944 llvm_unreachable(
"type is illegal as a nested name specifier");
1946 case Type::SubstTemplateTypeParmPack:
1951 Out <<
"_SUBSTPACK_";
1958 case Type::TypeOfExpr:
1960 case Type::Decltype:
1961 case Type::TemplateTypeParm:
1962 case Type::UnaryTransform:
1963 case Type::SubstTemplateTypeParm:
1977 mangleSourceNameWithAbiTags(cast<TypedefType>(Ty)->getDecl());
1980 case Type::UnresolvedUsing:
1981 mangleSourceNameWithAbiTags(
1982 cast<UnresolvedUsingType>(Ty)->getDecl());
1987 mangleSourceNameWithAbiTags(cast<TagType>(Ty)->getDecl());
1990 case Type::TemplateSpecialization: {
1992 cast<TemplateSpecializationType>(Ty);
1994 switch (TN.getKind()) {
2001 assert(TD &&
"no template for template specialization type");
2002 if (isa<TemplateTemplateParmDecl>(TD))
2003 goto unresolvedType;
2005 mangleSourceNameWithAbiTags(TD);
2011 llvm_unreachable(
"invalid base for a template specialization type");
2025 Out <<
"_SUBSTPACK_";
2034 case Type::InjectedClassName:
2035 mangleSourceNameWithAbiTags(
2036 cast<InjectedClassNameType>(Ty)->getDecl());
2039 case Type::DependentName:
2040 mangleSourceName(cast<DependentNameType>(Ty)->
getIdentifier());
2043 case Type::DependentTemplateSpecialization: {
2045 cast<DependentTemplateSpecializationType>(Ty);
2051 case Type::Elaborated:
2052 return mangleUnresolvedTypeOrSimpleId(
2053 cast<ElaboratedType>(Ty)->getNamedType(), Prefix);
2059 void CXXNameMangler::mangleOperatorName(
DeclarationName Name,
unsigned Arity) {
2069 llvm_unreachable(
"Not an operator name");
2092 case OO_New: Out <<
"nw";
break;
2094 case OO_Array_New: Out <<
"na";
break;
2096 case OO_Delete: Out <<
"dl";
break;
2098 case OO_Array_Delete: Out <<
"da";
break;
2102 Out << (Arity == 1?
"ps" :
"pl");
break;
2106 Out << (Arity == 1?
"ng" :
"mi");
break;
2110 Out << (Arity == 1?
"ad" :
"an");
break;
2115 Out << (Arity == 1?
"de" :
"ml");
break;
2117 case OO_Tilde: Out <<
"co";
break;
2119 case OO_Slash: Out <<
"dv";
break;
2121 case OO_Percent: Out <<
"rm";
break;
2123 case OO_Pipe: Out <<
"or";
break;
2125 case OO_Caret: Out <<
"eo";
break;
2127 case OO_Equal: Out <<
"aS";
break;
2129 case OO_PlusEqual: Out <<
"pL";
break;
2131 case OO_MinusEqual: Out <<
"mI";
break;
2133 case OO_StarEqual: Out <<
"mL";
break;
2135 case OO_SlashEqual: Out <<
"dV";
break;
2137 case OO_PercentEqual: Out <<
"rM";
break;
2139 case OO_AmpEqual: Out <<
"aN";
break;
2141 case OO_PipeEqual: Out <<
"oR";
break;
2143 case OO_CaretEqual: Out <<
"eO";
break;
2145 case OO_LessLess: Out <<
"ls";
break;
2147 case OO_GreaterGreater: Out <<
"rs";
break;
2149 case OO_LessLessEqual: Out <<
"lS";
break;
2151 case OO_GreaterGreaterEqual: Out <<
"rS";
break;
2153 case OO_EqualEqual: Out <<
"eq";
break;
2155 case OO_ExclaimEqual: Out <<
"ne";
break;
2157 case OO_Less: Out <<
"lt";
break;
2159 case OO_Greater: Out <<
"gt";
break;
2161 case OO_LessEqual: Out <<
"le";
break;
2163 case OO_GreaterEqual: Out <<
"ge";
break;
2165 case OO_Exclaim: Out <<
"nt";
break;
2167 case OO_AmpAmp: Out <<
"aa";
break;
2169 case OO_PipePipe: Out <<
"oo";
break;
2171 case OO_PlusPlus: Out <<
"pp";
break;
2173 case OO_MinusMinus: Out <<
"mm";
break;
2175 case OO_Comma: Out <<
"cm";
break;
2177 case OO_ArrowStar: Out <<
"pm";
break;
2179 case OO_Arrow: Out <<
"pt";
break;
2181 case OO_Call: Out <<
"cl";
break;
2183 case OO_Subscript: Out <<
"ix";
break;
2188 case OO_Conditional: Out <<
"qu";
break;
2191 case OO_Coawait: Out <<
"aw";
break;
2194 case OO_Spaceship: Out <<
"ss";
break;
2198 llvm_unreachable(
"Not an overloaded operator");
2224 if (Context.getASTContext().addressSpaceMapManglingFor(AS)) {
2226 unsigned TargetAS = Context.getASTContext().getTargetAddressSpace(AS);
2228 ASString =
"AS" + llvm::utostr(TargetAS);
2231 default: llvm_unreachable(
"Not a language specific address space");
2245 if (!ASString.empty())
2246 mangleVendorQualifier(ASString);
2259 mangleVendorQualifier(
"__weak");
2263 mangleVendorQualifier(
"__unaligned");
2275 mangleVendorQualifier(
"__strong");
2279 mangleVendorQualifier(
"__autoreleasing");
2302 void CXXNameMangler::mangleVendorQualifier(StringRef name) {
2303 Out <<
'U' << name.size() << name;
2309 switch (RefQualifier) {
2323 void CXXNameMangler::mangleObjCMethodName(
const ObjCMethodDecl *MD) {
2324 Context.mangleObjCMethodName(MD, Out);
2345 void CXXNameMangler::mangleType(
QualType T) {
2386 = dyn_cast<TemplateSpecializationType>(T))
2387 if (!TST->isTypeAlias())
2400 const Type *ty = split.
Ty;
2402 bool isSubstitutable =
2404 if (isSubstitutable && mangleSubstitution(T))
2409 if (quals && isa<ArrayType>(T)) {
2410 ty = Context.getASTContext().getAsArrayType(T);
2419 dyn_cast<DependentAddressSpaceType>(ty)) {
2421 mangleQualifiers(splitDAST.
Quals, DAST);
2424 mangleQualifiers(quals);
2432 #define ABSTRACT_TYPE(CLASS, PARENT) 2433 #define NON_CANONICAL_TYPE(CLASS, PARENT) \ 2435 llvm_unreachable("can't mangle non-canonical type " #CLASS "Type"); \ 2437 #define TYPE(CLASS, PARENT) \ 2439 mangleType(static_cast<const CLASS##Type*>(ty)); \ 2441 #include "clang/AST/TypeNodes.def" 2446 if (isSubstitutable)
2450 void CXXNameMangler::mangleNameOrStandardSubstitution(
const NamedDecl *ND) {
2451 if (!mangleStandardSubstitution(ND))
2455 void CXXNameMangler::mangleType(
const BuiltinType *T) {
2486 std::string type_name;
2488 case BuiltinType::Void:
2491 case BuiltinType::Bool:
2494 case BuiltinType::Char_U:
2495 case BuiltinType::Char_S:
2498 case BuiltinType::UChar:
2501 case BuiltinType::UShort:
2504 case BuiltinType::UInt:
2507 case BuiltinType::ULong:
2510 case BuiltinType::ULongLong:
2513 case BuiltinType::UInt128:
2516 case BuiltinType::SChar:
2519 case BuiltinType::WChar_S:
2520 case BuiltinType::WChar_U:
2523 case BuiltinType::Char8:
2526 case BuiltinType::Char16:
2529 case BuiltinType::Char32:
2532 case BuiltinType::Short:
2535 case BuiltinType::Int:
2538 case BuiltinType::Long:
2541 case BuiltinType::LongLong:
2544 case BuiltinType::Int128:
2547 case BuiltinType::Float16:
2550 case BuiltinType::ShortAccum:
2551 case BuiltinType::Accum:
2552 case BuiltinType::LongAccum:
2553 case BuiltinType::UShortAccum:
2554 case BuiltinType::UAccum:
2555 case BuiltinType::ULongAccum:
2556 case BuiltinType::ShortFract:
2557 case BuiltinType::Fract:
2558 case BuiltinType::LongFract:
2559 case BuiltinType::UShortFract:
2560 case BuiltinType::UFract:
2561 case BuiltinType::ULongFract:
2562 case BuiltinType::SatShortAccum:
2563 case BuiltinType::SatAccum:
2564 case BuiltinType::SatLongAccum:
2565 case BuiltinType::SatUShortAccum:
2566 case BuiltinType::SatUAccum:
2567 case BuiltinType::SatULongAccum:
2568 case BuiltinType::SatShortFract:
2569 case BuiltinType::SatFract:
2570 case BuiltinType::SatLongFract:
2571 case BuiltinType::SatUShortFract:
2572 case BuiltinType::SatUFract:
2573 case BuiltinType::SatULongFract:
2574 llvm_unreachable(
"Fixed point types are disabled for c++");
2575 case BuiltinType::Half:
2578 case BuiltinType::Float:
2581 case BuiltinType::Double:
2584 case BuiltinType::LongDouble:
2585 Out << (getASTContext().getTargetInfo().useFloat128ManglingForLongDouble()
2589 case BuiltinType::Float128:
2590 if (getASTContext().getTargetInfo().useFloat128ManglingForLongDouble())
2591 Out <<
"U10__float128";
2595 case BuiltinType::NullPtr:
2599 #define BUILTIN_TYPE(Id, SingletonId) 2600 #define PLACEHOLDER_TYPE(Id, SingletonId) \ 2601 case BuiltinType::Id: 2602 #include "clang/AST/BuiltinTypes.def" 2603 case BuiltinType::Dependent:
2605 llvm_unreachable(
"mangling a placeholder type");
2607 case BuiltinType::ObjCId:
2608 Out <<
"11objc_object";
2610 case BuiltinType::ObjCClass:
2611 Out <<
"10objc_class";
2613 case BuiltinType::ObjCSel:
2614 Out <<
"13objc_selector";
2616 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 2617 case BuiltinType::Id: \ 2618 type_name = "ocl_" #ImgType "_" #Suffix; \ 2619 Out << type_name.size() << type_name; \ 2621 #include "clang/Basic/OpenCLImageTypes.def" 2622 case BuiltinType::OCLSampler:
2623 Out <<
"11ocl_sampler";
2625 case BuiltinType::OCLEvent:
2626 Out <<
"9ocl_event";
2628 case BuiltinType::OCLClkEvent:
2629 Out <<
"12ocl_clkevent";
2631 case BuiltinType::OCLQueue:
2632 Out <<
"9ocl_queue";
2634 case BuiltinType::OCLReserveID:
2635 Out <<
"13ocl_reserveid";
2637 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 2638 case BuiltinType::Id: \ 2639 type_name = "ocl_" #ExtType; \ 2640 Out << type_name.size() << type_name; \ 2642 #include "clang/Basic/OpenCLExtensionTypes.def" 2646 StringRef CXXNameMangler::getCallingConvQualifierName(
CallingConv CC) {
2684 llvm_unreachable(
"bad calling convention");
2687 void CXXNameMangler::mangleExtFunctionInfo(
const FunctionType *T) {
2696 StringRef CCQualifier = getCallingConvQualifierName(T->
getExtInfo().
getCC());
2697 if (!CCQualifier.empty())
2698 mangleVendorQualifier(CCQualifier);
2705 CXXNameMangler::mangleExtParameterInfo(FunctionProtoType::ExtParameterInfo PI) {
2711 switch (PI.getABI()) {
2723 if (PI.isConsumed())
2724 mangleVendorQualifier(
"ns_consumed");
2726 if (PI.isNoEscape())
2727 mangleVendorQualifier(
"noescape");
2734 mangleExtFunctionInfo(T);
2751 mangleType(ExceptTy);
2762 mangleBareFunctionType(T,
true);
2776 FunctionTypeDepthState saved = FunctionTypeDepth.push();
2778 FunctionTypeDepth.enterResultType();
2780 FunctionTypeDepth.leaveResultType();
2782 FunctionTypeDepth.pop(saved);
2787 bool MangleReturnType,
2791 FunctionTypeDepthState saved = FunctionTypeDepth.push();
2794 if (MangleReturnType) {
2795 FunctionTypeDepth.enterResultType();
2799 mangleVendorQualifier(
"ns_returns_retained");
2804 auto SplitReturnTy = ReturnTy.
split();
2806 ReturnTy = getASTContext().getQualifiedType(SplitReturnTy);
2808 mangleType(ReturnTy);
2810 FunctionTypeDepth.leaveResultType();
2817 FunctionTypeDepth.pop(saved);
2822 for (
unsigned I = 0, E = Proto->
getNumParams(); I != E; ++I) {
2830 mangleType(Context.getASTContext().getSignatureParameterType(ParamTy));
2835 assert(
Attr->getType() <= 9 &&
Attr->getType() >= 0);
2836 Out <<
"U17pass_object_size" <<
Attr->getType();
2841 FunctionTypeDepth.pop(saved);
2856 void CXXNameMangler::mangleType(
const EnumType *T) {
2857 mangleType(static_cast<const TagType*>(T));
2859 void CXXNameMangler::mangleType(
const RecordType *T) {
2860 mangleType(static_cast<const TagType*>(T));
2862 void CXXNameMangler::mangleType(
const TagType *T) {
2870 Out <<
'A' << T->
getSize() <<
'_';
2919 mangleType(PointeeType);
2924 mangleTemplateParameter(T->
getIndex());
2933 Out <<
"_SUBSTPACK_";
2937 void CXXNameMangler::mangleType(
const PointerType *T) {
2959 void CXXNameMangler::mangleType(
const ComplexType *T) {
2967 void CXXNameMangler::mangleNeonVectorType(
const VectorType *T) {
2969 assert(EltType->
isBuiltinType() &&
"Neon vector element not a BuiltinType");
2970 const char *EltName =
nullptr;
2972 switch (cast<BuiltinType>(EltType)->getKind()) {
2973 case BuiltinType::SChar:
2974 case BuiltinType::UChar:
2975 EltName =
"poly8_t";
2977 case BuiltinType::Short:
2978 case BuiltinType::UShort:
2979 EltName =
"poly16_t";
2981 case BuiltinType::ULongLong:
2982 EltName =
"poly64_t";
2984 default: llvm_unreachable(
"unexpected Neon polynomial vector element type");
2987 switch (cast<BuiltinType>(EltType)->
getKind()) {
2988 case BuiltinType::SChar: EltName =
"int8_t";
break;
2989 case BuiltinType::UChar: EltName =
"uint8_t";
break;
2990 case BuiltinType::Short: EltName =
"int16_t";
break;
2991 case BuiltinType::UShort: EltName =
"uint16_t";
break;
2992 case BuiltinType::Int: EltName =
"int32_t";
break;
2993 case BuiltinType::UInt: EltName =
"uint32_t";
break;
2994 case BuiltinType::LongLong: EltName =
"int64_t";
break;
2995 case BuiltinType::ULongLong: EltName =
"uint64_t";
break;
2996 case BuiltinType::Double: EltName =
"float64_t";
break;
2997 case BuiltinType::Float: EltName =
"float32_t";
break;
2998 case BuiltinType::Half: EltName =
"float16_t";
break;
3000 llvm_unreachable(
"unexpected Neon vector element type");
3003 const char *BaseName =
nullptr;
3005 getASTContext().getTypeSize(EltType));
3007 BaseName =
"__simd64_";
3009 assert(BitSize == 128 &&
"Neon vector type not 64 or 128 bits");
3010 BaseName =
"__simd128_";
3012 Out << strlen(BaseName) + strlen(EltName);
3013 Out << BaseName << EltName;
3020 "cannot mangle this dependent neon vector type yet");
3026 case BuiltinType::SChar:
3028 case BuiltinType::Short:
3030 case BuiltinType::Int:
3032 case BuiltinType::Long:
3033 case BuiltinType::LongLong:
3035 case BuiltinType::UChar:
3037 case BuiltinType::UShort:
3039 case BuiltinType::UInt:
3041 case BuiltinType::ULong:
3042 case BuiltinType::ULongLong:
3044 case BuiltinType::Half:
3046 case BuiltinType::Float:
3048 case BuiltinType::Double:
3051 llvm_unreachable(
"Unexpected vector element base type");
3058 void CXXNameMangler::mangleAArch64NeonVectorType(
const VectorType *T) {
3060 assert(EltType->
isBuiltinType() &&
"Neon vector element not a BuiltinType");
3065 assert((BitSize == 64 || BitSize == 128) &&
3066 "Neon vector type not 64 or 128 bits");
3070 switch (cast<BuiltinType>(EltType)->getKind()) {
3071 case BuiltinType::UChar:
3074 case BuiltinType::UShort:
3077 case BuiltinType::ULong:
3078 case BuiltinType::ULongLong:
3082 llvm_unreachable(
"unexpected Neon polynomial vector element type");
3087 std::string TypeName =
3088 (
"__" + EltName +
"x" + Twine(T->
getNumElements()) +
"_t").str();
3089 Out << TypeName.length() << TypeName;
3095 "cannot mangle this dependent neon vector type yet");
3107 void CXXNameMangler::mangleType(
const VectorType *T) {
3110 llvm::Triple
Target = getASTContext().getTargetInfo().getTriple();
3111 llvm::Triple::ArchType Arch =
3112 getASTContext().getTargetInfo().getTriple().getArch();
3113 if ((Arch == llvm::Triple::aarch64 ||
3114 Arch == llvm::Triple::aarch64_be) && !Target.isOSDarwin())
3115 mangleAArch64NeonVectorType(T);
3117 mangleNeonVectorType(T);
3132 llvm::Triple
Target = getASTContext().getTargetInfo().getTriple();
3133 llvm::Triple::ArchType Arch =
3134 getASTContext().getTargetInfo().getTriple().getArch();
3135 if ((Arch == llvm::Triple::aarch64 || Arch == llvm::Triple::aarch64_be) &&
3136 !Target.isOSDarwin())
3137 mangleAArch64NeonVectorType(T);
3139 mangleNeonVectorType(T);
3155 mangleType(static_cast<const VectorType*>(T));
3166 mangleQualifiers(split.
Quals, T);
3183 Out <<
"U8__kindof";
3188 llvm::raw_svector_ostream QualOS(QualStr);
3189 QualOS <<
"objcproto";
3190 for (
const auto *I : T->
quals()) {
3191 StringRef name = I->getName();
3192 QualOS << name.size() << name;
3194 Out <<
'U' << QualStr.size() << QualStr;
3203 mangleType(typeArg);
3209 Out <<
"U13block_pointer";
3224 if (mangleSubstitution(
QualType(T, 0)))
3277 getASTContext().getDependentTemplateName(T->
getQualifier(),
3279 mangleTemplatePrefix(Prefix);
3288 void CXXNameMangler::mangleType(
const TypeOfType *T) {
3300 void CXXNameMangler::mangleType(
const DecltypeType *T) {
3311 if (isa<DeclRefExpr>(E) ||
3312 isa<MemberExpr>(E) ||
3313 isa<UnresolvedLookupExpr>(E) ||
3314 isa<DependentScopeDeclRefExpr>(E) ||
3315 isa<CXXDependentScopeMemberExpr>(E) ||
3316 isa<UnresolvedMemberExpr>(E))
3320 mangleExpression(E);
3340 void CXXNameMangler::mangleType(
const AutoType *T) {
3342 "Deduced AutoType shouldn't be handled here!");
3344 "shouldn't need to mangle __auto_type!");
3360 void CXXNameMangler::mangleType(
const AtomicType *T) {
3367 void CXXNameMangler::mangleType(
const PipeType *T) {
3374 void CXXNameMangler::mangleIntegerLiteral(
QualType T,
3375 const llvm::APSInt &Value) {
3382 Out << (Value.getBoolValue() ?
'1' :
'0');
3384 mangleNumber(Value);
3390 void CXXNameMangler::mangleMemberExprBase(
const Expr *
Base,
bool IsArrow) {
3393 if (!RT->getDecl()->isAnonymousStructOrUnion())
3398 Base = ME->getBase();
3399 IsArrow = ME->isArrow();
3408 Out << (IsArrow ?
"pt" :
"dt");
3409 mangleExpression(Base);
3414 void CXXNameMangler::mangleMemberExpr(
const Expr *base,
3420 unsigned NumTemplateArgs,
3425 mangleMemberExprBase(base, isArrow);
3426 mangleUnresolvedName(qualifier, member, TemplateArgs, NumTemplateArgs, arity);
3439 if (callee == fn)
return false;
3443 if (!lookup)
return false;
3460 void CXXNameMangler::mangleCastExpression(
const Expr *E, StringRef CastEncoding) {
3462 Out << CastEncoding;
3467 void CXXNameMangler::mangleInitListElements(
const InitListExpr *InitList) {
3469 InitList = Syntactic;
3470 for (
unsigned i = 0, e = InitList->
getNumInits(); i != e; ++i)
3471 mangleExpression(InitList->
getInit(i));
3474 void CXXNameMangler::mangleExpression(
const Expr *E,
unsigned Arity) {
3498 QualType ImplicitlyConvertedToType;
3503 #define ABSTRACT_STMT(Type) 3504 #define EXPR(Type, Base) 3505 #define STMT(Type, Base) \ 3506 case Expr::Type##Class: 3507 #include "clang/AST/StmtNodes.inc" 3512 case Expr::AddrLabelExprClass:
3513 case Expr::DesignatedInitUpdateExprClass:
3514 case Expr::ImplicitValueInitExprClass:
3515 case Expr::ArrayInitLoopExprClass:
3516 case Expr::ArrayInitIndexExprClass:
3517 case Expr::NoInitExprClass:
3518 case Expr::ParenListExprClass:
3519 case Expr::LambdaExprClass:
3520 case Expr::MSPropertyRefExprClass:
3521 case Expr::MSPropertySubscriptExprClass:
3522 case Expr::TypoExprClass:
3523 case Expr::OMPArraySectionExprClass:
3524 case Expr::CXXInheritedCtorInitExprClass:
3525 llvm_unreachable(
"unexpected statement kind");
3527 case Expr::ConstantExprClass:
3528 E = cast<ConstantExpr>(E)->getSubExpr();
3532 case Expr::BlockExprClass:
3533 case Expr::ChooseExprClass:
3534 case Expr::CompoundLiteralExprClass:
3535 case Expr::ExtVectorElementExprClass:
3536 case Expr::GenericSelectionExprClass:
3537 case Expr::ObjCEncodeExprClass:
3538 case Expr::ObjCIsaExprClass:
3539 case Expr::ObjCIvarRefExprClass:
3540 case Expr::ObjCMessageExprClass:
3541 case Expr::ObjCPropertyRefExprClass:
3542 case Expr::ObjCProtocolExprClass:
3543 case Expr::ObjCSelectorExprClass:
3544 case Expr::ObjCStringLiteralClass:
3545 case Expr::ObjCBoxedExprClass:
3546 case Expr::ObjCArrayLiteralClass:
3547 case Expr::ObjCDictionaryLiteralClass:
3548 case Expr::ObjCSubscriptRefExprClass:
3549 case Expr::ObjCIndirectCopyRestoreExprClass:
3550 case Expr::ObjCAvailabilityCheckExprClass:
3551 case Expr::OffsetOfExprClass:
3552 case Expr::PredefinedExprClass:
3553 case Expr::ShuffleVectorExprClass:
3554 case Expr::ConvertVectorExprClass:
3555 case Expr::StmtExprClass:
3556 case Expr::TypeTraitExprClass:
3557 case Expr::ArrayTypeTraitExprClass:
3558 case Expr::ExpressionTraitExprClass:
3559 case Expr::VAArgExprClass:
3560 case Expr::CUDAKernelCallExprClass:
3561 case Expr::AsTypeExprClass:
3562 case Expr::PseudoObjectExprClass:
3563 case Expr::AtomicExprClass:
3564 case Expr::FixedPointLiteralClass:
3570 "cannot yet mangle expression type %0");
3577 case Expr::CXXUuidofExprClass: {
3581 Out <<
"u8__uuidoft";
3585 Out <<
"u8__uuidofz";
3586 mangleExpression(UuidExp, Arity);
3592 case Expr::BinaryConditionalOperatorClass: {
3596 "?: operator with omitted middle operand cannot be mangled");
3603 case Expr::OpaqueValueExprClass:
3604 llvm_unreachable(
"cannot mangle opaque value; mangling wrong thing?");
3606 case Expr::InitListExprClass: {
3608 mangleInitListElements(cast<InitListExpr>(E));
3613 case Expr::DesignatedInitExprClass: {
3614 auto *DIE = cast<DesignatedInitExpr>(E);
3615 for (
const auto &
Designator : DIE->designators()) {
3621 mangleExpression(DIE->getArrayIndex(
Designator));
3624 "unknown designator kind");
3626 mangleExpression(DIE->getArrayRangeStart(
Designator));
3627 mangleExpression(DIE->getArrayRangeEnd(
Designator));
3630 mangleExpression(DIE->getInit());
3634 case Expr::CXXDefaultArgExprClass:
3635 mangleExpression(cast<CXXDefaultArgExpr>(E)->getExpr(), Arity);
3638 case Expr::CXXDefaultInitExprClass:
3639 mangleExpression(cast<CXXDefaultInitExpr>(E)->getExpr(), Arity);
3642 case Expr::CXXStdInitializerListExprClass:
3643 mangleExpression(cast<CXXStdInitializerListExpr>(E)->getSubExpr(), Arity);
3646 case Expr::SubstNonTypeTemplateParmExprClass:
3647 mangleExpression(cast<SubstNonTypeTemplateParmExpr>(E)->getReplacement(),
3651 case Expr::UserDefinedLiteralClass:
3654 case Expr::CXXMemberCallExprClass:
3655 case Expr::CallExprClass: {
3656 const CallExpr *CE = cast<CallExpr>(E);
3675 if (isa<PackExpansionExpr>(Arg))
3676 CallArity = UnknownArity;
3678 mangleExpression(CE->
getCallee(), CallArity);
3680 mangleExpression(Arg);
3685 case Expr::CXXNewExprClass: {
3688 Out << (New->
isArray() ?
"na" :
"nw");
3691 mangleExpression(*I);
3705 mangleExpression(*I);
3706 }
else if (
const ParenListExpr *PLE = dyn_cast<ParenListExpr>(Init)) {
3707 for (
unsigned i = 0, e = PLE->getNumExprs(); i != e; ++i)
3708 mangleExpression(PLE->getExpr(i));
3710 isa<InitListExpr>(Init)) {
3712 mangleInitListElements(cast<InitListExpr>(Init));
3714 mangleExpression(Init);
3720 case Expr::CXXPseudoDestructorExprClass: {
3721 const auto *PDE = cast<CXXPseudoDestructorExpr>(E);
3722 if (
const Expr *Base = PDE->getBase())
3723 mangleMemberExprBase(Base, PDE->isArrow());
3727 mangleUnresolvedPrefix(Qualifier,
3729 mangleUnresolvedTypeOrSimpleId(ScopeInfo->getType());
3733 if (!mangleUnresolvedTypeOrSimpleId(ScopeInfo->getType()))
3736 }
else if (Qualifier) {
3737 mangleUnresolvedPrefix(Qualifier);
3741 QualType DestroyedType = PDE->getDestroyedType();
3742 mangleUnresolvedTypeOrSimpleId(DestroyedType);
3746 case Expr::MemberExprClass: {
3756 case Expr::UnresolvedMemberExprClass: {
3766 case Expr::CXXDependentScopeMemberExprClass: {
3768 = cast<CXXDependentScopeMemberExpr>(E);
3778 case Expr::UnresolvedLookupExprClass: {
3786 case Expr::CXXUnresolvedConstructExprClass: {
3791 assert(N == 1 &&
"unexpected form for list initialization");
3792 auto *IL = cast<InitListExpr>(CE->
getArg(0));
3795 mangleInitListElements(IL);
3802 if (N != 1) Out <<
'_';
3803 for (
unsigned I = 0; I != N; ++I) mangleExpression(CE->
getArg(I));
3804 if (N != 1) Out <<
'E';
3808 case Expr::CXXConstructExprClass: {
3809 const auto *CE = cast<CXXConstructExpr>(E);
3810 if (!CE->isListInitialization() || CE->isStdInitListInitialization()) {
3812 CE->getNumArgs() >= 1 &&
3813 (CE->getNumArgs() == 1 || isa<CXXDefaultArgExpr>(CE->getArg(1))) &&
3814 "implicit CXXConstructExpr must have one argument");
3815 return mangleExpression(cast<CXXConstructExpr>(E)->getArg(0));
3818 for (
auto *E : CE->arguments())
3819 mangleExpression(E);
3824 case Expr::CXXTemporaryObjectExprClass: {
3825 const auto *CE = cast<CXXTemporaryObjectExpr>(E);
3826 unsigned N = CE->getNumArgs();
3827 bool List = CE->isListInitialization();
3833 mangleType(CE->getType());
3834 if (!List && N != 1)
3836 if (CE->isStdInitListInitialization()) {
3841 cast<CXXStdInitializerListExpr>(CE->getArg(0)->IgnoreImplicit());
3842 auto *ILE = cast<InitListExpr>(SILE->getSubExpr()->IgnoreImplicit());
3843 mangleInitListElements(ILE);
3845 for (
auto *E : CE->arguments())
3846 mangleExpression(E);
3853 case Expr::CXXScalarValueInitExprClass:
3859 case Expr::CXXNoexceptExprClass:
3861 mangleExpression(cast<CXXNoexceptExpr>(E)->getOperand());
3864 case Expr::UnaryExprOrTypeTraitExprClass: {
3878 : ImplicitlyConvertedToType;
3880 mangleIntegerLiteral(T, V);
3895 "cannot yet mangle vec_step expression");
3903 "cannot yet mangle __builtin_omp_required_simd_align expression");
3917 case Expr::CXXThrowExprClass: {
3930 case Expr::CXXTypeidExprClass: {
3944 case Expr::CXXDeleteExprClass: {
3954 case Expr::UnaryOperatorClass: {
3962 case Expr::ArraySubscriptExprClass: {
3968 mangleExpression(AE->
getLHS());
3969 mangleExpression(AE->
getRHS());
3973 case Expr::CompoundAssignOperatorClass:
3974 case Expr::BinaryOperatorClass: {
3981 mangleExpression(BO->
getLHS());
3982 mangleExpression(BO->
getRHS());
3986 case Expr::ConditionalOperatorClass: {
3988 mangleOperatorName(OO_Conditional, 3);
3989 mangleExpression(CO->
getCond());
3990 mangleExpression(CO->
getLHS(), Arity);
3991 mangleExpression(CO->
getRHS(), Arity);
3995 case Expr::ImplicitCastExprClass: {
3996 ImplicitlyConvertedToType = E->
getType();
3997 E = cast<ImplicitCastExpr>(E)->getSubExpr();
4001 case Expr::ObjCBridgedCastExprClass: {
4004 StringRef
Kind = cast<ObjCBridgedCastExpr>(E)->getBridgeKindName();
4005 Out <<
"v1U" << Kind.size() <<
Kind;
4010 case Expr::CStyleCastExprClass:
4011 mangleCastExpression(E,
"cv");
4014 case Expr::CXXFunctionalCastExprClass: {
4015 auto *Sub = cast<ExplicitCastExpr>(E)->getSubExpr()->IgnoreImplicit();
4017 if (
auto *CCE = dyn_cast<CXXConstructExpr>(Sub))
4018 if (CCE->getParenOrBraceRange().isInvalid())
4019 Sub = CCE->getArg(0)->IgnoreImplicit();
4020 if (
auto *StdInitList = dyn_cast<CXXStdInitializerListExpr>(Sub))
4021 Sub = StdInitList->getSubExpr()->IgnoreImplicit();
4022 if (
auto *IL = dyn_cast<InitListExpr>(Sub)) {
4025 mangleInitListElements(IL);
4028 mangleCastExpression(E,
"cv");
4033 case Expr::CXXStaticCastExprClass:
4034 mangleCastExpression(E,
"sc");
4036 case Expr::CXXDynamicCastExprClass:
4037 mangleCastExpression(E,
"dc");
4039 case Expr::CXXReinterpretCastExprClass:
4040 mangleCastExpression(E,
"rc");
4042 case Expr::CXXConstCastExprClass:
4043 mangleCastExpression(E,
"cc");
4046 case Expr::CXXOperatorCallExprClass: {
4054 for (
unsigned i = 0; i != NumArgs; ++i)
4055 mangleExpression(CE->
getArg(i));
4059 case Expr::ParenExprClass:
4060 mangleExpression(cast<ParenExpr>(E)->getSubExpr(), Arity);
4063 case Expr::DeclRefExprClass: {
4064 const NamedDecl *D = cast<DeclRefExpr>(E)->getDecl();
4075 mangleFunctionParam(cast<ParmVarDecl>(D));
4078 case Decl::EnumConstant: {
4084 case Decl::NonTypeTemplateParm: {
4086 mangleTemplateParameter(PD->
getIndex());
4095 case Expr::SubstNonTypeTemplateParmPackExprClass:
4100 Out <<
"_SUBSTPACK_";
4103 case Expr::FunctionParmPackExprClass: {
4106 Out <<
"v110_SUBSTPACK";
4111 case Expr::DependentScopeDeclRefExprClass: {
4119 case Expr::CXXBindTemporaryExprClass:
4120 mangleExpression(cast<CXXBindTemporaryExpr>(E)->getSubExpr());
4123 case Expr::ExprWithCleanupsClass:
4124 mangleExpression(cast<ExprWithCleanups>(E)->getSubExpr(), Arity);
4127 case Expr::FloatingLiteralClass: {
4136 case Expr::CharacterLiteralClass:
4139 Out << cast<CharacterLiteral>(E)->
getValue();
4144 case Expr::ObjCBoolLiteralExprClass:
4146 Out << (cast<ObjCBoolLiteralExpr>(E)->
getValue() ?
'1' :
'0');
4150 case Expr::CXXBoolLiteralExprClass:
4152 Out << (cast<CXXBoolLiteralExpr>(E)->
getValue() ?
'1' :
'0');
4156 case Expr::IntegerLiteralClass: {
4159 Value.setIsSigned(
true);
4164 case Expr::ImaginaryLiteralClass: {
4171 dyn_cast<FloatingLiteral>(IE->
getSubExpr())) {
4173 mangleFloat(llvm::APFloat(Imag->getValue().getSemantics()));
4175 mangleFloat(Imag->getValue());
4180 Value.setIsSigned(
true);
4181 mangleNumber(Value);
4187 case Expr::StringLiteralClass: {
4190 assert(isa<ConstantArrayType>(E->
getType()));
4196 case Expr::GNUNullExprClass:
4200 case Expr::CXXNullPtrLiteralExprClass: {
4205 case Expr::PackExpansionExprClass:
4207 mangleExpression(cast<PackExpansionExpr>(E)->getPattern());
4210 case Expr::SizeOfPackExprClass: {
4211 auto *SPE = cast<SizeOfPackExpr>(E);
4212 if (SPE->isPartiallySubstituted()) {
4214 for (
const auto &A : SPE->getPartialArguments())
4215 mangleTemplateArg(A);
4223 mangleTemplateParameter(TTP->getIndex());
4225 = dyn_cast<NonTypeTemplateParmDecl>(Pack))
4226 mangleTemplateParameter(NTTP->getIndex());
4228 = dyn_cast<TemplateTemplateParmDecl>(Pack))
4229 mangleTemplateParameter(TempTP->getIndex());
4231 mangleFunctionParam(cast<ParmVarDecl>(Pack));
4235 case Expr::MaterializeTemporaryExprClass: {
4236 mangleExpression(cast<MaterializeTemporaryExpr>(E)->GetTemporaryExpr());
4240 case Expr::CXXFoldExprClass: {
4241 auto *FE = cast<CXXFoldExpr>(E);
4242 if (FE->isLeftFold())
4243 Out << (FE->getInit() ?
"fL" :
"fl");
4245 Out << (FE->getInit() ?
"fR" :
"fr");
4247 if (FE->getOperator() == BO_PtrMemD)
4255 mangleExpression(FE->getLHS());
4257 mangleExpression(FE->getRHS());
4261 case Expr::CXXThisExprClass:
4265 case Expr::CoawaitExprClass:
4267 Out <<
"v18co_await";
4268 mangleExpression(cast<CoawaitExpr>(E)->getOperand());
4271 case Expr::DependentCoawaitExprClass:
4273 Out <<
"v18co_await";
4274 mangleExpression(cast<DependentCoawaitExpr>(E)->getOperand());
4277 case Expr::CoyieldExprClass:
4279 Out <<
"v18co_yield";
4280 mangleExpression(cast<CoawaitExpr>(E)->getOperand());
4313 void CXXNameMangler::mangleFunctionParam(
const ParmVarDecl *parm) {
4320 assert(parmDepth < FunctionTypeDepth.getDepth());
4321 unsigned nestingDepth = FunctionTypeDepth.getDepth() - parmDepth;
4322 if (FunctionTypeDepth.isInResultType())
4325 if (nestingDepth == 0) {
4328 Out <<
"fL" << (nestingDepth - 1) <<
'p';
4336 &&
"parameter's type is still an array type?");
4339 dyn_cast<DependentAddressSpaceType>(parm->
getType())) {
4346 if (parmIndex != 0) {
4347 Out << (parmIndex - 1);
4352 void CXXNameMangler::mangleCXXCtorType(
CXXCtorType T,
4375 llvm_unreachable(
"closure constructors don't exist for the Itanium ABI!");
4378 mangleName(InheritedFrom);
4381 void CXXNameMangler::mangleCXXDtorType(
CXXDtorType T) {
4404 unsigned NumTemplateArgs) {
4407 for (
unsigned i = 0; i != NumTemplateArgs; ++i)
4415 for (
unsigned i = 0, e = AL.
size(); i != e; ++i)
4416 mangleTemplateArg(AL[i]);
4420 void CXXNameMangler::mangleTemplateArgs(
const TemplateArgument *TemplateArgs,
4421 unsigned NumTemplateArgs) {
4424 for (
unsigned i = 0; i != NumTemplateArgs; ++i)
4425 mangleTemplateArg(TemplateArgs[i]);
4435 A = Context.getASTContext().getCanonicalTemplateArgument(A);
4439 llvm_unreachable(
"Cannot mangle NULL template argument");
4458 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
4460 if (isa<VarDecl>(D) || isa<FunctionDecl>(D)) {
4469 mangleExpression(E);
4483 if (compensateMangling) {
4485 mangleOperatorName(OO_Amp, 1);
4494 if (compensateMangling)
4510 mangleTemplateArg(
P);
4516 void CXXNameMangler::mangleTemplateParameter(
unsigned Index) {
4522 Out <<
'T' << (Index - 1) <<
'_';
4525 void CXXNameMangler::mangleSeqID(
unsigned SeqID) {
4528 else if (SeqID > 1) {
4536 for (; SeqID != 0; SeqID /= 36) {
4537 unsigned C = SeqID % 36;
4538 *I++ = (C < 10 ?
'0' +
C :
'A' + C - 10);
4541 Out.write(I.base(), I - BufferRef.rbegin());
4546 void CXXNameMangler::mangleExistingSubstitution(
TemplateName tname) {
4547 bool result = mangleSubstitution(tname);
4548 assert(result &&
"no existing substitution for template name");
4554 bool CXXNameMangler::mangleSubstitution(
const NamedDecl *ND) {
4556 if (mangleStandardSubstitution(ND))
4560 return mangleSubstitution(reinterpret_cast<uintptr_t>(ND));
4570 bool CXXNameMangler::mangleSubstitution(
QualType T) {
4573 return mangleSubstitution(RT->getDecl());
4578 return mangleSubstitution(TypePtr);
4581 bool CXXNameMangler::mangleSubstitution(
TemplateName Template) {
4583 return mangleSubstitution(TD);
4585 Template = Context.getASTContext().getCanonicalTemplateName(Template);
4586 return mangleSubstitution(
4590 bool CXXNameMangler::mangleSubstitution(
uintptr_t Ptr) {
4591 llvm::DenseMap<uintptr_t, unsigned>::iterator I = Substitutions.find(Ptr);
4592 if (I == Substitutions.end())
4595 unsigned SeqID = I->second;
4629 if (TemplateArgs.
size() != 1)
4632 if (!
isCharType(TemplateArgs[0].getAsType()))
4638 template <std::
size_t StrLen>
4640 const char (&Str)[StrLen]) {
4645 if (TemplateArgs.
size() != 2)
4648 if (!
isCharType(TemplateArgs[0].getAsType()))
4657 bool CXXNameMangler::mangleStandardSubstitution(
const NamedDecl *ND) {
4659 if (
const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) {
4684 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
4694 if (TemplateArgs.
size() != 3)
4697 if (!
isCharType(TemplateArgs[0].getAsType()))
4734 void CXXNameMangler::addSubstitution(
QualType T) {
4737 addSubstitution(RT->getDecl());
4743 addSubstitution(TypePtr);
4746 void CXXNameMangler::addSubstitution(
TemplateName Template) {
4748 return addSubstitution(TD);
4750 Template = Context.getASTContext().getCanonicalTemplateName(Template);
4754 void CXXNameMangler::addSubstitution(
uintptr_t Ptr) {
4755 assert(!Substitutions.count(Ptr) &&
"Substitution already exists!");
4756 Substitutions[Ptr] = SeqID++;
4759 void CXXNameMangler::extendSubstitutions(CXXNameMangler* Other) {
4760 assert(Other->SeqID >= SeqID &&
"Must be superset of substitutions!");
4761 if (Other->SeqID > SeqID) {
4762 Substitutions.swap(Other->Substitutions);
4763 SeqID = Other->SeqID;
4767 CXXNameMangler::AbiTagList
4768 CXXNameMangler::makeFunctionReturnTypeTags(
const FunctionDecl *FD) {
4770 if (DisableDerivedAbiTags)
4771 return AbiTagList();
4773 llvm::raw_null_ostream NullOutStream;
4774 CXXNameMangler TrackReturnTypeTags(*
this, NullOutStream);
4775 TrackReturnTypeTags.disableDerivedAbiTags();
4779 FunctionTypeDepthState saved = TrackReturnTypeTags.FunctionTypeDepth.push();
4780 TrackReturnTypeTags.FunctionTypeDepth.enterResultType();
4782 TrackReturnTypeTags.FunctionTypeDepth.leaveResultType();
4783 TrackReturnTypeTags.FunctionTypeDepth.pop(saved);
4785 return TrackReturnTypeTags.AbiTagsRoot.getSortedUniqueUsedAbiTags();
4788 CXXNameMangler::AbiTagList
4789 CXXNameMangler::makeVariableTypeTags(
const VarDecl *VD) {
4791 if (DisableDerivedAbiTags)
4792 return AbiTagList();
4794 llvm::raw_null_ostream NullOutStream;
4795 CXXNameMangler TrackVariableType(*
this, NullOutStream);
4796 TrackVariableType.disableDerivedAbiTags();
4798 TrackVariableType.mangleType(VD->
getType());
4800 return TrackVariableType.AbiTagsRoot.getSortedUniqueUsedAbiTags();
4803 bool CXXNameMangler::shouldHaveAbiTags(ItaniumMangleContextImpl &C,
4805 llvm::raw_null_ostream NullOutStream;
4806 CXXNameMangler TrackAbiTags(C, NullOutStream,
nullptr,
true);
4807 TrackAbiTags.mangle(VD);
4808 return TrackAbiTags.AbiTagsRoot.getUsedAbiTags().size();
4821 void ItaniumMangleContextImpl::mangleCXXName(
const NamedDecl *D,
4823 assert((isa<FunctionDecl>(D) || isa<VarDecl>(D)) &&
4824 "Invalid mangleName() call, argument is not a variable or function!");
4825 assert(!isa<CXXConstructorDecl>(D) && !isa<CXXDestructorDecl>(D) &&
4826 "Invalid mangleName() call on 'structor decl!");
4829 getASTContext().getSourceManager(),
4830 "Mangling declaration");
4832 CXXNameMangler Mangler(*
this, Out, D);
4839 CXXNameMangler Mangler(*
this, Out, D, Type);
4846 CXXNameMangler Mangler(*
this, Out, D, Type);
4852 CXXNameMangler Mangler(*
this, Out, D,
Ctor_Comdat);
4858 CXXNameMangler Mangler(*
this, Out, D,
Dtor_Comdat);
4862 void ItaniumMangleContextImpl::mangleThunk(
const CXXMethodDecl *MD,
4872 assert(!isa<CXXDestructorDecl>(MD) &&
4873 "Use mangleCXXDtor for destructor decls!");
4874 CXXNameMangler Mangler(*
this, Out);
4875 Mangler.getStream() <<
"_ZT";
4877 Mangler.getStream() <<
'c';
4888 Mangler.mangleFunctionEncoding(MD);
4891 void ItaniumMangleContextImpl::mangleCXXDtorThunk(
4896 CXXNameMangler Mangler(*
this, Out, DD, Type);
4897 Mangler.getStream() <<
"_ZT";
4900 Mangler.mangleCallOffset(ThisAdjustment.
NonVirtual,
4903 Mangler.mangleFunctionEncoding(DD);
4907 void ItaniumMangleContextImpl::mangleStaticGuardVariable(
const VarDecl *D,
4911 CXXNameMangler Mangler(*
this, Out);
4914 Mangler.getStream() <<
"_ZGV";
4915 Mangler.mangleName(D);
4918 void ItaniumMangleContextImpl::mangleDynamicInitializer(
const VarDecl *MD,
4923 Out <<
"__cxx_global_var_init";
4926 void ItaniumMangleContextImpl::mangleDynamicAtExitDestructor(
const VarDecl *D,
4929 CXXNameMangler Mangler(*
this, Out);
4930 Mangler.getStream() <<
"__dtor_";
4931 if (shouldMangleDeclName(D))
4934 Mangler.getStream() << D->
getName();
4937 void ItaniumMangleContextImpl::mangleSEHFilterExpression(
4938 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
4939 CXXNameMangler Mangler(*
this, Out);
4940 Mangler.getStream() <<
"__filt_";
4941 if (shouldMangleDeclName(EnclosingDecl))
4942 Mangler.mangle(EnclosingDecl);
4944 Mangler.getStream() << EnclosingDecl->
getName();
4947 void ItaniumMangleContextImpl::mangleSEHFinallyBlock(
4948 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
4949 CXXNameMangler Mangler(*
this, Out);
4950 Mangler.getStream() <<
"__fin_";
4951 if (shouldMangleDeclName(EnclosingDecl))
4952 Mangler.mangle(EnclosingDecl);
4954 Mangler.getStream() << EnclosingDecl->
getName();
4957 void ItaniumMangleContextImpl::mangleItaniumThreadLocalInit(
const VarDecl *D,
4960 CXXNameMangler Mangler(*
this, Out);
4961 Mangler.getStream() <<
"_ZTH";
4962 Mangler.mangleName(D);
4966 ItaniumMangleContextImpl::mangleItaniumThreadLocalWrapper(
const VarDecl *D,
4969 CXXNameMangler Mangler(*
this, Out);
4970 Mangler.getStream() <<
"_ZTW";
4971 Mangler.mangleName(D);
4974 void ItaniumMangleContextImpl::mangleReferenceTemporary(
const VarDecl *D,
4975 unsigned ManglingNumber,
4979 CXXNameMangler Mangler(*
this, Out);
4980 Mangler.getStream() <<
"_ZGR";
4981 Mangler.mangleName(D);
4982 assert(ManglingNumber > 0 &&
"Reference temporary mangling number is zero!");
4983 Mangler.mangleSeqID(ManglingNumber - 1);
4986 void ItaniumMangleContextImpl::mangleCXXVTable(
const CXXRecordDecl *RD,
4989 CXXNameMangler Mangler(*
this, Out);
4990 Mangler.getStream() <<
"_ZTV";
4991 Mangler.mangleNameOrStandardSubstitution(RD);
4994 void ItaniumMangleContextImpl::mangleCXXVTT(
const CXXRecordDecl *RD,
4997 CXXNameMangler Mangler(*
this, Out);
4998 Mangler.getStream() <<
"_ZTT";
4999 Mangler.mangleNameOrStandardSubstitution(RD);
5002 void ItaniumMangleContextImpl::mangleCXXCtorVTable(
const CXXRecordDecl *RD,
5007 CXXNameMangler Mangler(*
this, Out);
5008 Mangler.getStream() <<
"_ZTC";
5009 Mangler.mangleNameOrStandardSubstitution(RD);
5010 Mangler.getStream() <<
Offset;
5011 Mangler.getStream() <<
'_';
5012 Mangler.mangleNameOrStandardSubstitution(Type);
5015 void ItaniumMangleContextImpl::mangleCXXRTTI(
QualType Ty, raw_ostream &Out) {
5017 assert(!Ty.
hasQualifiers() &&
"RTTI info cannot have top-level qualifiers");
5018 CXXNameMangler Mangler(*
this, Out);
5019 Mangler.getStream() <<
"_ZTI";
5020 Mangler.mangleType(Ty);
5023 void ItaniumMangleContextImpl::mangleCXXRTTIName(
QualType Ty,
5026 CXXNameMangler Mangler(*
this, Out);
5027 Mangler.getStream() <<
"_ZTS";
5028 Mangler.mangleType(Ty);
5031 void ItaniumMangleContextImpl::mangleTypeName(
QualType Ty, raw_ostream &Out) {
5032 mangleCXXRTTIName(Ty, Out);
5035 void ItaniumMangleContextImpl::mangleStringLiteral(
const StringLiteral *, raw_ostream &) {
5036 llvm_unreachable(
"Can't mangle string literals");
5041 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)
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
struct clang::ThisAdjustment::VirtualAdjustment::@133 Itanium
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...
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.
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.
struct clang::ReturnAdjustment::VirtualAdjustment::@131 Itanium
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
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.
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.
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...
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)
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
CallingConv
CallingConv - Specifies the calling convention that a function uses.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1...
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
RecordDecl * getDecl() const
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the member name.
int64_t NonVirtual
The non-virtual adjustment from the derived object to its nearest virtual base.
static bool hasMangledSubstitutionQualifiers(QualType T)
Determine whether the given type has any qualifiers that are relevant for substitutions.
A template template parameter pack that has been substituted for a template template argument pack...
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
There is no lifetime qualification on this type.
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template.
is AltiVec 'vector Pixel'
Assigning into this object requires the old value to be released and the new value to be retained...
QualType getCanonicalType() const
bool isBuiltinType() const
Helper methods to distinguish type categories.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
ExtParameterInfo getExtParameterInfo(unsigned I) const
bool isSpecialized() const
Determine whether this object type is "specialized", meaning that it has type arguments.
ElaboratedTypeKeyword getKeyword() const
Encodes a location in the source.
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
QualType getReturnType() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the type.
Expr * getSubExpr() const
Represents typeof(type), a GCC extension.
Interfaces are the core concept in Objective-C for object oriented design.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
Represents the declaration of a struct/union/class/enum.
LanguageLinkage
Describes the different kinds of language linkage (C++ [dcl.link]) that an entity may have...
CallingConv getCC() const
QualType getElementType() const
Represents a vector type where either the type or size is dependent.
bool isFieldDesignator() const
Represents a static or instance method of a struct/union/class.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
No ref-qualifier was provided.
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 that has been substituted but not yet expanded...
Represents a template argument.
Represents a template name that was expressed as a qualified name.
bool isTypeOperand() const
Dataflow Directional Tag Classes.
ThisAdjustment This
The this pointer adjustment.
ExtInfo getExtInfo() const
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
NestedNameSpecifier * getQualifier() const
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
The base class of all kinds of template declarations (e.g., class, function, etc.).
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
The template argument is a pack expansion of a template name that was provided for a template templat...
const TemplateArgument * getArgs() const
Retrieve the template arguments.
Represents a field injected from an anonymous union/struct into the parent scope. ...
bool isDependentAddressSpaceType() const
NamespaceDecl * getOriginalNamespace()
Get the original (first) namespace declaration.
DeclarationName getMember() const
Retrieve the name of the member that this expression refers to.
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
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.