31 #include "llvm/ADT/StringExtras.h"
32 #include "llvm/Support/ErrorHandling.h"
33 #include "llvm/Support/raw_ostream.h"
35 #define MANGLE_CHECKER 0
41 using namespace clang;
57 = dyn_cast_or_null<ParmVarDecl>(RD->getLambdaContextDecl()))
58 return ContextParam->getDeclContext();
62 if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
64 = dyn_cast_or_null<ParmVarDecl>(BD->getBlockManglingContextDecl()))
65 return ContextParam->getDeclContext();
70 return getEffectiveDeclContext(CD);
72 if (
const auto *VD = dyn_cast<VarDecl>(D))
74 return VD->getASTContext().getTranslationUnitDecl();
76 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
78 return FD->getASTContext().getTranslationUnitDecl();
84 return getEffectiveDeclContext(cast<Decl>(DC));
87 static bool isLocalContainerContext(
const DeclContext *DC) {
88 return isa<FunctionDecl>(DC) || isa<ObjCMethodDecl>(DC) || isa<BlockDecl>(DC);
94 if (isLocalContainerContext(DC))
95 return dyn_cast<RecordDecl>(D);
97 DC = getEffectiveDeclContext(D);
104 return ftd->getTemplatedDecl();
111 return (fn ? getStructor(fn) :
decl);
114 static bool isLambda(
const NamedDecl *ND) {
122 static const unsigned UnknownArity = ~0U;
125 typedef std::pair<const DeclContext*, IdentifierInfo*> DiscriminatorKeyTy;
126 llvm::DenseMap<DiscriminatorKeyTy, unsigned> Discriminator;
127 llvm::DenseMap<const NamedDecl*, unsigned> Uniquifier;
137 bool shouldMangleCXXName(
const NamedDecl *D)
override;
138 bool shouldMangleStringLiteral(
const StringLiteral *)
override {
141 void mangleCXXName(
const NamedDecl *D, raw_ostream &)
override;
143 raw_ostream &)
override;
146 raw_ostream &)
override;
147 void mangleReferenceTemporary(
const VarDecl *D,
unsigned ManglingNumber,
148 raw_ostream &)
override;
149 void mangleCXXVTable(
const CXXRecordDecl *RD, raw_ostream &)
override;
150 void mangleCXXVTT(
const CXXRecordDecl *RD, raw_ostream &)
override;
153 void mangleCXXRTTI(
QualType T, raw_ostream &)
override;
154 void mangleCXXRTTIName(
QualType T, raw_ostream &)
override;
155 void mangleTypeName(
QualType T, raw_ostream &)
override;
157 raw_ostream &)
override;
159 raw_ostream &)
override;
163 void mangleStaticGuardVariable(
const VarDecl *D, raw_ostream &)
override;
164 void mangleDynamicInitializer(
const VarDecl *D, raw_ostream &Out)
override;
165 void mangleDynamicAtExitDestructor(
const VarDecl *D,
166 raw_ostream &Out)
override;
167 void mangleSEHFilterExpression(
const NamedDecl *EnclosingDecl,
168 raw_ostream &Out)
override;
169 void mangleSEHFinallyBlock(
const NamedDecl *EnclosingDecl,
170 raw_ostream &Out)
override;
171 void mangleItaniumThreadLocalInit(
const VarDecl *D, raw_ostream &)
override;
172 void mangleItaniumThreadLocalWrapper(
const VarDecl *D,
173 raw_ostream &)
override;
175 void mangleStringLiteral(
const StringLiteral *, raw_ostream &)
override;
177 bool getNextDiscriminator(
const NamedDecl *ND,
unsigned &disc) {
183 if (
const TagDecl *Tag = dyn_cast<TagDecl>(ND)) {
184 if (Tag->getName().empty() && !Tag->getTypedefNameForAnonDecl())
190 unsigned discriminator = getASTContext().getManglingNumber(ND);
191 if (discriminator == 1)
193 disc = discriminator - 2;
198 unsigned &discriminator = Uniquifier[ND];
199 if (!discriminator) {
200 const DeclContext *DC = getEffectiveDeclContext(ND);
201 discriminator = ++Discriminator[std::make_pair(DC, ND->
getIdentifier())];
203 if (discriminator == 1)
205 disc = discriminator-2;
212 class CXXNameMangler {
213 ItaniumMangleContextImpl &
Context;
225 class FunctionTypeDepthState {
228 enum { InResultTypeMask = 1 };
231 FunctionTypeDepthState() : Bits(0) {}
234 unsigned getDepth()
const {
239 bool isInResultType()
const {
240 return Bits & InResultTypeMask;
243 FunctionTypeDepthState push() {
244 FunctionTypeDepthState tmp = *
this;
245 Bits = (Bits & ~InResultTypeMask) + 2;
249 void enterResultType() {
250 Bits |= InResultTypeMask;
253 void leaveResultType() {
254 Bits &= ~InResultTypeMask;
257 void pop(FunctionTypeDepthState saved) {
258 assert(getDepth() == saved.getDepth() + 1);
264 llvm::DenseMap<uintptr_t, unsigned> Substitutions;
269 CXXNameMangler(ItaniumMangleContextImpl &
C, raw_ostream &Out_,
274 assert(!D || (!isa<CXXDestructorDecl>(D) &&
275 !isa<CXXConstructorDecl>(D)));
277 CXXNameMangler(ItaniumMangleContextImpl &C, raw_ostream &Out_,
281 CXXNameMangler(ItaniumMangleContextImpl &C, raw_ostream &Out_,
288 if (Out.str()[0] ==
'\01')
292 char *result = abi::__cxa_demangle(Out.str().str().c_str(), 0, 0, &status);
293 assert(status == 0 &&
"Could not demangle mangled name!");
297 raw_ostream &getStream() {
return Out; }
300 void mangleCallOffset(int64_t NonVirtual, int64_t Virtual);
301 void mangleNumber(
const llvm::APSInt &
I);
302 void mangleNumber(int64_t Number);
303 void mangleFloat(
const llvm::APFloat &F);
305 void mangleSeqID(
unsigned SeqID);
308 void mangleNameOrStandardSubstitution(
const NamedDecl *ND);
312 bool mangleSubstitution(
const NamedDecl *ND);
313 bool mangleSubstitution(
QualType T);
315 bool mangleSubstitution(uintptr_t Ptr);
320 bool mangleStandardSubstitution(
const NamedDecl *ND);
322 void addSubstitution(
const NamedDecl *ND) {
325 addSubstitution(reinterpret_cast<uintptr_t>(ND));
329 void addSubstitution(uintptr_t Ptr);
332 bool recursive =
false);
335 unsigned KnownArity = UnknownArity);
339 unsigned NumTemplateArgs);
340 void mangleUnqualifiedName(
const NamedDecl *ND) {
341 mangleUnqualifiedName(ND, ND->
getDeclName(), UnknownArity);
344 unsigned KnownArity);
345 void mangleUnscopedName(
const NamedDecl *ND);
346 void mangleUnscopedTemplateName(
const TemplateDecl *ND);
349 void mangleLocalName(
const Decl *D);
350 void mangleBlockForPrefix(
const BlockDecl *Block);
351 void mangleUnqualifiedBlock(
const BlockDecl *Block);
354 bool NoFunction=
false);
357 unsigned NumTemplateArgs);
359 void manglePrefix(
const DeclContext *DC,
bool NoFunction=
false);
361 void mangleTemplatePrefix(
const TemplateDecl *ND,
bool NoFunction=
false);
363 bool mangleUnresolvedTypeOrSimpleId(
QualType DestroyedType,
364 StringRef Prefix =
"");
373 #define ABSTRACT_TYPE(CLASS, PARENT)
374 #define NON_CANONICAL_TYPE(CLASS, PARENT)
375 #define TYPE(CLASS, PARENT) void mangleType(const CLASS##Type *T);
376 #include "clang/AST/TypeNodes.def"
378 void mangleType(
const TagType*);
380 void mangleBareFunctionType(
const FunctionType *T,
bool MangleReturnType,
382 void mangleNeonVectorType(
const VectorType *T);
383 void mangleAArch64NeonVectorType(
const VectorType *T);
385 void mangleIntegerLiteral(
QualType T,
const llvm::APSInt &
Value);
386 void mangleMemberExprBase(
const Expr *base,
bool isArrow);
387 void mangleMemberExpr(
const Expr *base,
bool isArrow,
391 unsigned knownArity);
392 void mangleCastExpression(
const Expr *
E, StringRef CastEncoding);
393 void mangleInitListElements(
const InitListExpr *InitList);
394 void mangleExpression(
const Expr *
E,
unsigned Arity = UnknownArity);
399 unsigned NumTemplateArgs);
401 unsigned NumTemplateArgs);
405 void mangleTemplateParameter(
unsigned Index);
412 bool ItaniumMangleContextImpl::shouldMangleCXXName(
const NamedDecl *D) {
417 if (FD->
hasAttr<OverloadableAttr>())
435 if (!getASTContext().getLangOpts().CPlusPlus)
445 const DeclContext *DC = getEffectiveDeclContext(D);
449 DC = getEffectiveParentContext(DC);
451 !isa<VarTemplateSpecializationDecl>(D))
458 void CXXNameMangler::mangle(
const NamedDecl *D) {
464 mangleFunctionEncoding(FD);
465 else if (
const VarDecl *VD = dyn_cast<VarDecl>(D))
468 mangleName(IFD->getAnonField());
470 mangleName(cast<FieldDecl>(D));
473 void CXXNameMangler::mangleFunctionEncoding(
const FunctionDecl *FD) {
478 if (!
Context.shouldMangleDeclName(FD))
481 if (FD->
hasAttr<EnableIfAttr>()) {
482 FunctionTypeDepthState Saved = FunctionTypeDepth.push();
483 Out <<
"Ua9enable_ifI";
486 for (AttrVec::const_reverse_iterator
I = FD->
getAttrs().rbegin(),
489 EnableIfAttr *EIA = dyn_cast<EnableIfAttr>(*I);
493 mangleExpression(EIA->getCond());
497 FunctionTypeDepth.pop(Saved);
516 bool MangleReturnType =
false;
518 if (!(isa<CXXConstructorDecl>(FD) || isa<CXXDestructorDecl>(FD) ||
519 isa<CXXConversionDecl>(FD)))
520 MangleReturnType =
true;
523 FD = PrimaryTemplate->getTemplatedDecl();
527 MangleReturnType, FD);
531 while (isa<LinkageSpecDecl>(DC)) {
532 DC = getEffectiveParentContext(DC);
541 ->isTranslationUnit())
545 return II && II->
isStr(
"std");
554 return isStd(cast<NamespaceDecl>(DC));
560 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)){
569 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
570 TemplateArgs = &Spec->getTemplateArgs();
571 return Spec->getSpecializedTemplate();
576 dyn_cast<VarTemplateSpecializationDecl>(ND)) {
577 TemplateArgs = &Spec->getTemplateArgs();
578 return Spec->getSpecializedTemplate();
584 void CXXNameMangler::mangleName(
const NamedDecl *ND) {
590 const DeclContext *DC = getEffectiveDeclContext(ND);
596 if (isLocalContainerContext(DC) && ND->
hasLinkage() && !isLambda(ND))
598 DC = getEffectiveParentContext(DC);
599 else if (GetLocalClassDecl(ND)) {
610 mangleUnscopedTemplateName(TD);
611 mangleTemplateArgs(*TemplateArgs);
615 mangleUnscopedName(ND);
619 if (isLocalContainerContext(DC)) {
624 mangleNestedName(ND, DC);
628 unsigned NumTemplateArgs) {
632 mangleUnscopedTemplateName(TD);
633 mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
635 mangleNestedName(TD, TemplateArgs, NumTemplateArgs);
639 void CXXNameMangler::mangleUnscopedName(
const NamedDecl *ND) {
646 mangleUnqualifiedName(ND);
649 void CXXNameMangler::mangleUnscopedTemplateName(
const TemplateDecl *ND) {
652 if (mangleSubstitution(ND))
656 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND))
657 mangleTemplateParameter(TTP->getIndex());
664 void CXXNameMangler::mangleUnscopedTemplateName(
TemplateName Template) {
668 return mangleUnscopedTemplateName(TD);
670 if (mangleSubstitution(Template))
674 assert(Dependent &&
"Not a dependent template name?");
676 mangleSourceName(Id);
678 mangleOperatorName(Dependent->
getOperator(), UnknownArity);
680 addSubstitution(Template);
683 void CXXNameMangler::mangleFloat(
const llvm::APFloat &f) {
697 llvm::APInt valueBits = f.bitcastToAPInt();
698 unsigned numCharacters = (valueBits.getBitWidth() + 3) / 4;
699 assert(numCharacters != 0);
705 for (
unsigned stringIndex = 0; stringIndex != numCharacters; ++stringIndex) {
707 unsigned digitBitIndex = 4 * (numCharacters - stringIndex - 1);
710 llvm::integerPart hexDigit
711 = valueBits.getRawData()[digitBitIndex / llvm::integerPartWidth];
712 hexDigit >>= (digitBitIndex % llvm::integerPartWidth);
716 static const char charForHex[16] = {
717 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
718 '8',
'9',
'a',
'b',
'c',
'd',
'e',
'f'
720 buffer[stringIndex] = charForHex[hexDigit];
723 Out.write(buffer.data(), numCharacters);
726 void CXXNameMangler::mangleNumber(
const llvm::APSInt &
Value) {
727 if (Value.isSigned() && Value.isNegative()) {
729 Value.abs().print(Out,
false);
731 Value.print(Out,
false);
735 void CXXNameMangler::mangleNumber(int64_t Number) {
745 void CXXNameMangler::mangleCallOffset(int64_t NonVirtual, int64_t Virtual) {
753 mangleNumber(NonVirtual);
759 mangleNumber(NonVirtual);
761 mangleNumber(Virtual);
767 if (!mangleSubstitution(
QualType(TST, 0))) {
768 mangleTemplatePrefix(TST->getTemplateName());
773 mangleTemplateArgs(TST->getArgs(), TST->getNumArgs());
776 }
else if (
const auto *DTST =
778 if (!mangleSubstitution(
QualType(DTST, 0))) {
779 TemplateName Template = getASTContext().getDependentTemplateName(
780 DTST->getQualifier(), DTST->getIdentifier());
781 mangleTemplatePrefix(Template);
786 mangleTemplateArgs(DTST->getArgs(), DTST->getNumArgs());
817 switch (qualifier->
getKind()) {
829 llvm_unreachable(
"Can't mangle __super specifier");
833 mangleUnresolvedPrefix(qualifier->
getPrefix(),
841 mangleUnresolvedPrefix(qualifier->
getPrefix(),
858 mangleUnresolvedPrefix(qualifier->
getPrefix(),
865 if (mangleUnresolvedTypeOrSimpleId(
QualType(type, 0), recursive ?
"N" :
""))
874 mangleUnresolvedPrefix(qualifier->
getPrefix(),
893 unsigned knownArity) {
894 if (qualifier) mangleUnresolvedPrefix(qualifier);
910 mangleOperatorName(name, knownArity);
913 llvm_unreachable(
"Can't mangle a constructor name!");
915 llvm_unreachable(
"Can't mangle a using directive name!");
919 llvm_unreachable(
"Can't mangle Objective-C selector names here!");
923 void CXXNameMangler::mangleUnqualifiedName(
const NamedDecl *ND,
925 unsigned KnownArity) {
926 unsigned Arity = KnownArity;
940 getEffectiveDeclContext(ND)->isFileContext())
943 mangleSourceName(II);
948 assert(ND &&
"mangling empty name without declaration");
951 if (NS->isAnonymousNamespace()) {
953 Out <<
"12_GLOBAL__N_1";
958 if (
const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
973 &&
"Expected anonymous struct or union!");
980 assert(FD->getIdentifier() &&
"Data member name isn't an identifier!");
982 mangleSourceName(FD->getIdentifier());
992 if (isa<ObjCContainerDecl>(ND))
996 const TagDecl *TD = cast<TagDecl>(ND);
999 "Typedef should not be in another decl context!");
1001 "Typedef was not named!");
1010 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(TD)) {
1011 if (Record->isLambda() && Record->getLambdaManglingNumber()) {
1012 mangleLambda(Record);
1018 unsigned UnnamedMangle = getASTContext().getManglingNumber(TD);
1020 if (UnnamedMangle > 1)
1021 Out << UnnamedMangle - 2;
1027 unsigned AnonStructId =
Context.getAnonymousStructId(TD);
1034 Str += llvm::utostr(AnonStructId);
1044 llvm_unreachable(
"Can't mangle Objective-C selector names here!");
1050 mangleCXXCtorType(static_cast<CXXCtorType>(
StructorType));
1061 mangleCXXDtorType(static_cast<CXXDtorType>(
StructorType));
1069 if (ND && Arity == UnknownArity) {
1070 Arity = cast<FunctionDecl>(ND)->getNumParams();
1073 if (
const auto *MD = dyn_cast<CXXMethodDecl>(ND))
1074 if (!MD->isStatic())
1080 mangleOperatorName(Name, Arity);
1084 llvm_unreachable(
"Can't mangle a using directive name!");
1088 void CXXNameMangler::mangleSourceName(
const IdentifierInfo *II) {
1095 void CXXNameMangler::mangleNestedName(
const NamedDecl *ND,
1104 if (
const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(ND)) {
1110 mangleQualifiers(MethodQuals);
1111 mangleRefQualifier(Method->getRefQualifier());
1117 mangleTemplatePrefix(TD, NoFunction);
1118 mangleTemplateArgs(*TemplateArgs);
1121 manglePrefix(DC, NoFunction);
1122 mangleUnqualifiedName(ND);
1127 void CXXNameMangler::mangleNestedName(
const TemplateDecl *TD,
1129 unsigned NumTemplateArgs) {
1134 mangleTemplatePrefix(TD);
1135 mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
1140 void CXXNameMangler::mangleLocalName(
const Decl *D) {
1146 assert(isa<NamedDecl>(D) || isa<BlockDecl>(D));
1148 const DeclContext *DC = getEffectiveDeclContext(RD ? RD : D);
1153 mangleObjCMethodName(MD);
1154 else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(DC))
1155 mangleBlockForPrefix(BD);
1157 mangleFunctionEncoding(cast<FunctionDecl>(DC));
1172 = dyn_cast<FunctionDecl>(Parm->getDeclContext())) {
1174 unsigned Num = Func->getNumParams() - Parm->getFunctionScopeIndex();
1176 mangleNumber(Num - 2);
1185 mangleUnqualifiedName(RD);
1186 }
else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
1187 manglePrefix(getEffectiveDeclContext(BD),
true );
1188 mangleUnqualifiedBlock(BD);
1190 const NamedDecl *ND = cast<NamedDecl>(D);
1191 mangleNestedName(ND, getEffectiveDeclContext(ND),
true );
1193 }
else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
1197 = dyn_cast_or_null<ParmVarDecl>(BD->getBlockManglingContextDecl())) {
1199 = dyn_cast<FunctionDecl>(Parm->getDeclContext())) {
1201 unsigned Num = Func->getNumParams() - Parm->getFunctionScopeIndex();
1203 mangleNumber(Num - 2);
1208 mangleUnqualifiedBlock(BD);
1210 mangleUnqualifiedName(cast<NamedDecl>(D));
1213 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(RD ? RD : D)) {
1215 if (
Context.getNextDiscriminator(ND, disc)) {
1219 Out <<
"__" << disc <<
'_';
1224 void CXXNameMangler::mangleBlockForPrefix(
const BlockDecl *Block) {
1225 if (GetLocalClassDecl(Block)) {
1226 mangleLocalName(Block);
1229 const DeclContext *DC = getEffectiveDeclContext(Block);
1230 if (isLocalContainerContext(DC)) {
1231 mangleLocalName(Block);
1234 manglePrefix(getEffectiveDeclContext(Block));
1235 mangleUnqualifiedBlock(Block);
1238 void CXXNameMangler::mangleUnqualifiedBlock(
const BlockDecl *Block) {
1241 Context->getDeclContext()->isRecord()) {
1243 = cast<NamedDecl>(
Context)->getIdentifier()) {
1244 mangleSourceName(Name);
1255 Number =
Context.getBlockId(Block,
false);
1262 void CXXNameMangler::mangleLambda(
const CXXRecordDecl *Lambda) {
1274 Context->getDeclContext()->isRecord()) {
1276 = cast<NamedDecl>(
Context)->getIdentifier()) {
1277 mangleSourceName(Name);
1285 getAs<FunctionProtoType>();
1286 mangleBareFunctionType(Proto,
false,
1296 assert(Number > 0 &&
"Lambda should be mangled as an unnamed class");
1298 mangleNumber(Number - 2);
1303 switch (qualifier->
getKind()) {
1309 llvm_unreachable(
"Can't mangle __super specifier");
1334 llvm_unreachable(
"unexpected nested name specifier");
1337 void CXXNameMangler::manglePrefix(
const DeclContext *DC,
bool NoFunction) {
1349 if (NoFunction && isLocalContainerContext(DC))
1352 assert(!isLocalContainerContext(DC));
1354 const NamedDecl *ND = cast<NamedDecl>(DC);
1355 if (mangleSubstitution(ND))
1361 mangleTemplatePrefix(TD);
1362 mangleTemplateArgs(*TemplateArgs);
1364 manglePrefix(getEffectiveDeclContext(ND), NoFunction);
1365 mangleUnqualifiedName(ND);
1368 addSubstitution(ND);
1371 void CXXNameMangler::mangleTemplatePrefix(
TemplateName Template) {
1376 return mangleTemplatePrefix(TD);
1379 manglePrefix(Qualified->getQualifier());
1383 mangleUnqualifiedName(
nullptr, (*Overloaded->begin())->getDeclName(),
1389 assert(Dependent &&
"Unknown template name kind?");
1391 manglePrefix(Qualifier);
1392 mangleUnscopedTemplateName(Template);
1395 void CXXNameMangler::mangleTemplatePrefix(
const TemplateDecl *ND,
1403 if (mangleSubstitution(ND))
1407 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND)) {
1408 mangleTemplateParameter(TTP->getIndex());
1410 manglePrefix(getEffectiveDeclContext(ND), NoFunction);
1414 addSubstitution(ND);
1423 if (mangleSubstitution(TN))
1438 if (isa<TemplateTemplateParmDecl>(TD))
1439 mangleTemplateParameter(cast<TemplateTemplateParmDecl>(TD)->getIndex());
1445 llvm_unreachable(
"can't mangle an overloaded template name as a <type>");
1474 Out <<
"_SUBSTPACK_";
1479 addSubstitution(TN);
1482 bool CXXNameMangler::mangleUnresolvedTypeOrSimpleId(
QualType Ty,
1488 case Type::Adjusted:
1491 case Type::BlockPointer:
1492 case Type::LValueReference:
1493 case Type::RValueReference:
1494 case Type::MemberPointer:
1495 case Type::ConstantArray:
1496 case Type::IncompleteArray:
1497 case Type::VariableArray:
1498 case Type::DependentSizedArray:
1499 case Type::DependentSizedExtVector:
1501 case Type::ExtVector:
1502 case Type::FunctionProto:
1503 case Type::FunctionNoProto:
1505 case Type::Attributed:
1507 case Type::PackExpansion:
1508 case Type::ObjCObject:
1509 case Type::ObjCInterface:
1510 case Type::ObjCObjectPointer:
1513 llvm_unreachable(
"type is illegal as a nested name specifier");
1515 case Type::SubstTemplateTypeParmPack:
1520 Out <<
"_SUBSTPACK_";
1527 case Type::TypeOfExpr:
1529 case Type::Decltype:
1530 case Type::TemplateTypeParm:
1531 case Type::UnaryTransform:
1532 case Type::SubstTemplateTypeParm:
1546 mangleSourceName(cast<TypedefType>(Ty)->getDecl()->
getIdentifier());
1549 case Type::UnresolvedUsing:
1556 mangleSourceName(cast<TagType>(Ty)->getDecl()->
getIdentifier());
1559 case Type::TemplateSpecialization: {
1561 cast<TemplateSpecializationType>(Ty);
1563 switch (TN.getKind()) {
1570 assert(TD &&
"no template for template specialization type");
1571 if (isa<TemplateTemplateParmDecl>(TD))
1572 goto unresolvedType;
1580 llvm_unreachable(
"invalid base for a template specialization type");
1594 Out <<
"_SUBSTPACK_";
1599 mangleTemplateArgs(TST->getArgs(), TST->getNumArgs());
1603 case Type::InjectedClassName:
1605 cast<InjectedClassNameType>(Ty)->getDecl()->
getIdentifier());
1608 case Type::DependentName:
1609 mangleSourceName(cast<DependentNameType>(Ty)->
getIdentifier());
1612 case Type::DependentTemplateSpecialization: {
1614 cast<DependentTemplateSpecializationType>(Ty);
1615 mangleSourceName(DTST->getIdentifier());
1616 mangleTemplateArgs(DTST->getArgs(), DTST->getNumArgs());
1620 case Type::Elaborated:
1621 return mangleUnresolvedTypeOrSimpleId(
1622 cast<ElaboratedType>(Ty)->getNamedType(), Prefix);
1628 void CXXNameMangler::mangleOperatorName(
DeclarationName Name,
unsigned Arity) {
1637 llvm_unreachable(
"Not an operator name");
1662 case OO_New: Out <<
"nw";
break;
1664 case OO_Array_New: Out <<
"na";
break;
1666 case OO_Delete: Out <<
"dl";
break;
1668 case OO_Array_Delete: Out <<
"da";
break;
1672 Out << (Arity == 1?
"ps" :
"pl");
break;
1676 Out << (Arity == 1?
"ng" :
"mi");
break;
1680 Out << (Arity == 1?
"ad" :
"an");
break;
1685 Out << (Arity == 1?
"de" :
"ml");
break;
1687 case OO_Tilde: Out <<
"co";
break;
1689 case OO_Slash: Out <<
"dv";
break;
1691 case OO_Percent: Out <<
"rm";
break;
1693 case OO_Pipe: Out <<
"or";
break;
1695 case OO_Caret: Out <<
"eo";
break;
1697 case OO_Equal: Out <<
"aS";
break;
1699 case OO_PlusEqual: Out <<
"pL";
break;
1701 case OO_MinusEqual: Out <<
"mI";
break;
1703 case OO_StarEqual: Out <<
"mL";
break;
1705 case OO_SlashEqual: Out <<
"dV";
break;
1707 case OO_PercentEqual: Out <<
"rM";
break;
1709 case OO_AmpEqual: Out <<
"aN";
break;
1711 case OO_PipeEqual: Out <<
"oR";
break;
1713 case OO_CaretEqual: Out <<
"eO";
break;
1715 case OO_LessLess: Out <<
"ls";
break;
1717 case OO_GreaterGreater: Out <<
"rs";
break;
1719 case OO_LessLessEqual: Out <<
"lS";
break;
1721 case OO_GreaterGreaterEqual: Out <<
"rS";
break;
1723 case OO_EqualEqual: Out <<
"eq";
break;
1725 case OO_ExclaimEqual: Out <<
"ne";
break;
1727 case OO_Less: Out <<
"lt";
break;
1729 case OO_Greater: Out <<
"gt";
break;
1731 case OO_LessEqual: Out <<
"le";
break;
1733 case OO_GreaterEqual: Out <<
"ge";
break;
1735 case OO_Exclaim: Out <<
"nt";
break;
1737 case OO_AmpAmp: Out <<
"aa";
break;
1739 case OO_PipePipe: Out <<
"oo";
break;
1741 case OO_PlusPlus: Out <<
"pp";
break;
1743 case OO_MinusMinus: Out <<
"mm";
break;
1745 case OO_Comma: Out <<
"cm";
break;
1747 case OO_ArrowStar: Out <<
"pm";
break;
1749 case OO_Arrow: Out <<
"pt";
break;
1751 case OO_Call: Out <<
"cl";
break;
1753 case OO_Subscript: Out <<
"ix";
break;
1758 case OO_Conditional: Out <<
"qu";
break;
1761 case OO_Coawait: Out <<
"aw";
break;
1765 llvm_unreachable(
"Not an overloaded operator");
1769 void CXXNameMangler::mangleQualifiers(
Qualifiers Quals) {
1791 ASString =
"AS" + llvm::utostr_32(TargetAS);
1794 default: llvm_unreachable(
"Not a language specific address space");
1805 Out <<
'U' << ASString.size() << ASString;
1808 StringRef LifetimeName;
1819 LifetimeName =
"__weak";
1823 LifetimeName =
"__strong";
1827 LifetimeName =
"__autoreleasing";
1840 if (!LifetimeName.empty())
1841 Out <<
'U' << LifetimeName.size() << LifetimeName;
1847 switch (RefQualifier) {
1861 void CXXNameMangler::mangleObjCMethodName(
const ObjCMethodDecl *MD) {
1862 Context.mangleObjCMethodName(MD, Out);
1878 void CXXNameMangler::mangleType(
QualType T) {
1903 = dyn_cast<TemplateSpecializationType>(T))
1904 if (!TST->isTypeAlias())
1917 const Type *ty = split.
Ty;
1920 if (isSubstitutable && mangleSubstitution(T))
1925 if (quals && isa<ArrayType>(T)) {
1934 mangleQualifiers(quals);
1940 #define ABSTRACT_TYPE(CLASS, PARENT)
1941 #define NON_CANONICAL_TYPE(CLASS, PARENT) \
1943 llvm_unreachable("can't mangle non-canonical type " #CLASS "Type"); \
1945 #define TYPE(CLASS, PARENT) \
1947 mangleType(static_cast<const CLASS##Type*>(ty)); \
1949 #include "clang/AST/TypeNodes.def"
1954 if (isSubstitutable)
1958 void CXXNameMangler::mangleNameOrStandardSubstitution(
const NamedDecl *ND) {
1959 if (!mangleStandardSubstitution(ND))
1963 void CXXNameMangler::mangleType(
const BuiltinType *T) {
1994 case BuiltinType::Void:
1997 case BuiltinType::Bool:
2000 case BuiltinType::Char_U:
2001 case BuiltinType::Char_S:
2004 case BuiltinType::UChar:
2007 case BuiltinType::UShort:
2010 case BuiltinType::UInt:
2013 case BuiltinType::ULong:
2016 case BuiltinType::ULongLong:
2019 case BuiltinType::UInt128:
2022 case BuiltinType::SChar:
2025 case BuiltinType::WChar_S:
2026 case BuiltinType::WChar_U:
2029 case BuiltinType::Char16:
2032 case BuiltinType::Char32:
2035 case BuiltinType::Short:
2038 case BuiltinType::Int:
2041 case BuiltinType::Long:
2044 case BuiltinType::LongLong:
2047 case BuiltinType::Int128:
2050 case BuiltinType::Half:
2053 case BuiltinType::Float:
2056 case BuiltinType::Double:
2059 case BuiltinType::LongDouble:
2060 Out << (getASTContext().getTargetInfo().useFloat128ManglingForLongDouble()
2064 case BuiltinType::NullPtr:
2068 #define BUILTIN_TYPE(Id, SingletonId)
2069 #define PLACEHOLDER_TYPE(Id, SingletonId) \
2070 case BuiltinType::Id:
2071 #include "clang/AST/BuiltinTypes.def"
2072 case BuiltinType::Dependent:
2073 llvm_unreachable(
"mangling a placeholder type");
2074 case BuiltinType::ObjCId:
2075 Out <<
"11objc_object";
2077 case BuiltinType::ObjCClass:
2078 Out <<
"10objc_class";
2080 case BuiltinType::ObjCSel:
2081 Out <<
"13objc_selector";
2083 case BuiltinType::OCLImage1d:
2084 Out <<
"11ocl_image1d";
2086 case BuiltinType::OCLImage1dArray:
2087 Out <<
"16ocl_image1darray";
2089 case BuiltinType::OCLImage1dBuffer:
2090 Out <<
"17ocl_image1dbuffer";
2092 case BuiltinType::OCLImage2d:
2093 Out <<
"11ocl_image2d";
2095 case BuiltinType::OCLImage2dArray:
2096 Out <<
"16ocl_image2darray";
2098 case BuiltinType::OCLImage2dDepth:
2099 Out <<
"16ocl_image2ddepth";
2101 case BuiltinType::OCLImage2dArrayDepth:
2102 Out <<
"21ocl_image2darraydepth";
2104 case BuiltinType::OCLImage2dMSAA:
2105 Out <<
"15ocl_image2dmsaa";
2107 case BuiltinType::OCLImage2dArrayMSAA:
2108 Out <<
"20ocl_image2darraymsaa";
2110 case BuiltinType::OCLImage2dMSAADepth:
2111 Out <<
"20ocl_image2dmsaadepth";
2113 case BuiltinType::OCLImage2dArrayMSAADepth:
2114 Out <<
"35ocl_image2darraymsaadepth";
2116 case BuiltinType::OCLImage3d:
2117 Out <<
"11ocl_image3d";
2119 case BuiltinType::OCLSampler:
2120 Out <<
"11ocl_sampler";
2122 case BuiltinType::OCLEvent:
2123 Out <<
"9ocl_event";
2125 case BuiltinType::OCLClkEvent:
2126 Out <<
"12ocl_clkevent";
2128 case BuiltinType::OCLQueue:
2129 Out <<
"9ocl_queue";
2131 case BuiltinType::OCLNDRange:
2132 Out <<
"11ocl_ndrange";
2134 case BuiltinType::OCLReserveID:
2135 Out <<
"13ocl_reserveid";
2152 mangleBareFunctionType(T,
true);
2166 FunctionTypeDepthState saved = FunctionTypeDepth.push();
2168 FunctionTypeDepth.enterResultType();
2170 FunctionTypeDepth.leaveResultType();
2172 FunctionTypeDepth.pop(saved);
2176 void CXXNameMangler::mangleBareFunctionType(
const FunctionType *T,
2177 bool MangleReturnType,
2184 FunctionTypeDepthState saved = FunctionTypeDepth.push();
2187 if (MangleReturnType) {
2188 FunctionTypeDepth.enterResultType();
2190 FunctionTypeDepth.leaveResultType();
2197 FunctionTypeDepth.pop(saved);
2209 assert(
Attr->getType() <= 9 &&
Attr->getType() >= 0);
2210 Out <<
"U17pass_object_size" <<
Attr->getType();
2215 FunctionTypeDepth.pop(saved);
2230 void CXXNameMangler::mangleType(
const EnumType *T) {
2231 mangleType(static_cast<const TagType*>(T));
2233 void CXXNameMangler::mangleType(
const RecordType *T) {
2234 mangleType(static_cast<const TagType*>(T));
2236 void CXXNameMangler::mangleType(
const TagType *T) {
2244 Out <<
'A' << T->
getSize() <<
'_';
2293 mangleType(PointeeType);
2298 mangleTemplateParameter(T->
getIndex());
2307 Out <<
"_SUBSTPACK_";
2311 void CXXNameMangler::mangleType(
const PointerType *T) {
2333 void CXXNameMangler::mangleType(
const ComplexType *T) {
2341 void CXXNameMangler::mangleNeonVectorType(
const VectorType *T) {
2343 assert(EltType->
isBuiltinType() &&
"Neon vector element not a BuiltinType");
2344 const char *EltName =
nullptr;
2346 switch (cast<BuiltinType>(EltType)->getKind()) {
2347 case BuiltinType::SChar:
2348 case BuiltinType::UChar:
2349 EltName =
"poly8_t";
2351 case BuiltinType::Short:
2352 case BuiltinType::UShort:
2353 EltName =
"poly16_t";
2355 case BuiltinType::ULongLong:
2356 EltName =
"poly64_t";
2358 default: llvm_unreachable(
"unexpected Neon polynomial vector element type");
2361 switch (cast<BuiltinType>(EltType)->
getKind()) {
2362 case BuiltinType::SChar: EltName =
"int8_t";
break;
2363 case BuiltinType::UChar: EltName =
"uint8_t";
break;
2364 case BuiltinType::Short: EltName =
"int16_t";
break;
2365 case BuiltinType::UShort: EltName =
"uint16_t";
break;
2366 case BuiltinType::Int: EltName =
"int32_t";
break;
2367 case BuiltinType::UInt: EltName =
"uint32_t";
break;
2368 case BuiltinType::LongLong: EltName =
"int64_t";
break;
2369 case BuiltinType::ULongLong: EltName =
"uint64_t";
break;
2370 case BuiltinType::Double: EltName =
"float64_t";
break;
2371 case BuiltinType::Float: EltName =
"float32_t";
break;
2372 case BuiltinType::Half: EltName =
"float16_t";
break;
2374 llvm_unreachable(
"unexpected Neon vector element type");
2377 const char *BaseName =
nullptr;
2379 getASTContext().getTypeSize(EltType));
2381 BaseName =
"__simd64_";
2383 assert(BitSize == 128 &&
"Neon vector type not 64 or 128 bits");
2384 BaseName =
"__simd128_";
2386 Out << strlen(BaseName) + strlen(EltName);
2387 Out << BaseName << EltName;
2392 case BuiltinType::SChar:
2394 case BuiltinType::Short:
2396 case BuiltinType::Int:
2398 case BuiltinType::Long:
2399 case BuiltinType::LongLong:
2401 case BuiltinType::UChar:
2403 case BuiltinType::UShort:
2405 case BuiltinType::UInt:
2407 case BuiltinType::ULong:
2408 case BuiltinType::ULongLong:
2410 case BuiltinType::Half:
2412 case BuiltinType::Float:
2414 case BuiltinType::Double:
2417 llvm_unreachable(
"Unexpected vector element base type");
2424 void CXXNameMangler::mangleAArch64NeonVectorType(
const VectorType *T) {
2426 assert(EltType->
isBuiltinType() &&
"Neon vector element not a BuiltinType");
2431 assert((BitSize == 64 || BitSize == 128) &&
2432 "Neon vector type not 64 or 128 bits");
2436 switch (cast<BuiltinType>(EltType)->getKind()) {
2437 case BuiltinType::UChar:
2440 case BuiltinType::UShort:
2443 case BuiltinType::ULong:
2444 case BuiltinType::ULongLong:
2448 llvm_unreachable(
"unexpected Neon polynomial vector element type");
2453 std::string TypeName =
2454 (
"__" + EltName +
"x" + Twine(T->
getNumElements()) +
"_t").str();
2455 Out << TypeName.length() << TypeName;
2466 void CXXNameMangler::mangleType(
const VectorType *T) {
2469 llvm::Triple Target = getASTContext().getTargetInfo().getTriple();
2470 llvm::Triple::ArchType Arch =
2471 getASTContext().getTargetInfo().getTriple().getArch();
2472 if ((Arch == llvm::Triple::aarch64 ||
2473 Arch == llvm::Triple::aarch64_be) && !Target.isOSDarwin())
2474 mangleAArch64NeonVectorType(T);
2476 mangleNeonVectorType(T);
2488 mangleType(static_cast<const VectorType*>(T));
2510 Out <<
"U8__kindof";
2515 llvm::raw_svector_ostream QualOS(QualStr);
2516 QualOS <<
"objcproto";
2517 for (
const auto *I : T->
quals()) {
2518 StringRef name = I->getName();
2519 QualOS << name.size() << name;
2521 Out <<
'U' << QualStr.size() << QualStr;
2530 mangleType(typeArg);
2536 Out <<
"U13block_pointer";
2548 if (
TemplateDecl *TD = T->getTemplateName().getAsTemplateDecl()) {
2549 mangleName(TD, T->getArgs(), T->getNumArgs());
2551 if (mangleSubstitution(
QualType(T, 0)))
2554 mangleTemplatePrefix(T->getTemplateName());
2559 mangleTemplateArgs(T->getArgs(), T->getNumArgs());
2590 llvm_unreachable(
"unexpected keyword for dependent type name");
2605 getASTContext().getDependentTemplateName(T->getQualifier(),
2606 T->getIdentifier());
2607 mangleTemplatePrefix(Prefix);
2612 mangleTemplateArgs(T->getArgs(), T->getNumArgs());
2616 void CXXNameMangler::mangleType(
const TypeOfType *T) {
2628 void CXXNameMangler::mangleType(
const DecltypeType *T) {
2639 if (isa<DeclRefExpr>(E) ||
2640 isa<MemberExpr>(E) ||
2641 isa<UnresolvedLookupExpr>(E) ||
2642 isa<DependentScopeDeclRefExpr>(E) ||
2643 isa<CXXDependentScopeMemberExpr>(E) ||
2644 isa<UnresolvedMemberExpr>(E))
2648 mangleExpression(E);
2668 void CXXNameMangler::mangleType(
const AutoType *T) {
2673 "shouldn't need to mangle __auto_type!");
2679 void CXXNameMangler::mangleType(
const AtomicType *T) {
2686 void CXXNameMangler::mangleType(
const PipeType *T) {
2693 void CXXNameMangler::mangleIntegerLiteral(
QualType T,
2694 const llvm::APSInt &Value) {
2701 Out << (Value.getBoolValue() ?
'1' :
'0');
2703 mangleNumber(Value);
2709 void CXXNameMangler::mangleMemberExprBase(
const Expr *
Base,
bool IsArrow) {
2712 if (!RT->getDecl()->isAnonymousStructOrUnion())
2717 Base = ME->getBase();
2718 IsArrow = ME->isArrow();
2727 Out << (IsArrow ?
"pt" :
"dt");
2728 mangleExpression(Base);
2733 void CXXNameMangler::mangleMemberExpr(
const Expr *base,
2742 mangleMemberExprBase(base, isArrow);
2743 mangleUnresolvedName(qualifier, member, arity);
2756 if (callee == fn)
return false;
2760 if (!lookup)
return false;
2777 void CXXNameMangler::mangleCastExpression(
const Expr *E, StringRef CastEncoding) {
2779 Out << CastEncoding;
2784 void CXXNameMangler::mangleInitListElements(
const InitListExpr *InitList) {
2786 InitList = Syntactic;
2787 for (
unsigned i = 0, e = InitList->
getNumInits(); i != e; ++i)
2788 mangleExpression(InitList->
getInit(i));
2791 void CXXNameMangler::mangleExpression(
const Expr *E,
unsigned Arity) {
2815 QualType ImplicitlyConvertedToType;
2818 switch (E->getStmtClass()) {
2819 case Expr::NoStmtClass:
2820 #define ABSTRACT_STMT(Type)
2821 #define EXPR(Type, Base)
2822 #define STMT(Type, Base) \
2823 case Expr::Type##Class:
2824 #include "clang/AST/StmtNodes.inc"
2829 case Expr::AddrLabelExprClass:
2830 case Expr::DesignatedInitUpdateExprClass:
2831 case Expr::ImplicitValueInitExprClass:
2832 case Expr::NoInitExprClass:
2833 case Expr::ParenListExprClass:
2834 case Expr::LambdaExprClass:
2835 case Expr::MSPropertyRefExprClass:
2836 case Expr::MSPropertySubscriptExprClass:
2837 case Expr::TypoExprClass:
2838 case Expr::OMPArraySectionExprClass:
2839 llvm_unreachable(
"unexpected statement kind");
2842 case Expr::BlockExprClass:
2843 case Expr::ChooseExprClass:
2844 case Expr::CompoundLiteralExprClass:
2845 case Expr::DesignatedInitExprClass:
2846 case Expr::ExtVectorElementExprClass:
2847 case Expr::GenericSelectionExprClass:
2848 case Expr::ObjCEncodeExprClass:
2849 case Expr::ObjCIsaExprClass:
2850 case Expr::ObjCIvarRefExprClass:
2851 case Expr::ObjCMessageExprClass:
2852 case Expr::ObjCPropertyRefExprClass:
2853 case Expr::ObjCProtocolExprClass:
2854 case Expr::ObjCSelectorExprClass:
2855 case Expr::ObjCStringLiteralClass:
2856 case Expr::ObjCBoxedExprClass:
2857 case Expr::ObjCArrayLiteralClass:
2858 case Expr::ObjCDictionaryLiteralClass:
2859 case Expr::ObjCSubscriptRefExprClass:
2860 case Expr::ObjCIndirectCopyRestoreExprClass:
2861 case Expr::OffsetOfExprClass:
2862 case Expr::PredefinedExprClass:
2863 case Expr::ShuffleVectorExprClass:
2864 case Expr::ConvertVectorExprClass:
2865 case Expr::StmtExprClass:
2866 case Expr::TypeTraitExprClass:
2867 case Expr::ArrayTypeTraitExprClass:
2868 case Expr::ExpressionTraitExprClass:
2869 case Expr::VAArgExprClass:
2870 case Expr::CUDAKernelCallExprClass:
2871 case Expr::AsTypeExprClass:
2872 case Expr::PseudoObjectExprClass:
2873 case Expr::AtomicExprClass:
2878 "cannot yet mangle expression type %0");
2880 << E->getStmtClassName() << E->getSourceRange();
2884 case Expr::CXXUuidofExprClass: {
2888 Out <<
"u8__uuidoft";
2892 Out <<
"u8__uuidofz";
2893 mangleExpression(UuidExp, Arity);
2899 case Expr::BinaryConditionalOperatorClass: {
2903 "?: operator with omitted middle operand cannot be mangled");
2905 << E->getStmtClassName() << E->getSourceRange();
2910 case Expr::OpaqueValueExprClass:
2911 llvm_unreachable(
"cannot mangle opaque value; mangling wrong thing?");
2913 case Expr::InitListExprClass: {
2915 mangleInitListElements(cast<InitListExpr>(E));
2920 case Expr::CXXDefaultArgExprClass:
2921 mangleExpression(cast<CXXDefaultArgExpr>(E)->getExpr(), Arity);
2924 case Expr::CXXDefaultInitExprClass:
2925 mangleExpression(cast<CXXDefaultInitExpr>(E)->getExpr(), Arity);
2928 case Expr::CXXStdInitializerListExprClass:
2929 mangleExpression(cast<CXXStdInitializerListExpr>(E)->getSubExpr(), Arity);
2932 case Expr::SubstNonTypeTemplateParmExprClass:
2933 mangleExpression(cast<SubstNonTypeTemplateParmExpr>(E)->getReplacement(),
2937 case Expr::UserDefinedLiteralClass:
2940 case Expr::CXXMemberCallExprClass:
2941 case Expr::CallExprClass: {
2961 if (isa<PackExpansionExpr>(Arg))
2962 CallArity = UnknownArity;
2964 mangleExpression(CE->
getCallee(), CallArity);
2966 mangleExpression(Arg);
2971 case Expr::CXXNewExprClass: {
2974 Out << (New->
isArray() ?
"na" :
"nw");
2977 mangleExpression(*I);
2991 mangleExpression(*I);
2992 }
else if (
const ParenListExpr *PLE = dyn_cast<ParenListExpr>(Init)) {
2993 for (
unsigned i = 0, e = PLE->getNumExprs(); i != e; ++i)
2994 mangleExpression(PLE->getExpr(i));
2996 isa<InitListExpr>(Init)) {
2998 mangleInitListElements(cast<InitListExpr>(Init));
3000 mangleExpression(Init);
3006 case Expr::CXXPseudoDestructorExprClass: {
3007 const auto *PDE = cast<CXXPseudoDestructorExpr>(
E);
3008 if (
const Expr *Base = PDE->getBase())
3009 mangleMemberExprBase(Base, PDE->isArrow());
3014 mangleUnresolvedPrefix(Qualifier,
3016 mangleUnresolvedTypeOrSimpleId(ScopeInfo->getType());
3020 if (!mangleUnresolvedTypeOrSimpleId(ScopeInfo->getType()))
3023 }
else if (Qualifier) {
3024 mangleUnresolvedPrefix(Qualifier);
3028 QualType DestroyedType = PDE->getDestroyedType();
3029 mangleUnresolvedTypeOrSimpleId(DestroyedType);
3033 case Expr::MemberExprClass: {
3041 case Expr::UnresolvedMemberExprClass: {
3051 case Expr::CXXDependentScopeMemberExprClass: {
3053 = cast<CXXDependentScopeMemberExpr>(
E);
3063 case Expr::UnresolvedLookupExprClass: {
3075 case Expr::CXXUnresolvedConstructExprClass: {
3081 if (N != 1) Out <<
'_';
3082 for (
unsigned I = 0; I != N; ++
I) mangleExpression(CE->
getArg(I));
3083 if (N != 1) Out <<
'E';
3087 case Expr::CXXConstructExprClass: {
3088 const auto *CE = cast<CXXConstructExpr>(
E);
3089 if (!CE->isListInitialization() || CE->isStdInitListInitialization()) {
3091 CE->getNumArgs() >= 1 &&
3092 (CE->getNumArgs() == 1 || isa<CXXDefaultArgExpr>(CE->
getArg(1))) &&
3093 "implicit CXXConstructExpr must have one argument");
3094 return mangleExpression(cast<CXXConstructExpr>(E)->
getArg(0));
3097 for (
auto *E : CE->arguments())
3098 mangleExpression(E);
3103 case Expr::CXXTemporaryObjectExprClass: {
3104 const auto *CE = cast<CXXTemporaryObjectExpr>(
E);
3105 unsigned N = CE->getNumArgs();
3106 bool List = CE->isListInitialization();
3113 if (!List && N != 1)
3115 if (CE->isStdInitListInitialization()) {
3121 auto *ILE = cast<InitListExpr>(SILE->getSubExpr()->IgnoreImplicit());
3122 mangleInitListElements(ILE);
3124 for (
auto *E : CE->arguments())
3125 mangleExpression(E);
3132 case Expr::CXXScalarValueInitExprClass:
3138 case Expr::CXXNoexceptExprClass:
3140 mangleExpression(cast<CXXNoexceptExpr>(E)->getOperand());
3143 case Expr::UnaryExprOrTypeTraitExprClass: {
3157 : ImplicitlyConvertedToType;
3159 mangleIntegerLiteral(T, V);
3173 "cannot yet mangle vec_step expression");
3181 "cannot yet mangle __builtin_omp_required_simd_align expression");
3195 case Expr::CXXThrowExprClass: {
3208 case Expr::CXXTypeidExprClass: {
3222 case Expr::CXXDeleteExprClass: {
3232 case Expr::UnaryOperatorClass: {
3240 case Expr::ArraySubscriptExprClass: {
3246 mangleExpression(AE->
getLHS());
3247 mangleExpression(AE->
getRHS());
3251 case Expr::CompoundAssignOperatorClass:
3252 case Expr::BinaryOperatorClass: {
3259 mangleExpression(BO->
getLHS());
3260 mangleExpression(BO->
getRHS());
3264 case Expr::ConditionalOperatorClass: {
3266 mangleOperatorName(OO_Conditional, 3);
3267 mangleExpression(CO->
getCond());
3268 mangleExpression(CO->
getLHS(), Arity);
3269 mangleExpression(CO->
getRHS(), Arity);
3273 case Expr::ImplicitCastExprClass: {
3274 ImplicitlyConvertedToType = E->
getType();
3275 E = cast<ImplicitCastExpr>(
E)->getSubExpr();
3279 case Expr::ObjCBridgedCastExprClass: {
3282 StringRef
Kind = cast<ObjCBridgedCastExpr>(
E)->getBridgeKindName();
3283 Out <<
"v1U" << Kind.size() <<
Kind;
3287 case Expr::CStyleCastExprClass:
3288 mangleCastExpression(E,
"cv");
3291 case Expr::CXXFunctionalCastExprClass: {
3292 auto *Sub = cast<ExplicitCastExpr>(
E)->getSubExpr()->IgnoreImplicit();
3294 if (
auto *CCE = dyn_cast<CXXConstructExpr>(Sub))
3295 if (CCE->getParenOrBraceRange().isInvalid())
3296 Sub = CCE->getArg(0)->IgnoreImplicit();
3297 if (
auto *StdInitList = dyn_cast<CXXStdInitializerListExpr>(Sub))
3298 Sub = StdInitList->getSubExpr()->IgnoreImplicit();
3299 if (
auto *IL = dyn_cast<InitListExpr>(Sub)) {
3302 mangleInitListElements(IL);
3305 mangleCastExpression(E,
"cv");
3310 case Expr::CXXStaticCastExprClass:
3311 mangleCastExpression(E,
"sc");
3313 case Expr::CXXDynamicCastExprClass:
3314 mangleCastExpression(E,
"dc");
3316 case Expr::CXXReinterpretCastExprClass:
3317 mangleCastExpression(E,
"rc");
3319 case Expr::CXXConstCastExprClass:
3320 mangleCastExpression(E,
"cc");
3323 case Expr::CXXOperatorCallExprClass: {
3328 for (
unsigned i = 0; i !=
NumArgs; ++i)
3329 mangleExpression(CE->
getArg(i));
3333 case Expr::ParenExprClass:
3334 mangleExpression(cast<ParenExpr>(E)->getSubExpr(), Arity);
3337 case Expr::DeclRefExprClass: {
3338 const NamedDecl *D = cast<DeclRefExpr>(
E)->getDecl();
3349 mangleFunctionParam(cast<ParmVarDecl>(D));
3352 case Decl::EnumConstant: {
3358 case Decl::NonTypeTemplateParm: {
3360 mangleTemplateParameter(PD->
getIndex());
3369 case Expr::SubstNonTypeTemplateParmPackExprClass:
3374 Out <<
"_SUBSTPACK_";
3377 case Expr::FunctionParmPackExprClass: {
3380 Out <<
"v110_SUBSTPACK";
3385 case Expr::DependentScopeDeclRefExprClass: {
3397 case Expr::CXXBindTemporaryExprClass:
3398 mangleExpression(cast<CXXBindTemporaryExpr>(E)->getSubExpr());
3401 case Expr::ExprWithCleanupsClass:
3402 mangleExpression(cast<ExprWithCleanups>(E)->getSubExpr(), Arity);
3405 case Expr::FloatingLiteralClass: {
3414 case Expr::CharacterLiteralClass:
3417 Out << cast<CharacterLiteral>(
E)->
getValue();
3422 case Expr::ObjCBoolLiteralExprClass:
3424 Out << (cast<ObjCBoolLiteralExpr>(
E)->
getValue() ?
'1' :
'0');
3428 case Expr::CXXBoolLiteralExprClass:
3430 Out << (cast<CXXBoolLiteralExpr>(
E)->
getValue() ?
'1' :
'0');
3434 case Expr::IntegerLiteralClass: {
3437 Value.setIsSigned(
true);
3442 case Expr::ImaginaryLiteralClass: {
3449 dyn_cast<FloatingLiteral>(IE->
getSubExpr())) {
3451 mangleFloat(llvm::APFloat(Imag->getValue().getSemantics()));
3453 mangleFloat(Imag->getValue());
3458 Value.setIsSigned(
true);
3459 mangleNumber(Value);
3465 case Expr::StringLiteralClass: {
3468 assert(isa<ConstantArrayType>(E->
getType()));
3474 case Expr::GNUNullExprClass:
3478 case Expr::CXXNullPtrLiteralExprClass: {
3483 case Expr::PackExpansionExprClass:
3485 mangleExpression(cast<PackExpansionExpr>(E)->getPattern());
3488 case Expr::SizeOfPackExprClass: {
3489 auto *SPE = cast<SizeOfPackExpr>(
E);
3490 if (SPE->isPartiallySubstituted()) {
3492 for (
const auto &A : SPE->getPartialArguments())
3493 mangleTemplateArg(A);
3501 mangleTemplateParameter(TTP->getIndex());
3503 = dyn_cast<NonTypeTemplateParmDecl>(Pack))
3504 mangleTemplateParameter(NTTP->getIndex());
3506 = dyn_cast<TemplateTemplateParmDecl>(Pack))
3507 mangleTemplateParameter(TempTP->getIndex());
3509 mangleFunctionParam(cast<ParmVarDecl>(Pack));
3513 case Expr::MaterializeTemporaryExprClass: {
3514 mangleExpression(cast<MaterializeTemporaryExpr>(E)->GetTemporaryExpr());
3518 case Expr::CXXFoldExprClass: {
3519 auto *FE = cast<CXXFoldExpr>(
E);
3520 if (FE->isLeftFold())
3521 Out << (FE->getInit() ?
"fL" :
"fl");
3523 Out << (FE->getInit() ?
"fR" :
"fr");
3533 mangleExpression(FE->getLHS());
3535 mangleExpression(FE->getRHS());
3539 case Expr::CXXThisExprClass:
3543 case Expr::CoawaitExprClass:
3545 Out <<
"v18co_await";
3546 mangleExpression(cast<CoawaitExpr>(E)->getOperand());
3549 case Expr::CoyieldExprClass:
3551 Out <<
"v18co_yield";
3552 mangleExpression(cast<CoawaitExpr>(E)->getOperand());
3585 void CXXNameMangler::mangleFunctionParam(
const ParmVarDecl *parm) {
3592 assert(parmDepth < FunctionTypeDepth.getDepth());
3593 unsigned nestingDepth = FunctionTypeDepth.getDepth() - parmDepth;
3594 if (FunctionTypeDepth.isInResultType())
3597 if (nestingDepth == 0) {
3600 Out <<
"fL" << (nestingDepth - 1) <<
'p';
3608 &&
"parameter's type is still an array type?");
3612 if (parmIndex != 0) {
3613 Out << (parmIndex - 1);
3618 void CXXNameMangler::mangleCXXCtorType(
CXXCtorType T) {
3635 llvm_unreachable(
"closure constructors don't exist for the Itanium ABI!");
3639 void CXXNameMangler::mangleCXXDtorType(
CXXDtorType T) {
3662 unsigned NumTemplateArgs) {
3665 for (
unsigned i = 0; i != NumTemplateArgs; ++i)
3666 mangleTemplateArg(TemplateArgs[i].getArgument());
3673 for (
unsigned i = 0, e = AL.
size(); i != e; ++i)
3674 mangleTemplateArg(AL[i]);
3678 void CXXNameMangler::mangleTemplateArgs(
const TemplateArgument *TemplateArgs,
3679 unsigned NumTemplateArgs) {
3682 for (
unsigned i = 0; i != NumTemplateArgs; ++i)
3683 mangleTemplateArg(TemplateArgs[i]);
3697 llvm_unreachable(
"Cannot mangle NULL template argument");
3716 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
3718 if (isa<VarDecl>(D) || isa<FunctionDecl>(D)) {
3727 mangleExpression(E);
3741 if (compensateMangling) {
3743 mangleOperatorName(OO_Amp, 1);
3752 if (compensateMangling)
3768 mangleTemplateArg(
P);
3774 void CXXNameMangler::mangleTemplateParameter(
unsigned Index) {
3780 Out <<
'T' << (Index - 1) <<
'_';
3783 void CXXNameMangler::mangleSeqID(
unsigned SeqID) {
3786 else if (SeqID > 1) {
3794 for (; SeqID != 0; SeqID /= 36) {
3795 unsigned C = SeqID % 36;
3796 *I++ = (C < 10 ?
'0' + C :
'A' + C - 10);
3799 Out.write(I.base(), I - BufferRef.rbegin());
3804 void CXXNameMangler::mangleExistingSubstitution(
QualType type) {
3805 bool result = mangleSubstitution(type);
3806 assert(result &&
"no existing substitution for type");
3810 void CXXNameMangler::mangleExistingSubstitution(
TemplateName tname) {
3811 bool result = mangleSubstitution(tname);
3812 assert(result &&
"no existing substitution for template name");
3818 bool CXXNameMangler::mangleSubstitution(
const NamedDecl *ND) {
3820 if (mangleStandardSubstitution(ND))
3824 return mangleSubstitution(reinterpret_cast<uintptr_t>(ND));
3834 bool CXXNameMangler::mangleSubstitution(
QualType T) {
3837 return mangleSubstitution(RT->getDecl());
3840 uintptr_t TypePtr =
reinterpret_cast<uintptr_t
>(T.
getAsOpaquePtr());
3842 return mangleSubstitution(TypePtr);
3845 bool CXXNameMangler::mangleSubstitution(
TemplateName Template) {
3847 return mangleSubstitution(TD);
3850 return mangleSubstitution(
3854 bool CXXNameMangler::mangleSubstitution(uintptr_t Ptr) {
3856 if (I == Substitutions.end())
3859 unsigned SeqID = I->second;
3893 if (TemplateArgs.
size() != 1)
3896 if (!
isCharType(TemplateArgs[0].getAsType()))
3902 template <std::
size_t StrLen>
3904 const char (&Str)[StrLen]) {
3909 if (TemplateArgs.
size() != 2)
3912 if (!
isCharType(TemplateArgs[0].getAsType()))
3921 bool CXXNameMangler::mangleStandardSubstitution(
const NamedDecl *ND) {
3923 if (
const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) {
3948 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
3958 if (TemplateArgs.
size() != 3)
3961 if (!
isCharType(TemplateArgs[0].getAsType()))
3998 void CXXNameMangler::addSubstitution(
QualType T) {
4001 addSubstitution(RT->getDecl());
4006 uintptr_t TypePtr =
reinterpret_cast<uintptr_t
>(T.
getAsOpaquePtr());
4007 addSubstitution(TypePtr);
4010 void CXXNameMangler::addSubstitution(
TemplateName Template) {
4012 return addSubstitution(TD);
4018 void CXXNameMangler::addSubstitution(uintptr_t Ptr) {
4019 assert(!Substitutions.count(Ptr) &&
"Substitution already exists!");
4020 Substitutions[Ptr] = SeqID++;
4033 void ItaniumMangleContextImpl::mangleCXXName(
const NamedDecl *D,
4035 assert((isa<FunctionDecl>(D) || isa<VarDecl>(D)) &&
4036 "Invalid mangleName() call, argument is not a variable or function!");
4037 assert(!isa<CXXConstructorDecl>(D) && !isa<CXXDestructorDecl>(D) &&
4038 "Invalid mangleName() call on 'structor decl!");
4041 getASTContext().getSourceManager(),
4042 "Mangling declaration");
4044 CXXNameMangler Mangler(*
this, Out, D);
4051 CXXNameMangler Mangler(*
this, Out, D, Type);
4058 CXXNameMangler Mangler(*
this, Out, D, Type);
4064 CXXNameMangler Mangler(*
this, Out, D,
Ctor_Comdat);
4070 CXXNameMangler Mangler(*
this, Out, D,
Dtor_Comdat);
4074 void ItaniumMangleContextImpl::mangleThunk(
const CXXMethodDecl *MD,
4084 assert(!isa<CXXDestructorDecl>(MD) &&
4085 "Use mangleCXXDtor for destructor decls!");
4086 CXXNameMangler Mangler(*
this, Out);
4087 Mangler.getStream() <<
"_ZT";
4089 Mangler.getStream() <<
'c';
4100 Mangler.mangleFunctionEncoding(MD);
4103 void ItaniumMangleContextImpl::mangleCXXDtorThunk(
4108 CXXNameMangler Mangler(*
this, Out, DD, Type);
4109 Mangler.getStream() <<
"_ZT";
4112 Mangler.mangleCallOffset(ThisAdjustment.
NonVirtual,
4115 Mangler.mangleFunctionEncoding(DD);
4119 void ItaniumMangleContextImpl::mangleStaticGuardVariable(
const VarDecl *D,
4123 CXXNameMangler Mangler(*
this, Out);
4124 Mangler.getStream() <<
"_ZGV";
4125 Mangler.mangleName(D);
4128 void ItaniumMangleContextImpl::mangleDynamicInitializer(
const VarDecl *MD,
4133 Out <<
"__cxx_global_var_init";
4136 void ItaniumMangleContextImpl::mangleDynamicAtExitDestructor(
const VarDecl *D,
4139 CXXNameMangler Mangler(*
this, Out);
4140 Mangler.getStream() <<
"__dtor_";
4141 if (shouldMangleDeclName(D))
4144 Mangler.getStream() << D->
getName();
4147 void ItaniumMangleContextImpl::mangleSEHFilterExpression(
4148 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
4149 CXXNameMangler Mangler(*
this, Out);
4150 Mangler.getStream() <<
"__filt_";
4151 if (shouldMangleDeclName(EnclosingDecl))
4152 Mangler.mangle(EnclosingDecl);
4154 Mangler.getStream() << EnclosingDecl->
getName();
4157 void ItaniumMangleContextImpl::mangleSEHFinallyBlock(
4158 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
4159 CXXNameMangler Mangler(*
this, Out);
4160 Mangler.getStream() <<
"__fin_";
4161 if (shouldMangleDeclName(EnclosingDecl))
4162 Mangler.mangle(EnclosingDecl);
4164 Mangler.getStream() << EnclosingDecl->
getName();
4167 void ItaniumMangleContextImpl::mangleItaniumThreadLocalInit(
const VarDecl *D,
4170 CXXNameMangler Mangler(*
this, Out);
4171 Mangler.getStream() <<
"_ZTH";
4172 Mangler.mangleName(D);
4176 ItaniumMangleContextImpl::mangleItaniumThreadLocalWrapper(
const VarDecl *D,
4179 CXXNameMangler Mangler(*
this, Out);
4180 Mangler.getStream() <<
"_ZTW";
4181 Mangler.mangleName(D);
4184 void ItaniumMangleContextImpl::mangleReferenceTemporary(
const VarDecl *D,
4185 unsigned ManglingNumber,
4189 CXXNameMangler Mangler(*
this, Out);
4190 Mangler.getStream() <<
"_ZGR";
4191 Mangler.mangleName(D);
4192 assert(ManglingNumber > 0 &&
"Reference temporary mangling number is zero!");
4193 Mangler.mangleSeqID(ManglingNumber - 1);
4196 void ItaniumMangleContextImpl::mangleCXXVTable(
const CXXRecordDecl *RD,
4199 CXXNameMangler Mangler(*
this, Out);
4200 Mangler.getStream() <<
"_ZTV";
4201 Mangler.mangleNameOrStandardSubstitution(RD);
4204 void ItaniumMangleContextImpl::mangleCXXVTT(
const CXXRecordDecl *RD,
4207 CXXNameMangler Mangler(*
this, Out);
4208 Mangler.getStream() <<
"_ZTT";
4209 Mangler.mangleNameOrStandardSubstitution(RD);
4212 void ItaniumMangleContextImpl::mangleCXXCtorVTable(
const CXXRecordDecl *RD,
4217 CXXNameMangler Mangler(*
this, Out);
4218 Mangler.getStream() <<
"_ZTC";
4219 Mangler.mangleNameOrStandardSubstitution(RD);
4220 Mangler.getStream() <<
Offset;
4221 Mangler.getStream() <<
'_';
4222 Mangler.mangleNameOrStandardSubstitution(Type);
4225 void ItaniumMangleContextImpl::mangleCXXRTTI(
QualType Ty, raw_ostream &Out) {
4227 assert(!Ty.
hasQualifiers() &&
"RTTI info cannot have top-level qualifiers");
4228 CXXNameMangler Mangler(*
this, Out);
4229 Mangler.getStream() <<
"_ZTI";
4230 Mangler.mangleType(Ty);
4233 void ItaniumMangleContextImpl::mangleCXXRTTIName(
QualType Ty,
4236 CXXNameMangler Mangler(*
this, Out);
4237 Mangler.getStream() <<
"_ZTS";
4238 Mangler.mangleType(Ty);
4241 void ItaniumMangleContextImpl::mangleTypeName(
QualType Ty, raw_ostream &Out) {
4242 mangleCXXRTTIName(Ty, Out);
4245 void ItaniumMangleContextImpl::mangleStringLiteral(
const StringLiteral *, raw_ostream &) {
4246 llvm_unreachable(
"Can't mangle string literals");
4251 return new ItaniumMangleContextImpl(Context, Diags);
unsigned getNumElements() const
A call to an overloaded operator written using operator syntax.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
Defines the clang::ASTContext interface.
unsigned getNumInits() const
DeclarationName getMember() const
Retrieve the name of the member that this expression refers to.
Expr * getSizeExpr() const
const Type * Ty
The locally-unqualified type.
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
unsigned arg_size() const
Retrieve the number of arguments.
The "enum" keyword introduces the elaborated-type-specifier.
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
llvm::iterator_range< pack_iterator > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
PointerType - C99 6.7.5.1 - Pointer Declarators.
Represents the dependent type named by a dependently-scoped typename using declaration, e.g.
A (possibly-)qualified type.
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
TemplateName getReplacement() const
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
__auto_type (GNU extension)
The COMDAT used for ctors.
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
FunctionType - C99 6.7.5.3 - Function Declarators.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program...
bool isArgumentType() const
IdentifierInfo * getCXXLiteralIdentifier() const
getCXXLiteralIdentifier - If this name is the name of a literal operator, retrieve the identifier ass...
EnumConstantDecl - An instance of this object exists for each enum constant that is defined...
OverloadedOperatorKind getOperator() const
Return the overloaded operator to which this template name refers.
bool isGlobalDelete() const
Defines the SourceManager interface.
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
Represents a qualified type name for which the type name is dependent.
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
The template argument is an expression, and we've not resolved it to one of the other forms yet...
ConstExprIterator const_arg_iterator
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
Decl - This represents one declaration (or definition), e.g.
static bool isStreamCharSpecialization(const ClassTemplateSpecializationDecl *SD, const char(&Str)[StrLen])
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Defines the C++ template declaration subclasses.
Represents a C++11 auto or C++14 decltype(auto) type.
TemplateSpecializationType(TemplateName T, const TemplateArgument *Args, unsigned NumArgs, QualType Canon, QualType Aliased)
QualType getPointeeType() const
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
The base class of the type hierarchy.
bool hasLinkage() const
Determine whether this declaration has linkage.
int64_t NonVirtual
The non-virtual adjustment from the derived object to its nearest virtual base.
DependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, unsigned NumArgs, const TemplateArgument *Args, QualType Canon)
unsigned getLength() const
Efficiently return the length of this identifier info.
std::unique_ptr< llvm::MemoryBuffer > Buffer
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
InitListExpr * getSyntacticForm() const
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
NamespaceDecl - Represent a C++ namespace.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
Represents a call to a C++ constructor.
bool hasExplicitTemplateArgs() const
Determines whether this lookup had explicit template arguments.
static bool isParenthesizedADLCallee(const CallExpr *call)
Look at the callee of the given call expression and determine if it's a parenthesized id-expression w...
bool isDecltypeAuto() const
bool isBooleanType() const
A container of type source information.
unsigned getIndex() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Represents a C++ constructor within a class.
unsigned getNumTemplateArgs() const
A template template parameter that has been substituted for some other template name.
Default closure variant of a ctor.
const llvm::APInt & getSize() const
void * getAsOpaquePtr() const
An identifier, stored as an IdentifierInfo*.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
unsigned getBlockManglingNumber() const
const Expr * getCallee() const
ObjCLifetime getObjCLifetime() const
Represents an empty template argument, e.g., one that has not been deduced.
AutoTypeKeyword getKeyword() const
A this pointer adjustment.
Represents a variable template specialization, which refers to a variable template with a given set o...
ObjCMethodDecl - Represents an instance or class method declaration.
Expr * IgnoreImplicit() LLVM_READONLY
IgnoreImplicit - Skip past any implicit AST nodes which might surround this expression.
A namespace, stored as a NamespaceDecl*.
UnaryExprOrTypeTrait getKind() const
A C++ throw-expression (C++ [except.throw]).
bool isSpecialized() const
Determine whether this object type is "specialized", meaning that it has type arguments.
ParmVarDecl - Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
static const TemplateDecl * isTemplate(const NamedDecl *ND, const TemplateArgumentList *&TemplateArgs)
The collection of all-type qualifiers we support.
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
unsigned getNumParams() const
RecordDecl - Represents a struct/union/class.
bool isOpenCLSpecificType() const
DeclarationName getMemberName() const
Retrieve the name of the member that this expression refers to.
const IdentifierInfo * getIdentifier() const
Retrieve the type named by the typename specifier as an identifier.
QualType getElementType() const
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
static bool isTypeSubstitutable(Qualifiers Quals, const Type *Ty)
Represents a class type in Objective C.
Expr * getSizeExpr() const
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Represents a dependent template name that cannot be resolved prior to template instantiation.
bool isIdentifier() const
Determine whether this template name refers to an identifier.
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
bool isIdentifier() const
Predicate functions for querying what type of name this is.
bool isReferenceType() const
bool isImplicitCXXThis() const
Whether this expression is an implicit reference to 'this' in C++.
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm()
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
bool isTranslationUnit() const
unsigned getCVRQualifiers() const
unsigned size() const
Retrieve the number of template arguments in this template argument list.
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
Represents the result of substituting a set of types for a template type parameter pack...
TypeSourceInfo * getLambdaTypeInfo() const
Expr * getArg(unsigned I)
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
The this pointer adjustment as well as an optional return adjustment for a thunk. ...
Expr * getUnderlyingExpr() const
Describes an C or C++ initializer list.
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
An rvalue reference type, per C++11 [dcl.ref].
unsigned getLambdaManglingNumber() const
If this is the closure type of a lambda expression, retrieve the number to be used for name mangling ...
A qualified template name, where the qualification is kept to describe the source code as written...
An lvalue ref-qualifier was provided (&).
static ItaniumMangleContext * create(ASTContext &Context, DiagnosticsEngine &Diags)
QualType getBaseType() const
Gets the base type of this object type.
QualType getReturnType() const
The "struct" keyword introduces the elaborated-type-specifier.
const TemplateArgument & getArg(unsigned Idx) const
Retrieve a specific template argument as a type.
UnresolvedUsingTypenameDecl * getDecl() const
Expr * getInitializer()
The initializer of this new-expression.
bool isExternC() const
Determines whether this variable is a variable with external, C linkage.
Expr * getExprOperand() const
static bool isStdNamespace(const DeclContext *DC)
Concrete class used by the front-end to report problems and issues.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
Represents a typeof (or typeof) expression (a GCC extension).
A builtin binary operation expression such as "x + y" or "x <= y".
InitializationStyle getInitializationStyle() const
The kind of initializer this new-expression has.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
RecordDecl * getDecl() const
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies this declaration.
TemplateDecl * getTemplateDecl() const
The template declaration to which this qualified name refers.
QualType getSignatureParameterType(QualType T) const
Retrieve the parameter type as adjusted for use in the signature of a function, decaying array and fu...
Enums/classes describing ABI related information about constructors, destructors and thunks...
TypeClass getTypeClass() const
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this __uuidof() expression after various required adjustments (removing...
struct clang::ThisAdjustment::VirtualAdjustment::@113 Itanium
Represents a C++ member access expression where the actual member referenced could not be resolved be...
This represents the body of a CapturedStmt, and serves as its DeclContext.
detail::InMemoryDirectory::const_iterator I
is ARM Neon polynomial vector
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
arg_iterator placement_arg_end()
Represents an extended vector type where either the type or size is dependent.
This object can be modified without requiring retains or releases.
bool addressSpaceMapManglingFor(unsigned AS) const
Represents a K&R-style 'int foo()' function, which has no information available about its arguments...
bool isInstantiationDependent() const
Whether this template argument is dependent on a template parameter.
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
QualType getInjectedSpecializationType() const
ConditionalOperator - The ?: ternary operator.
unsigned getNumDecls() const
Gets the number of declarations in the unresolved set.
QualType getParamType(unsigned i) const
Represents a prototype with parameter type info, e.g.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the member name.
A dependent template name that has not been resolved to a template (or set of templates).
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
union clang::ReturnAdjustment::VirtualAdjustment Virtual
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
NamedDecl * getFirstQualifierFoundInScope() const
Retrieve the first part of the nested-name-specifier that was found in the scope of the member access...
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
Represents an array type in C++ whose size is a value-dependent expression.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
CXXDtorType
C++ destructor types.
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
QualType getPointeeType() const
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
static const DeclContext * IgnoreLinkageSpecDecls(const DeclContext *DC)
StringRef getName() const
Return the actual identifier string.
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
Declaration of a template type parameter.
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
Represents a C++ destructor within a class.
New-expression has a C++11 list-initializer.
bool hasExplicitTemplateArgs() const
Determines whether this member expression actually had a C++ template argument list explicitly specif...
ArgKind getKind() const
Return the kind of stored template argument.
const ParmVarDecl * getParamDecl(unsigned i) const
DeclContext * getDeclContext()
A structure for storing the information associated with a substituted template template parameter...
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode. ...
bool isImplicitAccess() const
True if this is an implicit access, i.e., one in which the member being accessed was not written in t...
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents a C++ template name within the type system.
Represents the type decltype(expr) (C++11).
static SVal getValue(SVal val, SValBuilder &svalBuilder)
Defines the clang::TypeLoc interface and its subclasses.
A namespace alias, stored as a NamespaceAliasDecl*.
Decl * getLambdaContextDecl() const
Retrieve the declaration that provides additional context for a lambda, when the normal declaration c...
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
static StringRef mangleAArch64VectorBase(const BuiltinType *EltType)
QualType getAllocatedType() const
Expr * getSubExpr() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isFunctionOrMethod() const
Qualifiers Quals
The local qualifiers.
QualType getCXXNameType() const
getCXXNameType - If this name is one of the C++ names (of a constructor, destructor, or conversion function), return the type associated with that name.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion, return the pattern as a template name.
bool isExternallyVisible() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Represents a GCC generic vector type.
An lvalue reference type, per C++11 [dcl.ref].
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
QualType getElementType() const
A type, stored as a Type*.
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
The COMDAT used for dtors.
TypedefNameDecl * getTypedefNameForAnonDecl() const
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1...
int64_t NonVirtual
The non-virtual adjustment from the derived object to its nearest virtual base.
decls_iterator decls_begin() const
unsigned getNumTemplateArgs() const
static bool hasMangledSubstitutionQualifiers(QualType T)
Determine whether the given type has any qualifiers that are relevant for substitutions.
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
A template template parameter pack that has been substituted for a template template argument pack...
There is no lifetime qualification on this type.
is AltiVec 'vector Pixel'
Assigning into this object requires the old value to be released and the new value to be retained...
Encodes a location in the source.
TemplateArgumentLoc const * getTemplateArgs() const
unsigned getNumParams() const
getNumParams - Return the number of parameters this function must have based on its FunctionType...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
const TemplateArgument * iterator
QualType getElementType() const
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
Represents typeof(type), a GCC extension.
Interfaces are the core concept in Objective-C for object oriented design.
bool isBuiltinType() const
Helper methods to distinguish type categories.
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
TagDecl - Represents the declaration of a struct/union/class/enum.
LanguageLinkage
Describes the different kinds of language linkage (C++ [dcl.link]) that an entity may have...
VectorKind getVectorKind() const
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
Represents a static or instance method of a struct/union/class.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
No ref-qualifier was provided.
bool isImplicitAccess() const
True if this is an implicit access, i.e.
struct clang::ReturnAdjustment::VirtualAdjustment::@111 Itanium
bool hasInitializer() const
Whether this new-expression has any initializer at all.
is AltiVec 'vector bool ...'
RefQualifierKind
The kind of C++11 ref-qualifier associated with a function type.
ParmVarDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
int64_t VCallOffsetOffset
The offset (in bytes), relative to the address point, of the virtual call offset. ...
const IdentifierInfo * getIdentifier() const
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '...
An rvalue ref-qualifier was provided (&&).
Assigning into this object requires a lifetime extension.
QualType getType() const
Return the type wrapped by this type source info.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
CXXCtorType
C++ constructor types.
CXXMethodDecl * getLambdaStaticInvoker() const
Retrieve the lambda static invoker, the address of which is returned by the conversion operator...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
The injected class name of a C++ class template or class template partial specialization.
QualType getPointeeType() const
A qualified reference to a name whose declaration cannot yet be resolved.
Represents a pack expansion of types.
Decl * getBlockManglingContextDecl() const
ArrayRef< QualType > getTypeArgs() const
Retrieve the type arguments of this object type (semantically).
Expr * getSizeExpr() const
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
Base class for declarations which introduce a typedef-name.
Represents a reference to a function parameter pack that has been substituted but not yet expanded...
bool isAnonymousStructOrUnion() const
isAnonymousStructOrUnion - Whether this is an anonymous struct or union.
Represents a template argument.
QualType getAsType() const
Retrieve the type for a type template argument.
Represents a template name that was expressed as a qualified name.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
const Expr * getSubExpr() const
ThisAdjustment This
The this pointer adjustment.
void * getAsVoidPointer() const
Retrieve the template name as a void pointer.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this typeid() expression after various required adjustments (removing r...
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
The base class of all kinds of template declarations (e.g., class, function, etc.).
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
TemplateArgumentLoc const * getTemplateArgs() const
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
bool isKindOfType() const
Whether this ia a "__kindof" type (semantically).
The template argument is a pack expansion of a template name that was provided for a template templat...
TemplateName getCanonicalTemplateName(TemplateName Name) const
Retrieves the "canonical" template name that refers to a given template.
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
const llvm::APSInt & getInitVal() const
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
NamespaceDecl * getOriginalNamespace()
Get the original (first) namespace declaration.
DeclarationName - The name of a declaration.
The "union" keyword introduces the elaborated-type-specifier.
The "class" keyword introduces the elaborated-type-specifier.
int64_t VBaseOffsetOffset
The offset (in bytes), relative to the address point of the virtual base class offset.
bool isTypeOperand() const
unsigned getFunctionScopeDepth() const
detail::InMemoryDirectory::const_iterator E
A pointer to member type per C++ 8.3.3 - Pointers to members.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
ExplicitCastExpr - An explicit cast written in the source code.
A type that was preceded by the 'template' keyword, stored as a Type*.
bool isLambda() const
Determine whether this class describes a lambda function object.
union clang::ThisAdjustment::VirtualAdjustment Virtual
llvm::APFloat getValue() const
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
Represents a pointer to an Objective C object.
Not an overloaded operator.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Complex values, per C99 6.2.5p11.
Location wrapper for a TemplateArgument.
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
const T * getAs() const
Member-template getAs<specific type>'.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
unsigned getTypeQuals() const
QualType getCanonicalType() const
LanguageLinkage getLanguageLinkage() const
Compute the language linkage.
QualType getIntegralType() const
Retrieve the type of the integral value.
ExtVectorType - Extended vector type.
ReturnAdjustment Return
The return adjustment.
Expr * getExprOperand() const
unsigned getAddressSpace() const
const Expr * getSubExpr() const
The template argument is a type.
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
The template argument is actually a parameter pack.
arg_iterator placement_arg_begin()
QualType getPointeeType() const
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
A template argument list.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
const Type * getClass() const
Reading or writing from this object requires a barrier call.
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
bool hasAddressSpace() const
bool isDependent() const
Whether this template argument is dependent on a template parameter such that its result can change f...
const FieldDecl * findFirstNamedDataMember() const
Finds the first data member which has a name.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
ConstExprIterator const_arg_iterator
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
Represents a C++ struct/union/class.
The template argument is a template name that was provided for a template template parameter...
Represents a C array with an unspecified size.
ElaboratedTypeKeyword getKeyword() const
A structure for storing the information associated with an overloaded template name.
Declaration of a class template.
This class is used for builtin types like 'int'.
static bool isCharSpecialization(QualType T, const char *Name)
Returns whether a given type is a template specialization of a given name with a single argument of t...
static bool isCharType(QualType T)
QualType getParamTypeForDecl() const
Copying closure variant of a ctor.
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
DeclarationName getName() const
Gets the name looked up.
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
static Qualifiers fromCVRMask(unsigned CVR)
TagDecl * getDecl() const
static Decl::Kind getKind(const Decl *D)
unsigned getTargetAddressSpace(QualType T) const
A reference to a declared variable, function, enum, etc.
QualType getElementType() const
bool hasQualifiers() const
Determine whether this type has any qualifiers.
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
const Expr * getInit(unsigned Init) const
A set of overloaded template declarations.
NamedDecl - This represents a decl with a name.
NestedNameSpecifier * getQualifier() const
Fetches the nested-name qualifier, if one was given.
Represents a C array with a specified size that is not an integer-constant-expression.
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
static bool isStd(const NamespaceDecl *NS)
Return whether a given namespace is the 'std' namespace.
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char, signed char, short, int, long..], or an enum decl which has a signed representation.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
bool isTypeOperand() const
The global specifier '::'. There is no stored value.
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the type.
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '...
The "__interface" keyword introduces the elaborated-type-specifier.
Represents the canonical version of C arrays with a specified constant size.
Declaration of a template function.
Attr - This represents one attribute.
A single template declaration.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
PrettyStackTraceDecl - If a crash occurs, indicate that it happened when doing something to a specifi...
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
QualType getArgumentType() const
QualType getDeducedType() const
Get the type deduced for this auto type, or null if it's either not been deduced or was deduced to a ...