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 void mangleCXXVTableBitSet(
const CXXRecordDecl *RD, raw_ostream &)
override;
179 bool getNextDiscriminator(
const NamedDecl *ND,
unsigned &disc) {
185 if (
const TagDecl *Tag = dyn_cast<TagDecl>(ND)) {
186 if (Tag->getName().empty() && !Tag->getTypedefNameForAnonDecl())
192 unsigned discriminator = getASTContext().getManglingNumber(ND);
193 if (discriminator == 1)
195 disc = discriminator - 2;
200 unsigned &discriminator = Uniquifier[ND];
201 if (!discriminator) {
202 const DeclContext *DC = getEffectiveDeclContext(ND);
203 discriminator = ++Discriminator[std::make_pair(DC, ND->
getIdentifier())];
205 if (discriminator == 1)
207 disc = discriminator-2;
214 class CXXNameMangler {
215 ItaniumMangleContextImpl &
Context;
227 class FunctionTypeDepthState {
230 enum { InResultTypeMask = 1 };
233 FunctionTypeDepthState() : Bits(0) {}
236 unsigned getDepth()
const {
241 bool isInResultType()
const {
242 return Bits & InResultTypeMask;
245 FunctionTypeDepthState push() {
246 FunctionTypeDepthState tmp = *
this;
247 Bits = (Bits & ~InResultTypeMask) + 2;
251 void enterResultType() {
252 Bits |= InResultTypeMask;
255 void leaveResultType() {
256 Bits &= ~InResultTypeMask;
259 void pop(FunctionTypeDepthState saved) {
260 assert(getDepth() == saved.getDepth() + 1);
266 llvm::DenseMap<uintptr_t, unsigned> Substitutions;
271 CXXNameMangler(ItaniumMangleContextImpl &
C, raw_ostream &Out_,
276 assert(!D || (!isa<CXXDestructorDecl>(D) &&
277 !isa<CXXConstructorDecl>(D)));
279 CXXNameMangler(ItaniumMangleContextImpl &C, raw_ostream &Out_,
283 CXXNameMangler(ItaniumMangleContextImpl &C, raw_ostream &Out_,
290 if (Out.str()[0] ==
'\01')
294 char *result = abi::__cxa_demangle(Out.str().str().c_str(), 0, 0, &status);
295 assert(status == 0 &&
"Could not demangle mangled name!");
299 raw_ostream &getStream() {
return Out; }
302 void mangleCallOffset(int64_t NonVirtual, int64_t Virtual);
303 void mangleNumber(
const llvm::APSInt &I);
304 void mangleNumber(int64_t Number);
305 void mangleFloat(
const llvm::APFloat &F);
307 void mangleSeqID(
unsigned SeqID);
310 void mangleNameOrStandardSubstitution(
const NamedDecl *ND);
314 bool mangleSubstitution(
const NamedDecl *ND);
315 bool mangleSubstitution(
QualType T);
317 bool mangleSubstitution(uintptr_t Ptr);
322 bool mangleStandardSubstitution(
const NamedDecl *ND);
324 void addSubstitution(
const NamedDecl *ND) {
327 addSubstitution(reinterpret_cast<uintptr_t>(ND));
331 void addSubstitution(uintptr_t Ptr);
334 bool recursive =
false);
337 unsigned KnownArity = UnknownArity);
341 unsigned NumTemplateArgs);
342 void mangleUnqualifiedName(
const NamedDecl *ND) {
343 mangleUnqualifiedName(ND, ND->
getDeclName(), UnknownArity);
346 unsigned KnownArity);
347 void mangleUnscopedName(
const NamedDecl *ND);
348 void mangleUnscopedTemplateName(
const TemplateDecl *ND);
351 void mangleLocalName(
const Decl *D);
352 void mangleBlockForPrefix(
const BlockDecl *Block);
353 void mangleUnqualifiedBlock(
const BlockDecl *Block);
356 bool NoFunction=
false);
359 unsigned NumTemplateArgs);
361 void manglePrefix(
const DeclContext *DC,
bool NoFunction=
false);
363 void mangleTemplatePrefix(
const TemplateDecl *ND,
bool NoFunction=
false);
365 bool mangleUnresolvedTypeOrSimpleId(
QualType DestroyedType,
366 StringRef Prefix =
"");
375 #define ABSTRACT_TYPE(CLASS, PARENT)
376 #define NON_CANONICAL_TYPE(CLASS, PARENT)
377 #define TYPE(CLASS, PARENT) void mangleType(const CLASS##Type *T);
378 #include "clang/AST/TypeNodes.def"
380 void mangleType(
const TagType*);
383 bool MangleReturnType);
384 void mangleNeonVectorType(
const VectorType *T);
385 void mangleAArch64NeonVectorType(
const VectorType *T);
387 void mangleIntegerLiteral(
QualType T,
const llvm::APSInt &
Value);
388 void mangleMemberExprBase(
const Expr *base,
bool isArrow);
389 void mangleMemberExpr(
const Expr *base,
bool isArrow,
393 unsigned knownArity);
394 void mangleCastExpression(
const Expr *E, StringRef CastEncoding);
395 void mangleInitListElements(
const InitListExpr *InitList);
396 void mangleExpression(
const Expr *E,
unsigned Arity = UnknownArity);
402 unsigned NumTemplateArgs);
406 void mangleTemplateParameter(
unsigned Index);
413 bool ItaniumMangleContextImpl::shouldMangleCXXName(
const NamedDecl *D) {
418 if (FD->
hasAttr<OverloadableAttr>())
436 if (!getASTContext().getLangOpts().CPlusPlus)
446 const DeclContext *DC = getEffectiveDeclContext(D);
450 DC = getEffectiveParentContext(DC);
452 !isa<VarTemplateSpecializationDecl>(D))
459 void CXXNameMangler::mangle(
const NamedDecl *D) {
465 mangleFunctionEncoding(FD);
466 else if (
const VarDecl *VD = dyn_cast<VarDecl>(D))
469 mangleName(IFD->getAnonField());
471 mangleName(cast<FieldDecl>(D));
474 void CXXNameMangler::mangleFunctionEncoding(
const FunctionDecl *FD) {
479 if (!
Context.shouldMangleDeclName(FD))
482 if (FD->
hasAttr<EnableIfAttr>()) {
483 FunctionTypeDepthState Saved = FunctionTypeDepth.push();
484 Out <<
"Ua9enable_ifI";
487 for (AttrVec::const_reverse_iterator I = FD->
getAttrs().rbegin(),
490 EnableIfAttr *EIA = dyn_cast<EnableIfAttr>(*I);
494 mangleExpression(EIA->getCond());
498 FunctionTypeDepth.pop(Saved);
517 bool MangleReturnType =
false;
519 if (!(isa<CXXConstructorDecl>(FD) || isa<CXXDestructorDecl>(FD) ||
520 isa<CXXConversionDecl>(FD)))
521 MangleReturnType =
true;
524 FD = PrimaryTemplate->getTemplatedDecl();
532 while (isa<LinkageSpecDecl>(DC)) {
533 DC = getEffectiveParentContext(DC);
542 ->isTranslationUnit())
546 return II && II->
isStr(
"std");
555 return isStd(cast<NamespaceDecl>(DC));
561 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)){
570 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
571 TemplateArgs = &Spec->getTemplateArgs();
572 return Spec->getSpecializedTemplate();
577 dyn_cast<VarTemplateSpecializationDecl>(ND)) {
578 TemplateArgs = &Spec->getTemplateArgs();
579 return Spec->getSpecializedTemplate();
585 void CXXNameMangler::mangleName(
const NamedDecl *ND) {
591 const DeclContext *DC = getEffectiveDeclContext(ND);
597 if (isLocalContainerContext(DC) && ND->
hasLinkage() && !isLambda(ND))
599 DC = getEffectiveParentContext(DC);
600 else if (GetLocalClassDecl(ND)) {
611 mangleUnscopedTemplateName(TD);
612 mangleTemplateArgs(*TemplateArgs);
616 mangleUnscopedName(ND);
620 if (isLocalContainerContext(DC)) {
625 mangleNestedName(ND, DC);
629 unsigned NumTemplateArgs) {
633 mangleUnscopedTemplateName(TD);
634 mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
636 mangleNestedName(TD, TemplateArgs, NumTemplateArgs);
640 void CXXNameMangler::mangleUnscopedName(
const NamedDecl *ND) {
647 mangleUnqualifiedName(ND);
650 void CXXNameMangler::mangleUnscopedTemplateName(
const TemplateDecl *ND) {
653 if (mangleSubstitution(ND))
657 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND))
658 mangleTemplateParameter(TTP->getIndex());
665 void CXXNameMangler::mangleUnscopedTemplateName(
TemplateName Template) {
669 return mangleUnscopedTemplateName(TD);
671 if (mangleSubstitution(Template))
675 assert(Dependent &&
"Not a dependent template name?");
677 mangleSourceName(Id);
679 mangleOperatorName(Dependent->
getOperator(), UnknownArity);
681 addSubstitution(Template);
684 void CXXNameMangler::mangleFloat(
const llvm::APFloat &f) {
698 llvm::APInt valueBits = f.bitcastToAPInt();
699 unsigned numCharacters = (valueBits.getBitWidth() + 3) / 4;
700 assert(numCharacters != 0);
704 buffer.set_size(numCharacters);
707 for (
unsigned stringIndex = 0; stringIndex != numCharacters; ++stringIndex) {
709 unsigned digitBitIndex = 4 * (numCharacters - stringIndex - 1);
712 llvm::integerPart hexDigit
713 = valueBits.getRawData()[digitBitIndex / llvm::integerPartWidth];
714 hexDigit >>= (digitBitIndex % llvm::integerPartWidth);
718 static const char charForHex[16] = {
719 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
720 '8',
'9',
'a',
'b',
'c',
'd',
'e',
'f'
722 buffer[stringIndex] = charForHex[hexDigit];
725 Out.write(buffer.data(), numCharacters);
728 void CXXNameMangler::mangleNumber(
const llvm::APSInt &
Value) {
729 if (Value.isSigned() && Value.isNegative()) {
731 Value.abs().print(Out,
false);
733 Value.print(Out,
false);
737 void CXXNameMangler::mangleNumber(int64_t Number) {
747 void CXXNameMangler::mangleCallOffset(int64_t NonVirtual, int64_t Virtual) {
755 mangleNumber(NonVirtual);
761 mangleNumber(NonVirtual);
763 mangleNumber(Virtual);
769 if (!mangleSubstitution(
QualType(TST, 0))) {
770 mangleTemplatePrefix(TST->getTemplateName());
775 mangleTemplateArgs(TST->getArgs(), TST->getNumArgs());
778 }
else if (
const auto *DTST =
780 if (!mangleSubstitution(
QualType(DTST, 0))) {
781 TemplateName Template = getASTContext().getDependentTemplateName(
782 DTST->getQualifier(), DTST->getIdentifier());
783 mangleTemplatePrefix(Template);
788 mangleTemplateArgs(DTST->getArgs(), DTST->getNumArgs());
819 switch (qualifier->
getKind()) {
831 llvm_unreachable(
"Can't mangle __super specifier");
835 mangleUnresolvedPrefix(qualifier->
getPrefix(),
843 mangleUnresolvedPrefix(qualifier->
getPrefix(),
860 mangleUnresolvedPrefix(qualifier->
getPrefix(),
867 if (mangleUnresolvedTypeOrSimpleId(
QualType(type, 0), recursive ?
"N" :
""))
876 mangleUnresolvedPrefix(qualifier->
getPrefix(),
895 unsigned knownArity) {
896 if (qualifier) mangleUnresolvedPrefix(qualifier);
912 mangleOperatorName(name, knownArity);
915 llvm_unreachable(
"Can't mangle a constructor name!");
917 llvm_unreachable(
"Can't mangle a using directive name!");
921 llvm_unreachable(
"Can't mangle Objective-C selector names here!");
925 void CXXNameMangler::mangleUnqualifiedName(
const NamedDecl *ND,
927 unsigned KnownArity) {
928 unsigned Arity = KnownArity;
942 getEffectiveDeclContext(ND)->isFileContext())
945 mangleSourceName(II);
950 assert(ND &&
"mangling empty name without declaration");
953 if (NS->isAnonymousNamespace()) {
955 Out <<
"12_GLOBAL__N_1";
960 if (
const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
975 &&
"Expected anonymous struct or union!");
982 assert(FD->getIdentifier() &&
"Data member name isn't an identifier!");
984 mangleSourceName(FD->getIdentifier());
994 if (isa<ObjCContainerDecl>(ND))
998 const TagDecl *TD = cast<TagDecl>(ND);
1001 "Typedef should not be in another decl context!");
1003 "Typedef was not named!");
1012 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(TD)) {
1013 if (Record->isLambda() && Record->getLambdaManglingNumber()) {
1014 mangleLambda(Record);
1020 unsigned UnnamedMangle = getASTContext().getManglingNumber(TD);
1022 if (UnnamedMangle > 1)
1023 Out << llvm::utostr(UnnamedMangle - 2);
1029 unsigned AnonStructId =
Context.getAnonymousStructId(TD);
1036 Str += llvm::utostr(AnonStructId);
1046 llvm_unreachable(
"Can't mangle Objective-C selector names here!");
1052 mangleCXXCtorType(static_cast<CXXCtorType>(
StructorType));
1063 mangleCXXDtorType(static_cast<CXXDtorType>(
StructorType));
1071 if (ND && Arity == UnknownArity) {
1072 Arity = cast<FunctionDecl>(ND)->getNumParams();
1075 if (
const auto *MD = dyn_cast<CXXMethodDecl>(ND))
1076 if (!MD->isStatic())
1082 mangleOperatorName(Name, Arity);
1086 llvm_unreachable(
"Can't mangle a using directive name!");
1090 void CXXNameMangler::mangleSourceName(
const IdentifierInfo *II) {
1097 void CXXNameMangler::mangleNestedName(
const NamedDecl *ND,
1106 if (
const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(ND)) {
1112 mangleQualifiers(MethodQuals);
1113 mangleRefQualifier(Method->getRefQualifier());
1119 mangleTemplatePrefix(TD, NoFunction);
1120 mangleTemplateArgs(*TemplateArgs);
1123 manglePrefix(DC, NoFunction);
1124 mangleUnqualifiedName(ND);
1129 void CXXNameMangler::mangleNestedName(
const TemplateDecl *TD,
1131 unsigned NumTemplateArgs) {
1136 mangleTemplatePrefix(TD);
1137 mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
1142 void CXXNameMangler::mangleLocalName(
const Decl *D) {
1148 assert(isa<NamedDecl>(D) || isa<BlockDecl>(D));
1150 const DeclContext *DC = getEffectiveDeclContext(RD ? RD : D);
1155 mangleObjCMethodName(MD);
1156 else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(DC))
1157 mangleBlockForPrefix(BD);
1159 mangleFunctionEncoding(cast<FunctionDecl>(DC));
1174 = dyn_cast<FunctionDecl>(Parm->getDeclContext())) {
1176 unsigned Num = Func->getNumParams() - Parm->getFunctionScopeIndex();
1178 mangleNumber(Num - 2);
1187 mangleUnqualifiedName(RD);
1188 }
else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
1189 manglePrefix(getEffectiveDeclContext(BD),
true );
1190 mangleUnqualifiedBlock(BD);
1192 const NamedDecl *ND = cast<NamedDecl>(D);
1193 mangleNestedName(ND, getEffectiveDeclContext(ND),
true );
1195 }
else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
1199 = dyn_cast_or_null<ParmVarDecl>(BD->getBlockManglingContextDecl())) {
1201 = dyn_cast<FunctionDecl>(Parm->getDeclContext())) {
1203 unsigned Num = Func->getNumParams() - Parm->getFunctionScopeIndex();
1205 mangleNumber(Num - 2);
1210 mangleUnqualifiedBlock(BD);
1212 mangleUnqualifiedName(cast<NamedDecl>(D));
1215 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(RD ? RD : D)) {
1217 if (
Context.getNextDiscriminator(ND, disc)) {
1221 Out <<
"__" << disc <<
'_';
1226 void CXXNameMangler::mangleBlockForPrefix(
const BlockDecl *Block) {
1227 if (GetLocalClassDecl(Block)) {
1228 mangleLocalName(Block);
1231 const DeclContext *DC = getEffectiveDeclContext(Block);
1232 if (isLocalContainerContext(DC)) {
1233 mangleLocalName(Block);
1236 manglePrefix(getEffectiveDeclContext(Block));
1237 mangleUnqualifiedBlock(Block);
1240 void CXXNameMangler::mangleUnqualifiedBlock(
const BlockDecl *Block) {
1243 Context->getDeclContext()->isRecord()) {
1245 = cast<NamedDecl>(
Context)->getIdentifier()) {
1246 mangleSourceName(Name);
1257 Number =
Context.getBlockId(Block,
false);
1264 void CXXNameMangler::mangleLambda(
const CXXRecordDecl *Lambda) {
1276 Context->getDeclContext()->isRecord()) {
1278 = cast<NamedDecl>(
Context)->getIdentifier()) {
1279 mangleSourceName(Name);
1287 getAs<FunctionProtoType>();
1288 mangleBareFunctionType(Proto,
false);
1297 assert(Number > 0 &&
"Lambda should be mangled as an unnamed class");
1299 mangleNumber(Number - 2);
1304 switch (qualifier->
getKind()) {
1310 llvm_unreachable(
"Can't mangle __super specifier");
1335 llvm_unreachable(
"unexpected nested name specifier");
1338 void CXXNameMangler::manglePrefix(
const DeclContext *DC,
bool NoFunction) {
1350 if (NoFunction && isLocalContainerContext(DC))
1353 assert(!isLocalContainerContext(DC));
1355 const NamedDecl *ND = cast<NamedDecl>(DC);
1356 if (mangleSubstitution(ND))
1362 mangleTemplatePrefix(TD);
1363 mangleTemplateArgs(*TemplateArgs);
1365 manglePrefix(getEffectiveDeclContext(ND), NoFunction);
1366 mangleUnqualifiedName(ND);
1369 addSubstitution(ND);
1372 void CXXNameMangler::mangleTemplatePrefix(
TemplateName Template) {
1377 return mangleTemplatePrefix(TD);
1380 manglePrefix(Qualified->getQualifier());
1384 mangleUnqualifiedName(
nullptr, (*Overloaded->begin())->getDeclName(),
1390 assert(Dependent &&
"Unknown template name kind?");
1392 manglePrefix(Qualifier);
1393 mangleUnscopedTemplateName(Template);
1396 void CXXNameMangler::mangleTemplatePrefix(
const TemplateDecl *ND,
1404 if (mangleSubstitution(ND))
1408 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND)) {
1409 mangleTemplateParameter(TTP->getIndex());
1411 manglePrefix(getEffectiveDeclContext(ND), NoFunction);
1415 addSubstitution(ND);
1424 if (mangleSubstitution(TN))
1439 if (isa<TemplateTemplateParmDecl>(TD))
1440 mangleTemplateParameter(cast<TemplateTemplateParmDecl>(TD)->getIndex());
1446 llvm_unreachable(
"can't mangle an overloaded template name as a <type>");
1475 Out <<
"_SUBSTPACK_";
1480 addSubstitution(TN);
1483 bool CXXNameMangler::mangleUnresolvedTypeOrSimpleId(
QualType Ty,
1489 case Type::Adjusted:
1492 case Type::BlockPointer:
1493 case Type::LValueReference:
1494 case Type::RValueReference:
1495 case Type::MemberPointer:
1496 case Type::ConstantArray:
1497 case Type::IncompleteArray:
1498 case Type::VariableArray:
1499 case Type::DependentSizedArray:
1500 case Type::DependentSizedExtVector:
1502 case Type::ExtVector:
1503 case Type::FunctionProto:
1504 case Type::FunctionNoProto:
1506 case Type::Attributed:
1508 case Type::PackExpansion:
1509 case Type::ObjCObject:
1510 case Type::ObjCInterface:
1511 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:
1551 cast<UnresolvedUsingType>(Ty)->getDecl()->getIdentifier());
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_";
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);
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;
1762 llvm_unreachable(
"Not an overloaded operator");
1766 void CXXNameMangler::mangleQualifiers(
Qualifiers Quals) {
1788 ASString =
"AS" + llvm::utostr_32(TargetAS);
1791 default: llvm_unreachable(
"Not a language specific address space");
1802 Out <<
'U' << ASString.size() << ASString;
1805 StringRef LifetimeName;
1816 LifetimeName =
"__weak";
1820 LifetimeName =
"__strong";
1824 LifetimeName =
"__autoreleasing";
1837 if (!LifetimeName.empty())
1838 Out <<
'U' << LifetimeName.size() << LifetimeName;
1844 switch (RefQualifier) {
1858 void CXXNameMangler::mangleObjCMethodName(
const ObjCMethodDecl *MD) {
1859 Context.mangleObjCMethodName(MD, Out);
1875 void CXXNameMangler::mangleType(
QualType T) {
1900 = dyn_cast<TemplateSpecializationType>(T))
1914 const Type *ty = split.
Ty;
1917 if (isSubstitutable && mangleSubstitution(T))
1922 if (quals && isa<ArrayType>(T)) {
1931 mangleQualifiers(quals);
1937 #define ABSTRACT_TYPE(CLASS, PARENT)
1938 #define NON_CANONICAL_TYPE(CLASS, PARENT) \
1940 llvm_unreachable("can't mangle non-canonical type " #CLASS "Type"); \
1942 #define TYPE(CLASS, PARENT) \
1944 mangleType(static_cast<const CLASS##Type*>(ty)); \
1946 #include "clang/AST/TypeNodes.def"
1951 if (isSubstitutable)
1955 void CXXNameMangler::mangleNameOrStandardSubstitution(
const NamedDecl *ND) {
1956 if (!mangleStandardSubstitution(ND))
1960 void CXXNameMangler::mangleType(
const BuiltinType *T) {
1991 case BuiltinType::Void: Out <<
'v';
break;
1992 case BuiltinType::Bool: Out <<
'b';
break;
1993 case BuiltinType::Char_U:
case BuiltinType::Char_S: Out <<
'c';
break;
1994 case BuiltinType::UChar: Out <<
'h';
break;
1995 case BuiltinType::UShort: Out <<
't';
break;
1996 case BuiltinType::UInt: Out <<
'j';
break;
1997 case BuiltinType::ULong: Out <<
'm';
break;
1998 case BuiltinType::ULongLong: Out <<
'y';
break;
1999 case BuiltinType::UInt128: Out <<
'o';
break;
2000 case BuiltinType::SChar: Out <<
'a';
break;
2001 case BuiltinType::WChar_S:
2002 case BuiltinType::WChar_U: Out <<
'w';
break;
2003 case BuiltinType::Char16: Out <<
"Ds";
break;
2004 case BuiltinType::Char32: Out <<
"Di";
break;
2005 case BuiltinType::Short: Out <<
's';
break;
2006 case BuiltinType::Int: Out <<
'i';
break;
2007 case BuiltinType::Long: Out <<
'l';
break;
2008 case BuiltinType::LongLong: Out <<
'x';
break;
2009 case BuiltinType::Int128: Out <<
'n';
break;
2010 case BuiltinType::Half: Out <<
"Dh";
break;
2011 case BuiltinType::Float: Out <<
'f';
break;
2012 case BuiltinType::Double: Out <<
'd';
break;
2013 case BuiltinType::LongDouble:
2014 Out << (getASTContext().getTargetInfo().useFloat128ManglingForLongDouble()
2018 case BuiltinType::NullPtr: Out <<
"Dn";
break;
2020 #define BUILTIN_TYPE(Id, SingletonId)
2021 #define PLACEHOLDER_TYPE(Id, SingletonId) \
2022 case BuiltinType::Id:
2023 #include "clang/AST/BuiltinTypes.def"
2024 case BuiltinType::Dependent:
2025 llvm_unreachable(
"mangling a placeholder type");
2026 case BuiltinType::ObjCId: Out <<
"11objc_object";
break;
2027 case BuiltinType::ObjCClass: Out <<
"10objc_class";
break;
2028 case BuiltinType::ObjCSel: Out <<
"13objc_selector";
break;
2029 case BuiltinType::OCLImage1d: Out <<
"11ocl_image1d";
break;
2030 case BuiltinType::OCLImage1dArray: Out <<
"16ocl_image1darray";
break;
2031 case BuiltinType::OCLImage1dBuffer: Out <<
"17ocl_image1dbuffer";
break;
2032 case BuiltinType::OCLImage2d: Out <<
"11ocl_image2d";
break;
2033 case BuiltinType::OCLImage2dArray: Out <<
"16ocl_image2darray";
break;
2034 case BuiltinType::OCLImage3d: Out <<
"11ocl_image3d";
break;
2035 case BuiltinType::OCLSampler: Out <<
"11ocl_sampler";
break;
2036 case BuiltinType::OCLEvent: Out <<
"9ocl_event";
break;
2052 mangleBareFunctionType(T,
true);
2060 llvm_unreachable(
"Can't mangle K&R function prototypes");
2062 void CXXNameMangler::mangleBareFunctionType(
const FunctionType *T,
2063 bool MangleReturnType) {
2069 FunctionTypeDepthState saved = FunctionTypeDepth.push();
2072 if (MangleReturnType) {
2073 FunctionTypeDepth.enterResultType();
2075 FunctionTypeDepth.leaveResultType();
2082 FunctionTypeDepth.pop(saved);
2089 FunctionTypeDepth.pop(saved);
2104 void CXXNameMangler::mangleType(
const EnumType *T) {
2105 mangleType(static_cast<const TagType*>(T));
2107 void CXXNameMangler::mangleType(
const RecordType *T) {
2108 mangleType(static_cast<const TagType*>(T));
2110 void CXXNameMangler::mangleType(
const TagType *T) {
2118 Out <<
'A' << T->
getSize() <<
'_';
2167 mangleType(PointeeType);
2172 mangleTemplateParameter(T->
getIndex());
2181 Out <<
"_SUBSTPACK_";
2185 void CXXNameMangler::mangleType(
const PointerType *T) {
2207 void CXXNameMangler::mangleType(
const ComplexType *T) {
2215 void CXXNameMangler::mangleNeonVectorType(
const VectorType *T) {
2217 assert(EltType->
isBuiltinType() &&
"Neon vector element not a BuiltinType");
2218 const char *EltName =
nullptr;
2220 switch (cast<BuiltinType>(EltType)->getKind()) {
2221 case BuiltinType::SChar:
2222 case BuiltinType::UChar:
2223 EltName =
"poly8_t";
2225 case BuiltinType::Short:
2226 case BuiltinType::UShort:
2227 EltName =
"poly16_t";
2229 case BuiltinType::ULongLong:
2230 EltName =
"poly64_t";
2232 default: llvm_unreachable(
"unexpected Neon polynomial vector element type");
2235 switch (cast<BuiltinType>(EltType)->
getKind()) {
2236 case BuiltinType::SChar: EltName =
"int8_t";
break;
2237 case BuiltinType::UChar: EltName =
"uint8_t";
break;
2238 case BuiltinType::Short: EltName =
"int16_t";
break;
2239 case BuiltinType::UShort: EltName =
"uint16_t";
break;
2240 case BuiltinType::Int: EltName =
"int32_t";
break;
2241 case BuiltinType::UInt: EltName =
"uint32_t";
break;
2242 case BuiltinType::LongLong: EltName =
"int64_t";
break;
2243 case BuiltinType::ULongLong: EltName =
"uint64_t";
break;
2244 case BuiltinType::Double: EltName =
"float64_t";
break;
2245 case BuiltinType::Float: EltName =
"float32_t";
break;
2246 case BuiltinType::Half: EltName =
"float16_t";
break;
2248 llvm_unreachable(
"unexpected Neon vector element type");
2251 const char *BaseName =
nullptr;
2253 getASTContext().getTypeSize(EltType));
2255 BaseName =
"__simd64_";
2257 assert(BitSize == 128 &&
"Neon vector type not 64 or 128 bits");
2258 BaseName =
"__simd128_";
2260 Out << strlen(BaseName) + strlen(EltName);
2261 Out << BaseName << EltName;
2266 case BuiltinType::SChar:
2268 case BuiltinType::Short:
2270 case BuiltinType::Int:
2272 case BuiltinType::Long:
2273 case BuiltinType::LongLong:
2275 case BuiltinType::UChar:
2277 case BuiltinType::UShort:
2279 case BuiltinType::UInt:
2281 case BuiltinType::ULong:
2282 case BuiltinType::ULongLong:
2284 case BuiltinType::Half:
2286 case BuiltinType::Float:
2288 case BuiltinType::Double:
2291 llvm_unreachable(
"Unexpected vector element base type");
2298 void CXXNameMangler::mangleAArch64NeonVectorType(
const VectorType *T) {
2300 assert(EltType->
isBuiltinType() &&
"Neon vector element not a BuiltinType");
2305 assert((BitSize == 64 || BitSize == 128) &&
2306 "Neon vector type not 64 or 128 bits");
2310 switch (cast<BuiltinType>(EltType)->getKind()) {
2311 case BuiltinType::UChar:
2314 case BuiltinType::UShort:
2317 case BuiltinType::ULong:
2318 case BuiltinType::ULongLong:
2322 llvm_unreachable(
"unexpected Neon polynomial vector element type");
2327 std::string TypeName =
2328 (
"__" + EltName +
"x" + llvm::utostr(T->
getNumElements()) +
"_t").str();
2329 Out << TypeName.length() << TypeName;
2340 void CXXNameMangler::mangleType(
const VectorType *T) {
2343 llvm::Triple Target = getASTContext().getTargetInfo().getTriple();
2344 llvm::Triple::ArchType Arch =
2345 getASTContext().getTargetInfo().getTriple().getArch();
2346 if ((Arch == llvm::Triple::aarch64 ||
2347 Arch == llvm::Triple::aarch64_be) && !Target.isOSDarwin())
2348 mangleAArch64NeonVectorType(T);
2350 mangleNeonVectorType(T);
2362 mangleType(static_cast<const VectorType*>(T));
2384 Out <<
"U8__kindof";
2389 llvm::raw_svector_ostream QualOS(QualStr);
2390 QualOS <<
"objcproto";
2391 for (
const auto *I : T->
quals()) {
2392 StringRef name = I->getName();
2393 QualOS << name.size() << name;
2396 Out <<
'U' << QualStr.size() << QualStr;
2405 mangleType(typeArg);
2411 Out <<
"U13block_pointer";
2426 if (mangleSubstitution(
QualType(T, 0)))
2465 llvm_unreachable(
"unexpected keyword for dependent type name");
2480 getASTContext().getDependentTemplateName(T->
getQualifier(),
2482 mangleTemplatePrefix(Prefix);
2491 void CXXNameMangler::mangleType(
const TypeOfType *T) {
2503 void CXXNameMangler::mangleType(
const DecltypeType *T) {
2514 if (isa<DeclRefExpr>(E) ||
2515 isa<MemberExpr>(E) ||
2516 isa<UnresolvedLookupExpr>(E) ||
2517 isa<DependentScopeDeclRefExpr>(E) ||
2518 isa<CXXDependentScopeMemberExpr>(E) ||
2519 isa<UnresolvedMemberExpr>(E))
2523 mangleExpression(E);
2543 void CXXNameMangler::mangleType(
const AutoType *T) {
2552 void CXXNameMangler::mangleType(
const AtomicType *T) {
2559 void CXXNameMangler::mangleIntegerLiteral(
QualType T,
2560 const llvm::APSInt &Value) {
2567 Out << (Value.getBoolValue() ?
'1' :
'0');
2569 mangleNumber(Value);
2575 void CXXNameMangler::mangleMemberExprBase(
const Expr *
Base,
bool IsArrow) {
2578 if (!RT->getDecl()->isAnonymousStructOrUnion())
2583 Base = ME->getBase();
2584 IsArrow = ME->isArrow();
2593 Out << (IsArrow ?
"pt" :
"dt");
2594 mangleExpression(Base);
2599 void CXXNameMangler::mangleMemberExpr(
const Expr *base,
2608 mangleMemberExprBase(base, isArrow);
2609 mangleUnresolvedName(qualifier, member, arity);
2622 if (callee == fn)
return false;
2626 if (!lookup)
return false;
2643 void CXXNameMangler::mangleCastExpression(
const Expr *E, StringRef CastEncoding) {
2645 Out << CastEncoding;
2650 void CXXNameMangler::mangleInitListElements(
const InitListExpr *InitList) {
2652 InitList = Syntactic;
2653 for (
unsigned i = 0, e = InitList->
getNumInits(); i != e; ++i)
2654 mangleExpression(InitList->
getInit(i));
2657 void CXXNameMangler::mangleExpression(
const Expr *E,
unsigned Arity) {
2681 QualType ImplicitlyConvertedToType;
2684 switch (E->getStmtClass()) {
2685 case Expr::NoStmtClass:
2686 #define ABSTRACT_STMT(Type)
2687 #define EXPR(Type, Base)
2688 #define STMT(Type, Base) \
2689 case Expr::Type##Class:
2690 #include "clang/AST/StmtNodes.inc"
2695 case Expr::AddrLabelExprClass:
2696 case Expr::DesignatedInitUpdateExprClass:
2697 case Expr::ImplicitValueInitExprClass:
2698 case Expr::NoInitExprClass:
2699 case Expr::ParenListExprClass:
2700 case Expr::LambdaExprClass:
2701 case Expr::MSPropertyRefExprClass:
2702 case Expr::TypoExprClass:
2703 llvm_unreachable(
"unexpected statement kind");
2706 case Expr::BlockExprClass:
2707 case Expr::ChooseExprClass:
2708 case Expr::CompoundLiteralExprClass:
2709 case Expr::DesignatedInitExprClass:
2710 case Expr::ExtVectorElementExprClass:
2711 case Expr::GenericSelectionExprClass:
2712 case Expr::ObjCEncodeExprClass:
2713 case Expr::ObjCIsaExprClass:
2714 case Expr::ObjCIvarRefExprClass:
2715 case Expr::ObjCMessageExprClass:
2716 case Expr::ObjCPropertyRefExprClass:
2717 case Expr::ObjCProtocolExprClass:
2718 case Expr::ObjCSelectorExprClass:
2719 case Expr::ObjCStringLiteralClass:
2720 case Expr::ObjCBoxedExprClass:
2721 case Expr::ObjCArrayLiteralClass:
2722 case Expr::ObjCDictionaryLiteralClass:
2723 case Expr::ObjCSubscriptRefExprClass:
2724 case Expr::ObjCIndirectCopyRestoreExprClass:
2725 case Expr::OffsetOfExprClass:
2726 case Expr::PredefinedExprClass:
2727 case Expr::ShuffleVectorExprClass:
2728 case Expr::ConvertVectorExprClass:
2729 case Expr::StmtExprClass:
2730 case Expr::TypeTraitExprClass:
2731 case Expr::ArrayTypeTraitExprClass:
2732 case Expr::ExpressionTraitExprClass:
2733 case Expr::VAArgExprClass:
2734 case Expr::CUDAKernelCallExprClass:
2735 case Expr::AsTypeExprClass:
2736 case Expr::PseudoObjectExprClass:
2737 case Expr::AtomicExprClass:
2742 "cannot yet mangle expression type %0");
2744 << E->getStmtClassName() << E->getSourceRange();
2748 case Expr::CXXUuidofExprClass: {
2752 Out <<
"u8__uuidoft";
2756 Out <<
"u8__uuidofz";
2757 mangleExpression(UuidExp, Arity);
2763 case Expr::BinaryConditionalOperatorClass: {
2767 "?: operator with omitted middle operand cannot be mangled");
2769 << E->getStmtClassName() << E->getSourceRange();
2774 case Expr::OpaqueValueExprClass:
2775 llvm_unreachable(
"cannot mangle opaque value; mangling wrong thing?");
2777 case Expr::InitListExprClass: {
2779 mangleInitListElements(cast<InitListExpr>(E));
2784 case Expr::CXXDefaultArgExprClass:
2785 mangleExpression(cast<CXXDefaultArgExpr>(E)->getExpr(), Arity);
2788 case Expr::CXXDefaultInitExprClass:
2789 mangleExpression(cast<CXXDefaultInitExpr>(E)->getExpr(), Arity);
2792 case Expr::CXXStdInitializerListExprClass:
2793 mangleExpression(cast<CXXStdInitializerListExpr>(E)->getSubExpr(), Arity);
2796 case Expr::SubstNonTypeTemplateParmExprClass:
2797 mangleExpression(cast<SubstNonTypeTemplateParmExpr>(E)->getReplacement(),
2801 case Expr::UserDefinedLiteralClass:
2804 case Expr::CXXMemberCallExprClass:
2805 case Expr::CallExprClass: {
2806 const CallExpr *CE = cast<CallExpr>(E);
2825 if (isa<PackExpansionExpr>(Arg))
2826 CallArity = UnknownArity;
2828 mangleExpression(CE->
getCallee(), CallArity);
2830 mangleExpression(Arg);
2835 case Expr::CXXNewExprClass: {
2838 Out << (New->
isArray() ?
"na" :
"nw");
2841 mangleExpression(*I);
2855 mangleExpression(*I);
2856 }
else if (
const ParenListExpr *PLE = dyn_cast<ParenListExpr>(Init)) {
2857 for (
unsigned i = 0, e = PLE->getNumExprs(); i != e; ++i)
2858 mangleExpression(PLE->getExpr(i));
2860 isa<InitListExpr>(Init)) {
2862 mangleInitListElements(cast<InitListExpr>(Init));
2864 mangleExpression(Init);
2870 case Expr::CXXPseudoDestructorExprClass: {
2871 const auto *PDE = cast<CXXPseudoDestructorExpr>(E);
2872 if (
const Expr *Base = PDE->getBase())
2873 mangleMemberExprBase(Base, PDE->isArrow());
2878 mangleUnresolvedPrefix(Qualifier,
2880 mangleUnresolvedTypeOrSimpleId(ScopeInfo->getType());
2884 if (!mangleUnresolvedTypeOrSimpleId(ScopeInfo->getType()))
2887 }
else if (Qualifier) {
2888 mangleUnresolvedPrefix(Qualifier);
2892 QualType DestroyedType = PDE->getDestroyedType();
2893 mangleUnresolvedTypeOrSimpleId(DestroyedType);
2897 case Expr::MemberExprClass: {
2905 case Expr::UnresolvedMemberExprClass: {
2915 case Expr::CXXDependentScopeMemberExprClass: {
2917 = cast<CXXDependentScopeMemberExpr>(E);
2927 case Expr::UnresolvedLookupExprClass: {
2939 case Expr::CXXUnresolvedConstructExprClass: {
2945 if (N != 1) Out <<
'_';
2946 for (
unsigned I = 0; I != N; ++I) mangleExpression(CE->
getArg(I));
2947 if (N != 1) Out <<
'E';
2951 case Expr::CXXConstructExprClass: {
2952 const auto *CE = cast<CXXConstructExpr>(E);
2953 if (!CE->isListInitialization() || CE->isStdInitListInitialization()) {
2955 CE->getNumArgs() >= 1 &&
2956 (CE->getNumArgs() == 1 || isa<CXXDefaultArgExpr>(CE->
getArg(1))) &&
2957 "implicit CXXConstructExpr must have one argument");
2958 return mangleExpression(cast<CXXConstructExpr>(E)->getArg(0));
2961 for (
auto *E : CE->arguments())
2962 mangleExpression(E);
2967 case Expr::CXXTemporaryObjectExprClass: {
2968 const auto *CE = cast<CXXTemporaryObjectExpr>(E);
2969 unsigned N = CE->getNumArgs();
2970 bool List = CE->isListInitialization();
2977 if (!List && N != 1)
2979 if (CE->isStdInitListInitialization()) {
2985 auto *ILE = cast<InitListExpr>(SILE->getSubExpr()->IgnoreImplicit());
2986 mangleInitListElements(ILE);
2988 for (
auto *E : CE->arguments())
2989 mangleExpression(E);
2996 case Expr::CXXScalarValueInitExprClass:
3002 case Expr::CXXNoexceptExprClass:
3004 mangleExpression(cast<CXXNoexceptExpr>(E)->getOperand());
3007 case Expr::UnaryExprOrTypeTraitExprClass: {
3021 : ImplicitlyConvertedToType;
3023 mangleIntegerLiteral(T, V);
3037 "cannot yet mangle vec_step expression");
3045 "cannot yet mangle __builtin_omp_required_simd_align expression");
3059 case Expr::CXXThrowExprClass: {
3072 case Expr::CXXTypeidExprClass: {
3086 case Expr::CXXDeleteExprClass: {
3096 case Expr::UnaryOperatorClass: {
3104 case Expr::ArraySubscriptExprClass: {
3110 mangleExpression(AE->
getLHS());
3111 mangleExpression(AE->
getRHS());
3115 case Expr::CompoundAssignOperatorClass:
3116 case Expr::BinaryOperatorClass: {
3123 mangleExpression(BO->
getLHS());
3124 mangleExpression(BO->
getRHS());
3128 case Expr::ConditionalOperatorClass: {
3130 mangleOperatorName(OO_Conditional, 3);
3131 mangleExpression(CO->
getCond());
3132 mangleExpression(CO->
getLHS(), Arity);
3133 mangleExpression(CO->
getRHS(), Arity);
3137 case Expr::ImplicitCastExprClass: {
3138 ImplicitlyConvertedToType = E->
getType();
3139 E = cast<ImplicitCastExpr>(E)->getSubExpr();
3143 case Expr::ObjCBridgedCastExprClass: {
3146 StringRef
Kind = cast<ObjCBridgedCastExpr>(E)->getBridgeKindName();
3147 Out <<
"v1U" << Kind.size() <<
Kind;
3151 case Expr::CStyleCastExprClass:
3152 mangleCastExpression(E,
"cv");
3155 case Expr::CXXFunctionalCastExprClass: {
3156 auto *Sub = cast<ExplicitCastExpr>(E)->getSubExpr()->IgnoreImplicit();
3158 if (
auto *CCE = dyn_cast<CXXConstructExpr>(Sub))
3159 if (CCE->getParenOrBraceRange().isInvalid())
3160 Sub = CCE->getArg(0)->IgnoreImplicit();
3161 if (
auto *StdInitList = dyn_cast<CXXStdInitializerListExpr>(Sub))
3162 Sub = StdInitList->getSubExpr()->IgnoreImplicit();
3163 if (
auto *IL = dyn_cast<InitListExpr>(Sub)) {
3166 mangleInitListElements(IL);
3169 mangleCastExpression(E,
"cv");
3174 case Expr::CXXStaticCastExprClass:
3175 mangleCastExpression(E,
"sc");
3177 case Expr::CXXDynamicCastExprClass:
3178 mangleCastExpression(E,
"dc");
3180 case Expr::CXXReinterpretCastExprClass:
3181 mangleCastExpression(E,
"rc");
3183 case Expr::CXXConstCastExprClass:
3184 mangleCastExpression(E,
"cc");
3187 case Expr::CXXOperatorCallExprClass: {
3192 for (
unsigned i = 0; i != NumArgs; ++i)
3193 mangleExpression(CE->
getArg(i));
3197 case Expr::ParenExprClass:
3198 mangleExpression(cast<ParenExpr>(E)->getSubExpr(), Arity);
3201 case Expr::DeclRefExprClass: {
3202 const NamedDecl *D = cast<DeclRefExpr>(E)->getDecl();
3213 mangleFunctionParam(cast<ParmVarDecl>(D));
3216 case Decl::EnumConstant: {
3222 case Decl::NonTypeTemplateParm: {
3224 mangleTemplateParameter(PD->
getIndex());
3233 case Expr::SubstNonTypeTemplateParmPackExprClass:
3238 Out <<
"_SUBSTPACK_";
3241 case Expr::FunctionParmPackExprClass: {
3244 Out <<
"v110_SUBSTPACK";
3249 case Expr::DependentScopeDeclRefExprClass: {
3261 case Expr::CXXBindTemporaryExprClass:
3262 mangleExpression(cast<CXXBindTemporaryExpr>(E)->getSubExpr());
3265 case Expr::ExprWithCleanupsClass:
3266 mangleExpression(cast<ExprWithCleanups>(E)->getSubExpr(), Arity);
3269 case Expr::FloatingLiteralClass: {
3278 case Expr::CharacterLiteralClass:
3281 Out << cast<CharacterLiteral>(E)->
getValue();
3286 case Expr::ObjCBoolLiteralExprClass:
3288 Out << (cast<ObjCBoolLiteralExpr>(E)->
getValue() ?
'1' :
'0');
3292 case Expr::CXXBoolLiteralExprClass:
3294 Out << (cast<CXXBoolLiteralExpr>(E)->
getValue() ?
'1' :
'0');
3298 case Expr::IntegerLiteralClass: {
3301 Value.setIsSigned(
true);
3306 case Expr::ImaginaryLiteralClass: {
3313 dyn_cast<FloatingLiteral>(IE->
getSubExpr())) {
3315 mangleFloat(llvm::APFloat(Imag->getValue().getSemantics()));
3317 mangleFloat(Imag->getValue());
3322 Value.setIsSigned(
true);
3323 mangleNumber(Value);
3329 case Expr::StringLiteralClass: {
3332 assert(isa<ConstantArrayType>(E->
getType()));
3338 case Expr::GNUNullExprClass:
3342 case Expr::CXXNullPtrLiteralExprClass: {
3347 case Expr::PackExpansionExprClass:
3349 mangleExpression(cast<PackExpansionExpr>(E)->getPattern());
3352 case Expr::SizeOfPackExprClass: {
3354 const NamedDecl *Pack = cast<SizeOfPackExpr>(E)->getPack();
3356 mangleTemplateParameter(TTP->getIndex());
3358 = dyn_cast<NonTypeTemplateParmDecl>(Pack))
3359 mangleTemplateParameter(NTTP->getIndex());
3361 = dyn_cast<TemplateTemplateParmDecl>(Pack))
3362 mangleTemplateParameter(TempTP->getIndex());
3364 mangleFunctionParam(cast<ParmVarDecl>(Pack));
3368 case Expr::MaterializeTemporaryExprClass: {
3369 mangleExpression(cast<MaterializeTemporaryExpr>(E)->GetTemporaryExpr());
3373 case Expr::CXXFoldExprClass: {
3374 auto *FE = cast<CXXFoldExpr>(E);
3375 if (FE->isLeftFold())
3376 Out << (FE->getInit() ?
"fL" :
"fl");
3378 Out << (FE->getInit() ?
"fR" :
"fr");
3388 mangleExpression(FE->getLHS());
3390 mangleExpression(FE->getRHS());
3394 case Expr::CXXThisExprClass:
3428 void CXXNameMangler::mangleFunctionParam(
const ParmVarDecl *parm) {
3435 assert(parmDepth < FunctionTypeDepth.getDepth());
3436 unsigned nestingDepth = FunctionTypeDepth.getDepth() - parmDepth;
3437 if (FunctionTypeDepth.isInResultType())
3440 if (nestingDepth == 0) {
3443 Out <<
"fL" << (nestingDepth - 1) <<
'p';
3451 &&
"parameter's type is still an array type?");
3455 if (parmIndex != 0) {
3456 Out << (parmIndex - 1);
3461 void CXXNameMangler::mangleCXXCtorType(
CXXCtorType T) {
3478 llvm_unreachable(
"closure constructors don't exist for the Itanium ABI!");
3482 void CXXNameMangler::mangleCXXDtorType(
CXXDtorType T) {
3504 void CXXNameMangler::mangleTemplateArgs(
3516 for (
unsigned i = 0, e = AL.
size(); i != e; ++i)
3517 mangleTemplateArg(AL[i]);
3521 void CXXNameMangler::mangleTemplateArgs(
const TemplateArgument *TemplateArgs,
3522 unsigned NumTemplateArgs) {
3525 for (
unsigned i = 0; i != NumTemplateArgs; ++i)
3526 mangleTemplateArg(TemplateArgs[i]);
3540 llvm_unreachable(
"Cannot mangle NULL template argument");
3559 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
3561 if (isa<VarDecl>(D) || isa<FunctionDecl>(D)) {
3570 mangleExpression(E);
3584 if (compensateMangling) {
3586 mangleOperatorName(OO_Amp, 1);
3595 if (compensateMangling)
3611 mangleTemplateArg(
P);
3617 void CXXNameMangler::mangleTemplateParameter(
unsigned Index) {
3623 Out <<
'T' << (Index - 1) <<
'_';
3626 void CXXNameMangler::mangleSeqID(
unsigned SeqID) {
3629 else if (SeqID > 1) {
3637 for (; SeqID != 0; SeqID /= 36) {
3638 unsigned C = SeqID % 36;
3639 *I++ = (C < 10 ?
'0' + C :
'A' + C - 10);
3642 Out.write(I.base(), I - BufferRef.rbegin());
3647 void CXXNameMangler::mangleExistingSubstitution(
QualType type) {
3648 bool result = mangleSubstitution(type);
3649 assert(result &&
"no existing substitution for type");
3653 void CXXNameMangler::mangleExistingSubstitution(
TemplateName tname) {
3654 bool result = mangleSubstitution(tname);
3655 assert(result &&
"no existing substitution for template name");
3661 bool CXXNameMangler::mangleSubstitution(
const NamedDecl *ND) {
3663 if (mangleStandardSubstitution(ND))
3667 return mangleSubstitution(reinterpret_cast<uintptr_t>(ND));
3677 bool CXXNameMangler::mangleSubstitution(
QualType T) {
3680 return mangleSubstitution(RT->getDecl());
3683 uintptr_t TypePtr =
reinterpret_cast<uintptr_t
>(T.
getAsOpaquePtr());
3685 return mangleSubstitution(TypePtr);
3688 bool CXXNameMangler::mangleSubstitution(
TemplateName Template) {
3690 return mangleSubstitution(TD);
3693 return mangleSubstitution(
3697 bool CXXNameMangler::mangleSubstitution(uintptr_t Ptr) {
3698 llvm::DenseMap<uintptr_t, unsigned>::iterator I = Substitutions.find(Ptr);
3699 if (I == Substitutions.end())
3702 unsigned SeqID = I->second;
3736 if (TemplateArgs.
size() != 1)
3739 if (!
isCharType(TemplateArgs[0].getAsType()))
3745 template <std::
size_t StrLen>
3747 const char (&Str)[StrLen]) {
3752 if (TemplateArgs.
size() != 2)
3755 if (!
isCharType(TemplateArgs[0].getAsType()))
3764 bool CXXNameMangler::mangleStandardSubstitution(
const NamedDecl *ND) {
3766 if (
const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) {
3791 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
3801 if (TemplateArgs.
size() != 3)
3804 if (!
isCharType(TemplateArgs[0].getAsType()))
3841 void CXXNameMangler::addSubstitution(
QualType T) {
3844 addSubstitution(RT->getDecl());
3849 uintptr_t TypePtr =
reinterpret_cast<uintptr_t
>(T.
getAsOpaquePtr());
3850 addSubstitution(TypePtr);
3853 void CXXNameMangler::addSubstitution(
TemplateName Template) {
3855 return addSubstitution(TD);
3861 void CXXNameMangler::addSubstitution(uintptr_t Ptr) {
3862 assert(!Substitutions.count(Ptr) &&
"Substitution already exists!");
3863 Substitutions[Ptr] = SeqID++;
3876 void ItaniumMangleContextImpl::mangleCXXName(
const NamedDecl *D,
3878 assert((isa<FunctionDecl>(D) || isa<VarDecl>(D)) &&
3879 "Invalid mangleName() call, argument is not a variable or function!");
3880 assert(!isa<CXXConstructorDecl>(D) && !isa<CXXDestructorDecl>(D) &&
3881 "Invalid mangleName() call on 'structor decl!");
3884 getASTContext().getSourceManager(),
3885 "Mangling declaration");
3887 CXXNameMangler Mangler(*
this, Out, D);
3894 CXXNameMangler Mangler(*
this, Out, D, Type);
3901 CXXNameMangler Mangler(*
this, Out, D, Type);
3907 CXXNameMangler Mangler(*
this, Out, D,
Ctor_Comdat);
3913 CXXNameMangler Mangler(*
this, Out, D,
Dtor_Comdat);
3917 void ItaniumMangleContextImpl::mangleThunk(
const CXXMethodDecl *MD,
3927 assert(!isa<CXXDestructorDecl>(MD) &&
3928 "Use mangleCXXDtor for destructor decls!");
3929 CXXNameMangler Mangler(*
this, Out);
3930 Mangler.getStream() <<
"_ZT";
3932 Mangler.getStream() <<
'c';
3943 Mangler.mangleFunctionEncoding(MD);
3946 void ItaniumMangleContextImpl::mangleCXXDtorThunk(
3951 CXXNameMangler Mangler(*
this, Out, DD, Type);
3952 Mangler.getStream() <<
"_ZT";
3955 Mangler.mangleCallOffset(ThisAdjustment.
NonVirtual,
3958 Mangler.mangleFunctionEncoding(DD);
3962 void ItaniumMangleContextImpl::mangleStaticGuardVariable(
const VarDecl *D,
3966 CXXNameMangler Mangler(*
this, Out);
3967 Mangler.getStream() <<
"_ZGV";
3968 Mangler.mangleName(D);
3971 void ItaniumMangleContextImpl::mangleDynamicInitializer(
const VarDecl *MD,
3976 Out <<
"__cxx_global_var_init";
3979 void ItaniumMangleContextImpl::mangleDynamicAtExitDestructor(
const VarDecl *D,
3982 CXXNameMangler Mangler(*
this, Out);
3983 Mangler.getStream() <<
"__dtor_";
3984 if (shouldMangleDeclName(D))
3987 Mangler.getStream() << D->
getName();
3990 void ItaniumMangleContextImpl::mangleSEHFilterExpression(
3991 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
3992 CXXNameMangler Mangler(*
this, Out);
3993 Mangler.getStream() <<
"__filt_";
3994 if (shouldMangleDeclName(EnclosingDecl))
3995 Mangler.mangle(EnclosingDecl);
3997 Mangler.getStream() << EnclosingDecl->
getName();
4000 void ItaniumMangleContextImpl::mangleSEHFinallyBlock(
4001 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
4002 CXXNameMangler Mangler(*
this, Out);
4003 Mangler.getStream() <<
"__fin_";
4004 if (shouldMangleDeclName(EnclosingDecl))
4005 Mangler.mangle(EnclosingDecl);
4007 Mangler.getStream() << EnclosingDecl->
getName();
4010 void ItaniumMangleContextImpl::mangleItaniumThreadLocalInit(
const VarDecl *D,
4013 CXXNameMangler Mangler(*
this, Out);
4014 Mangler.getStream() <<
"_ZTH";
4015 Mangler.mangleName(D);
4019 ItaniumMangleContextImpl::mangleItaniumThreadLocalWrapper(
const VarDecl *D,
4022 CXXNameMangler Mangler(*
this, Out);
4023 Mangler.getStream() <<
"_ZTW";
4024 Mangler.mangleName(D);
4027 void ItaniumMangleContextImpl::mangleReferenceTemporary(
const VarDecl *D,
4028 unsigned ManglingNumber,
4032 CXXNameMangler Mangler(*
this, Out);
4033 Mangler.getStream() <<
"_ZGR";
4034 Mangler.mangleName(D);
4035 assert(ManglingNumber > 0 &&
"Reference temporary mangling number is zero!");
4036 Mangler.mangleSeqID(ManglingNumber - 1);
4039 void ItaniumMangleContextImpl::mangleCXXVTable(
const CXXRecordDecl *RD,
4042 CXXNameMangler Mangler(*
this, Out);
4043 Mangler.getStream() <<
"_ZTV";
4044 Mangler.mangleNameOrStandardSubstitution(RD);
4047 void ItaniumMangleContextImpl::mangleCXXVTT(
const CXXRecordDecl *RD,
4050 CXXNameMangler Mangler(*
this, Out);
4051 Mangler.getStream() <<
"_ZTT";
4052 Mangler.mangleNameOrStandardSubstitution(RD);
4055 void ItaniumMangleContextImpl::mangleCXXCtorVTable(
const CXXRecordDecl *RD,
4060 CXXNameMangler Mangler(*
this, Out);
4061 Mangler.getStream() <<
"_ZTC";
4062 Mangler.mangleNameOrStandardSubstitution(RD);
4063 Mangler.getStream() <<
Offset;
4064 Mangler.getStream() <<
'_';
4065 Mangler.mangleNameOrStandardSubstitution(Type);
4068 void ItaniumMangleContextImpl::mangleCXXRTTI(
QualType Ty, raw_ostream &Out) {
4070 assert(!Ty.
hasQualifiers() &&
"RTTI info cannot have top-level qualifiers");
4071 CXXNameMangler Mangler(*
this, Out);
4072 Mangler.getStream() <<
"_ZTI";
4073 Mangler.mangleType(Ty);
4076 void ItaniumMangleContextImpl::mangleCXXRTTIName(
QualType Ty,
4079 CXXNameMangler Mangler(*
this, Out);
4080 Mangler.getStream() <<
"_ZTS";
4081 Mangler.mangleType(Ty);
4084 void ItaniumMangleContextImpl::mangleTypeName(
QualType Ty, raw_ostream &Out) {
4085 mangleCXXRTTIName(Ty, Out);
4088 void ItaniumMangleContextImpl::mangleCXXVTableBitSet(
const CXXRecordDecl *RD,
4099 CXXNameMangler Mangler(*
this, Out);
4103 void ItaniumMangleContextImpl::mangleStringLiteral(
const StringLiteral *, raw_ostream &) {
4104 llvm_unreachable(
"Can't mangle string literals");
4109 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
getDecl - Get the declaration of this interface.
unsigned arg_size() const
Retrieve the number of arguments.
The "enum" keyword introduces the elaborated-type-specifier.
StringRef getName() const
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
llvm::iterator_range< pack_iterator > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
Represents the dependent type named by a dependently-scoped typename using declaration, e.g. using typename Base<T>::foo; Template instantiation turns these into the underlying type.
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
TemplateName getReplacement() const
bool isSpecificBuiltinType(unsigned K) const
isSpecificBuiltinType - 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.
The COMDAT used for ctors.
IdentifierInfo * getIdentifier() const
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
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
unsigned getNumArgs() const
Retrieve the number of template arguments.
IdentifierInfo * getCXXLiteralIdentifier() const
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.
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
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++1y decltype(auto) type.
QualType getPointeeType() const
IdentifierInfo * getAsIdentifierInfo() const
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.
unsigned getLength() const
Efficiently return the length of this identifier info.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
InitListExpr * getSyntacticForm() const
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)
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.
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*.
unsigned getBlockManglingNumber() const
const Expr * getCallee() const
ObjCLifetime getObjCLifetime() const
Represents an empty template argument, e.g., one that has not been deduced.
A this pointer adjustment.
Represents a variable template specialization, which refers to a variable template with a given set o...
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>". This is safe to be used inside an AST node, in contrast with TemplateArgumentListInfo.
Expr * IgnoreImplicit() LLVM_READONLY
A namespace, stored as a NamespaceDecl*.
UnaryExprOrTypeTrait getKind() const
A C++ throw-expression (C++ [except.throw]).
bool isSpecialized() const
ParmVarDecl - Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
unsigned getNumArgs() const
Retrieve the number of template arguments.
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
static const TemplateDecl * isTemplate(const NamedDecl *ND, const TemplateArgumentList *&TemplateArgs)
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
unsigned getNumParams() const
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...
static bool isTypeSubstitutable(Qualifiers Quals, const Type *Ty)
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.
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++.
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.
struct clang::ReturnAdjustment::VirtualAdjustment::@113 Itanium
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
ASTTemplateArgumentListInfo & getExplicitTemplateArgs()
Describes an C or C++ initializer list.
param_type_range param_types() const
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
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
QualType getReturnType() const
The "struct" keyword introduces the elaborated-type-specifier.
UnresolvedUsingTypenameDecl * getDecl() const
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template.
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
TypeOfExprType (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.
RecordDecl * getDecl() const
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...
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.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
arg_iterator placement_arg_end()
bool addressSpaceMapManglingFor(unsigned AS) const
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
bool isInstantiationDependent() const
Whether this template argument is dependent on a template parameter.
QualType getValueType() const
QualType getInjectedSpecializationType() const
unsigned getNumDecls() const
Gets the number of declarations in the unresolved set.
const FileEntry * getFileEntryForID(FileID FID) const
Returns the FileEntry record for the provided FileID.
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).
ASTTemplateArgumentListInfo & getExplicitTemplateArgs()
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...
struct clang::ThisAdjustment::VirtualAdjustment::@115 Itanium
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
SplitQualType split() const
CXXDtorType
C++ destructor types.
const Type * getTypeForDecl() const
QualType getPointeeType() const
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.
Declaration of a template type parameter.
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs. The actual template arguments (if any) are stored a...
Represents a C++ destructor within a class.
New-expression has a C++11 list-initializer.
bool isTypeAlias() const
Determine if this template specialization type is for a type alias template that has been substituted...
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.
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...
Represents a C++ template name within the type system.
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...
static StringRef mangleAArch64VectorBase(const BuiltinType *EltType)
QualType getAllocatedType() const
Expr * getSubExpr() const
bool isDependentType() const
bool isFunctionOrMethod() const
Qualifiers Quals
The local qualifiers.
QualType getCXXNameType() const
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
DeclarationName getDeclName() const
TemplateArgumentLoc * getTemplateArgs()
Retrieve the template arguments.
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. Entities in anonymous namespaces are external (in c++9...
QualType getElementType() const
A type, stored as a Type*.
The COMDAT used for dtors.
TypedefNameDecl * getTypedefNameForAnonDecl() const
int64_t NonVirtual
The non-virtual adjustment from the derived object to its nearest virtual base.
decls_iterator decls_begin() const
static bool hasMangledSubstitutionQualifiers(QualType T)
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
const IdentifierInfo * getIdentifier() const
A template template parameter pack that has been substituted for a template template argument pack...
There is no lifetime qualification on this type.
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
QualType getElementType() const
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
TypeOfType (GCC extension).
bool isBuiltinType() const
isBuiltinType - returns true if the type is a builtin type.
OverloadedOperatorKind getCXXOverloadedOperator() const
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
ASTTemplateArgumentListInfo & getExplicitTemplateArgs()
Retrieve the explicit template argument list that followed the member template name, if any.
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
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. one in which the member being accessed was not written in th...
bool hasInitializer() const
Whether this new-expression has any initializer at all.
RefQualifierKind
The kind of C++0x ref-qualifier associated with a function type, which determines whether a member fu...
ParmVarDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
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. ...
FileID getMainFileID() const
Returns the FileID of the main source file.
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.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
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.
SourceLocation getExprLoc() const LLVM_READONLY
The injected class name of a C++ class template or class template partial specialization. Used to record that a type was spelled with a bare identifier rather than as a template-id; the equivalent for non-templated classes is just RecordType.
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
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.
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. "delete[] pArray"...
The base class of all kinds of template declarations (e.g., class, function, etc.).
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
bool isKindOfType() const
Whether this ia a "__kindof" type (semantically).
TemplateName getCanonicalTemplateName(TemplateName Name) const
Retrieves the "canonical" template name that refers to a given template.
const llvm::APSInt & getInitVal() const
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
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
unsigned getNumArgs() const
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
Not an overloaded operator.
const TemplateArgument * getArgs() const
Retrieve the template arguments.
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
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.
const TemplateArgument * getArgs() const
Retrieve the template arguments.
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...
NestedNameSpecifier * getQualifier() const
NamespaceDecl * getOriginalNamespace()
Get the original (first) namespace declaration.
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.
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
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
Represents a C++ struct/union/class.
ElaboratedTypeKeyword getKeyword() const
A structure for storing the information associated with an overloaded template name.
Declaration of a class template.
static bool isCharSpecialization(QualType T, const char *Name)
static bool isCharType(QualType T)
QualType getParamTypeForDecl() const
Copying closure variant of a ctor.
Defines the clang::TargetInfo interface.
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. [C99 6.5.1p2].
Represents a type template specialization; the template must be a class template, a type alias templa...
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.
NestedNameSpecifier * getQualifier() const
Fetches the nested-name qualifier, if one was given.
static bool isStd(const NamespaceDecl *NS)
Return whether a given namespace is the 'std' namespace.
bool isSignedIntegerType() const
bool isNull() const
isNull - Return true if this QualType doesn't point to a type yet.
bool isTypeOperand() const
The global specifier '::'. There is no stored value.
const TemplateArgument & getArgument() const
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.
This class handles loading and caching of source files into memory.
Declaration of a template function.
A single template declaration.
bool isIntegerType() const
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
Expr * IgnoreParens() LLVM_READONLY
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 ...