32 #include "llvm/ADT/StringExtras.h" 33 #include "llvm/Support/ErrorHandling.h" 34 #include "llvm/Support/raw_ostream.h" 36 using namespace clang;
52 = dyn_cast_or_null<ParmVarDecl>(RD->getLambdaContextDecl()))
53 return ContextParam->getDeclContext();
57 if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
59 = dyn_cast_or_null<ParmVarDecl>(BD->getBlockManglingContextDecl()))
60 return ContextParam->getDeclContext();
64 if (isa<CapturedDecl>(DC) || isa<OMPDeclareReductionDecl>(DC) ||
65 isa<OMPDeclareMapperDecl>(DC)) {
66 return getEffectiveDeclContext(cast<Decl>(DC));
69 if (
const auto *VD = dyn_cast<VarDecl>(D))
71 return VD->getASTContext().getTranslationUnitDecl();
73 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
75 return FD->getASTContext().getTranslationUnitDecl();
81 return getEffectiveDeclContext(cast<Decl>(DC));
84 static bool isLocalContainerContext(
const DeclContext *DC) {
85 return isa<FunctionDecl>(DC) || isa<ObjCMethodDecl>(DC) || isa<BlockDecl>(DC);
91 if (isLocalContainerContext(DC))
92 return dyn_cast<RecordDecl>(D);
94 DC = getEffectiveDeclContext(D);
101 return ftd->getTemplatedDecl();
108 return (fn ? getStructor(fn) :
decl);
111 static bool isLambda(
const NamedDecl *ND) {
119 static const unsigned UnknownArity = ~0U;
122 typedef std::pair<const DeclContext*, IdentifierInfo*> DiscriminatorKeyTy;
123 llvm::DenseMap<DiscriminatorKeyTy, unsigned> Discriminator;
124 llvm::DenseMap<const NamedDecl*, unsigned> Uniquifier;
127 explicit ItaniumMangleContextImpl(
ASTContext &Context,
134 bool shouldMangleCXXName(
const NamedDecl *D)
override;
135 bool shouldMangleStringLiteral(
const StringLiteral *)
override {
138 void mangleCXXName(
const NamedDecl *D, raw_ostream &)
override;
140 raw_ostream &)
override;
143 raw_ostream &)
override;
144 void mangleReferenceTemporary(
const VarDecl *D,
unsigned ManglingNumber,
145 raw_ostream &)
override;
146 void mangleCXXVTable(
const CXXRecordDecl *RD, raw_ostream &)
override;
147 void mangleCXXVTT(
const CXXRecordDecl *RD, raw_ostream &)
override;
150 void mangleCXXRTTI(
QualType T, raw_ostream &)
override;
151 void mangleCXXRTTIName(
QualType T, raw_ostream &)
override;
152 void mangleTypeName(
QualType T, raw_ostream &)
override;
154 raw_ostream &)
override;
156 raw_ostream &)
override;
160 void mangleStaticGuardVariable(
const VarDecl *D, raw_ostream &)
override;
161 void mangleDynamicInitializer(
const VarDecl *D, raw_ostream &Out)
override;
162 void mangleDynamicAtExitDestructor(
const VarDecl *D,
163 raw_ostream &Out)
override;
164 void mangleSEHFilterExpression(
const NamedDecl *EnclosingDecl,
165 raw_ostream &Out)
override;
166 void mangleSEHFinallyBlock(
const NamedDecl *EnclosingDecl,
167 raw_ostream &Out)
override;
168 void mangleItaniumThreadLocalInit(
const VarDecl *D, raw_ostream &)
override;
169 void mangleItaniumThreadLocalWrapper(
const VarDecl *D,
170 raw_ostream &)
override;
172 void mangleStringLiteral(
const StringLiteral *, raw_ostream &)
override;
174 void mangleLambdaSig(
const CXXRecordDecl *Lambda, raw_ostream &)
override;
176 bool getNextDiscriminator(
const NamedDecl *ND,
unsigned &disc) {
182 if (
const TagDecl *Tag = dyn_cast<TagDecl>(ND)) {
183 if (Tag->getName().empty() && !Tag->getTypedefNameForAnonDecl())
189 unsigned discriminator = getASTContext().getManglingNumber(ND);
190 if (discriminator == 1)
192 disc = discriminator - 2;
197 unsigned &discriminator = Uniquifier[ND];
198 if (!discriminator) {
199 const DeclContext *DC = getEffectiveDeclContext(ND);
200 discriminator = ++Discriminator[std::make_pair(DC, ND->
getIdentifier())];
202 if (discriminator == 1)
204 disc = discriminator-2;
211 class CXXNameMangler {
212 ItaniumMangleContextImpl &Context;
214 bool NullOut =
false;
219 bool DisableDerivedAbiTags =
false;
225 unsigned StructorType;
230 class FunctionTypeDepthState {
233 enum { InResultTypeMask = 1 };
236 FunctionTypeDepthState() : Bits(0) {}
239 unsigned getDepth()
const {
244 bool isInResultType()
const {
245 return Bits & InResultTypeMask;
248 FunctionTypeDepthState push() {
249 FunctionTypeDepthState tmp = *
this;
250 Bits = (Bits & ~InResultTypeMask) + 2;
254 void enterResultType() {
255 Bits |= InResultTypeMask;
258 void leaveResultType() {
259 Bits &= ~InResultTypeMask;
262 void pop(FunctionTypeDepthState saved) {
263 assert(getDepth() == saved.getDepth() + 1);
278 class AbiTagState final {
280 explicit AbiTagState(AbiTagState *&Head) : LinkHead(Head) {
286 AbiTagState(
const AbiTagState &) =
delete;
287 AbiTagState &operator=(
const AbiTagState &) =
delete;
289 ~AbiTagState() { pop(); }
291 void write(raw_ostream &Out,
const NamedDecl *ND,
292 const AbiTagList *AdditionalAbiTags) {
294 if (!isa<FunctionDecl>(ND) && !isa<VarDecl>(ND)) {
296 !AdditionalAbiTags &&
297 "only function and variables need a list of additional abi tags");
298 if (
const auto *NS = dyn_cast<NamespaceDecl>(ND)) {
299 if (
const auto *AbiTag = NS->getAttr<AbiTagAttr>()) {
300 UsedAbiTags.insert(UsedAbiTags.end(), AbiTag->tags().begin(),
301 AbiTag->tags().end());
309 if (
const auto *AbiTag = ND->
getAttr<AbiTagAttr>()) {
310 UsedAbiTags.insert(UsedAbiTags.end(), AbiTag->tags().begin(),
311 AbiTag->tags().end());
312 TagList.insert(TagList.end(), AbiTag->tags().begin(),
313 AbiTag->tags().end());
316 if (AdditionalAbiTags) {
317 UsedAbiTags.insert(UsedAbiTags.end(), AdditionalAbiTags->begin(),
318 AdditionalAbiTags->end());
319 TagList.insert(TagList.end(), AdditionalAbiTags->begin(),
320 AdditionalAbiTags->end());
324 TagList.erase(std::unique(TagList.begin(), TagList.end()), TagList.end());
326 writeSortedUniqueAbiTags(Out, TagList);
329 const AbiTagList &getUsedAbiTags()
const {
return UsedAbiTags; }
330 void setUsedAbiTags(
const AbiTagList &AbiTags) {
331 UsedAbiTags = AbiTags;
334 const AbiTagList &getEmittedAbiTags()
const {
335 return EmittedAbiTags;
338 const AbiTagList &getSortedUniqueUsedAbiTags() {
339 llvm::sort(UsedAbiTags);
340 UsedAbiTags.erase(std::unique(UsedAbiTags.begin(), UsedAbiTags.end()),
347 AbiTagList UsedAbiTags;
349 AbiTagList EmittedAbiTags;
351 AbiTagState *&LinkHead;
352 AbiTagState *
Parent =
nullptr;
355 assert(LinkHead ==
this &&
356 "abi tag link head must point to us on destruction");
358 Parent->UsedAbiTags.insert(Parent->UsedAbiTags.end(),
359 UsedAbiTags.begin(), UsedAbiTags.end());
360 Parent->EmittedAbiTags.insert(Parent->EmittedAbiTags.end(),
361 EmittedAbiTags.begin(),
362 EmittedAbiTags.end());
367 void writeSortedUniqueAbiTags(raw_ostream &Out,
const AbiTagList &AbiTags) {
368 for (
const auto &Tag : AbiTags) {
369 EmittedAbiTags.push_back(Tag);
377 AbiTagState *AbiTags =
nullptr;
378 AbiTagState AbiTagsRoot;
380 llvm::DenseMap<uintptr_t, unsigned> Substitutions;
381 llvm::DenseMap<StringRef, unsigned> ModuleSubstitutions;
383 ASTContext &getASTContext()
const {
return Context.getASTContext(); }
386 CXXNameMangler(ItaniumMangleContextImpl &
C, raw_ostream &Out_,
387 const NamedDecl *D =
nullptr,
bool NullOut_ =
false)
388 : Context(C), Out(Out_), NullOut(NullOut_), Structor(getStructor(D)),
389 StructorType(0), SeqID(0), AbiTagsRoot(AbiTags) {
391 assert(!D || (!isa<CXXDestructorDecl>(D) &&
392 !isa<CXXConstructorDecl>(D)));
394 CXXNameMangler(ItaniumMangleContextImpl &C, raw_ostream &Out_,
396 : Context(C), Out(Out_), Structor(getStructor(D)), StructorType(Type),
397 SeqID(0), AbiTagsRoot(AbiTags) { }
398 CXXNameMangler(ItaniumMangleContextImpl &C, raw_ostream &Out_,
400 : Context(C), Out(Out_), Structor(getStructor(D)), StructorType(Type),
401 SeqID(0), AbiTagsRoot(AbiTags) { }
403 CXXNameMangler(CXXNameMangler &Outer, raw_ostream &Out_)
404 : Context(Outer.Context), Out(Out_), NullOut(
false),
405 Structor(Outer.Structor), StructorType(Outer.StructorType),
406 SeqID(Outer.SeqID), FunctionTypeDepth(Outer.FunctionTypeDepth),
407 AbiTagsRoot(AbiTags), Substitutions(Outer.Substitutions) {}
409 CXXNameMangler(CXXNameMangler &Outer, llvm::raw_null_ostream &Out_)
410 : Context(Outer.Context), Out(Out_), NullOut(
true),
411 Structor(Outer.Structor), StructorType(Outer.StructorType),
412 SeqID(Outer.SeqID), FunctionTypeDepth(Outer.FunctionTypeDepth),
413 AbiTagsRoot(AbiTags), Substitutions(Outer.Substitutions) {}
415 raw_ostream &getStream() {
return Out; }
417 void disableDerivedAbiTags() { DisableDerivedAbiTags =
true; }
418 static bool shouldHaveAbiTags(ItaniumMangleContextImpl &C,
const VarDecl *VD);
421 void mangleCallOffset(int64_t NonVirtual, int64_t
Virtual);
423 void mangleNumber(int64_t Number);
424 void mangleFloat(
const llvm::APFloat &F);
426 void mangleSeqID(
unsigned SeqID);
429 void mangleNameOrStandardSubstitution(
const NamedDecl *ND);
434 bool mangleSubstitution(
const NamedDecl *ND);
435 bool mangleSubstitution(
QualType T);
441 bool mangleStandardSubstitution(
const NamedDecl *ND);
443 void addSubstitution(
const NamedDecl *ND) {
446 addSubstitution(reinterpret_cast<uintptr_t>(ND));
452 void extendSubstitutions(CXXNameMangler* Other);
455 bool recursive =
false);
459 unsigned NumTemplateArgs,
460 unsigned KnownArity = UnknownArity);
462 void mangleFunctionEncodingBareType(
const FunctionDecl *FD);
464 void mangleNameWithAbiTags(
const NamedDecl *ND,
465 const AbiTagList *AdditionalAbiTags);
466 void mangleModuleName(
const Module *M);
467 void mangleModuleNamePrefix(StringRef Name);
470 unsigned NumTemplateArgs);
471 void mangleUnqualifiedName(
const NamedDecl *ND,
472 const AbiTagList *AdditionalAbiTags) {
473 mangleUnqualifiedName(ND, ND->
getDeclName(), UnknownArity,
478 const AbiTagList *AdditionalAbiTags);
479 void mangleUnscopedName(
const NamedDecl *ND,
480 const AbiTagList *AdditionalAbiTags);
482 const AbiTagList *AdditionalAbiTags);
484 const AbiTagList *AdditionalAbiTags);
487 void mangleSourceNameWithAbiTags(
488 const NamedDecl *ND,
const AbiTagList *AdditionalAbiTags =
nullptr);
489 void mangleLocalName(
const Decl *D,
490 const AbiTagList *AdditionalAbiTags);
491 void mangleBlockForPrefix(
const BlockDecl *Block);
492 void mangleUnqualifiedBlock(
const BlockDecl *Block);
496 const AbiTagList *AdditionalAbiTags,
497 bool NoFunction=
false);
500 unsigned NumTemplateArgs);
502 void manglePrefix(
const DeclContext *DC,
bool NoFunction=
false);
504 void mangleTemplatePrefix(
const TemplateDecl *ND,
bool NoFunction=
false);
506 bool mangleUnresolvedTypeOrSimpleId(
QualType DestroyedType,
507 StringRef Prefix =
"");
510 void mangleVendorQualifier(StringRef qualifier);
517 #define ABSTRACT_TYPE(CLASS, PARENT) 518 #define NON_CANONICAL_TYPE(CLASS, PARENT) 519 #define TYPE(CLASS, PARENT) void mangleType(const CLASS##Type *T); 520 #include "clang/AST/TypeNodes.inc" 522 void mangleType(
const TagType*);
524 static StringRef getCallingConvQualifierName(
CallingConv CC);
525 void mangleExtParameterInfo(FunctionProtoType::ExtParameterInfo info);
529 void mangleNeonVectorType(
const VectorType *T);
531 void mangleAArch64NeonVectorType(
const VectorType *T);
535 void mangleMemberExprBase(
const Expr *base,
bool isArrow);
536 void mangleMemberExpr(
const Expr *base,
bool isArrow,
541 unsigned NumTemplateArgs,
542 unsigned knownArity);
543 void mangleCastExpression(
const Expr *E, StringRef CastEncoding);
544 void mangleInitListElements(
const InitListExpr *InitList);
545 void mangleDeclRefExpr(
const NamedDecl *D);
546 void mangleExpression(
const Expr *E,
unsigned Arity = UnknownArity);
551 unsigned NumTemplateArgs);
553 unsigned NumTemplateArgs);
557 void mangleTemplateParameter(
unsigned Depth,
unsigned Index);
562 const AbiTagList *AdditionalAbiTags);
565 AbiTagList makeFunctionReturnTypeTags(
const FunctionDecl *FD);
567 AbiTagList makeVariableTypeTags(
const VarDecl *VD);
572 bool ItaniumMangleContextImpl::shouldMangleCXXName(
const NamedDecl *D) {
577 if (FD->
hasAttr<OverloadableAttr>())
607 if (!getASTContext().getLangOpts().CPlusPlus)
611 if (VD && !isa<DecompositionDecl>(D)) {
617 const DeclContext *DC = getEffectiveDeclContext(D);
621 DC = getEffectiveParentContext(DC);
623 !CXXNameMangler::shouldHaveAbiTags(*
this, VD) &&
624 !isa<VarTemplateSpecializationDecl>(D))
631 void CXXNameMangler::writeAbiTags(
const NamedDecl *ND,
632 const AbiTagList *AdditionalAbiTags) {
633 assert(AbiTags &&
"require AbiTagState");
634 AbiTags->write(Out, ND, DisableDerivedAbiTags ?
nullptr : AdditionalAbiTags);
637 void CXXNameMangler::mangleSourceNameWithAbiTags(
638 const NamedDecl *ND,
const AbiTagList *AdditionalAbiTags) {
640 writeAbiTags(ND, AdditionalAbiTags);
643 void CXXNameMangler::mangle(
const NamedDecl *D) {
649 mangleFunctionEncoding(FD);
650 else if (
const VarDecl *VD = dyn_cast<VarDecl>(D))
653 mangleName(IFD->getAnonField());
655 mangleName(cast<FieldDecl>(D));
658 void CXXNameMangler::mangleFunctionEncoding(
const FunctionDecl *FD) {
662 if (!Context.shouldMangleDeclName(FD)) {
667 AbiTagList ReturnTypeAbiTags = makeFunctionReturnTypeTags(FD);
668 if (ReturnTypeAbiTags.empty()) {
671 mangleFunctionEncodingBareType(FD);
679 llvm::raw_svector_ostream FunctionEncodingStream(FunctionEncodingBuf);
680 CXXNameMangler FunctionEncodingMangler(*
this, FunctionEncodingStream);
682 FunctionEncodingMangler.disableDerivedAbiTags();
683 FunctionEncodingMangler.mangleNameWithAbiTags(FD,
nullptr);
686 size_t EncodingPositionStart = FunctionEncodingStream.str().size();
687 FunctionEncodingMangler.mangleFunctionEncodingBareType(FD);
691 const AbiTagList &UsedAbiTags =
692 FunctionEncodingMangler.AbiTagsRoot.getSortedUniqueUsedAbiTags();
693 AbiTagList AdditionalAbiTags(ReturnTypeAbiTags.size());
694 AdditionalAbiTags.erase(
695 std::set_difference(ReturnTypeAbiTags.begin(), ReturnTypeAbiTags.end(),
696 UsedAbiTags.begin(), UsedAbiTags.end(),
697 AdditionalAbiTags.begin()),
698 AdditionalAbiTags.end());
701 mangleNameWithAbiTags(FD, &AdditionalAbiTags);
702 Out << FunctionEncodingStream.str().substr(EncodingPositionStart);
706 extendSubstitutions(&FunctionEncodingMangler);
709 void CXXNameMangler::mangleFunctionEncodingBareType(
const FunctionDecl *FD) {
710 if (FD->
hasAttr<EnableIfAttr>()) {
711 FunctionTypeDepthState Saved = FunctionTypeDepth.push();
712 Out <<
"Ua9enable_ifI";
713 for (AttrVec::const_iterator I = FD->
getAttrs().begin(),
716 EnableIfAttr *EIA = dyn_cast<EnableIfAttr>(*I);
720 mangleExpression(EIA->getCond());
724 FunctionTypeDepth.pop(Saved);
729 if (
auto *CD = dyn_cast<CXXConstructorDecl>(FD))
730 if (
auto Inherited = CD->getInheritedConstructor())
731 FD = Inherited.getConstructor();
749 bool MangleReturnType =
false;
751 if (!(isa<CXXConstructorDecl>(FD) || isa<CXXDestructorDecl>(FD) ||
752 isa<CXXConversionDecl>(FD)))
753 MangleReturnType =
true;
756 FD = PrimaryTemplate->getTemplatedDecl();
760 MangleReturnType, FD);
764 while (isa<LinkageSpecDecl>(DC)) {
765 DC = getEffectiveParentContext(DC);
774 ->isTranslationUnit())
778 return II && II->
isStr(
"std");
787 return isStd(cast<NamespaceDecl>(DC));
793 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
802 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
803 TemplateArgs = &Spec->getTemplateArgs();
804 return Spec->getSpecializedTemplate();
809 dyn_cast<VarTemplateSpecializationDecl>(ND)) {
810 TemplateArgs = &Spec->getTemplateArgs();
811 return Spec->getSpecializedTemplate();
817 void CXXNameMangler::mangleName(
const NamedDecl *ND) {
818 if (
const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
820 AbiTagList VariableTypeAbiTags = makeVariableTypeTags(VD);
821 if (VariableTypeAbiTags.empty()) {
823 mangleNameWithAbiTags(VD,
nullptr);
828 llvm::raw_null_ostream NullOutStream;
829 CXXNameMangler VariableNameMangler(*
this, NullOutStream);
830 VariableNameMangler.disableDerivedAbiTags();
831 VariableNameMangler.mangleNameWithAbiTags(VD,
nullptr);
834 const AbiTagList &UsedAbiTags =
835 VariableNameMangler.AbiTagsRoot.getSortedUniqueUsedAbiTags();
836 AbiTagList AdditionalAbiTags(VariableTypeAbiTags.size());
837 AdditionalAbiTags.erase(
838 std::set_difference(VariableTypeAbiTags.begin(),
839 VariableTypeAbiTags.end(), UsedAbiTags.begin(),
840 UsedAbiTags.end(), AdditionalAbiTags.begin()),
841 AdditionalAbiTags.end());
844 mangleNameWithAbiTags(VD, &AdditionalAbiTags);
846 mangleNameWithAbiTags(ND,
nullptr);
850 void CXXNameMangler::mangleNameWithAbiTags(
const NamedDecl *ND,
851 const AbiTagList *AdditionalAbiTags) {
857 const DeclContext *DC = getEffectiveDeclContext(ND);
863 if (isLocalContainerContext(DC) && ND->
hasLinkage() && !isLambda(ND))
865 DC = getEffectiveParentContext(DC);
866 else if (GetLocalClassDecl(ND)) {
867 mangleLocalName(ND, AdditionalAbiTags);
873 if (isLocalContainerContext(DC)) {
874 mangleLocalName(ND, AdditionalAbiTags);
890 mangleUnscopedTemplateName(TD, AdditionalAbiTags);
891 mangleTemplateArgs(*TemplateArgs);
895 mangleUnscopedName(ND, AdditionalAbiTags);
899 mangleNestedName(ND, DC, AdditionalAbiTags);
902 void CXXNameMangler::mangleModuleName(
const Module *M) {
909 mangleModuleNamePrefix(M->
Name);
913 void CXXNameMangler::mangleModuleNamePrefix(StringRef Name) {
916 auto It = ModuleSubstitutions.find(Name);
917 if (It != ModuleSubstitutions.end()) {
919 Out << '_' << static_cast<char>(
'0' + It->second);
921 Out <<
'W' << (It->second - 10) <<
'_';
927 auto Parts = Name.rsplit(
'.');
928 if (Parts.second.empty())
929 Parts.second = Parts.first;
931 mangleModuleNamePrefix(Parts.first);
933 Out << Parts.second.size() << Parts.second;
934 ModuleSubstitutions.insert({Name, ModuleSubstitutions.size()});
937 void CXXNameMangler::mangleTemplateName(
const TemplateDecl *TD,
939 unsigned NumTemplateArgs) {
943 mangleUnscopedTemplateName(TD,
nullptr);
944 mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
946 mangleNestedName(TD, TemplateArgs, NumTemplateArgs);
950 void CXXNameMangler::mangleUnscopedName(
const NamedDecl *ND,
951 const AbiTagList *AdditionalAbiTags) {
958 mangleUnqualifiedName(ND, AdditionalAbiTags);
961 void CXXNameMangler::mangleUnscopedTemplateName(
962 const TemplateDecl *ND,
const AbiTagList *AdditionalAbiTags) {
965 if (mangleSubstitution(ND))
969 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND)) {
970 assert(!AdditionalAbiTags &&
971 "template template param cannot have abi tags");
972 mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
973 }
else if (isa<BuiltinTemplateDecl>(ND) || isa<ConceptDecl>(ND)) {
974 mangleUnscopedName(ND, AdditionalAbiTags);
982 void CXXNameMangler::mangleUnscopedTemplateName(
983 TemplateName Template,
const AbiTagList *AdditionalAbiTags) {
987 return mangleUnscopedTemplateName(TD, AdditionalAbiTags);
989 if (mangleSubstitution(Template))
992 assert(!AdditionalAbiTags &&
993 "dependent template name cannot have abi tags");
996 assert(Dependent &&
"Not a dependent template name?");
998 mangleSourceName(
Id);
1000 mangleOperatorName(Dependent->
getOperator(), UnknownArity);
1002 addSubstitution(Template);
1005 void CXXNameMangler::mangleFloat(
const llvm::APFloat &f) {
1020 unsigned numCharacters = (valueBits.getBitWidth() + 3) / 4;
1021 assert(numCharacters != 0);
1027 for (
unsigned stringIndex = 0; stringIndex != numCharacters; ++stringIndex) {
1029 unsigned digitBitIndex = 4 * (numCharacters - stringIndex - 1);
1032 uint64_t hexDigit = valueBits.getRawData()[digitBitIndex / 64];
1033 hexDigit >>= (digitBitIndex % 64);
1037 static const char charForHex[16] = {
1038 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
1039 '8',
'9',
'a',
'b',
'c',
'd',
'e',
'f' 1041 buffer[stringIndex] = charForHex[hexDigit];
1044 Out.write(buffer.data(), numCharacters);
1048 if (Value.isSigned() && Value.isNegative()) {
1050 Value.abs().print(Out,
false);
1052 Value.print(Out,
false);
1056 void CXXNameMangler::mangleNumber(int64_t Number) {
1066 void CXXNameMangler::mangleCallOffset(int64_t NonVirtual, int64_t
Virtual) {
1074 mangleNumber(NonVirtual);
1080 mangleNumber(NonVirtual);
1082 mangleNumber(Virtual);
1088 if (!mangleSubstitution(
QualType(TST, 0))) {
1089 mangleTemplatePrefix(TST->getTemplateName());
1094 mangleTemplateArgs(TST->getArgs(), TST->getNumArgs());
1097 }
else if (
const auto *DTST =
1099 if (!mangleSubstitution(
QualType(DTST, 0))) {
1100 TemplateName Template = getASTContext().getDependentTemplateName(
1101 DTST->getQualifier(), DTST->getIdentifier());
1102 mangleTemplatePrefix(Template);
1107 mangleTemplateArgs(DTST->getArgs(), DTST->getNumArgs());
1108 addSubstitution(
QualType(DTST, 0));
1138 switch (qualifier->
getKind()) {
1150 llvm_unreachable(
"Can't mangle __super specifier");
1154 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1162 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1179 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1186 if (mangleUnresolvedTypeOrSimpleId(
QualType(type, 0), recursive ?
"N" :
""))
1195 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1213 void CXXNameMangler::mangleUnresolvedName(
1216 unsigned knownArity) {
1217 if (qualifier) mangleUnresolvedPrefix(qualifier);
1233 mangleOperatorName(name, knownArity);
1236 llvm_unreachable(
"Can't mangle a constructor name!");
1238 llvm_unreachable(
"Can't mangle a using directive name!");
1240 llvm_unreachable(
"Can't mangle a deduction guide name!");
1244 llvm_unreachable(
"Can't mangle Objective-C selector names here!");
1250 mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
1253 void CXXNameMangler::mangleUnqualifiedName(
const NamedDecl *ND,
1255 unsigned KnownArity,
1256 const AbiTagList *AdditionalAbiTags) {
1257 unsigned Arity = KnownArity;
1266 if (
auto *DD = dyn_cast<DecompositionDecl>(ND)) {
1275 for (
auto *BD : DD->bindings())
1276 mangleSourceName(BD->getDeclName().getAsIdentifierInfo());
1278 writeAbiTags(ND, AdditionalAbiTags);
1298 getEffectiveDeclContext(ND)->isFileContext() &&
1303 bool IsRegCall = FD &&
1307 mangleRegCallName(II);
1309 mangleSourceName(II);
1311 writeAbiTags(ND, AdditionalAbiTags);
1316 assert(ND &&
"mangling empty name without declaration");
1318 if (
const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) {
1319 if (NS->isAnonymousNamespace()) {
1321 Out <<
"12_GLOBAL__N_1";
1326 if (
const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
1340 &&
"Expected anonymous struct or union!");
1347 assert(FD->getIdentifier() &&
"Data member name isn't an identifier!");
1349 mangleSourceName(FD->getIdentifier());
1360 if (isa<ObjCContainerDecl>(ND))
1364 const TagDecl *TD = cast<TagDecl>(ND);
1367 "Typedef should not be in another decl context!");
1369 "Typedef was not named!");
1371 assert(!AdditionalAbiTags &&
"Type cannot have additional abi tags");
1374 writeAbiTags(TD,
nullptr);
1383 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(TD)) {
1385 assert(!AdditionalAbiTags &&
1386 "Lambda type cannot have additional abi tags");
1387 mangleLambda(Record);
1393 unsigned UnnamedMangle = getASTContext().getManglingNumber(TD);
1395 if (UnnamedMangle > 1)
1396 Out << UnnamedMangle - 2;
1398 writeAbiTags(TD, AdditionalAbiTags);
1404 unsigned AnonStructId = NullOut ? 0 : Context.getAnonymousStructId(TD);
1411 Str += llvm::utostr(AnonStructId);
1421 llvm_unreachable(
"Can't mangle Objective-C selector names here!");
1426 if (
auto Inherited =
1427 cast<CXXConstructorDecl>(ND)->getInheritedConstructor()) {
1428 InheritedFrom = Inherited.getConstructor()->
getParent();
1429 InheritedTemplateArgs =
1430 Inherited.getConstructor()->getTemplateSpecializationArgs();
1436 mangleCXXCtorType(static_cast<CXXCtorType>(StructorType), InheritedFrom);
1444 if (InheritedTemplateArgs)
1445 mangleTemplateArgs(*InheritedTemplateArgs);
1447 writeAbiTags(ND, AdditionalAbiTags);
1455 mangleCXXDtorType(static_cast<CXXDtorType>(StructorType));
1460 writeAbiTags(ND, AdditionalAbiTags);
1464 if (ND && Arity == UnknownArity) {
1465 Arity = cast<FunctionDecl>(ND)->getNumParams();
1468 if (
const auto *MD = dyn_cast<CXXMethodDecl>(ND))
1469 if (!MD->isStatic())
1475 mangleOperatorName(Name, Arity);
1476 writeAbiTags(ND, AdditionalAbiTags);
1480 llvm_unreachable(
"Can't mangle a deduction guide name!");
1483 llvm_unreachable(
"Can't mangle a using directive name!");
1487 void CXXNameMangler::mangleRegCallName(
const IdentifierInfo *II) {
1491 Out << II->
getLength() +
sizeof(
"__regcall3__") - 1 <<
"__regcall3__" 1495 void CXXNameMangler::mangleSourceName(
const IdentifierInfo *II) {
1502 void CXXNameMangler::mangleNestedName(
const NamedDecl *ND,
1504 const AbiTagList *AdditionalAbiTags,
1512 if (
const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(ND)) {
1513 Qualifiers MethodQuals = Method->getMethodQualifiers();
1517 mangleQualifiers(MethodQuals);
1518 mangleRefQualifier(Method->getRefQualifier());
1524 mangleTemplatePrefix(TD, NoFunction);
1525 mangleTemplateArgs(*TemplateArgs);
1528 manglePrefix(DC, NoFunction);
1529 mangleUnqualifiedName(ND, AdditionalAbiTags);
1534 void CXXNameMangler::mangleNestedName(
const TemplateDecl *TD,
1536 unsigned NumTemplateArgs) {
1541 mangleTemplatePrefix(TD);
1542 mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
1547 void CXXNameMangler::mangleLocalName(
const Decl *D,
1548 const AbiTagList *AdditionalAbiTags) {
1554 assert(isa<NamedDecl>(D) || isa<BlockDecl>(D));
1556 const DeclContext *DC = getEffectiveDeclContext(RD ? RD : D);
1561 AbiTagState LocalAbiTags(AbiTags);
1564 mangleObjCMethodName(MD);
1565 else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(DC))
1566 mangleBlockForPrefix(BD);
1568 mangleFunctionEncoding(cast<FunctionDecl>(DC));
1572 LocalAbiTags.setUsedAbiTags(LocalAbiTags.getEmittedAbiTags());
1591 = dyn_cast<FunctionDecl>(Parm->getDeclContext())) {
1593 unsigned Num = Func->getNumParams() - Parm->getFunctionScopeIndex();
1595 mangleNumber(Num - 2);
1604 mangleUnqualifiedName(RD, AdditionalAbiTags);
1605 }
else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
1606 manglePrefix(getEffectiveDeclContext(BD),
true );
1607 assert(!AdditionalAbiTags &&
"Block cannot have additional abi tags");
1608 mangleUnqualifiedBlock(BD);
1610 const NamedDecl *ND = cast<NamedDecl>(D);
1611 mangleNestedName(ND, getEffectiveDeclContext(ND), AdditionalAbiTags,
1614 }
else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
1618 = dyn_cast_or_null<ParmVarDecl>(BD->getBlockManglingContextDecl())) {
1620 = dyn_cast<FunctionDecl>(Parm->getDeclContext())) {
1622 unsigned Num = Func->getNumParams() - Parm->getFunctionScopeIndex();
1624 mangleNumber(Num - 2);
1629 assert(!AdditionalAbiTags &&
"Block cannot have additional abi tags");
1630 mangleUnqualifiedBlock(BD);
1632 mangleUnqualifiedName(cast<NamedDecl>(D), AdditionalAbiTags);
1635 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(RD ? RD : D)) {
1637 if (Context.getNextDiscriminator(ND, disc)) {
1641 Out <<
"__" << disc <<
'_';
1646 void CXXNameMangler::mangleBlockForPrefix(
const BlockDecl *Block) {
1647 if (GetLocalClassDecl(Block)) {
1648 mangleLocalName(Block,
nullptr);
1651 const DeclContext *DC = getEffectiveDeclContext(Block);
1652 if (isLocalContainerContext(DC)) {
1653 mangleLocalName(Block,
nullptr);
1656 manglePrefix(getEffectiveDeclContext(Block));
1657 mangleUnqualifiedBlock(Block);
1660 void CXXNameMangler::mangleUnqualifiedBlock(
const BlockDecl *Block) {
1662 if ((isa<VarDecl>(Context) || isa<FieldDecl>(Context)) &&
1663 Context->getDeclContext()->isRecord()) {
1664 const auto *ND = cast<NamedDecl>(Context);
1666 mangleSourceNameWithAbiTags(ND);
1677 Number = Context.getBlockId(Block,
false);
1693 void CXXNameMangler::mangleTemplateParamDecl(
const NamedDecl *
Decl) {
1694 if (
auto *Ty = dyn_cast<TemplateTypeParmDecl>(Decl)) {
1695 if (Ty->isParameterPack())
1698 }
else if (
auto *Tn = dyn_cast<NonTypeTemplateParmDecl>(Decl)) {
1699 if (Tn->isExpandedParameterPack()) {
1700 for (
unsigned I = 0, N = Tn->getNumExpansionTypes(); I != N; ++I) {
1702 mangleType(Tn->getExpansionType(I));
1706 if (Tn->isParameterPack()) {
1709 T = PackExpansion->getPattern();
1714 }
else if (
auto *Tt = dyn_cast<TemplateTemplateParmDecl>(Decl)) {
1715 if (Tt->isExpandedParameterPack()) {
1716 for (
unsigned I = 0, N = Tt->getNumExpansionTemplateParameters(); I != N;
1719 for (
auto *Param : *Tt->getExpansionTemplateParameters(I))
1720 mangleTemplateParamDecl(Param);
1724 if (Tt->isParameterPack())
1727 for (
auto *Param : *Tt->getTemplateParameters())
1728 mangleTemplateParamDecl(Param);
1734 void CXXNameMangler::mangleLambda(
const CXXRecordDecl *Lambda) {
1745 if ((isa<VarDecl>(Context) || isa<FieldDecl>(Context)) &&
1746 !isa<ParmVarDecl>(Context)) {
1750 = cast<NamedDecl>(Context)->getIdentifier()) {
1751 mangleSourceName(Name);
1753 if (
isTemplate(cast<NamedDecl>(Context), TemplateArgs))
1754 mangleTemplateArgs(*TemplateArgs);
1761 mangleLambdaSig(Lambda);
1770 assert(Number > 0 &&
"Lambda should be mangled as an unnamed class");
1772 mangleNumber(Number - 2);
1776 void CXXNameMangler::mangleLambdaSig(
const CXXRecordDecl *Lambda) {
1778 mangleTemplateParamDecl(D);
1780 getAs<FunctionProtoType>();
1781 mangleBareFunctionType(Proto,
false,
1786 switch (qualifier->
getKind()) {
1792 llvm_unreachable(
"Can't mangle __super specifier");
1817 llvm_unreachable(
"unexpected nested name specifier");
1820 void CXXNameMangler::manglePrefix(
const DeclContext *DC,
bool NoFunction) {
1832 if (NoFunction && isLocalContainerContext(DC))
1835 assert(!isLocalContainerContext(DC));
1837 const NamedDecl *ND = cast<NamedDecl>(DC);
1838 if (mangleSubstitution(ND))
1844 mangleTemplatePrefix(TD);
1845 mangleTemplateArgs(*TemplateArgs);
1847 manglePrefix(getEffectiveDeclContext(ND), NoFunction);
1848 mangleUnqualifiedName(ND,
nullptr);
1851 addSubstitution(ND);
1854 void CXXNameMangler::mangleTemplatePrefix(
TemplateName Template) {
1859 return mangleTemplatePrefix(TD);
1862 manglePrefix(Qualified->getQualifier());
1866 mangleUnqualifiedName(
nullptr, (*Overloaded->begin())->getDeclName(),
1867 UnknownArity,
nullptr);
1872 assert(Dependent &&
"Unknown template name kind?");
1874 manglePrefix(Qualifier);
1875 mangleUnscopedTemplateName(Template,
nullptr);
1878 void CXXNameMangler::mangleTemplatePrefix(
const TemplateDecl *ND,
1886 if (mangleSubstitution(ND))
1890 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND)) {
1891 mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
1893 manglePrefix(getEffectiveDeclContext(ND), NoFunction);
1894 if (isa<BuiltinTemplateDecl>(ND) || isa<ConceptDecl>(ND))
1895 mangleUnqualifiedName(ND,
nullptr);
1900 addSubstitution(ND);
1909 if (mangleSubstitution(TN))
1924 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(TD))
1925 mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
1932 llvm_unreachable(
"can't mangle an overloaded template name as a <type>");
1961 Out <<
"_SUBSTPACK_";
1966 addSubstitution(TN);
1969 bool CXXNameMangler::mangleUnresolvedTypeOrSimpleId(
QualType Ty,
1975 case Type::Adjusted:
1978 case Type::BlockPointer:
1979 case Type::LValueReference:
1980 case Type::RValueReference:
1981 case Type::MemberPointer:
1982 case Type::ConstantArray:
1983 case Type::IncompleteArray:
1984 case Type::VariableArray:
1985 case Type::DependentSizedArray:
1986 case Type::DependentAddressSpace:
1987 case Type::DependentVector:
1988 case Type::DependentSizedExtVector:
1990 case Type::ExtVector:
1991 case Type::FunctionProto:
1992 case Type::FunctionNoProto:
1994 case Type::Attributed:
1996 case Type::DeducedTemplateSpecialization:
1997 case Type::PackExpansion:
1998 case Type::ObjCObject:
1999 case Type::ObjCInterface:
2000 case Type::ObjCObjectPointer:
2001 case Type::ObjCTypeParam:
2004 case Type::MacroQualified:
2005 llvm_unreachable(
"type is illegal as a nested name specifier");
2007 case Type::SubstTemplateTypeParmPack:
2012 Out <<
"_SUBSTPACK_";
2019 case Type::TypeOfExpr:
2021 case Type::Decltype:
2022 case Type::TemplateTypeParm:
2023 case Type::UnaryTransform:
2024 case Type::SubstTemplateTypeParm:
2038 mangleSourceNameWithAbiTags(cast<TypedefType>(Ty)->getDecl());
2041 case Type::UnresolvedUsing:
2042 mangleSourceNameWithAbiTags(
2043 cast<UnresolvedUsingType>(Ty)->getDecl());
2048 mangleSourceNameWithAbiTags(cast<TagType>(Ty)->getDecl());
2051 case Type::TemplateSpecialization: {
2053 cast<TemplateSpecializationType>(Ty);
2055 switch (TN.getKind()) {
2062 assert(TD &&
"no template for template specialization type");
2063 if (isa<TemplateTemplateParmDecl>(TD))
2064 goto unresolvedType;
2066 mangleSourceNameWithAbiTags(TD);
2073 llvm_unreachable(
"invalid base for a template specialization type");
2087 Out <<
"_SUBSTPACK_";
2096 case Type::InjectedClassName:
2097 mangleSourceNameWithAbiTags(
2098 cast<InjectedClassNameType>(Ty)->getDecl());
2101 case Type::DependentName:
2102 mangleSourceName(cast<DependentNameType>(Ty)->
getIdentifier());
2105 case Type::DependentTemplateSpecialization: {
2107 cast<DependentTemplateSpecializationType>(Ty);
2113 case Type::Elaborated:
2114 return mangleUnresolvedTypeOrSimpleId(
2115 cast<ElaboratedType>(Ty)->getNamedType(), Prefix);
2121 void CXXNameMangler::mangleOperatorName(
DeclarationName Name,
unsigned Arity) {
2131 llvm_unreachable(
"Not an operator name");
2154 case OO_New: Out <<
"nw";
break;
2156 case OO_Array_New: Out <<
"na";
break;
2158 case OO_Delete: Out <<
"dl";
break;
2160 case OO_Array_Delete: Out <<
"da";
break;
2164 Out << (Arity == 1?
"ps" :
"pl");
break;
2168 Out << (Arity == 1?
"ng" :
"mi");
break;
2172 Out << (Arity == 1?
"ad" :
"an");
break;
2177 Out << (Arity == 1?
"de" :
"ml");
break;
2179 case OO_Tilde: Out <<
"co";
break;
2181 case OO_Slash: Out <<
"dv";
break;
2183 case OO_Percent: Out <<
"rm";
break;
2185 case OO_Pipe: Out <<
"or";
break;
2187 case OO_Caret: Out <<
"eo";
break;
2189 case OO_Equal: Out <<
"aS";
break;
2191 case OO_PlusEqual: Out <<
"pL";
break;
2193 case OO_MinusEqual: Out <<
"mI";
break;
2195 case OO_StarEqual: Out <<
"mL";
break;
2197 case OO_SlashEqual: Out <<
"dV";
break;
2199 case OO_PercentEqual: Out <<
"rM";
break;
2201 case OO_AmpEqual: Out <<
"aN";
break;
2203 case OO_PipeEqual: Out <<
"oR";
break;
2205 case OO_CaretEqual: Out <<
"eO";
break;
2207 case OO_LessLess: Out <<
"ls";
break;
2209 case OO_GreaterGreater: Out <<
"rs";
break;
2211 case OO_LessLessEqual: Out <<
"lS";
break;
2213 case OO_GreaterGreaterEqual: Out <<
"rS";
break;
2215 case OO_EqualEqual: Out <<
"eq";
break;
2217 case OO_ExclaimEqual: Out <<
"ne";
break;
2219 case OO_Less: Out <<
"lt";
break;
2221 case OO_Greater: Out <<
"gt";
break;
2223 case OO_LessEqual: Out <<
"le";
break;
2225 case OO_GreaterEqual: Out <<
"ge";
break;
2227 case OO_Exclaim: Out <<
"nt";
break;
2229 case OO_AmpAmp: Out <<
"aa";
break;
2231 case OO_PipePipe: Out <<
"oo";
break;
2233 case OO_PlusPlus: Out <<
"pp";
break;
2235 case OO_MinusMinus: Out <<
"mm";
break;
2237 case OO_Comma: Out <<
"cm";
break;
2239 case OO_ArrowStar: Out <<
"pm";
break;
2241 case OO_Arrow: Out <<
"pt";
break;
2243 case OO_Call: Out <<
"cl";
break;
2245 case OO_Subscript: Out <<
"ix";
break;
2250 case OO_Conditional: Out <<
"qu";
break;
2253 case OO_Coawait: Out <<
"aw";
break;
2256 case OO_Spaceship: Out <<
"ss";
break;
2260 llvm_unreachable(
"Not an overloaded operator");
2286 if (Context.getASTContext().addressSpaceMapManglingFor(AS)) {
2288 unsigned TargetAS = Context.getASTContext().getTargetAddressSpace(AS);
2290 ASString =
"AS" + llvm::utostr(TargetAS);
2293 default: llvm_unreachable(
"Not a language specific address space");
2307 ASString =
"ptr32_sptr";
2310 ASString =
"ptr32_uptr";
2317 if (!ASString.empty())
2318 mangleVendorQualifier(ASString);
2331 mangleVendorQualifier(
"__weak");
2335 mangleVendorQualifier(
"__unaligned");
2347 mangleVendorQualifier(
"__strong");
2351 mangleVendorQualifier(
"__autoreleasing");
2374 void CXXNameMangler::mangleVendorQualifier(StringRef name) {
2375 Out <<
'U' << name.size() <<
name;
2381 switch (RefQualifier) {
2395 void CXXNameMangler::mangleObjCMethodName(
const ObjCMethodDecl *MD) {
2396 Context.mangleObjCMethodName(MD, Out);
2417 void CXXNameMangler::mangleType(
QualType T) {
2458 = dyn_cast<TemplateSpecializationType>(T))
2459 if (!TST->isTypeAlias())
2472 const Type *ty = split.
Ty;
2474 bool isSubstitutable =
2476 if (isSubstitutable && mangleSubstitution(T))
2481 if (quals && isa<ArrayType>(T)) {
2482 ty = Context.getASTContext().getAsArrayType(T);
2491 dyn_cast<DependentAddressSpaceType>(ty)) {
2493 mangleQualifiers(splitDAST.
Quals, DAST);
2496 mangleQualifiers(quals);
2504 #define ABSTRACT_TYPE(CLASS, PARENT) 2505 #define NON_CANONICAL_TYPE(CLASS, PARENT) \ 2507 llvm_unreachable("can't mangle non-canonical type " #CLASS "Type"); \ 2509 #define TYPE(CLASS, PARENT) \ 2511 mangleType(static_cast<const CLASS##Type*>(ty)); \ 2513 #include "clang/AST/TypeNodes.inc" 2518 if (isSubstitutable)
2522 void CXXNameMangler::mangleNameOrStandardSubstitution(
const NamedDecl *ND) {
2523 if (!mangleStandardSubstitution(ND))
2527 void CXXNameMangler::mangleType(
const BuiltinType *T) {
2558 std::string type_name;
2560 case BuiltinType::Void:
2563 case BuiltinType::Bool:
2566 case BuiltinType::Char_U:
2567 case BuiltinType::Char_S:
2570 case BuiltinType::UChar:
2573 case BuiltinType::UShort:
2576 case BuiltinType::UInt:
2579 case BuiltinType::ULong:
2582 case BuiltinType::ULongLong:
2585 case BuiltinType::UInt128:
2588 case BuiltinType::SChar:
2591 case BuiltinType::WChar_S:
2592 case BuiltinType::WChar_U:
2595 case BuiltinType::Char8:
2598 case BuiltinType::Char16:
2601 case BuiltinType::Char32:
2604 case BuiltinType::Short:
2607 case BuiltinType::Int:
2610 case BuiltinType::Long:
2613 case BuiltinType::LongLong:
2616 case BuiltinType::Int128:
2619 case BuiltinType::Float16:
2622 case BuiltinType::ShortAccum:
2623 case BuiltinType::Accum:
2624 case BuiltinType::LongAccum:
2625 case BuiltinType::UShortAccum:
2626 case BuiltinType::UAccum:
2627 case BuiltinType::ULongAccum:
2628 case BuiltinType::ShortFract:
2629 case BuiltinType::Fract:
2630 case BuiltinType::LongFract:
2631 case BuiltinType::UShortFract:
2632 case BuiltinType::UFract:
2633 case BuiltinType::ULongFract:
2634 case BuiltinType::SatShortAccum:
2635 case BuiltinType::SatAccum:
2636 case BuiltinType::SatLongAccum:
2637 case BuiltinType::SatUShortAccum:
2638 case BuiltinType::SatUAccum:
2639 case BuiltinType::SatULongAccum:
2640 case BuiltinType::SatShortFract:
2641 case BuiltinType::SatFract:
2642 case BuiltinType::SatLongFract:
2643 case BuiltinType::SatUShortFract:
2644 case BuiltinType::SatUFract:
2645 case BuiltinType::SatULongFract:
2646 llvm_unreachable(
"Fixed point types are disabled for c++");
2647 case BuiltinType::Half:
2650 case BuiltinType::Float:
2653 case BuiltinType::Double:
2656 case BuiltinType::LongDouble: {
2657 const TargetInfo *TI = getASTContext().getLangOpts().OpenMP &&
2658 getASTContext().getLangOpts().OpenMPIsDevice
2659 ? getASTContext().getAuxTargetInfo()
2660 : &getASTContext().getTargetInfo();
2664 case BuiltinType::Float128: {
2665 const TargetInfo *TI = getASTContext().getLangOpts().OpenMP &&
2666 getASTContext().getLangOpts().OpenMPIsDevice
2667 ? getASTContext().getAuxTargetInfo()
2668 : &getASTContext().getTargetInfo();
2672 case BuiltinType::NullPtr:
2676 #define BUILTIN_TYPE(Id, SingletonId) 2677 #define PLACEHOLDER_TYPE(Id, SingletonId) \ 2678 case BuiltinType::Id: 2679 #include "clang/AST/BuiltinTypes.def" 2680 case BuiltinType::Dependent:
2682 llvm_unreachable(
"mangling a placeholder type");
2684 case BuiltinType::ObjCId:
2685 Out <<
"11objc_object";
2687 case BuiltinType::ObjCClass:
2688 Out <<
"10objc_class";
2690 case BuiltinType::ObjCSel:
2691 Out <<
"13objc_selector";
2693 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 2694 case BuiltinType::Id: \ 2695 type_name = "ocl_" #ImgType "_" #Suffix; \ 2696 Out << type_name.size() << type_name; \ 2698 #include "clang/Basic/OpenCLImageTypes.def" 2699 case BuiltinType::OCLSampler:
2700 Out <<
"11ocl_sampler";
2702 case BuiltinType::OCLEvent:
2703 Out <<
"9ocl_event";
2705 case BuiltinType::OCLClkEvent:
2706 Out <<
"12ocl_clkevent";
2708 case BuiltinType::OCLQueue:
2709 Out <<
"9ocl_queue";
2711 case BuiltinType::OCLReserveID:
2712 Out <<
"13ocl_reserveid";
2714 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 2715 case BuiltinType::Id: \ 2716 type_name = "ocl_" #ExtType; \ 2717 Out << type_name.size() << type_name; \ 2719 #include "clang/Basic/OpenCLExtensionTypes.def" 2723 #define SVE_TYPE(Name, Id, SingletonId) \ 2724 case BuiltinType::Id: \ 2726 Out << 'u' << type_name.size() << type_name; \ 2728 #include "clang/Basic/AArch64SVEACLETypes.def" 2732 StringRef CXXNameMangler::getCallingConvQualifierName(
CallingConv CC) {
2770 llvm_unreachable(
"bad calling convention");
2773 void CXXNameMangler::mangleExtFunctionInfo(
const FunctionType *T) {
2782 StringRef CCQualifier = getCallingConvQualifierName(T->
getExtInfo().
getCC());
2783 if (!CCQualifier.empty())
2784 mangleVendorQualifier(CCQualifier);
2791 CXXNameMangler::mangleExtParameterInfo(FunctionProtoType::ExtParameterInfo PI) {
2797 switch (PI.getABI()) {
2809 if (PI.isConsumed())
2810 mangleVendorQualifier(
"ns_consumed");
2812 if (PI.isNoEscape())
2813 mangleVendorQualifier(
"noescape");
2820 mangleExtFunctionInfo(T);
2837 mangleType(ExceptTy);
2848 mangleBareFunctionType(T,
true);
2862 FunctionTypeDepthState saved = FunctionTypeDepth.push();
2864 FunctionTypeDepth.enterResultType();
2866 FunctionTypeDepth.leaveResultType();
2868 FunctionTypeDepth.pop(saved);
2873 bool MangleReturnType,
2877 FunctionTypeDepthState saved = FunctionTypeDepth.push();
2880 if (MangleReturnType) {
2881 FunctionTypeDepth.enterResultType();
2885 mangleVendorQualifier(
"ns_returns_retained");
2890 auto SplitReturnTy = ReturnTy.
split();
2892 ReturnTy = getASTContext().getQualifiedType(SplitReturnTy);
2894 mangleType(ReturnTy);
2896 FunctionTypeDepth.leaveResultType();
2903 FunctionTypeDepth.pop(saved);
2908 for (
unsigned I = 0, E = Proto->
getNumParams(); I != E; ++I) {
2916 mangleType(Context.getASTContext().getSignatureParameterType(ParamTy));
2921 assert(
Attr->getType() <= 9 &&
Attr->getType() >= 0);
2922 if (
Attr->isDynamic())
2923 Out <<
"U25pass_dynamic_object_size" <<
Attr->getType();
2925 Out <<
"U17pass_object_size" <<
Attr->getType();
2930 FunctionTypeDepth.pop(saved);
2945 void CXXNameMangler::mangleType(
const EnumType *T) {
2946 mangleType(static_cast<const TagType*>(T));
2948 void CXXNameMangler::mangleType(
const RecordType *T) {
2949 mangleType(static_cast<const TagType*>(T));
2951 void CXXNameMangler::mangleType(
const TagType *T) {
2959 Out <<
'A' << T->
getSize() <<
'_';
3008 mangleType(PointeeType);
3022 Out <<
"_SUBSTPACK_";
3026 void CXXNameMangler::mangleType(
const PointerType *T) {
3048 void CXXNameMangler::mangleType(
const ComplexType *T) {
3056 void CXXNameMangler::mangleNeonVectorType(
const VectorType *T) {
3058 assert(EltType->
isBuiltinType() &&
"Neon vector element not a BuiltinType");
3059 const char *EltName =
nullptr;
3061 switch (cast<BuiltinType>(EltType)->getKind()) {
3062 case BuiltinType::SChar:
3063 case BuiltinType::UChar:
3064 EltName =
"poly8_t";
3066 case BuiltinType::Short:
3067 case BuiltinType::UShort:
3068 EltName =
"poly16_t";
3070 case BuiltinType::ULongLong:
3071 EltName =
"poly64_t";
3073 default: llvm_unreachable(
"unexpected Neon polynomial vector element type");
3076 switch (cast<BuiltinType>(EltType)->
getKind()) {
3077 case BuiltinType::SChar: EltName =
"int8_t";
break;
3078 case BuiltinType::UChar: EltName =
"uint8_t";
break;
3079 case BuiltinType::Short: EltName =
"int16_t";
break;
3080 case BuiltinType::UShort: EltName =
"uint16_t";
break;
3081 case BuiltinType::Int: EltName =
"int32_t";
break;
3082 case BuiltinType::UInt: EltName =
"uint32_t";
break;
3083 case BuiltinType::LongLong: EltName =
"int64_t";
break;
3084 case BuiltinType::ULongLong: EltName =
"uint64_t";
break;
3085 case BuiltinType::Double: EltName =
"float64_t";
break;
3086 case BuiltinType::Float: EltName =
"float32_t";
break;
3087 case BuiltinType::Half: EltName =
"float16_t";
break;
3089 llvm_unreachable(
"unexpected Neon vector element type");
3092 const char *BaseName =
nullptr;
3094 getASTContext().getTypeSize(EltType));
3096 BaseName =
"__simd64_";
3098 assert(BitSize == 128 &&
"Neon vector type not 64 or 128 bits");
3099 BaseName =
"__simd128_";
3101 Out << strlen(BaseName) + strlen(EltName);
3102 Out << BaseName << EltName;
3109 "cannot mangle this dependent neon vector type yet");
3115 case BuiltinType::SChar:
3117 case BuiltinType::Short:
3119 case BuiltinType::Int:
3121 case BuiltinType::Long:
3122 case BuiltinType::LongLong:
3124 case BuiltinType::UChar:
3126 case BuiltinType::UShort:
3128 case BuiltinType::UInt:
3130 case BuiltinType::ULong:
3131 case BuiltinType::ULongLong:
3133 case BuiltinType::Half:
3135 case BuiltinType::Float:
3137 case BuiltinType::Double:
3140 llvm_unreachable(
"Unexpected vector element base type");
3147 void CXXNameMangler::mangleAArch64NeonVectorType(
const VectorType *T) {
3149 assert(EltType->
isBuiltinType() &&
"Neon vector element not a BuiltinType");
3154 assert((BitSize == 64 || BitSize == 128) &&
3155 "Neon vector type not 64 or 128 bits");
3159 switch (cast<BuiltinType>(EltType)->getKind()) {
3160 case BuiltinType::UChar:
3163 case BuiltinType::UShort:
3166 case BuiltinType::ULong:
3167 case BuiltinType::ULongLong:
3171 llvm_unreachable(
"unexpected Neon polynomial vector element type");
3176 std::string TypeName =
3177 (
"__" + EltName +
"x" + Twine(T->
getNumElements()) +
"_t").str();
3178 Out << TypeName.length() << TypeName;
3184 "cannot mangle this dependent neon vector type yet");
3196 void CXXNameMangler::mangleType(
const VectorType *T) {
3199 llvm::Triple
Target = getASTContext().getTargetInfo().getTriple();
3200 llvm::Triple::ArchType Arch =
3201 getASTContext().getTargetInfo().getTriple().getArch();
3202 if ((Arch == llvm::Triple::aarch64 ||
3203 Arch == llvm::Triple::aarch64_be) && !Target.isOSDarwin())
3204 mangleAArch64NeonVectorType(T);
3206 mangleNeonVectorType(T);
3221 llvm::Triple
Target = getASTContext().getTargetInfo().getTriple();
3222 llvm::Triple::ArchType Arch =
3223 getASTContext().getTargetInfo().getTriple().getArch();
3224 if ((Arch == llvm::Triple::aarch64 || Arch == llvm::Triple::aarch64_be) &&
3225 !Target.isOSDarwin())
3226 mangleAArch64NeonVectorType(T);
3228 mangleNeonVectorType(T);
3244 mangleType(static_cast<const VectorType*>(T));
3255 mangleQualifiers(split.
Quals, T);
3272 Out <<
"U8__kindof";
3277 llvm::raw_svector_ostream QualOS(QualStr);
3278 QualOS <<
"objcproto";
3279 for (
const auto *I : T->
quals()) {
3280 StringRef name = I->getName();
3281 QualOS << name.size() <<
name;
3283 Out <<
'U' << QualStr.size() << QualStr;
3292 mangleType(typeArg);
3298 Out <<
"U13block_pointer";
3313 if (mangleSubstitution(
QualType(T, 0)))
3366 getASTContext().getDependentTemplateName(T->
getQualifier(),
3368 mangleTemplatePrefix(Prefix);
3377 void CXXNameMangler::mangleType(
const TypeOfType *T) {
3389 void CXXNameMangler::mangleType(
const DecltypeType *T) {
3400 if (isa<DeclRefExpr>(E) ||
3401 isa<MemberExpr>(E) ||
3402 isa<UnresolvedLookupExpr>(E) ||
3403 isa<DependentScopeDeclRefExpr>(E) ||
3404 isa<CXXDependentScopeMemberExpr>(E) ||
3405 isa<UnresolvedMemberExpr>(E))
3409 mangleExpression(E);
3429 void CXXNameMangler::mangleType(
const AutoType *T) {
3431 "Deduced AutoType shouldn't be handled here!");
3433 "shouldn't need to mangle __auto_type!");
3449 void CXXNameMangler::mangleType(
const AtomicType *T) {
3456 void CXXNameMangler::mangleType(
const PipeType *T) {
3463 void CXXNameMangler::mangleIntegerLiteral(
QualType T,
3471 Out << (Value.getBoolValue() ?
'1' :
'0');
3473 mangleNumber(Value);
3479 void CXXNameMangler::mangleMemberExprBase(
const Expr *
Base,
bool IsArrow) {
3482 if (!RT->getDecl()->isAnonymousStructOrUnion())
3487 Base = ME->getBase();
3488 IsArrow = ME->isArrow();
3497 Out << (IsArrow ?
"pt" :
"dt");
3498 mangleExpression(Base);
3503 void CXXNameMangler::mangleMemberExpr(
const Expr *base,
3509 unsigned NumTemplateArgs,
3514 mangleMemberExprBase(base, isArrow);
3515 mangleUnresolvedName(qualifier, member, TemplateArgs, NumTemplateArgs, arity);
3528 if (callee == fn)
return false;
3532 if (!lookup)
return false;
3549 void CXXNameMangler::mangleCastExpression(
const Expr *E, StringRef CastEncoding) {
3551 Out << CastEncoding;
3556 void CXXNameMangler::mangleInitListElements(
const InitListExpr *InitList) {
3558 InitList = Syntactic;
3559 for (
unsigned i = 0, e = InitList->
getNumInits(); i != e; ++i)
3560 mangleExpression(InitList->
getInit(i));
3563 void CXXNameMangler::mangleDeclRefExpr(
const NamedDecl *D) {
3573 mangleFunctionParam(cast<ParmVarDecl>(D));
3576 case Decl::EnumConstant: {
3582 case Decl::NonTypeTemplateParm:
3589 void CXXNameMangler::mangleExpression(
const Expr *E,
unsigned Arity) {
3613 QualType ImplicitlyConvertedToType;
3618 #define ABSTRACT_STMT(Type) 3619 #define EXPR(Type, Base) 3620 #define STMT(Type, Base) \ 3621 case Expr::Type##Class: 3622 #include "clang/AST/StmtNodes.inc" 3627 case Expr::AddrLabelExprClass:
3628 case Expr::DesignatedInitUpdateExprClass:
3629 case Expr::ImplicitValueInitExprClass:
3630 case Expr::ArrayInitLoopExprClass:
3631 case Expr::ArrayInitIndexExprClass:
3632 case Expr::NoInitExprClass:
3633 case Expr::ParenListExprClass:
3634 case Expr::LambdaExprClass:
3635 case Expr::MSPropertyRefExprClass:
3636 case Expr::MSPropertySubscriptExprClass:
3637 case Expr::TypoExprClass:
3638 case Expr::OMPArraySectionExprClass:
3639 case Expr::CXXInheritedCtorInitExprClass:
3640 llvm_unreachable(
"unexpected statement kind");
3642 case Expr::ConstantExprClass:
3643 E = cast<ConstantExpr>(E)->getSubExpr();
3647 case Expr::BlockExprClass:
3648 case Expr::ChooseExprClass:
3649 case Expr::CompoundLiteralExprClass:
3650 case Expr::ExtVectorElementExprClass:
3651 case Expr::GenericSelectionExprClass:
3652 case Expr::ObjCEncodeExprClass:
3653 case Expr::ObjCIsaExprClass:
3654 case Expr::ObjCIvarRefExprClass:
3655 case Expr::ObjCMessageExprClass:
3656 case Expr::ObjCPropertyRefExprClass:
3657 case Expr::ObjCProtocolExprClass:
3658 case Expr::ObjCSelectorExprClass:
3659 case Expr::ObjCStringLiteralClass:
3660 case Expr::ObjCBoxedExprClass:
3661 case Expr::ObjCArrayLiteralClass:
3662 case Expr::ObjCDictionaryLiteralClass:
3663 case Expr::ObjCSubscriptRefExprClass:
3664 case Expr::ObjCIndirectCopyRestoreExprClass:
3665 case Expr::ObjCAvailabilityCheckExprClass:
3666 case Expr::OffsetOfExprClass:
3667 case Expr::PredefinedExprClass:
3668 case Expr::ShuffleVectorExprClass:
3669 case Expr::ConvertVectorExprClass:
3670 case Expr::StmtExprClass:
3671 case Expr::TypeTraitExprClass:
3672 case Expr::RequiresExprClass:
3673 case Expr::ArrayTypeTraitExprClass:
3674 case Expr::ExpressionTraitExprClass:
3675 case Expr::VAArgExprClass:
3676 case Expr::CUDAKernelCallExprClass:
3677 case Expr::AsTypeExprClass:
3678 case Expr::PseudoObjectExprClass:
3679 case Expr::AtomicExprClass:
3680 case Expr::SourceLocExprClass:
3681 case Expr::FixedPointLiteralClass:
3682 case Expr::BuiltinBitCastExprClass:
3688 "cannot yet mangle expression type %0");
3695 case Expr::CXXUuidofExprClass: {
3699 Out <<
"u8__uuidoft";
3703 Out <<
"u8__uuidofz";
3704 mangleExpression(UuidExp, Arity);
3710 case Expr::BinaryConditionalOperatorClass: {
3714 "?: operator with omitted middle operand cannot be mangled");
3721 case Expr::OpaqueValueExprClass:
3722 llvm_unreachable(
"cannot mangle opaque value; mangling wrong thing?");
3724 case Expr::InitListExprClass: {
3726 mangleInitListElements(cast<InitListExpr>(E));
3731 case Expr::DesignatedInitExprClass: {
3732 auto *DIE = cast<DesignatedInitExpr>(E);
3733 for (
const auto &
Designator : DIE->designators()) {
3739 mangleExpression(DIE->getArrayIndex(
Designator));
3742 "unknown designator kind");
3744 mangleExpression(DIE->getArrayRangeStart(
Designator));
3745 mangleExpression(DIE->getArrayRangeEnd(
Designator));
3748 mangleExpression(DIE->getInit());
3752 case Expr::CXXDefaultArgExprClass:
3753 mangleExpression(cast<CXXDefaultArgExpr>(E)->getExpr(), Arity);
3756 case Expr::CXXDefaultInitExprClass:
3757 mangleExpression(cast<CXXDefaultInitExpr>(E)->getExpr(), Arity);
3760 case Expr::CXXStdInitializerListExprClass:
3761 mangleExpression(cast<CXXStdInitializerListExpr>(E)->getSubExpr(), Arity);
3764 case Expr::SubstNonTypeTemplateParmExprClass:
3765 mangleExpression(cast<SubstNonTypeTemplateParmExpr>(E)->getReplacement(),
3769 case Expr::UserDefinedLiteralClass:
3772 case Expr::CXXMemberCallExprClass:
3773 case Expr::CallExprClass: {
3774 const CallExpr *CE = cast<CallExpr>(E);
3793 if (isa<PackExpansionExpr>(Arg))
3794 CallArity = UnknownArity;
3796 mangleExpression(CE->
getCallee(), CallArity);
3798 mangleExpression(Arg);
3803 case Expr::CXXNewExprClass: {
3806 Out << (New->
isArray() ?
"na" :
"nw");
3809 mangleExpression(*I);
3823 mangleExpression(*I);
3824 }
else if (
const ParenListExpr *PLE = dyn_cast<ParenListExpr>(Init)) {
3825 for (
unsigned i = 0, e = PLE->getNumExprs(); i != e; ++i)
3826 mangleExpression(PLE->getExpr(i));
3828 isa<InitListExpr>(Init)) {
3830 mangleInitListElements(cast<InitListExpr>(Init));
3832 mangleExpression(Init);
3838 case Expr::CXXPseudoDestructorExprClass: {
3839 const auto *PDE = cast<CXXPseudoDestructorExpr>(E);
3840 if (
const Expr *Base = PDE->getBase())
3841 mangleMemberExprBase(Base, PDE->isArrow());
3845 mangleUnresolvedPrefix(Qualifier,
3847 mangleUnresolvedTypeOrSimpleId(ScopeInfo->getType());
3851 if (!mangleUnresolvedTypeOrSimpleId(ScopeInfo->getType()))
3854 }
else if (Qualifier) {
3855 mangleUnresolvedPrefix(Qualifier);
3859 QualType DestroyedType = PDE->getDestroyedType();
3860 mangleUnresolvedTypeOrSimpleId(DestroyedType);
3864 case Expr::MemberExprClass: {
3874 case Expr::UnresolvedMemberExprClass: {
3884 case Expr::CXXDependentScopeMemberExprClass: {
3886 = cast<CXXDependentScopeMemberExpr>(E);
3896 case Expr::UnresolvedLookupExprClass: {
3904 case Expr::CXXUnresolvedConstructExprClass: {
3909 assert(N == 1 &&
"unexpected form for list initialization");
3910 auto *IL = cast<InitListExpr>(CE->
getArg(0));
3913 mangleInitListElements(IL);
3920 if (N != 1) Out <<
'_';
3921 for (
unsigned I = 0; I != N; ++I) mangleExpression(CE->
getArg(I));
3922 if (N != 1) Out <<
'E';
3926 case Expr::CXXConstructExprClass: {
3927 const auto *CE = cast<CXXConstructExpr>(E);
3928 if (!CE->isListInitialization() || CE->isStdInitListInitialization()) {
3930 CE->getNumArgs() >= 1 &&
3931 (CE->getNumArgs() == 1 || isa<CXXDefaultArgExpr>(CE->getArg(1))) &&
3932 "implicit CXXConstructExpr must have one argument");
3933 return mangleExpression(cast<CXXConstructExpr>(E)->getArg(0));
3936 for (
auto *E : CE->arguments())
3937 mangleExpression(E);
3942 case Expr::CXXTemporaryObjectExprClass: {
3943 const auto *CE = cast<CXXTemporaryObjectExpr>(E);
3944 unsigned N = CE->getNumArgs();
3945 bool List = CE->isListInitialization();
3951 mangleType(CE->getType());
3952 if (!List && N != 1)
3954 if (CE->isStdInitListInitialization()) {
3959 cast<CXXStdInitializerListExpr>(CE->getArg(0)->IgnoreImplicit());
3960 auto *ILE = cast<InitListExpr>(SILE->getSubExpr()->IgnoreImplicit());
3961 mangleInitListElements(ILE);
3963 for (
auto *E : CE->arguments())
3964 mangleExpression(E);
3971 case Expr::CXXScalarValueInitExprClass:
3977 case Expr::CXXNoexceptExprClass:
3979 mangleExpression(cast<CXXNoexceptExpr>(E)->getOperand());
3982 case Expr::UnaryExprOrTypeTraitExprClass: {
3996 : ImplicitlyConvertedToType;
3998 mangleIntegerLiteral(T, V);
4013 "cannot yet mangle vec_step expression");
4021 "cannot yet mangle __builtin_omp_required_simd_align expression");
4036 case Expr::CXXThrowExprClass: {
4049 case Expr::CXXTypeidExprClass: {
4063 case Expr::CXXDeleteExprClass: {
4073 case Expr::UnaryOperatorClass: {
4081 case Expr::ArraySubscriptExprClass: {
4087 mangleExpression(AE->
getLHS());
4088 mangleExpression(AE->
getRHS());
4092 case Expr::CompoundAssignOperatorClass:
4093 case Expr::BinaryOperatorClass: {
4100 mangleExpression(BO->
getLHS());
4101 mangleExpression(BO->
getRHS());
4105 case Expr::CXXRewrittenBinaryOperatorClass: {
4108 cast<CXXRewrittenBinaryOperator>(E)->getDecomposedForm();
4111 mangleExpression(Decomposed.
LHS);
4112 mangleExpression(Decomposed.
RHS);
4116 case Expr::ConditionalOperatorClass: {
4118 mangleOperatorName(OO_Conditional, 3);
4119 mangleExpression(CO->
getCond());
4120 mangleExpression(CO->
getLHS(), Arity);
4121 mangleExpression(CO->
getRHS(), Arity);
4125 case Expr::ImplicitCastExprClass: {
4126 ImplicitlyConvertedToType = E->
getType();
4127 E = cast<ImplicitCastExpr>(E)->getSubExpr();
4131 case Expr::ObjCBridgedCastExprClass: {
4134 StringRef
Kind = cast<ObjCBridgedCastExpr>(E)->getBridgeKindName();
4135 Out <<
"v1U" << Kind.size() <<
Kind;
4140 case Expr::CStyleCastExprClass:
4141 mangleCastExpression(E,
"cv");
4144 case Expr::CXXFunctionalCastExprClass: {
4145 auto *
Sub = cast<ExplicitCastExpr>(E)->getSubExpr()->IgnoreImplicit();
4147 if (
auto *CCE = dyn_cast<CXXConstructExpr>(
Sub))
4148 if (CCE->getParenOrBraceRange().isInvalid())
4149 Sub = CCE->getArg(0)->IgnoreImplicit();
4150 if (
auto *StdInitList = dyn_cast<CXXStdInitializerListExpr>(
Sub))
4151 Sub = StdInitList->getSubExpr()->IgnoreImplicit();
4152 if (
auto *IL = dyn_cast<InitListExpr>(
Sub)) {
4155 mangleInitListElements(IL);
4158 mangleCastExpression(E,
"cv");
4163 case Expr::CXXStaticCastExprClass:
4164 mangleCastExpression(E,
"sc");
4166 case Expr::CXXDynamicCastExprClass:
4167 mangleCastExpression(E,
"dc");
4169 case Expr::CXXReinterpretCastExprClass:
4170 mangleCastExpression(E,
"rc");
4172 case Expr::CXXConstCastExprClass:
4173 mangleCastExpression(E,
"cc");
4176 case Expr::CXXOperatorCallExprClass: {
4184 for (
unsigned i = 0; i != NumArgs; ++i)
4185 mangleExpression(CE->
getArg(i));
4189 case Expr::ParenExprClass:
4190 mangleExpression(cast<ParenExpr>(E)->getSubExpr(), Arity);
4194 case Expr::ConceptSpecializationExprClass: {
4197 auto *CSE = cast<ConceptSpecializationExpr>(E);
4198 mangleTemplateName(CSE->getNamedConcept(),
4199 CSE->getTemplateArguments().data(),
4200 CSE->getTemplateArguments().size());
4205 case Expr::DeclRefExprClass:
4206 mangleDeclRefExpr(cast<DeclRefExpr>(E)->getDecl());
4209 case Expr::SubstNonTypeTemplateParmPackExprClass:
4214 Out <<
"_SUBSTPACK_";
4217 case Expr::FunctionParmPackExprClass: {
4220 Out <<
"v110_SUBSTPACK";
4225 case Expr::DependentScopeDeclRefExprClass: {
4233 case Expr::CXXBindTemporaryExprClass:
4234 mangleExpression(cast<CXXBindTemporaryExpr>(E)->getSubExpr());
4237 case Expr::ExprWithCleanupsClass:
4238 mangleExpression(cast<ExprWithCleanups>(E)->getSubExpr(), Arity);
4241 case Expr::FloatingLiteralClass: {
4250 case Expr::CharacterLiteralClass:
4253 Out << cast<CharacterLiteral>(E)->
getValue();
4258 case Expr::ObjCBoolLiteralExprClass:
4260 Out << (cast<ObjCBoolLiteralExpr>(E)->
getValue() ?
'1' :
'0');
4264 case Expr::CXXBoolLiteralExprClass:
4266 Out << (cast<CXXBoolLiteralExpr>(E)->
getValue() ?
'1' :
'0');
4270 case Expr::IntegerLiteralClass: {
4273 Value.setIsSigned(
true);
4278 case Expr::ImaginaryLiteralClass: {
4285 dyn_cast<FloatingLiteral>(IE->
getSubExpr())) {
4287 mangleFloat(llvm::APFloat(Imag->getValue().getSemantics()));
4289 mangleFloat(Imag->getValue());
4294 Value.setIsSigned(
true);
4295 mangleNumber(Value);
4301 case Expr::StringLiteralClass: {
4304 assert(isa<ConstantArrayType>(E->
getType()));
4310 case Expr::GNUNullExprClass:
4317 case Expr::CXXNullPtrLiteralExprClass: {
4322 case Expr::PackExpansionExprClass:
4324 mangleExpression(cast<PackExpansionExpr>(E)->getPattern());
4327 case Expr::SizeOfPackExprClass: {
4328 auto *SPE = cast<SizeOfPackExpr>(E);
4329 if (SPE->isPartiallySubstituted()) {
4331 for (
const auto &A : SPE->getPartialArguments())
4332 mangleTemplateArg(A);
4340 mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
4342 = dyn_cast<NonTypeTemplateParmDecl>(Pack))
4343 mangleTemplateParameter(NTTP->getDepth(), NTTP->getIndex());
4345 = dyn_cast<TemplateTemplateParmDecl>(Pack))
4346 mangleTemplateParameter(TempTP->getDepth(), TempTP->getIndex());
4348 mangleFunctionParam(cast<ParmVarDecl>(Pack));
4352 case Expr::MaterializeTemporaryExprClass: {
4353 mangleExpression(cast<MaterializeTemporaryExpr>(E)->getSubExpr());
4357 case Expr::CXXFoldExprClass: {
4358 auto *FE = cast<CXXFoldExpr>(E);
4359 if (FE->isLeftFold())
4360 Out << (FE->getInit() ?
"fL" :
"fl");
4362 Out << (FE->getInit() ?
"fR" :
"fr");
4364 if (FE->getOperator() == BO_PtrMemD)
4372 mangleExpression(FE->getLHS());
4374 mangleExpression(FE->getRHS());
4378 case Expr::CXXThisExprClass:
4382 case Expr::CoawaitExprClass:
4384 Out <<
"v18co_await";
4385 mangleExpression(cast<CoawaitExpr>(E)->getOperand());
4388 case Expr::DependentCoawaitExprClass:
4390 Out <<
"v18co_await";
4391 mangleExpression(cast<DependentCoawaitExpr>(E)->getOperand());
4394 case Expr::CoyieldExprClass:
4396 Out <<
"v18co_yield";
4397 mangleExpression(cast<CoawaitExpr>(E)->getOperand());
4430 void CXXNameMangler::mangleFunctionParam(
const ParmVarDecl *parm) {
4437 assert(parmDepth < FunctionTypeDepth.getDepth());
4438 unsigned nestingDepth = FunctionTypeDepth.getDepth() - parmDepth;
4439 if (FunctionTypeDepth.isInResultType())
4442 if (nestingDepth == 0) {
4445 Out <<
"fL" << (nestingDepth - 1) <<
'p';
4453 &&
"parameter's type is still an array type?");
4456 dyn_cast<DependentAddressSpaceType>(parm->
getType())) {
4463 if (parmIndex != 0) {
4464 Out << (parmIndex - 1);
4469 void CXXNameMangler::mangleCXXCtorType(
CXXCtorType T,
4492 llvm_unreachable(
"closure constructors don't exist for the Itanium ABI!");
4495 mangleName(InheritedFrom);
4498 void CXXNameMangler::mangleCXXDtorType(
CXXDtorType T) {
4521 unsigned NumTemplateArgs) {
4524 for (
unsigned i = 0; i != NumTemplateArgs; ++i)
4532 for (
unsigned i = 0, e = AL.
size(); i != e; ++i)
4533 mangleTemplateArg(AL[i]);
4537 void CXXNameMangler::mangleTemplateArgs(
const TemplateArgument *TemplateArgs,
4538 unsigned NumTemplateArgs) {
4541 for (
unsigned i = 0; i != NumTemplateArgs; ++i)
4542 mangleTemplateArg(TemplateArgs[i]);
4552 A = Context.getASTContext().getCanonicalTemplateArgument(A);
4556 llvm_unreachable(
"Cannot mangle NULL template argument");
4575 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
4577 if (isa<VarDecl>(D) || isa<FunctionDecl>(D)) {
4586 mangleExpression(E);
4600 if (compensateMangling) {
4602 mangleOperatorName(OO_Amp, 1);
4611 if (compensateMangling)
4627 mangleTemplateArg(
P);
4633 void CXXNameMangler::mangleTemplateParameter(
unsigned Depth,
unsigned Index) {
4644 Out <<
'L' << (Depth - 1) <<
'_';
4650 void CXXNameMangler::mangleSeqID(
unsigned SeqID) {
4653 else if (SeqID > 1) {
4661 for (; SeqID != 0; SeqID /= 36) {
4662 unsigned C = SeqID % 36;
4663 *I++ = (C < 10 ?
'0' +
C :
'A' + C - 10);
4666 Out.write(I.base(), I - BufferRef.rbegin());
4671 void CXXNameMangler::mangleExistingSubstitution(
TemplateName tname) {
4672 bool result = mangleSubstitution(tname);
4673 assert(result &&
"no existing substitution for template name");
4679 bool CXXNameMangler::mangleSubstitution(
const NamedDecl *ND) {
4681 if (mangleStandardSubstitution(ND))
4685 return mangleSubstitution(reinterpret_cast<uintptr_t>(ND));
4695 bool CXXNameMangler::mangleSubstitution(
QualType T) {
4698 return mangleSubstitution(RT->getDecl());
4703 return mangleSubstitution(TypePtr);
4706 bool CXXNameMangler::mangleSubstitution(
TemplateName Template) {
4708 return mangleSubstitution(TD);
4710 Template = Context.getASTContext().getCanonicalTemplateName(Template);
4711 return mangleSubstitution(
4715 bool CXXNameMangler::mangleSubstitution(
uintptr_t Ptr) {
4716 llvm::DenseMap<uintptr_t, unsigned>::iterator I = Substitutions.find(Ptr);
4717 if (I == Substitutions.end())
4720 unsigned SeqID = I->second;
4754 if (TemplateArgs.
size() != 1)
4757 if (!
isCharType(TemplateArgs[0].getAsType()))
4763 template <std::
size_t StrLen>
4765 const char (&Str)[StrLen]) {
4770 if (TemplateArgs.
size() != 2)
4773 if (!
isCharType(TemplateArgs[0].getAsType()))
4782 bool CXXNameMangler::mangleStandardSubstitution(
const NamedDecl *ND) {
4784 if (
const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) {
4809 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
4819 if (TemplateArgs.
size() != 3)
4822 if (!
isCharType(TemplateArgs[0].getAsType()))
4859 void CXXNameMangler::addSubstitution(
QualType T) {
4862 addSubstitution(RT->getDecl());
4868 addSubstitution(TypePtr);
4871 void CXXNameMangler::addSubstitution(
TemplateName Template) {
4873 return addSubstitution(TD);
4875 Template = Context.getASTContext().getCanonicalTemplateName(Template);
4879 void CXXNameMangler::addSubstitution(
uintptr_t Ptr) {
4880 assert(!Substitutions.count(Ptr) &&
"Substitution already exists!");
4881 Substitutions[Ptr] = SeqID++;
4884 void CXXNameMangler::extendSubstitutions(CXXNameMangler* Other) {
4885 assert(Other->SeqID >= SeqID &&
"Must be superset of substitutions!");
4886 if (Other->SeqID > SeqID) {
4887 Substitutions.swap(Other->Substitutions);
4888 SeqID = Other->SeqID;
4892 CXXNameMangler::AbiTagList
4893 CXXNameMangler::makeFunctionReturnTypeTags(
const FunctionDecl *FD) {
4895 if (DisableDerivedAbiTags)
4896 return AbiTagList();
4898 llvm::raw_null_ostream NullOutStream;
4899 CXXNameMangler TrackReturnTypeTags(*
this, NullOutStream);
4900 TrackReturnTypeTags.disableDerivedAbiTags();
4904 FunctionTypeDepthState saved = TrackReturnTypeTags.FunctionTypeDepth.push();
4905 TrackReturnTypeTags.FunctionTypeDepth.enterResultType();
4907 TrackReturnTypeTags.FunctionTypeDepth.leaveResultType();
4908 TrackReturnTypeTags.FunctionTypeDepth.pop(saved);
4910 return TrackReturnTypeTags.AbiTagsRoot.getSortedUniqueUsedAbiTags();
4913 CXXNameMangler::AbiTagList
4914 CXXNameMangler::makeVariableTypeTags(
const VarDecl *VD) {
4916 if (DisableDerivedAbiTags)
4917 return AbiTagList();
4919 llvm::raw_null_ostream NullOutStream;
4920 CXXNameMangler TrackVariableType(*
this, NullOutStream);
4921 TrackVariableType.disableDerivedAbiTags();
4923 TrackVariableType.mangleType(VD->
getType());
4925 return TrackVariableType.AbiTagsRoot.getSortedUniqueUsedAbiTags();
4928 bool CXXNameMangler::shouldHaveAbiTags(ItaniumMangleContextImpl &C,
4930 llvm::raw_null_ostream NullOutStream;
4931 CXXNameMangler TrackAbiTags(C, NullOutStream,
nullptr,
true);
4932 TrackAbiTags.mangle(VD);
4933 return TrackAbiTags.AbiTagsRoot.getUsedAbiTags().size();
4946 void ItaniumMangleContextImpl::mangleCXXName(
const NamedDecl *D,
4948 assert((isa<FunctionDecl>(D) || isa<VarDecl>(D)) &&
4949 "Invalid mangleName() call, argument is not a variable or function!");
4950 assert(!isa<CXXConstructorDecl>(D) && !isa<CXXDestructorDecl>(D) &&
4951 "Invalid mangleName() call on 'structor decl!");
4954 getASTContext().getSourceManager(),
4955 "Mangling declaration");
4957 CXXNameMangler Mangler(*
this, Out, D);
4964 CXXNameMangler Mangler(*
this, Out, D, Type);
4971 CXXNameMangler Mangler(*
this, Out, D, Type);
4977 CXXNameMangler Mangler(*
this, Out, D,
Ctor_Comdat);
4983 CXXNameMangler Mangler(*
this, Out, D,
Dtor_Comdat);
4987 void ItaniumMangleContextImpl::mangleThunk(
const CXXMethodDecl *MD,
4997 assert(!isa<CXXDestructorDecl>(MD) &&
4998 "Use mangleCXXDtor for destructor decls!");
4999 CXXNameMangler Mangler(*
this, Out);
5000 Mangler.getStream() <<
"_ZT";
5002 Mangler.getStream() <<
'c';
5013 Mangler.mangleFunctionEncoding(MD);
5016 void ItaniumMangleContextImpl::mangleCXXDtorThunk(
5021 CXXNameMangler Mangler(*
this, Out, DD, Type);
5022 Mangler.getStream() <<
"_ZT";
5025 Mangler.mangleCallOffset(ThisAdjustment.
NonVirtual,
5028 Mangler.mangleFunctionEncoding(DD);
5032 void ItaniumMangleContextImpl::mangleStaticGuardVariable(
const VarDecl *D,
5036 CXXNameMangler Mangler(*
this, Out);
5039 Mangler.getStream() <<
"_ZGV";
5040 Mangler.mangleName(D);
5043 void ItaniumMangleContextImpl::mangleDynamicInitializer(
const VarDecl *MD,
5048 Out <<
"__cxx_global_var_init";
5051 void ItaniumMangleContextImpl::mangleDynamicAtExitDestructor(
const VarDecl *D,
5054 CXXNameMangler Mangler(*
this, Out);
5055 Mangler.getStream() <<
"__dtor_";
5056 if (shouldMangleDeclName(D))
5059 Mangler.getStream() << D->
getName();
5062 void ItaniumMangleContextImpl::mangleSEHFilterExpression(
5063 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
5064 CXXNameMangler Mangler(*
this, Out);
5065 Mangler.getStream() <<
"__filt_";
5066 if (shouldMangleDeclName(EnclosingDecl))
5067 Mangler.mangle(EnclosingDecl);
5069 Mangler.getStream() << EnclosingDecl->
getName();
5072 void ItaniumMangleContextImpl::mangleSEHFinallyBlock(
5073 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
5074 CXXNameMangler Mangler(*
this, Out);
5075 Mangler.getStream() <<
"__fin_";
5076 if (shouldMangleDeclName(EnclosingDecl))
5077 Mangler.mangle(EnclosingDecl);
5079 Mangler.getStream() << EnclosingDecl->
getName();
5082 void ItaniumMangleContextImpl::mangleItaniumThreadLocalInit(
const VarDecl *D,
5085 CXXNameMangler Mangler(*
this, Out);
5086 Mangler.getStream() <<
"_ZTH";
5087 Mangler.mangleName(D);
5091 ItaniumMangleContextImpl::mangleItaniumThreadLocalWrapper(
const VarDecl *D,
5094 CXXNameMangler Mangler(*
this, Out);
5095 Mangler.getStream() <<
"_ZTW";
5096 Mangler.mangleName(D);
5099 void ItaniumMangleContextImpl::mangleReferenceTemporary(
const VarDecl *D,
5100 unsigned ManglingNumber,
5104 CXXNameMangler Mangler(*
this, Out);
5105 Mangler.getStream() <<
"_ZGR";
5106 Mangler.mangleName(D);
5107 assert(ManglingNumber > 0 &&
"Reference temporary mangling number is zero!");
5108 Mangler.mangleSeqID(ManglingNumber - 1);
5111 void ItaniumMangleContextImpl::mangleCXXVTable(
const CXXRecordDecl *RD,
5114 CXXNameMangler Mangler(*
this, Out);
5115 Mangler.getStream() <<
"_ZTV";
5116 Mangler.mangleNameOrStandardSubstitution(RD);
5119 void ItaniumMangleContextImpl::mangleCXXVTT(
const CXXRecordDecl *RD,
5122 CXXNameMangler Mangler(*
this, Out);
5123 Mangler.getStream() <<
"_ZTT";
5124 Mangler.mangleNameOrStandardSubstitution(RD);
5127 void ItaniumMangleContextImpl::mangleCXXCtorVTable(
const CXXRecordDecl *RD,
5132 CXXNameMangler Mangler(*
this, Out);
5133 Mangler.getStream() <<
"_ZTC";
5134 Mangler.mangleNameOrStandardSubstitution(RD);
5135 Mangler.getStream() <<
Offset;
5136 Mangler.getStream() <<
'_';
5137 Mangler.mangleNameOrStandardSubstitution(Type);
5140 void ItaniumMangleContextImpl::mangleCXXRTTI(
QualType Ty, raw_ostream &Out) {
5142 assert(!Ty.
hasQualifiers() &&
"RTTI info cannot have top-level qualifiers");
5143 CXXNameMangler Mangler(*
this, Out);
5144 Mangler.getStream() <<
"_ZTI";
5145 Mangler.mangleType(Ty);
5148 void ItaniumMangleContextImpl::mangleCXXRTTIName(
QualType Ty,
5151 CXXNameMangler Mangler(*
this, Out);
5152 Mangler.getStream() <<
"_ZTS";
5153 Mangler.mangleType(Ty);
5156 void ItaniumMangleContextImpl::mangleTypeName(
QualType Ty, raw_ostream &Out) {
5157 mangleCXXRTTIName(Ty, Out);
5160 void ItaniumMangleContextImpl::mangleStringLiteral(
const StringLiteral *, raw_ostream &) {
5161 llvm_unreachable(
"Can't mangle string literals");
5164 void ItaniumMangleContextImpl::mangleLambdaSig(
const CXXRecordDecl *Lambda,
5166 CXXNameMangler Mangler(*
this, Out);
5167 Mangler.mangleLambdaSig(Lambda);
5172 return new ItaniumMangleContextImpl(Context, Diags);
A call to an overloaded operator written using operator syntax.
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
Defines the clang::ASTContext interface.
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it's either not been deduced or was deduce...
const Type * Ty
The locally-unqualified type.
unsigned getNumDecls() const
Gets the number of declarations in the unresolved set.
Represents a function declaration or definition.
std::string Name
The name of this module.
The "enum" keyword introduces the elaborated-type-specifier.
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this __uuidof() expression after various required adjustments (removing...
PointerType - C99 6.7.5.1 - Pointer Declarators.
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
void * getAsVoidPointer() const
Retrieve the template name as a void pointer.
QualType getPointeeType() const
Represents the dependent type named by a dependently-scoped typename using declaration, e.g.
A (possibly-)qualified type.
OverloadedOperatorKind getOperator() const
Return the overloaded operator to which this template name refers.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
Attempt to be ABI-compatible with code generated by Clang 6.0.x (SVN r321711).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
static const TemplateArgument & getArgument(const TemplateArgument &A)
QualType getInjectedSpecializationType() const
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
const Expr * getSubExpr() const
__auto_type (GNU extension)
VarDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
The COMDAT used for ctors.
const Expr * getInit(unsigned Init) const
bool isListInitialization() const
Determine whether this expression models list-initialization.
Expr * getUnderlyingExpr() const
bool isDependent() const
Whether this template argument is dependent on a template parameter such that its result can change f...
Module * getOwningModuleForLinkage(bool IgnoreLinkage=false) const
Get the module that owns this declaration for linkage purposes.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
FunctionType - C99 6.7.5.3 - Function Declarators.
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program...
bool hasExtParameterInfos() const
Is there any interesting extra information for any of the parameters of this function type...
TemplateArgumentLoc const * getTemplateArgs() const
An instance of this object exists for each enum constant that is defined.
Defines the SourceManager interface.
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
Represents a qualified type name for which the type name is dependent.
The template argument is an expression, and we've not resolved it to one of the other forms yet...
unsigned size() const
Retrieve the number of template arguments in this template argument list.
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
bool isDecltypeAuto() const
Decl - This represents one declaration (or definition), e.g.
bool isVariadic() const
Whether this function prototype is variadic.
TagDecl * getDecl() const
static bool isStreamCharSpecialization(const ClassTemplateSpecializationDecl *SD, const char(&Str)[StrLen])
llvm::APFloat getValue() const
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
Defines the C++ template declaration subclasses.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
unsigned getBlockManglingNumber() const
The base class of the type hierarchy.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies this declaration.
int64_t NonVirtual
The non-virtual adjustment from the derived object to its nearest virtual base.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
Represent a C++ namespace.
bool isArrayRangeDesignator() const
Represents a call to a C++ constructor.
static bool isParenthesizedADLCallee(const CallExpr *call)
Look at the callee of the given call expression and determine if it's a parenthesized id-expression w...
ArrayRef< NamedDecl * > getLambdaExplicitTemplateParameters() const
Retrieve the lambda template parameters that were specified explicitly.
A container of type source information.
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
SourceLocation getAttributeLoc() const
Represents a C++ constructor within a class.
A template template parameter that has been substituted for some other template name.
Default closure variant of a ctor.
QualType getElementType() const
const Expr * getSubExpr() const
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
TemplateName getTemplateName() const
Retrieve the name of the template that we are deducing.
An identifier, stored as an IdentifierInfo*.
unsigned getDepth() const
Get the nesting depth of the template parameter.
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.
Expr * getExprOperand() const
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
const char * getStmtClassName() const
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Represents a struct/union/class.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
bool isNothrow(bool ResultIfDependent=false) const
Determine whether this function type has a non-throwing exception specification.
bool isInAnonymousNamespace() const
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Represents a class type in Objective C.
QualType getPointeeType() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Represents a dependent template name that cannot be resolved prior to template instantiation.
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
Used for GCC's __alignof.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
NameKind getNameKind() const
Determine what kind of name this is.
Represents a member of a struct/union/class.
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
const llvm::APSInt & getInitVal() const
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm()
bool isReferenceType() const
Represents the result of substituting a set of types for a template type parameter pack...
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
Expr * getArg(unsigned I)
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
The this pointer adjustment as well as an optional return adjustment for a thunk. ...
TypeSourceInfo * getLambdaTypeInfo() const
TemplateName getReplacement() const
QualType getParamTypeForDecl() const
Describes a module or submodule.
bool getProducesResult() const
Describes an C or C++ initializer list.
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
This parameter (which must have pointer type) uses the special Swift context-pointer ABI treatment...
An rvalue reference type, per C++11 [dcl.ref].
UnresolvedUsingTypenameDecl * getDecl() const
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
A qualified template name, where the qualification is kept to describe the source code as written...
An lvalue ref-qualifier was provided (&).
static ItaniumMangleContext * create(ASTContext &Context, DiagnosticsEngine &Diags)
ArrayRef< QualType > getTypeArgs() const
Retrieve the type arguments of this object type (semantically).
bool hasAddressSpace() const
An unqualified-id that has been assumed to name a function template that will be found by ADL...
The "struct" keyword introduces the elaborated-type-specifier.
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
Expr * getInitializer()
The initializer of this new-expression.
static bool isStdNamespace(const DeclContext *DC)
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
Concrete class used by the front-end to report problems and issues.
Represents a typeof (or typeof) expression (a GCC extension).
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
A builtin binary operation expression such as "x + y" or "x <= y".
LangAS getAddressSpace() const
const Type * getClass() const
bool isLambda() const
Determine whether this class describes a lambda function object.
Expr * getSizeExpr() const
const TemplateArgument * getArgs() const
Retrieve the template arguments.
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
NestedNameSpecifier * getQualifier() const
Fetches the nested-name qualifier, if one was given.
Enums/classes describing ABI related information about constructors, destructors and thunks...
bool isInstantiationDependent() const
Whether this template argument is dependent on a template parameter.
virtual const char * getLongDoubleMangling() const
Return the mangled code of long double.
void * getAsOpaquePtr() const
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
Represents a C++ member access expression where the actual member referenced could not be resolved be...
is ARM Neon polynomial vector
Expr * getSizeExpr() const
unsigned getLength() const
Efficiently return the length of this identifier info.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
bool isTypeOperand() const
Expr * getSizeExpr() const
QualType getElementType() const
arg_iterator placement_arg_end()
This parameter (which must have pointer-to-pointer type) uses the special Swift error-result ABI trea...
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
Represents an extended vector type where either the type or size is dependent.
This object can be modified without requiring retains or releases.
NamedDecl * getFirstQualifierFoundInScope() const
Retrieve the first part of the nested-name-specifier that was found in the scope of the member access...
DeclarationName getMemberName() const
Retrieve the name of the member that this expression refers to.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
Represents a K&R-style 'int foo()' function, which has no information available about its arguments...
Expr * getAddrSpaceExpr() const
bool isExternC() const
Determines whether this variable is a variable with external, C linkage.
llvm::StringRef getParameterABISpelling(ParameterABI kind)
unsigned getLambdaManglingNumber() const
If this is the closure type of a lambda expression, retrieve the number to be used for name mangling ...
ConditionalOperator - The ?: ternary operator.
QualType getBaseType() const
Gets the base type of this object type.
Represents a prototype with parameter type info, e.g.
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
A dependent template name that has not been resolved to a template (or set of templates).
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
union clang::ReturnAdjustment::VirtualAdjustment Virtual
bool hasQualifiers() const
Determine whether this type has any qualifiers.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
bool isImplicitAccess() const
True if this is an implicit access, i.e.
Exposes information about the current target.
Represents an array type in C++ whose size is a value-dependent expression.
CXXDtorType
C++ destructor types.
QualType getElementType() const
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function)...
unsigned getNumArgs() const
Retrieve the number of template arguments.
unsigned getFunctionScopeDepth() const
Represents a block literal declaration, which is like an unnamed FunctionDecl.
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
const FieldDecl * findFirstNamedDataMember() const
Finds the first data member which has a name.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
static const DeclContext * IgnoreLinkageSpecDecls(const DeclContext *DC)
QualType getPointeeType() const
TemplateDecl * getTemplateDecl() const
The template declaration to which this qualified name refers.
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
TemplateArgumentLoc const * getTemplateArgs() const
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '...
Declaration of a template type parameter.
unsigned getIndex() const
bool isImplicitAccess() const
True if this is an implicit access, i.e., one in which the member being accessed was not written in t...
const T * castAs() const
Member-template castAs<specific type>.
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
Represents a C++ destructor within a class.
New-expression has a C++11 list-initializer.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
unsigned getNumInits() const
bool isArrayDesignator() const
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
QualType getArgumentType() const
ObjCLifetime getObjCLifetime() const
unsigned getNumTemplateArgs() const
DeclContext * getDeclContext()
LanguageLinkage getLanguageLinkage() const
Compute the language linkage.
A structure for storing the information associated with a substituted template template parameter...
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode. ...
const IdentifierInfo * getIdentifier() const
Retrieve the type named by the typename specifier as an identifier.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents a C++ template name within the type system.
Represents the type decltype(expr) (C++11).
decls_iterator decls_begin() const
static SVal getValue(SVal val, SValBuilder &svalBuilder)
Defines the clang::TypeLoc interface and its subclasses.
bool isIdentifier() const
Determine whether this template name refers to an identifier.
A namespace alias, stored as a NamespaceAliasDecl*.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
static StringRef mangleAArch64VectorBase(const BuiltinType *EltType)
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char, signed char, short, int, long..], or an enum decl which has a signed representation.
bool isFunctionOrMethod() const
bool isIdentifier() const
Predicate functions for querying what type of name this is.
Qualifiers Quals
The local qualifiers.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool hasInitializer() const
Whether this new-expression has any initializer at all.
bool hasInstantiationDependentExceptionSpec() const
Return whether this function has an instantiation-dependent exception spec.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Represents a GCC generic vector type.
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this typeid() expression after various required adjustments (removing r...
An lvalue reference type, per C++11 [dcl.ref].
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
A type, stored as a Type*.
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
The COMDAT used for dtors.
static StringRef getIdentifier(const Token &Tok)
CallingConv
CallingConv - Specifies the calling convention that a function uses.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1...
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
RecordDecl * getDecl() const
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the member name.
int64_t NonVirtual
The non-virtual adjustment from the derived object to its nearest virtual base.
static bool hasMangledSubstitutionQualifiers(QualType T)
Determine whether the given type has any qualifiers that are relevant for substitutions.
A template template parameter pack that has been substituted for a template template argument pack...
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
There is no lifetime qualification on this type.
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template declarations that this template name refers to...
is AltiVec 'vector Pixel'
Assigning into this object requires the old value to be released and the new value to be retained...
QualType getCanonicalType() const
bool isBuiltinType() const
Helper methods to distinguish type categories.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
ExtParameterInfo getExtParameterInfo(unsigned I) const
bool isSpecialized() const
Determine whether this object type is "specialized", meaning that it has type arguments.
ElaboratedTypeKeyword getKeyword() const
Encodes a location in the source.
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
QualType getReturnType() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the type.
Expr * getSubExpr() const
Represents typeof(type), a GCC extension.
Interfaces are the core concept in Objective-C for object oriented design.
virtual const char * getFloat128Mangling() const
Return the mangled code of __float128.
struct clang::ReturnAdjustment::VirtualAdjustment::@135 Itanium
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
Represents the declaration of a struct/union/class/enum.
LanguageLinkage
Describes the different kinds of language linkage (C++ [dcl.link]) that an entity may have...
CallingConv getCC() const
QualType getElementType() const
Represents a vector type where either the type or size is dependent.
bool isFieldDesignator() const
Represents a static or instance method of a struct/union/class.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
No ref-qualifier was provided.
QualType getAllocatedType() const
const ParmVarDecl * getParamDecl(unsigned i) const
This file defines OpenMP nodes for declarative directives.
Qualifiers getMethodQuals() const
Expr * getNoexceptExpr() const
Return the expression inside noexcept(expression), or a null pointer if there is none (because the ex...
UnaryExprOrTypeTrait getKind() const
is AltiVec 'vector bool ...'
RefQualifierKind
The kind of C++11 ref-qualifier associated with a function type.
Decl * getBlockManglingContextDecl() const
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
AutoTypeKeyword getKeyword() const
TypeClass getTypeClass() const
Used for C's _Alignof and C++'s alignof.
int64_t VCallOffsetOffset
The offset (in bytes), relative to the address point, of the virtual call offset. ...
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
An rvalue ref-qualifier was provided (&&).
Assigning into this object requires a lifetime extension.
bool isArgumentType() const
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
CXXCtorType
C++ constructor types.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
The injected class name of a C++ class template or class template partial specialization.
A qualified reference to a name whose declaration cannot yet be resolved.
QualType getPointeeType() const
Represents a pack expansion of types.
InitializationStyle getInitializationStyle() const
The kind of initializer this new-expression has.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
StringRef getName() const
Return the actual identifier string.
Base class for declarations which introduce a typedef-name.
Represents a reference to a function parameter pack or init-capture pack that has been substituted bu...
Represents a template argument.
Represents a template name that was expressed as a qualified name.
bool isTypeOperand() const
Dataflow Directional Tag Classes.
ThisAdjustment This
The this pointer adjustment.
ExtInfo getExtInfo() const
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
NestedNameSpecifier * getQualifier() const
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
The base class of all kinds of template declarations (e.g., class, function, etc.).
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
The template argument is a pack expansion of a template name that was provided for a template templat...
const TemplateArgument * getArgs() const
Retrieve the template arguments.
Represents a field injected from an anonymous union/struct into the parent scope. ...
bool isDependentAddressSpaceType() const
NamespaceDecl * getOriginalNamespace()
Get the original (first) namespace declaration.
DeclarationName getMember() const
Retrieve the name of the member that this expression refers to.
The name of a declaration.
StmtClass getStmtClass() const
VectorKind getVectorKind() const
ArrayRef< QualType > exceptions() const
The "union" keyword introduces the elaborated-type-specifier.
bool isBooleanType() const
bool isMSVCRTEntryPoint() const
Determines whether this function is a MSVCRT user defined entry point.
The "class" keyword introduces the elaborated-type-specifier.
bool isKindOfType() const
Whether this ia a "__kindof" type (semantically).
int64_t VBaseOffsetOffset
The offset (in bytes), relative to the address point of the virtual base class offset.
A pointer to member type per C++ 8.3.3 - Pointers to members.
ExplicitCastExpr - An explicit cast written in the source code.
A type that was preceded by the 'template' keyword, stored as a Type*.
union clang::ThisAdjustment::VirtualAdjustment Virtual
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
Represents a pointer to an Objective C object.
Not an overloaded operator.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Complex values, per C99 6.2.5p11.
Location wrapper for a TemplateArgument.
unsigned getNumArgs() const
Retrieve the number of template arguments.
Iterator for iterating over Stmt * arrays that contain only T *.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const llvm::APInt & getSize() const
ExtVectorType - Extended vector type.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
ReturnAdjustment Return
The return adjustment.
The template argument is a type.
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
The template argument is actually a parameter pack.
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '...
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
arg_iterator placement_arg_begin()
CXXMethodDecl * getLambdaStaticInvoker() const
Retrieve the lambda static invoker, the address of which is returned by the conversion operator...
unsigned arg_size() const
Retrieve the number of arguments.
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
A template argument list.
VectorType::VectorKind getVectorKind() const
Reading or writing from this object requires a barrier call.
ArgKind getKind() const
Return the kind of stored template argument.
unsigned getDepth() const
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
QualType getParamType(unsigned i) const
static bool isTypeSubstitutable(Qualifiers Quals, const Type *Ty, ASTContext &Ctx)
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
TypedefNameDecl * getTypedefNameForAnonDecl() const
bool hasUnaligned() const
Defines Expressions and AST nodes for C++2a concepts.
Represents a C++ struct/union/class.
Represents a template specialization type whose template cannot be resolved, e.g. ...
The template argument is a template name that was provided for a template template parameter...
Represents a C array with an unspecified size.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
A structure for storing the information associated with an overloaded template name.
Declaration of a class template.
This class is used for builtin types like 'int'.
Decl * getLambdaContextDecl() const
Retrieve the declaration that provides additional context for a lambda, when the normal declaration c...
static bool isCharSpecialization(QualType T, const char *Name)
Returns whether a given type is a template specialization of a given name with a single argument of t...
static bool isCharType(QualType T)
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
bool isGlobalDelete() const
bool isImplicitCXXThis() const
Whether this expression is an implicit reference to 'this' in C++.
Copying closure variant of a ctor.
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
unsigned getCVRQualifiers() const
static Decl::Kind getKind(const Decl *D)
unsigned getNumElements() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
QualType getAsType() const
Retrieve the type for a type template argument.
A reference to a declared variable, function, enum, etc.
Represents an extended address space qualifier where the input address space value is dependent...
Represents a type template specialization; the template must be a class template, a type alias templa...
Designator - A designator in a C99 designated initializer.
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
IdentifierInfo * getCXXLiteralIdentifier() const
If this name is the name of a literal operator, retrieve the identifier associated with it...
A set of overloaded template declarations.
This represents a decl that may have a name.
bool isTranslationUnit() const
bool isOpenCLSpecificType() const
Represents a C array with a specified size that is not an integer-constant-expression.
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
No keyword precedes the qualified type name.
static bool isStd(const NamespaceDecl *NS)
Return whether a given namespace is the 'std' namespace.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
unsigned getNumTemplateArgs() const
QualType getElementType() const
The global specifier '::'. There is no stored value.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion, return the pattern as a template name.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
const LangOptions & getLangOpts() const
The "__interface" keyword introduces the elaborated-type-specifier.
Represents the canonical version of C arrays with a specified constant size.
InitListExpr * getSyntacticForm() const
Declaration of a template function.
A class which abstracts out some details necessary for making a call.
bool Sub(InterpState &S, CodePtr OpPC)
bool hasLinkage() const
Determine whether this declaration has linkage.
Attr - This represents one attribute.
struct clang::ThisAdjustment::VirtualAdjustment::@137 Itanium
QualType getPointeeType() const
bool isExternallyVisible() const
QualType getType() const
Return the type wrapped by this type source info.
A single template declaration.
This parameter (which must have pointer type) is a Swift indirect result parameter.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point...
const IdentifierInfo * getIdentifier() const
Expr * getSizeExpr() const
bool hasExternalFormalLinkage() const
True if this decl has external linkage.
PrettyStackTraceDecl - If a crash occurs, indicate that it happened when doing something to a specifi...
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.