;
47 if(
auto*CD = dyn_cast<CXXConstructorDecl>(DC))
49 else if(
auto*DD = dyn_cast<CXXDestructorDecl>(DC))
56structmsvc_hashing_ostream :
publicllvm::raw_svector_ostream {
60msvc_hashing_ostream(raw_ostream &OS)
61:
llvm::raw_svector_ostream(Buffer), OS(OS) {}
62~msvc_hashing_ostream()
override{
63StringRef MangledName = str();
64 boolStartsWithEscape = MangledName.starts_with(
"\01");
66MangledName = MangledName.drop_front(1);
67 if(MangledName.size() < 4096) {
73llvm::MD5::MD5Result Hash;
74Hasher.update(MangledName);
78llvm::MD5::stringifyResult(Hash, HexString);
82OS <<
"??@"<< HexString <<
'@';
87getLambdaDefaultArgumentDeclContext(
const Decl*
D) {
88 if(
const auto*RD = dyn_cast<CXXRecordDecl>(
D))
90 if(
const auto*Parm =
91dyn_cast_or_null<ParmVarDecl>(RD->getLambdaContextDecl()))
92 returnParm->getDeclContext();
105 if(
const auto*LDADC = getLambdaDefaultArgumentDeclContext(
D))
109 if(
const BlockDecl*BD = dyn_cast<BlockDecl>(
D)) {
111dyn_cast_or_null<ParmVarDecl>(BD->getBlockManglingContextDecl()))
112 returnContextParam->getDeclContext();
116 if(isa<CapturedDecl>(DC) || isa<OMPDeclareReductionDecl>(DC) ||
117isa<OMPDeclareMapperDecl>(DC)) {
118 returngetEffectiveDeclContext(cast<Decl>(DC));
125 returngetEffectiveDeclContext(cast<Decl>(DC));
129 if(
const auto*FTD = dyn_cast<FunctionTemplateDecl>(ND))
132 const auto*FD = cast<FunctionDecl>(ND);
133 if(
const auto*FTD = FD->getPrimaryTemplate())
134 returnFTD->getTemplatedDecl()->getCanonicalDecl();
136 returnFD->getCanonicalDecl();
142 typedefstd::pair<const DeclContext *, IdentifierInfo *> DiscriminatorKeyTy;
143llvm::DenseMap<DiscriminatorKeyTy, unsigned> Discriminator;
144llvm::DenseMap<const NamedDecl *, unsigned> Uniquifier;
145llvm::DenseMap<const CXXRecordDecl *, unsigned> LambdaIds;
146llvm::DenseMap<GlobalDecl, unsigned> SEHFilterIds;
147llvm::DenseMap<GlobalDecl, unsigned> SEHFinallyIds;
152 boolIsAux =
false);
158raw_ostream &Out)
override;
160 boolElideOverrideInfo, raw_ostream &)
override;
162 const ThunkInfo&Thunk,
boolElideOverrideInfo,
163raw_ostream &)
override;
166raw_ostream &Out)
override;
169raw_ostream &Out)
override;
174raw_ostream &Out)
override;
176 boolIsUnaligned, uint32_t NumEntries,
177raw_ostream &Out)
override;
179raw_ostream &Out)
override;
182int32_t VBPtrOffset, uint32_t VBIndex,
183raw_ostream &Out)
override;
186 boolNormalizeIntegers)
override;
188uint32_t NVOffset, int32_t VBPtrOffset,
189uint32_t VBTableOffset, uint32_t Flags,
190raw_ostream &Out)
override;
192raw_ostream &Out)
override;
194raw_ostream &Out)
override;
198raw_ostream &Out)
override;
200 boolNormalizeIntegers)
override;
202raw_ostream &)
override;
205raw_ostream &Out)
override;
208raw_ostream &Out)
override;
210raw_ostream &Out)
override;
212raw_ostream &Out)
override;
214 boolgetNextDiscriminator(
const NamedDecl*ND,
unsigned&disc) {
215 const DeclContext*DC = getEffectiveDeclContext(ND);
221 if(
const auto*RD = dyn_cast<CXXRecordDecl>(ND)) {
222 if(RD->isLambda()) {
235 if(
const TagDecl*Tag = dyn_cast<TagDecl>(ND)) {
236 if(!
Tag->hasNameForLinkage() &&
237!getASTContext().getDeclaratorForUnnamedTagDecl(Tag) &&
243 unsigned&discriminator = Uniquifier[ND];
245discriminator = ++Discriminator[std::make_pair(DC, ND->
getIdentifier())];
246disc = discriminator + 1;
251assert(Lambda->
isLambda() &&
"RD must be a lambda!");
252std::string Name(
"<lambda_");
257 const ParmVarDecl*Parm = dyn_cast_or_null<ParmVarDecl>(LambdaContextDecl);
259Parm ? dyn_cast<FunctionDecl>(Parm->
getDeclContext()) : nullptr;
262 unsignedDefaultArgNo =
264Name += llvm::utostr(DefaultArgNo);
268 if(LambdaManglingNumber)
269LambdaId = LambdaManglingNumber;
271LambdaId = getLambdaIdForDebugInfo(Lambda);
273Name += llvm::utostr(LambdaId);
279assert(RD->
isLambda() &&
"RD must be a lambda!");
282 "RD must not have a mangling number!");
283std::pair<llvm::DenseMap<const CXXRecordDecl *, unsigned>::iterator,
bool>
284Result = LambdaIds.insert(std::make_pair(RD, LambdaIds.size()));
285 returnResult.first->second;
289assert(RD->
isLambda() &&
"RD must be a lambda!");
292 "RD must not have a mangling number!");
294 returnLambdaIds.lookup(RD);
299StringRef getAnonymousNamespaceHash()
const{
300 returnAnonymousNamespaceHash;
304 voidmangleInitFiniStub(
const VarDecl*
D,
charCharCode, raw_ostream &Out);
309classMicrosoftCXXNameMangler {
310MicrosoftMangleContextImpl &Context;
317 unsignedStructorType;
320BackRefVec NameBackReferences;
322 typedefllvm::DenseMap<const void *, unsigned> ArgBackRefMap;
323ArgBackRefMap FunArgBackReferences;
324ArgBackRefMap TemplateArgBackReferences;
326 typedefllvm::DenseMap<const void *, StringRef> TemplateArgStringMap;
327TemplateArgStringMap TemplateArgStrings;
328llvm::BumpPtrAllocator TemplateArgStringStorageAlloc;
329llvm::StringSaver TemplateArgStringStorage;
331 typedefstd::set<std::pair<int, bool>> PassObjectSizeArgsSet;
332PassObjectSizeArgsSet PassObjectSizeArgs;
334 ASTContext&getASTContext()
const{
returnContext.getASTContext(); }
336 const boolPointersAre64Bit;
343 enumQualifierMangleMode { QMM_Drop, QMM_Mangle, QMM_Escape, QMM_Result };
344 enum classTplArgKind { ClassNTTP, StructuralValue };
346MicrosoftCXXNameMangler(MicrosoftMangleContextImpl &
C, raw_ostream &Out_)
347: Context(
C), Out(Out_), Structor(nullptr), StructorType(-1),
348TemplateArgStringStorage(TemplateArgStringStorageAlloc),
349PointersAre64Bit(
C.getASTContext().getTargetInfo().getPointerWidth(
352MicrosoftCXXNameMangler(MicrosoftMangleContextImpl &
C, raw_ostream &Out_,
354: Context(
C), Out(Out_), Structor(getStructor(
D)), StructorType(
Type),
355TemplateArgStringStorage(TemplateArgStringStorageAlloc),
356PointersAre64Bit(
C.getASTContext().getTargetInfo().getPointerWidth(
359MicrosoftCXXNameMangler(MicrosoftMangleContextImpl &
C, raw_ostream &Out_,
361: Context(
C), Out(Out_), Structor(getStructor(
D)), StructorType(
Type),
362TemplateArgStringStorage(TemplateArgStringStorageAlloc),
363PointersAre64Bit(
C.getASTContext().getTargetInfo().getPointerWidth(
366raw_ostream &getStream()
const{
returnOut; }
368 voidmangle(
GlobalDeclGD, StringRef Prefix =
"?");
370 voidmangleFunctionEncoding(
GlobalDeclGD,
boolShouldMangle);
371 voidmangleVariableEncoding(
const VarDecl*VD);
375StringRef Prefix =
"$");
376 voidmangleMemberDataPointerInClassNTTP(
const CXXRecordDecl*,
382StringRef Prefix =
"$");
388 voidmangleMemberFunctionPointerInClassNTTP(
const CXXRecordDecl*RD,
392 voidmangleNumber(int64_t Number);
393 voidmangleNumber(llvm::APSInt Number);
394 voidmangleFloat(llvm::APFloat Number);
395 voidmangleBits(llvm::APInt Number);
397 voidmangleArtificialTagType(
TagTypeKindTK, StringRef UnqualifiedName,
401QualifierMangleMode QMM = QMM_Mangle);
404 boolForceThisQuals =
false,
405 boolMangleExceptionSpec =
true);
406 voidmangleSourceName(StringRef Name);
409 voidmangleAutoReturnType(
QualType T, QualifierMangleMode QMM);
412 boolisStructorDecl(
const NamedDecl*ND)
const{
413 returnND == Structor || getStructor(ND) == Structor;
416 boolis64BitPointer(
QualifiersQuals)
const{
418 returnAddrSpace == LangAS::ptr64 ||
419(PointersAre64Bit && !(AddrSpace == LangAS::ptr32_sptr ||
420AddrSpace == LangAS::ptr32_uptr));
424mangleUnqualifiedName(GD, cast<NamedDecl>(GD.
getDecl())->getDeclName());
429 voidmangleQualifiers(
QualifiersQuals,
boolIsMember);
431 voidmanglePointerCVQualifiers(
QualifiersQuals);
434 voidmangleUnscopedTemplateName(
GlobalDeclGD);
436mangleTemplateInstantiationName(
GlobalDeclGD,
441 voidmanglePassObjectSizeArg(
constPassObjectSizeAttr *POSA);
443 boolisArtificialTagType(
QualType T)
const;
446#define ABSTRACT_TYPE(CLASS, PARENT) 447#define NON_CANONICAL_TYPE(CLASS, PARENT) 448#define TYPE(CLASS, PARENT) void mangleType(const CLASS##Type *T, \ 451#include "clang/AST/TypeNodes.inc" 453#undef NON_CANONICAL_TYPE 456 voidmangleType(
const TagDecl*TD);
457 voidmangleDecayedArrayType(
const ArrayType*
T);
462 voidmangleIntegerLiteral(
constllvm::APSInt &Number,
473 boolWithScalarType =
false);
488MicrosoftMangleContextImpl::MicrosoftMangleContextImpl(
ASTContext&Context,
510AnonymousNamespaceHash = llvm::utohexstr(TruncatedHash);
513AnonymousNamespaceHash =
"0";
517boolMicrosoftMangleContextImpl::shouldMangleCXXName(
const NamedDecl*
D) {
521 if(FD->hasAttr<OverloadableAttr>())
533 if(FD->isMSVCRTEntryPoint())
547 if(!getASTContext().getLangOpts().
CPlusPlus)
550 const VarDecl*VD = dyn_cast<VarDecl>(
D);
551 if(VD && !isa<DecompositionDecl>(
D)) {
561DC = getEffectiveParentContext(DC);
564!isa<VarTemplateSpecializationDecl>(
D) &&
D->getIdentifier() !=
nullptr)
572MicrosoftMangleContextImpl::shouldMangleStringLiteral(
const StringLiteral*SL) {
581 "cannot mangle this %0 %1 yet");
582 returnDiags.
Report(loc, DiagID) << thing1 << thing2;
589 "cannot mangle this %0 yet");
590 returnDiags.
Report(loc, DiagID) << thingy;
597 "cannot mangle this %0 yet");
598 returnDiags.
Report(DiagID) << thingy;
601voidMicrosoftCXXNameMangler::mangle(
GlobalDeclGD, StringRef Prefix) {
613mangleFunctionEncoding(GD, Context.shouldMangleDeclName(FD));
614 else if(
const VarDecl*VD = dyn_cast<VarDecl>(
D))
615mangleVariableEncoding(VD);
616 else if(isa<MSGuidDecl>(
D))
619Out <<
"3U__s_GUID@@B";
620 else if(isa<TemplateParamObjectDecl>(
D)) {
624llvm_unreachable(
"Tried to mangle unexpected NamedDecl!");
627voidMicrosoftCXXNameMangler::mangleFunctionEncoding(
GlobalDeclGD,
652mangleFunctionClass(FD);
654mangleFunctionType(FT, FD,
false,
false);
660voidMicrosoftCXXNameMangler::mangleVariableEncoding(
const VarDecl*VD) {
691mangleType(Ty, SR, QMM_Drop);
692manglePointerExtQualifiers(
695mangleQualifiers(MPT->getPointeeType().getQualifiers(),
true);
698mangleName(MPT->getClass()->getAsCXXRecordDecl());
701}
else if(
const ArrayType*AT = getASTContext().getAsArrayType(Ty)) {
703mangleDecayedArrayType(AT);
704 if(AT->getElementType()->isArrayType())
709mangleType(Ty, SR, QMM_Drop);
714voidMicrosoftCXXNameMangler::mangleMemberDataPointer(
730FieldOffset = getASTContext().getFieldOffset(VD);
731assert(FieldOffset % getASTContext().
getCharWidth() == 0 &&
732 "cannot take address of bitfield");
733FieldOffset /= getASTContext().getCharWidth();
737 if(IM == MSInheritanceModel::Virtual)
738FieldOffset -= getASTContext().getOffsetOfBaseWithVBPtr(RD).getQuantity();
747 caseMSInheritanceModel::Single: Code =
'0';
break;
748 caseMSInheritanceModel::Multiple: Code =
'0';
break;
749 caseMSInheritanceModel::Virtual: Code =
'F';
break;
750 caseMSInheritanceModel::Unspecified: Code =
'G';
break;
756getASTContext().getLangOpts().isCompatibleWithMSVC(
757LangOptions::MSVC2019) &&
759!TemplateArgType.
isNull()) {
761mangleType(TemplateArgType,
SourceRange(), QMM_Drop);
766mangleNumber(FieldOffset);
774mangleNumber(VBTableOffset);
777voidMicrosoftCXXNameMangler::mangleMemberDataPointerInClassNTTP(
784 if(IM != MSInheritanceModel::Single && IM != MSInheritanceModel::Multiple)
785 returnmangleMemberDataPointer(RD, VD,
nullptr,
QualType(),
"");
793mangleNestedName(VD);
795mangleUnqualifiedName(VD);
799voidMicrosoftCXXNameMangler::mangleMemberFunctionPointer(
817 caseMSInheritanceModel::Single: Code =
'1';
break;
818 caseMSInheritanceModel::Multiple: Code =
'H';
break;
819 caseMSInheritanceModel::Virtual: Code =
'I';
break;
820 caseMSInheritanceModel::Unspecified: Code =
'J';
break;
831 if(getASTContext().getLangOpts().isCompatibleWithMSVC(
832LangOptions::MSVC2019) &&
834!TemplateArgType.
isNull()) {
836mangleType(TemplateArgType,
SourceRange(), QMM_Drop);
842cast<MicrosoftVTableContext>(getASTContext().getVTableContext());
845mangleVirtualMemPtrThunk(MD, ML);
849 const ASTRecordLayout&Layout = getASTContext().getASTRecordLayout(RD);
854mangleFunctionEncoding(MD,
true);
857 if(VBTableOffset == 0 && IM == MSInheritanceModel::Virtual)
858NVOffset -= getASTContext().getOffsetOfBaseWithVBPtr(RD).getQuantity();
861 if(IM == MSInheritanceModel::Single) {
862Out << Prefix <<
"0A@";
865 if(IM == MSInheritanceModel::Unspecified)
867Out << Prefix << Code;
871mangleNumber(
static_cast<uint32_t>(NVOffset));
873mangleNumber(VBPtrOffset);
875mangleNumber(VBTableOffset);
878voidMicrosoftCXXNameMangler::mangleFunctionPointer(
887 if(getASTContext().getLangOpts().isCompatibleWithMSVC(
888LangOptions::MSVC2019) &&
890!TemplateArgType.
isNull()) {
892mangleType(TemplateArgType,
SourceRange(), QMM_Drop);
897mangleFunctionEncoding(FD,
true);
900voidMicrosoftCXXNameMangler::mangleVarDecl(
const VarDecl*VD,
909 if(getASTContext().getLangOpts().isCompatibleWithMSVC(
910LangOptions::MSVC2019) &&
912!TemplateArgType.
isNull()) {
914mangleType(TemplateArgType,
SourceRange(), QMM_Drop);
919mangleVariableEncoding(VD);
922voidMicrosoftCXXNameMangler::mangleMemberFunctionPointerInClassNTTP(
931 returnmangleMemberFunctionPointer(RD, MD,
nullptr,
QualType(),
"");
940cast<MicrosoftVTableContext>(getASTContext().getVTableContext());
943mangleVirtualMemPtrThunk(MD, ML);
946mangleFunctionEncoding(MD,
true);
950voidMicrosoftCXXNameMangler::mangleVirtualMemPtrThunk(
953 CharUnitsPointerWidth = getASTContext().toCharUnitsFromBits(
954getASTContext().getTargetInfo().getPointerWidth(LangAS::Default));
960mangleNumber(OffsetInVFTable);
966voidMicrosoftCXXNameMangler::mangleName(
GlobalDeclGD) {
970mangleUnqualifiedName(GD);
972mangleNestedName(GD);
978voidMicrosoftCXXNameMangler::mangleNumber(int64_t Number) {
979mangleNumber(llvm::APSInt(llvm::APInt(64, Number),
false));
982voidMicrosoftCXXNameMangler::mangleNumber(llvm::APSInt Number) {
987 unsignedWidth = std::max(Number.getBitWidth(), 64U);
988llvm::APInt
Value= Number.extend(Width);
996 if(
Value.isNegative()) {
1000mangleBits(
Value);
1003voidMicrosoftCXXNameMangler::mangleFloat(llvm::APFloat Number) {
1004 usingllvm::APFloat;
1006 switch(APFloat::SemanticsToEnum(Number.getSemantics())) {
1007 caseAPFloat::S_IEEEsingle: Out <<
'A';
break;
1008 caseAPFloat::S_IEEEdouble: Out <<
'B';
break;
1012 caseAPFloat::S_IEEEhalf: Out <<
'V';
break;
1013 caseAPFloat::S_BFloat: Out <<
'W';
break;
1014 caseAPFloat::S_x87DoubleExtended: Out <<
'X';
break;
1015 caseAPFloat::S_IEEEquad: Out <<
'Y';
break;
1016 caseAPFloat::S_PPCDoubleDouble: Out <<
'Z';
break;
1017 caseAPFloat::S_PPCDoubleDoubleLegacy:
1018 caseAPFloat::S_Float8E5M2:
1019 caseAPFloat::S_Float8E4M3:
1020 caseAPFloat::S_Float8E4M3FN:
1021 caseAPFloat::S_Float8E5M2FNUZ:
1022 caseAPFloat::S_Float8E4M3FNUZ:
1023 caseAPFloat::S_Float8E4M3B11FNUZ:
1024 caseAPFloat::S_Float8E3M4:
1025 caseAPFloat::S_FloatTF32:
1026 caseAPFloat::S_Float8E8M0FNU:
1027 caseAPFloat::S_Float6E3M2FN:
1028 caseAPFloat::S_Float6E2M3FN:
1029 caseAPFloat::S_Float4E2M1FN:
1030llvm_unreachable(
"Tried to mangle unexpected APFloat semantics");
1033mangleBits(Number.bitcastToAPInt());
1036voidMicrosoftCXXNameMangler::mangleBits(llvm::APInt
Value) {
1040Out << (
Value- 1);
1047EncodedNumberBuffer.push_back(
'A'+ (
Value& 0xf).getZExtValue());
1048std::reverse(EncodedNumberBuffer.begin(), EncodedNumberBuffer.end());
1049Out.write(EncodedNumberBuffer.data(), EncodedNumberBuffer.size());
1058 if(
const FunctionDecl*FD = dyn_cast<FunctionDecl>(ND)) {
1067dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
1068TemplateArgs = &Spec->getTemplateArgs();
1069 returnGD.
getWithDecl(Spec->getSpecializedTemplate());
1074dyn_cast<VarTemplateSpecializationDecl>(ND)) {
1075TemplateArgs = &Spec->getTemplateArgs();
1076 returnGD.
getWithDecl(Spec->getSpecializedTemplate());
1082voidMicrosoftCXXNameMangler::mangleUnqualifiedName(
GlobalDeclGD,
1096 if(isa<FunctionTemplateDecl>(TD.getDecl())) {
1097mangleTemplateInstantiationName(TD, *TemplateArgs);
1120ArgBackRefMap::iterator
Found= TemplateArgBackReferences.find(ND);
1121 if(
Found== TemplateArgBackReferences.end()) {
1123TemplateArgStringMap::iterator
Found= TemplateArgStrings.find(ND);
1124 if(
Found== TemplateArgStrings.end()) {
1127llvm::raw_svector_ostream Stream(TemplateMangling);
1128MicrosoftCXXNameMangler Extra(Context, Stream);
1129Extra.mangleTemplateInstantiationName(TD, *TemplateArgs);
1132mangleSourceName(TemplateMangling);
1136BackRefVec::iterator StringFound =
1137llvm::find(NameBackReferences, TemplateMangling);
1138 if(StringFound != NameBackReferences.end()) {
1139TemplateArgBackReferences[ND] =
1140StringFound - NameBackReferences.begin();
1142TemplateArgStrings[ND] =
1143TemplateArgStringStorage.save(TemplateMangling.str());
1146Out <<
Found->second <<
'@';
1149Out <<
Found->second;
1154 switch(Name.getNameKind()) {
1159((isa<FunctionDecl>(ND) && ND->
hasAttr<CUDAGlobalAttr>()) ||
1160(isa<FunctionTemplateDecl>(ND) &&
1161cast<FunctionTemplateDecl>(ND)
1162->getTemplatedDecl()
1163->hasAttr<CUDAGlobalAttr>())) &&
1167(llvm::Twine(
"__device_stub__") + II->getName()).str());
1169mangleSourceName(II->getName());
1174assert(ND &&
"mangling empty name without declaration");
1176 if(
const NamespaceDecl*NS = dyn_cast<NamespaceDecl>(ND)) {
1177 if(NS->isAnonymousNamespace()) {
1178Out <<
"?A0x"<< Context.getAnonymousNamespaceHash() <<
'@';
1188Name += llvm::utostr(Context.getAnonymousStructId(DD) + 1);
1189mangleSourceName(Name);
1193 if(
const VarDecl*VD = dyn_cast<VarDecl>(ND)) {
1196assert(RD &&
"expected variable decl to have a record type");
1202Name += llvm::utostr(Context.getAnonymousStructId(RD) + 1);
1203mangleSourceName(Name.str());
1207 if(
const MSGuidDecl*GD = dyn_cast<MSGuidDecl>(ND)) {
1210 SmallString<
sizeof(
"_GUID_12345678_1234_1234_1234_1234567890ab")> GUID;
1211llvm::raw_svector_ostream GUIDOS(GUID);
1212Context.mangleMSGuidDecl(GD, GUIDOS);
1213mangleSourceName(GUID);
1217 if(
const auto*TPO = dyn_cast<TemplateParamObjectDecl>(ND)) {
1219mangleTemplateArgValue(TPO->getType().getUnqualifiedType(),
1220TPO->getValue(), TplArgKind::ClassNTTP);
1225 const TagDecl*TD = cast<TagDecl>(ND);
1228 "Typedef should not be in another decl context!");
1229assert(
D->getDeclName().getAsIdentifierInfo() &&
1230 "Typedef was not named!");
1231mangleSourceName(
D->getDeclName().getAsIdentifierInfo()->getName());
1236 if(
Record->isLambda()) {
1239 Decl*LambdaContextDecl =
Record->getLambdaContextDecl();
1240 unsignedLambdaManglingNumber =
Record->getLambdaManglingNumber();
1243dyn_cast_or_null<ParmVarDecl>(LambdaContextDecl);
1245Parm ? dyn_cast<FunctionDecl>(Parm->
getDeclContext()) : nullptr;
1248 unsignedDefaultArgNo =
1250Name += llvm::utostr(DefaultArgNo);
1254 if(LambdaManglingNumber)
1255LambdaId = LambdaManglingNumber;
1257LambdaId = Context.getLambdaId(
Record);
1259Name += llvm::utostr(LambdaId);
1262mangleSourceName(Name);
1266 if(LambdaManglingNumber && LambdaContextDecl) {
1267 if((isa<VarDecl>(LambdaContextDecl) ||
1268isa<FieldDecl>(LambdaContextDecl)) &&
1269!isa<ParmVarDecl>(LambdaContextDecl)) {
1270mangleUnqualifiedName(cast<NamedDecl>(LambdaContextDecl));
1282Name +=
"<unnamed-type-";
1283Name += DD->getName();
1289Name +=
"<unnamed-type-";
1290Name += TND->getName();
1291}
else if(isa<EnumDecl>(TD) &&
1292cast<EnumDecl>(TD)->enumerator_begin() !=
1293cast<EnumDecl>(TD)->enumerator_end()) {
1295 auto*ED = cast<EnumDecl>(TD);
1296Name +=
"<unnamed-enum-";
1297Name += ED->enumerator_begin()->getName();
1300Name +=
"<unnamed-type-$S";
1301Name += llvm::utostr(Context.getAnonymousStructId(TD) + 1);
1304mangleSourceName(Name.str());
1315mangleSourceName(Name.str());
1320 if(isStructorDecl(ND)) {
1334 if(isStructorDecl(ND))
1337mangleCXXDtorType(
static_cast<CXXDtorType>(StructorType));
1351mangleOperatorName(Name.getCXXOverloadedOperator(), ND->
getLocation());
1356mangleSourceName(Name.getCXXLiteralIdentifier()->getName());
1361llvm_unreachable(
"Can't mangle a deduction guide name!");
1364llvm_unreachable(
"Can't mangle a using directive name!");
1370voidMicrosoftCXXNameMangler::mangleNestedName(
GlobalDeclGD) {
1373 if(
const auto*ID = dyn_cast<IndirectFieldDecl>(ND))
1374 for(
unsignedI = 1, IE =
ID->getChainingSize(); I < IE; ++I)
1375mangleSourceName(
"<unnamed-tag>");
1377 const DeclContext*DC = getEffectiveDeclContext(ND);
1379 if(isa<TagDecl>(ND) || isa<VarDecl>(ND)) {
1381 if(Context.getNextDiscriminator(ND, Disc)) {
1388 if(
const BlockDecl*BD = dyn_cast<BlockDecl>(DC)) {
1390[](StringRef Name,
const unsignedDiscriminator,
1391 const unsignedParameterDiscriminator) -> std::string {
1393llvm::raw_string_ostream Stream(Buffer);
1396Stream <<
'_'<< Discriminator;
1397 if(ParameterDiscriminator)
1398Stream <<
'_'<< ParameterDiscriminator;
1402 unsignedDiscriminator = BD->getBlockManglingNumber();
1404Discriminator = Context.getBlockId(BD,
false);
1409 unsignedParameterDiscriminator = 0;
1410 if(
const auto*MC = BD->getBlockManglingContextDecl())
1411 if(
const auto*
P= dyn_cast<ParmVarDecl>(MC))
1412 if(
const auto*F = dyn_cast<FunctionDecl>(
P->getDeclContext()))
1413ParameterDiscriminator =
1414F->getNumParams() -
P->getFunctionScopeIndex();
1416DC = getEffectiveDeclContext(BD);
1419mangleSourceName(Discriminate(
"_block_invoke", Discriminator,
1420ParameterDiscriminator));
1425 if(
const auto*MC = BD->getBlockManglingContextDecl())
1426 if(!isa<ParmVarDecl>(MC))
1427 if(
const auto*ND = dyn_cast<NamedDecl>(MC))
1428mangleUnqualifiedName(ND);
1432 if(
const auto*RD = dyn_cast<RecordDecl>(DC))
1441 if(PointersAre64Bit)
1444mangleArtificialTagType(TagTypeKind::Struct,
1445Discriminate(
"__block_literal", Discriminator,
1446ParameterDiscriminator));
1451 if(isa<RecordDecl>(DC))
1454}
else if(
const ObjCMethodDecl*Method = dyn_cast<ObjCMethodDecl>(DC)) {
1455mangleObjCMethodName(Method);
1456}
else if(isa<NamedDecl>(DC)) {
1457ND = cast<NamedDecl>(DC);
1458 if(
const FunctionDecl*FD = dyn_cast<FunctionDecl>(ND)) {
1459mangle(getGlobalDeclAsDeclContext(FD),
"?");
1462mangleUnqualifiedName(ND);
1465 if(
const auto*LDADC = getLambdaDefaultArgumentDeclContext(ND)) {
1475voidMicrosoftCXXNameMangler::mangleCXXDtorType(
CXXDtorType T) {
1490llvm_unreachable(
"not expecting a COMDAT");
1492llvm_unreachable(
"Unsupported dtor type?");
1501 caseOO_New: Out <<
"?2";
break;
1503 caseOO_Delete: Out <<
"?3";
break;
1505 caseOO_Equal: Out <<
"?4";
break;
1507 caseOO_GreaterGreater: Out <<
"?5";
break;
1509 caseOO_LessLess: Out <<
"?6";
break;
1511 caseOO_Exclaim: Out <<
"?7";
break;
1513 caseOO_EqualEqual: Out <<
"?8";
break;
1515 caseOO_ExclaimEqual: Out <<
"?9";
break;
1517 caseOO_Subscript: Out <<
"?A";
break;
1520 caseOO_Arrow: Out <<
"?C";
break;
1522 caseOO_Star: Out <<
"?D";
break;
1524 caseOO_PlusPlus: Out <<
"?E";
break;
1526 caseOO_MinusMinus: Out <<
"?F";
break;
1528 caseOO_Minus: Out <<
"?G";
break;
1530 caseOO_Plus: Out <<
"?H";
break;
1532 caseOO_Amp: Out <<
"?I";
break;
1534 caseOO_ArrowStar: Out <<
"?J";
break;
1536 caseOO_Slash: Out <<
"?K";
break;
1538 caseOO_Percent: Out <<
"?L";
break;
1540 caseOO_Less: Out <<
"?M";
break;
1542 caseOO_LessEqual: Out <<
"?N";
break;
1544 caseOO_Greater: Out <<
"?O";
break;
1546 caseOO_GreaterEqual: Out <<
"?P";
break;
1548 caseOO_Comma: Out <<
"?Q";
break;
1550 caseOO_Call: Out <<
"?R";
break;
1552 caseOO_Tilde: Out <<
"?S";
break;
1554 caseOO_Caret: Out <<
"?T";
break;
1556 caseOO_Pipe: Out <<
"?U";
break;
1558 caseOO_AmpAmp: Out <<
"?V";
break;
1560 caseOO_PipePipe: Out <<
"?W";
break;
1562 caseOO_StarEqual: Out <<
"?X";
break;
1564 caseOO_PlusEqual: Out <<
"?Y";
break;
1566 caseOO_MinusEqual: Out <<
"?Z";
break;
1568 caseOO_SlashEqual: Out <<
"?_0";
break;
1570 caseOO_PercentEqual: Out <<
"?_1";
break;
1572 caseOO_GreaterGreaterEqual: Out <<
"?_2";
break;
1574 caseOO_LessLessEqual: Out <<
"?_3";
break;
1576 caseOO_AmpEqual: Out <<
"?_4";
break;
1578 caseOO_PipeEqual: Out <<
"?_5";
break;
1580 caseOO_CaretEqual: Out <<
"?_6";
break;
1609 caseOO_Array_New: Out <<
"?_U";
break;
1611 caseOO_Array_Delete: Out <<
"?_V";
break;
1613 caseOO_Coawait: Out <<
"?__L";
break;
1615 caseOO_Spaceship: Out <<
"?__M";
break;
1617 caseOO_Conditional: {
1618 Error(
Loc,
"conditional operator");
1624llvm_unreachable(
"Not an overloaded operator");
1628voidMicrosoftCXXNameMangler::mangleSourceName(StringRef Name) {
1630BackRefVec::iterator
Found= llvm::find(NameBackReferences, Name);
1631 if(
Found== NameBackReferences.end()) {
1632 if(NameBackReferences.size() < 10)
1633NameBackReferences.push_back(std::string(Name));
1634Out << Name <<
'@';
1636Out << (
Found- NameBackReferences.begin());
1640voidMicrosoftCXXNameMangler::mangleObjCMethodName(
const ObjCMethodDecl*MD) {
1641Context.mangleObjCMethodNameAsSourceName(MD, Out);
1644voidMicrosoftCXXNameMangler::mangleTemplateInstantiationName(
1651ArgBackRefMap OuterFunArgsContext;
1652ArgBackRefMap OuterTemplateArgsContext;
1653BackRefVec OuterTemplateContext;
1654PassObjectSizeArgsSet OuterPassObjectSizeArgs;
1655NameBackReferences.swap(OuterTemplateContext);
1656FunArgBackReferences.swap(OuterFunArgsContext);
1657TemplateArgBackReferences.swap(OuterTemplateArgsContext);
1658PassObjectSizeArgs.swap(OuterPassObjectSizeArgs);
1660mangleUnscopedTemplateName(GD);
1661mangleTemplateArgs(cast<TemplateDecl>(GD.
getDecl()), TemplateArgs);
1664NameBackReferences.swap(OuterTemplateContext);
1665FunArgBackReferences.swap(OuterFunArgsContext);
1666TemplateArgBackReferences.swap(OuterTemplateArgsContext);
1667PassObjectSizeArgs.swap(OuterPassObjectSizeArgs);
1670voidMicrosoftCXXNameMangler::mangleUnscopedTemplateName(
GlobalDeclGD) {
1673mangleUnqualifiedName(GD);
1676voidMicrosoftCXXNameMangler::mangleIntegerLiteral(
1687 if(getASTContext().getLangOpts().isCompatibleWithMSVC(
1688LangOptions::MSVC2019) &&
1690!TemplateArgType.
isNull()) {
1692mangleType(TemplateArgType,
SourceRange(), QMM_Drop);
1697mangleNumber(
Value);
1700voidMicrosoftCXXNameMangler::mangleExpression(
1703 if(std::optional<llvm::APSInt>
Value=
1714voidMicrosoftCXXNameMangler::mangleTemplateArgs(
1718assert(TPL->
size() == TemplateArgs.
size() &&
1719 "size mismatch between args and parms!");
1721 for(
size_ti = 0; i < TemplateArgs.
size(); ++i) {
1729mangleTemplateArg(TD, TA, TPL->
getParam(i));
1738!
V.getLValueBase())
1741 QualTypeBaseT =
V.getLValueBase().getType();
1742 if(!BaseT->
isArrayType() ||
V.getLValuePath().size() != 1 ||
1743 V.getLValuePath()[0].getAsArrayIndex() != 0)
1746 V.getLValueBase().dyn_cast<
const ValueDecl*>());
1749voidMicrosoftCXXNameMangler::mangleTemplateArg(
const TemplateDecl*TD,
1789llvm_unreachable(
"Can't mangle null template arguments!");
1791llvm_unreachable(
"Can't mangle template expansion arguments!");
1799 if(isa<FieldDecl>(ND) || isa<IndirectFieldDecl>(ND)) {
1800mangleMemberDataPointer(cast<CXXRecordDecl>(ND->
getDeclContext())
1801->getMostRecentNonInjectedDecl(),
1802cast<ValueDecl>(ND),
1803cast<NonTypeTemplateParmDecl>(Parm),
1805}
else if(
const FunctionDecl*FD = dyn_cast<FunctionDecl>(ND)) {
1808mangleMemberFunctionPointer(
1812mangleFunctionPointer(FD, cast<NonTypeTemplateParmDecl>(Parm),
1817 auto*TPO = cast<TemplateParamObjectDecl>(ND);
1818mangleTemplateArgValue(TPO->getType().getUnqualifiedType(),
1819TPO->getValue(), TplArgKind::ClassNTTP);
1820}
else if(
const VarDecl*VD = dyn_cast<VarDecl>(ND)) {
1821mangleVarDecl(VD, cast<NonTypeTemplateParmDecl>(Parm),
1831cast<NonTypeTemplateParmDecl>(Parm),
T);
1837 const CXXRecordDecl*RD = MPT->getMostRecentCXXRecordDecl();
1838 if(MPT->isMemberFunctionPointerType() &&
1839!isa<FunctionTemplateDecl>(TD)) {
1840mangleMemberFunctionPointer(RD,
nullptr,
nullptr,
QualType());
1843 if(MPT->isMemberDataPointer()) {
1844 if(!isa<FunctionTemplateDecl>(TD)) {
1845mangleMemberDataPointer(RD,
nullptr,
nullptr,
QualType());
1855mangleIntegerLiteral(llvm::APSInt::get(-1),
1856cast<NonTypeTemplateParmDecl>(Parm),
T);
1861mangleIntegerLiteral(llvm::APSInt::getUnsigned(0),
1862cast<NonTypeTemplateParmDecl>(Parm),
T);
1871 returnmangleTemplateArg(
1875 if(cast<NonTypeTemplateParmDecl>(Parm)
1877->getContainedDeducedType()) {
1883TplArgKind::StructuralValue,
1887mangleExpression(TA.
getAsExpr(), cast<NonTypeTemplateParmDecl>(Parm));
1891 if(TemplateArgs.empty()) {
1892 if(isa<TemplateTypeParmDecl>(Parm) ||
1893isa<TemplateTemplateParmDecl>(Parm))
1897LangOptions::MSVC2015)
1900 else if(isa<NonTypeTemplateParmDecl>(Parm))
1903llvm_unreachable(
"unexpected template parameter decl!");
1906mangleTemplateArg(TD, PA, Parm);
1913 if(
const auto*TD = dyn_cast<TagDecl>(ND)) {
1915}
else if(isa<TypeAliasDecl>(ND)) {
1919llvm_unreachable(
"unexpected template template NamedDecl!");
1926voidMicrosoftCXXNameMangler::mangleTemplateArgValue(
QualType T,
1929 boolWithScalarType) {
1930 switch(
V.getKind()) {
1944mangleNumber(
V.getInt());
1950mangleFloat(
V.getFloat());
1961 if(
V.isLValueOnePastTheEnd()) {
1970 if(!
V.hasLValuePath() ||
V.getLValuePath().empty()) {
1972 if(
Base.isNull()) {
1978mangleNumber(
V.getLValueOffset().getQuantity());
1979}
else if(!
V.hasLValuePath()) {
1981 Error(
"template argument (extension not comaptible with ms mangler)");
1983}
else if(
auto*VD =
Base.dyn_cast<
const ValueDecl*>()) {
1987 Error(
"template argument (undeclared base)");
1995 SmallVector<std::function<void()>, 2> EntryManglers;
1999EntryTypes.push_back(
'C');
2000EntryManglers.push_back([
this, I =
E.getAsArrayIndex()] {
2005ET = AT->getElementType();
2009 const Decl*
D=
E.getAsBaseOrMember().getPointer();
2010 if(
auto*FD = dyn_cast<FieldDecl>(
D)) {
2016ET = getASTContext().getRecordType(cast<CXXRecordDecl>(
D));
2022EntryTypes.push_back(
'6');
2023EntryManglers.push_back([
this,
D] {
2024mangleUnqualifiedName(cast<NamedDecl>(
D));
2029 for(
autoI = EntryTypes.rbegin(),
E= EntryTypes.rend(); I !=
E; ++I)
2034 Error(
"template argument (null value decl)");
2037Out << (TAK == TplArgKind::ClassNTTP ?
'E':
'1');
2040 for(
conststd::function<
void()> &Mangler : EntryManglers)
2056 if(TAK == TplArgKind::ClassNTTP) {
2058mangleMemberDataPointerInClassNTTP(RD,
D);
2060mangleMemberFunctionPointerInClassNTTP(RD,
2061cast_or_null<CXXMethodDecl>(
D));
2064mangleMemberDataPointer(RD,
D,
nullptr,
QualType(),
"");
2066mangleMemberFunctionPointer(RD, cast_or_null<CXXMethodDecl>(
D),
nullptr,
2076assert(RD &&
"unexpected type for record value");
2078 unsignedBaseIndex = 0;
2080mangleTemplateArgValue(B.getType(),
V.getStructBase(BaseIndex++), TAK);
2082 if(!FD->isUnnamedBitField())
2083mangleTemplateArgValue(FD->
getType(),
2084 V.getStructField(FD->getFieldIndex()), TAK,
2093 if(
const FieldDecl*FD =
V.getUnionField()) {
2094mangleUnqualifiedName(FD);
2095mangleTemplateArgValue(FD->
getType(),
V.getUnionValue(), TAK);
2105mangleNumber(
V.getComplexIntReal());
2107mangleNumber(
V.getComplexIntImag());
2114mangleFloat(
V.getComplexFloatReal());
2115mangleFloat(
V.getComplexFloatImag());
2121 QualTypeElemT = getASTContext().getAsArrayType(
T)->getElementType();
2123 for(
unsignedI = 0, N =
V.getArraySize(); I != N; ++I) {
2124 const APValue&ElemV = I <
V.getArrayInitializedElts()
2125?
V.getArrayInitializedElt(I)
2126:
V.getArrayFiller();
2127mangleTemplateArgValue(ElemT, ElemV, TAK);
2142 for(
unsignedI = 0, N =
V.getVectorLength(); I != N; ++I) {
2143 const APValue&ElemV =
V.getVectorElt(I);
2144mangleTemplateArgValue(ElemT, ElemV, TAK);
2152 Error(
"template argument (value type: address label diff)");
2157 Error(
"template argument (value type: fixed point)");
2163voidMicrosoftCXXNameMangler::mangleObjCProtocol(
const ObjCProtocolDecl*PD) {
2165llvm::raw_svector_ostream Stream(TemplateMangling);
2166MicrosoftCXXNameMangler Extra(Context, Stream);
2169Extra.mangleSourceName(
"Protocol");
2170Extra.mangleArtificialTagType(TagTypeKind::Struct, PD->
getName());
2172mangleArtificialTagType(TagTypeKind::Struct, TemplateMangling, {
"__ObjC"});
2175voidMicrosoftCXXNameMangler::mangleObjCLifetime(
const QualType Type,
2179llvm::raw_svector_ostream Stream(TemplateMangling);
2180MicrosoftCXXNameMangler Extra(Context, Stream);
2188Extra.mangleSourceName(
"Autoreleasing");
2191Extra.mangleSourceName(
"Strong");
2194Extra.mangleSourceName(
"Weak");
2197Extra.manglePointerCVQualifiers(Quals);
2198Extra.manglePointerExtQualifiers(Quals,
Type);
2201mangleArtificialTagType(TagTypeKind::Struct, TemplateMangling, {
"__ObjC"});
2204voidMicrosoftCXXNameMangler::mangleObjCKindOfType(
const ObjCObjectType*
T,
2208llvm::raw_svector_ostream Stream(TemplateMangling);
2209MicrosoftCXXNameMangler Extra(Context, Stream);
2212Extra.mangleSourceName(
"KindOf");
2214.stripObjCKindOfType(getASTContext())
2215->castAs<ObjCObjectType>(),
2218mangleArtificialTagType(TagTypeKind::Struct, TemplateMangling, {
"__ObjC"});
2221voidMicrosoftCXXNameMangler::mangleQualifiers(
QualifiersQuals,
2275 boolHasConst = Quals.
hasConst(),
2279 if(HasConst && HasVolatile) {
2281}
else if(HasVolatile) {
2283}
else if(HasConst) {
2289 if(HasConst && HasVolatile) {
2291}
else if(HasVolatile) {
2293}
else if(HasConst) {
2304MicrosoftCXXNameMangler::mangleRefQualifier(
RefQualifierKindRefQualifier) {
2307 switch(RefQualifier) {
2321voidMicrosoftCXXNameMangler::manglePointerExtQualifiers(
QualifiersQuals,
2324 boolis64Bit = PointeeType.
isNull() ? PointersAre64Bit :
2337voidMicrosoftCXXNameMangler::manglePointerCVQualifiers(
QualifiersQuals) {
2342 boolHasConst = Quals.
hasConst(),
2345 if(HasConst && HasVolatile) {
2347}
else if(HasVolatile) {
2349}
else if(HasConst) {
2356voidMicrosoftCXXNameMangler::mangleFunctionArgumentType(
QualType T,
2367 QualTypeOriginalType = DT->getOriginalType();
2370 if(
const auto*AT = getASTContext().getAsArrayType(OriginalType))
2371OriginalType = getASTContext().getIncompleteArrayType(
2372AT->getElementType(), AT->getSizeModifier(),
2373AT->getIndexTypeCVRQualifiers());
2384TypePtr =
T.getCanonicalType().getAsOpaquePtr();
2387ArgBackRefMap::iterator
Found= FunArgBackReferences.find(TypePtr);
2389 if(
Found== FunArgBackReferences.end()) {
2390 size_tOutSizeBefore = Out.tell();
2392mangleType(
T,
Range, QMM_Drop);
2397 boolLongerThanOneChar = (Out.tell() - OutSizeBefore > 1);
2398 if(LongerThanOneChar && FunArgBackReferences.size() < 10) {
2399 size_t Size= FunArgBackReferences.size();
2400FunArgBackReferences[TypePtr] =
Size;
2403Out <<
Found->second;
2407voidMicrosoftCXXNameMangler::manglePassObjectSizeArg(
2408 constPassObjectSizeAttr *POSA) {
2409 int Type= POSA->getType();
2410 bool Dynamic= POSA->isDynamic();
2413 auto*TypePtr = (
const void*)&*
Iter;
2414ArgBackRefMap::iterator
Found= FunArgBackReferences.find(TypePtr);
2416 if(
Found== FunArgBackReferences.end()) {
2418 Dynamic?
"__pass_dynamic_object_size":
"__pass_object_size";
2419mangleArtificialTagType(TagTypeKind::Enum, Name + llvm::utostr(
Type),
2422 if(FunArgBackReferences.size() < 10) {
2423 size_t Size= FunArgBackReferences.size();
2424FunArgBackReferences[TypePtr] =
Size;
2427Out <<
Found->second;
2431voidMicrosoftCXXNameMangler::mangleAddressSpaceType(
QualType T,
2447assert(Quals.
hasAddressSpace() &&
"Not valid without address space");
2449llvm::raw_svector_ostream Stream(ASMangling);
2450MicrosoftCXXNameMangler Extra(Context, Stream);
2456Extra.mangleSourceName(
"_AS");
2457Extra.mangleIntegerLiteral(llvm::APSInt::getUnsigned(TargetAS));
2461llvm_unreachable(
"Not a language specific address space");
2462 caseLangAS::opencl_global:
2463Extra.mangleSourceName(
"_ASCLglobal");
2465 caseLangAS::opencl_global_device:
2466Extra.mangleSourceName(
"_ASCLdevice");
2468 caseLangAS::opencl_global_host:
2469Extra.mangleSourceName(
"_ASCLhost");
2471 caseLangAS::opencl_local:
2472Extra.mangleSourceName(
"_ASCLlocal");
2474 caseLangAS::opencl_constant:
2475Extra.mangleSourceName(
"_ASCLconstant");
2477 caseLangAS::opencl_private:
2478Extra.mangleSourceName(
"_ASCLprivate");
2480 caseLangAS::opencl_generic:
2481Extra.mangleSourceName(
"_ASCLgeneric");
2483 caseLangAS::cuda_device:
2484Extra.mangleSourceName(
"_ASCUdevice");
2486 caseLangAS::cuda_constant:
2487Extra.mangleSourceName(
"_ASCUconstant");
2489 caseLangAS::cuda_shared:
2490Extra.mangleSourceName(
"_ASCUshared");
2492 caseLangAS::ptr32_sptr:
2493 caseLangAS::ptr32_uptr:
2495llvm_unreachable(
"don't mangle ptr address spaces with _AS");
2499Extra.mangleType(
T,
Range, QMM_Escape);
2501mangleArtificialTagType(TagTypeKind::Struct, ASMangling, {
"__clang"});
2504voidMicrosoftCXXNameMangler::mangleAutoReturnType(
QualType T,
2505QualifierMangleMode QMM) {
2506assert(getASTContext().getLangOpts().isCompatibleWithMSVC(
2507LangOptions::MSVC2019) &&
2508 "Cannot mangle MSVC 2017 auto return types!");
2510 if(isa<AutoType>(
T)) {
2514 if(QMM == QMM_Result)
2516 if(QMM != QMM_Drop)
2517mangleQualifiers(Quals,
false);
2518Out << (AT->isDecltypeAuto() ?
"_T":
"_P");
2522 T=
T.getDesugaredType(getASTContext());
2530mangleQualifiers(Quals,
false);
2533llvm_unreachable(
"QMM_Escape unexpected");
2536 const Type*ty =
T.getTypePtr();
2538 caseType::MemberPointer:
2539mangleAutoReturnType(cast<MemberPointerType>(ty), Quals);
2542mangleAutoReturnType(cast<PointerType>(ty), Quals);
2544 caseType::LValueReference:
2545mangleAutoReturnType(cast<LValueReferenceType>(ty), Quals);
2547 caseType::RValueReference:
2548mangleAutoReturnType(cast<RValueReferenceType>(ty), Quals);
2551llvm_unreachable(
"Invalid type expected");
2556QualifierMangleMode QMM) {
2559 T=
T.getDesugaredType(getASTContext());
2562 if(
const ArrayType*AT = getASTContext().getAsArrayType(
T)) {
2565 if(QMM == QMM_Mangle)
2567 else if(QMM == QMM_Escape || QMM == QMM_Result)
2569mangleArrayType(AT);
2582 if(
const FunctionType*FT = dyn_cast<FunctionType>(
T)) {
2584mangleFunctionType(FT);
2587mangleQualifiers(Quals,
false);
2590 if(!IsPointer && Quals) {
2592mangleQualifiers(Quals,
false);
2600 if((!IsPointer && Quals) || isa<TagType>(
T) || isArtificialTagType(
T)) {
2602mangleQualifiers(Quals,
false);
2607 const Type*ty =
T.getTypePtr();
2610#define ABSTRACT_TYPE(CLASS, PARENT) 2611#define NON_CANONICAL_TYPE(CLASS, PARENT) \ 2613 llvm_unreachable("can't mangle non-canonical type "#CLASS "Type"); \
2615#define TYPE(CLASS, PARENT) \ 2617 mangleType(cast<CLASS##Type>(ty), Quals, Range); \ 2619#include "clang/AST/TypeNodes.inc" 2621#undef NON_CANONICAL_TYPE 2655 switch(
T->getKind()) {
2656 caseBuiltinType::Void:
2659 caseBuiltinType::SChar:
2662 caseBuiltinType::Char_U:
2663 caseBuiltinType::Char_S:
2666 caseBuiltinType::UChar:
2669 caseBuiltinType::Short:
2672 caseBuiltinType::UShort:
2675 caseBuiltinType::Int:
2678 caseBuiltinType::UInt:
2681 caseBuiltinType::Long:
2684 caseBuiltinType::ULong:
2687 caseBuiltinType::Float:
2690 caseBuiltinType::Double:
2694 caseBuiltinType::LongDouble:
2697 caseBuiltinType::LongLong:
2700 caseBuiltinType::ULongLong:
2703 caseBuiltinType::Int128:
2706 caseBuiltinType::UInt128:
2709 caseBuiltinType::Bool:
2712 caseBuiltinType::Char8:
2715 caseBuiltinType::Char16:
2718 caseBuiltinType::Char32:
2721 caseBuiltinType::WChar_S:
2722 caseBuiltinType::WChar_U:
2726#define BUILTIN_TYPE(Id, SingletonId) 2727#define PLACEHOLDER_TYPE(Id, SingletonId) \ 2728 case BuiltinType::Id: 2729#include "clang/AST/BuiltinTypes.def" 2730 caseBuiltinType::Dependent:
2731llvm_unreachable(
"placeholder types shouldn't get to name mangling");
2733 caseBuiltinType::ObjCId:
2734mangleArtificialTagType(TagTypeKind::Struct,
"objc_object");
2736 caseBuiltinType::ObjCClass:
2737mangleArtificialTagType(TagTypeKind::Struct,
"objc_class");
2739 caseBuiltinType::ObjCSel:
2740mangleArtificialTagType(TagTypeKind::Struct,
"objc_selector");
2743#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 2744 case BuiltinType::Id: \ 2745 Out << "PAUocl_"#ImgType "_" #Suffix "@@"; \
2747#include "clang/Basic/OpenCLImageTypes.def" 2748 caseBuiltinType::OCLSampler:
2750mangleArtificialTagType(TagTypeKind::Struct,
"ocl_sampler");
2752 caseBuiltinType::OCLEvent:
2754mangleArtificialTagType(TagTypeKind::Struct,
"ocl_event");
2756 caseBuiltinType::OCLClkEvent:
2758mangleArtificialTagType(TagTypeKind::Struct,
"ocl_clkevent");
2760 caseBuiltinType::OCLQueue:
2762mangleArtificialTagType(TagTypeKind::Struct,
"ocl_queue");
2764 caseBuiltinType::OCLReserveID:
2766mangleArtificialTagType(TagTypeKind::Struct,
"ocl_reserveid");
2768#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 2769 case BuiltinType::Id: \ 2770 mangleArtificialTagType(TagTypeKind::Struct, "ocl_"#ExtType); \
2772#include "clang/Basic/OpenCLExtensionTypes.def" 2774 caseBuiltinType::NullPtr:
2778 caseBuiltinType::Float16:
2779mangleArtificialTagType(TagTypeKind::Struct,
"_Float16", {
"__clang"});
2782 caseBuiltinType::Half:
2783 if(!getASTContext().getLangOpts().
HLSL)
2784mangleArtificialTagType(TagTypeKind::Struct,
"_Half", {
"__clang"});
2785 else if(getASTContext().getLangOpts().NativeHalfType)
2791 caseBuiltinType::BFloat16:
2792mangleArtificialTagType(TagTypeKind::Struct,
"__bf16", {
"__clang"});
2795 caseBuiltinType::MFloat8:
2796mangleArtificialTagType(TagTypeKind::Struct,
"__mfp8", {
"__clang"});
2799#define WASM_REF_TYPE(InternalName, MangledName, Id, SingletonId, AS) \ 2800 case BuiltinType::Id: \ 2801 mangleArtificialTagType(TagTypeKind::Struct, MangledName); \ 2802 mangleArtificialTagType(TagTypeKind::Struct, MangledName, {"__clang"}); \
2805#include "clang/Basic/WebAssemblyReferenceTypes.def" 2807#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \ 2808 case BuiltinType::Id: \ 2809 mangleArtificialTagType(TagTypeKind::Struct, #Name); \ 2811#include "clang/Basic/HLSLIntangibleTypes.def" 2830mangleFunctionType(
T,
nullptr,
true);
2833mangleFunctionType(
T);
2839mangleFunctionType(
T);
2842voidMicrosoftCXXNameMangler::mangleFunctionType(
const FunctionType*
T,
2844 boolForceThisQuals,
2845 boolMangleExceptionSpec) {
2853 boolIsInLambda =
false;
2854 boolIsStructor =
false, HasThisQuals = ForceThisQuals, IsCtorClosure =
false;
2856 if(
const CXXMethodDecl*MD = dyn_cast_or_null<CXXMethodDecl>(
D)) {
2860HasThisQuals =
true;
2861 if(isa<CXXDestructorDecl>(MD)) {
2863}
else if(isa<CXXConstructorDecl>(MD)) {
2869CC = getASTContext().getDefaultCallingConvention(
2878manglePointerExtQualifiers(Quals,
QualType());
2880mangleQualifiers(Quals,
false);
2883mangleCallingConvention(CC,
Range);
2888 if(isa<CXXDestructorDecl>(
D) && isStructorDecl(
D)) {
2892Out << (PointersAre64Bit ?
"PEAXI@Z":
"PAXI@Z");
2901 if(IsCtorClosure) {
2911mangleFunctionArgumentType(getASTContext().getLValueReferenceType(
2919llvm_unreachable(
"unexpected constructor closure!");
2925}
else if(IsInLambda && isa_and_nonnull<CXXConversionDecl>(
D)) {
2932 if(IsInLambda && isa<CXXConversionDecl>(
D)) {
2936mangleType(ResultType,
Range, QMM_Result);
2937}
else if(IsInLambda) {
2939assert(AT->getKeyword() != AutoTypeKeyword::GNUAutoType &&
2940 "shouldn't need to mangle __auto_type!");
2944mangleSourceName(AT->isDecltypeAuto() ?
"<decltype-auto>":
"<auto>");
2950assert(AT->getKeyword() != AutoTypeKeyword::GNUAutoType &&
2951 "shouldn't need to mangle __auto_type!");
2957 autoUseClangMangling = [](
QualTypeResultType) {
2959 while(isa<PointerType>(
T.getTypePtr())) {
2961 if(
T.getQualifiers().hasAddressSpace())
2967 if(getASTContext().getLangOpts().isCompatibleWithMSVC(
2968LangOptions::MSVC2019) &&
2969!UseClangMangling(ResultType)) {
2970 if(
D&& !
D->getPrimaryTemplate()) {
2973 if(
D&&
D->getPrimaryTemplate()) {
2975->getTemplatedDecl()
2981mangleAutoReturnType(ResultType, QMM_Result);
2987mangleSourceName(AT->isDecltypeAuto() ?
"<decltype-auto>":
"<auto>");
2993mangleType(ResultType,
Range, QMM_Result);
3009 for(
unsignedI = 0,
E= Proto->
getNumParams(); I !=
E; ++I) {
3011 if(I == 0 &&
D&&
D->getParamDecl(I)->isExplicitObjectParameter())
3024 if(
const auto*
P=
D->getParamDecl(I)->
getAttr<PassObjectSizeAttr>())
3025manglePassObjectSizeArg(
P);
3034 if(MangleExceptionSpec && getASTContext().getLangOpts().
CPlusPlus17&&
3035getASTContext().getLangOpts().isCompatibleWithMSVC(
3036LangOptions::MSVC2017_5))
3037mangleThrowSpecification(Proto);
3042voidMicrosoftCXXNameMangler::mangleFunctionClass(
const FunctionDecl*FD) {
3067 if(
const CXXMethodDecl*MD = dyn_cast<CXXMethodDecl>(FD)) {
3071 if(isa<CXXDestructorDecl>(MD) && isStructorDecl(MD) &&
3077llvm_unreachable(
"Unsupported access specifier");
3106voidMicrosoftCXXNameMangler::mangleCallingConvention(
CallingConvCC,
3169 if(getASTContext().getLangOpts().RegCall4)
3178voidMicrosoftCXXNameMangler::mangleCallingConvention(
const FunctionType*
T,
3183voidMicrosoftCXXNameMangler::mangleThrowSpecification(
3205voidMicrosoftCXXNameMangler::mangleTagTypeKind(
TagTypeKindTTK) {
3207 caseTagTypeKind::Union:
3210 caseTagTypeKind::Struct:
3211 caseTagTypeKind::Interface:
3214 caseTagTypeKind::Class:
3217 caseTagTypeKind::Enum:
3224mangleType(cast<TagType>(
T)->getDecl());
3228mangleType(cast<TagType>(
T)->getDecl());
3230voidMicrosoftCXXNameMangler::mangleType(
const TagDecl*TD) {
3236voidMicrosoftCXXNameMangler::mangleArtificialTagType(
3240mangleTagTypeKind(TK);
3243mangleSourceName(UnqualifiedName);
3245 for(StringRef N : llvm::reverse(NestedNames))
3246mangleSourceName(N);
3259voidMicrosoftCXXNameMangler::mangleDecayedArrayType(
const ArrayType*
T) {
3262manglePointerCVQualifiers(
T->getElementType().getQualifiers());
3267llvm_unreachable(
"Should have been special cased");
3271llvm_unreachable(
"Should have been special cased");
3275llvm_unreachable(
"Should have been special cased");
3279llvm_unreachable(
"Should have been special cased");
3281voidMicrosoftCXXNameMangler::mangleArrayType(
const ArrayType*
T) {
3285 if(ElementTy->isConstantArrayType()) {
3287getASTContext().getAsConstantArrayType(ElementTy);
3288Dimensions.push_back(CAT->
getSize());
3290}
else if(ElementTy->isIncompleteArrayType()) {
3292getASTContext().getAsIncompleteArrayType(ElementTy);
3293Dimensions.push_back(llvm::APInt(32, 0));
3295}
else if(ElementTy->isVariableArrayType()) {
3297getASTContext().getAsVariableArrayType(ElementTy);
3298Dimensions.push_back(llvm::APInt(32, 0));
3300}
else if(ElementTy->isDependentSizedArrayType()) {
3303getASTContext().getAsDependentSizedArrayType(ElementTy);
3313mangleNumber(Dimensions.size());
3314 for(
constllvm::APInt &Dimension : Dimensions)
3315mangleNumber(Dimension.getLimitedValue());
3316mangleType(ElementTy,
SourceRange(), QMM_Escape);
3321mangleArrayType(cast<ConstantArrayType>(
T));
3330manglePointerCVQualifiers(Quals);
3331manglePointerExtQualifiers(Quals, PointeeType);
3335mangleFunctionType(FPT,
nullptr,
true);
3339mangleType(PointeeType,
Range, QMM_Drop);
3349Name += llvm::utostr(
T->getDepth());
3351Name += llvm::utostr(
T->getIndex());
3353mangleSourceName(Name);
3367manglePointerCVQualifiers(Quals);
3368manglePointerExtQualifiers(Quals, PointeeType);
3374mangleType(PointeeType,
Range);
3389 returnmangleObjCLifetime(PointeeType, Quals,
Range);
3391manglePointerCVQualifiers(Quals);
3392manglePointerExtQualifiers(Quals, PointeeType);
3393mangleType(PointeeType,
Range);
3404manglePointerExtQualifiers(Quals, PointeeType);
3405mangleType(PointeeType,
Range);
3416manglePointerExtQualifiers(Quals, PointeeType);
3417mangleType(PointeeType,
Range);
3422 QualTypeElementType =
T->getElementType();
3425llvm::raw_svector_ostream Stream(TemplateMangling);
3426MicrosoftCXXNameMangler Extra(Context, Stream);
3428Extra.mangleSourceName(
"_Complex");
3429Extra.mangleType(ElementType,
Range, QMM_Escape);
3431mangleArtificialTagType(TagTypeKind::Struct, TemplateMangling, {
"__clang"});
3439boolMicrosoftCXXNameMangler::isArtificialTagType(
QualType T)
const{
3440 const Type*ty =
T.getTypePtr();
3445 caseType::Vector: {
3459assert((ET || BitIntTy) &&
3460 "vectors with non-builtin/_BitInt elements are unsupported");
3461 uint64_tWidth = getASTContext().getTypeSize(
T);
3464 size_tOutSizeBefore = Out.tell();
3465 if(!isa<ExtVectorType>(
T)) {
3466 if(getASTContext().getTargetInfo().getTriple().isX86() && ET) {
3467 if(Width == 64 && ET->
getKind() == BuiltinType::LongLong) {
3468mangleArtificialTagType(TagTypeKind::Union,
"__m64");
3469}
else if(Width >= 128) {
3470 if(ET->
getKind() == BuiltinType::Float)
3471mangleArtificialTagType(TagTypeKind::Union,
3472 "__m"+ llvm::utostr(Width));
3473 else if(ET->
getKind() == BuiltinType::LongLong)
3474mangleArtificialTagType(TagTypeKind::Union,
3475 "__m"+ llvm::utostr(Width) +
'i');
3476 else if(ET->
getKind() == BuiltinType::Double)
3477mangleArtificialTagType(TagTypeKind::Struct,
3478 "__m"+ llvm::utostr(Width) +
'd');
3483 boolIsBuiltin = Out.tell() != OutSizeBefore;
3490llvm::raw_svector_ostream Stream(TemplateMangling);
3491MicrosoftCXXNameMangler Extra(Context, Stream);
3493Extra.mangleSourceName(
"__vector");
3494Extra.mangleType(
QualType(ET ?
static_cast<const Type*
>(ET) : BitIntTy, 0),
3495 Range, QMM_Escape);
3496Extra.mangleIntegerLiteral(llvm::APSInt::getUnsigned(
T->getNumElements()));
3498mangleArtificialTagType(TagTypeKind::Union, TemplateMangling, {
"__clang"});
3502voidMicrosoftCXXNameMangler::mangleType(
const ExtVectorType*
T,
3535mangleTagTypeKind(TagTypeKind::Struct);
3536mangleName(
T->getDecl());
3541 if(
T->isKindOfType())
3542 returnmangleObjCKindOfType(
T, Quals,
Range);
3544 if(
T->qual_empty() && !
T->isSpecialized())
3545 returnmangleType(
T->getBaseType(),
Range, QMM_Drop);
3547ArgBackRefMap OuterFunArgsContext;
3548ArgBackRefMap OuterTemplateArgsContext;
3549BackRefVec OuterTemplateContext;
3551FunArgBackReferences.swap(OuterFunArgsContext);
3552TemplateArgBackReferences.swap(OuterTemplateArgsContext);
3553NameBackReferences.swap(OuterTemplateContext);
3555mangleTagTypeKind(TagTypeKind::Struct);
3558 if(
T->isObjCId())
3559mangleSourceName(
"objc_object");
3560 else if(
T->isObjCClass())
3561mangleSourceName(
"objc_class");
3563mangleSourceName(
T->getInterface()->getName());
3565 for(
const auto&Q :
T->quals())
3566mangleObjCProtocol(Q);
3568 if(
T->isSpecialized())
3569 for(
const auto&TA :
T->getTypeArgs())
3570mangleType(TA,
Range, QMM_Drop);
3576FunArgBackReferences.swap(OuterFunArgsContext);
3577TemplateArgBackReferences.swap(OuterTemplateArgsContext);
3578NameBackReferences.swap(OuterTemplateContext);
3584manglePointerCVQualifiers(Quals);
3585manglePointerExtQualifiers(Quals, PointeeType);
3594llvm_unreachable(
"Cannot mangle injected class name type.");
3607voidMicrosoftCXXNameMangler::mangleType(
3620manglePointerCVQualifiers(Quals);
3621mangleType(
T->getSelectedType(),
Range);
3646assert(
T->getDeducedType().isNull() &&
"expecting a dependent type!");
3651voidMicrosoftCXXNameMangler::mangleType(
3653assert(
T->getDeducedType().isNull() &&
"expecting a dependent type!");
3661 QualTypeValueType =
T->getValueType();
3664llvm::raw_svector_ostream Stream(TemplateMangling);
3665MicrosoftCXXNameMangler Extra(Context, Stream);
3667Extra.mangleSourceName(
"_Atomic");
3668Extra.mangleType(ValueType,
Range, QMM_Escape);
3670mangleArtificialTagType(TagTypeKind::Struct, TemplateMangling, {
"__clang"});
3675 QualTypeElementType =
T->getElementType();
3678llvm::raw_svector_ostream Stream(TemplateMangling);
3679MicrosoftCXXNameMangler Extra(Context, Stream);
3681Extra.mangleSourceName(
"ocl_pipe");
3682Extra.mangleType(ElementType,
Range, QMM_Escape);
3683Extra.mangleIntegerLiteral(llvm::APSInt::get(
T->isReadOnly()));
3685mangleArtificialTagType(TagTypeKind::Struct, TemplateMangling, {
"__clang"});
3688voidMicrosoftMangleContextImpl::mangleCXXName(
GlobalDeclGD,
3692getASTContext().getSourceManager(),
3693 "Mangling declaration");
3695msvc_hashing_ostream MHO(Out);
3697 if(
auto*CD = dyn_cast<CXXConstructorDecl>(
D)) {
3699MicrosoftCXXNameMangler mangler(*
this, MHO, CD,
Type);
3700 returnmangler.mangle(GD);
3703 if(
auto*DD = dyn_cast<CXXDestructorDecl>(
D)) {
3705MicrosoftCXXNameMangler mangler(*
this, MHO, DD,
Type);
3706 returnmangler.mangle(GD);
3709MicrosoftCXXNameMangler Mangler(*
this, MHO);
3710 returnMangler.mangle(GD);
3716llvm::raw_svector_ostream Stream(TemplateMangling);
3717MicrosoftCXXNameMangler Extra(Context, Stream);
3719 if(
T->isUnsigned())
3720Extra.mangleSourceName(
"_UBitInt");
3722Extra.mangleSourceName(
"_BitInt");
3723Extra.mangleIntegerLiteral(llvm::APSInt::getUnsigned(
T->getNumBits()));
3725mangleArtificialTagType(TagTypeKind::Struct, TemplateMangling, {
"__clang"});
3735llvm_unreachable(
"HLSL uses Itanium name mangling");
3764MicrosoftCXXNameMangler &Mangler,
3771llvm_unreachable(
"Unsupported access specifier");
3782Out <<
'R'<< AccessSpec;
3783Mangler.mangleNumber(
3785Mangler.mangleNumber(
3787Mangler.mangleNumber(
3789Mangler.mangleNumber(
static_cast<uint32_t
>(Adjustment.
NonVirtual));
3792Mangler.mangleNumber(
3794Mangler.mangleNumber(-
static_cast<uint32_t
>(Adjustment.
NonVirtual));
3799llvm_unreachable(
"Unsupported access specifier");
3809Mangler.mangleNumber(-
static_cast<uint32_t
>(Adjustment.
NonVirtual));
3813llvm_unreachable(
"Unsupported access specifier");
3826voidMicrosoftMangleContextImpl::mangleVirtualMemPtrThunk(
3829msvc_hashing_ostream MHO(Out);
3830MicrosoftCXXNameMangler Mangler(*
this, MHO);
3831Mangler.getStream() <<
'?';
3832Mangler.mangleVirtualMemPtrThunk(MD, ML);
3835voidMicrosoftMangleContextImpl::mangleThunk(
const CXXMethodDecl*MD,
3839msvc_hashing_ostream MHO(Out);
3840MicrosoftCXXNameMangler Mangler(*
this, MHO);
3841Mangler.getStream() <<
'?';
3842Mangler.mangleName(MD);
3851assert(Thunk.
Method!=
nullptr&&
3852 "Thunk info should hold the overridee decl");
3855Mangler.mangleFunctionType(
3859voidMicrosoftMangleContextImpl::mangleCXXDtorThunk(
const CXXDestructorDecl*DD,
3868msvc_hashing_ostream MHO(Out);
3869MicrosoftCXXNameMangler Mangler(*
this, MHO, DD,
Type);
3870Mangler.getStream() <<
"??_E";
3872 auto&Adjustment = Thunk.
This;
3877voidMicrosoftMangleContextImpl::mangleCXXVFTable(
3884msvc_hashing_ostream MHO(Out);
3885MicrosoftCXXNameMangler Mangler(*
this, MHO);
3886 if(Derived->
hasAttr<DLLImportAttr>())
3887Mangler.getStream() <<
"??_S";
3889Mangler.getStream() <<
"??_7";
3890Mangler.mangleName(Derived);
3891Mangler.getStream() <<
"6B";
3893Mangler.mangleName(RD);
3894Mangler.getStream() <<
'@';
3897voidMicrosoftMangleContextImpl::mangleCXXVTable(
const CXXRecordDecl*Derived,
3900mangleCXXVFTable(Derived, {}, Out);
3903voidMicrosoftMangleContextImpl::mangleCXXVBTable(
3910msvc_hashing_ostream MHO(Out);
3911MicrosoftCXXNameMangler Mangler(*
this, MHO);
3912Mangler.getStream() <<
"??_8";
3913Mangler.mangleName(Derived);
3914Mangler.getStream() <<
"7B";
3916Mangler.mangleName(RD);
3917Mangler.getStream() <<
'@';
3920voidMicrosoftMangleContextImpl::mangleCXXRTTI(
QualType T, raw_ostream &Out) {
3921msvc_hashing_ostream MHO(Out);
3922MicrosoftCXXNameMangler Mangler(*
this, MHO);
3923Mangler.getStream() <<
"??_R0";
3924Mangler.mangleType(
T,
SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
3925Mangler.getStream() <<
"@8";
3928voidMicrosoftMangleContextImpl::mangleCXXRTTIName(
3929 QualType T, raw_ostream &Out,
boolNormalizeIntegers =
false) {
3930MicrosoftCXXNameMangler Mangler(*
this, Out);
3931Mangler.getStream() <<
'.';
3932Mangler.mangleType(
T,
SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
3935voidMicrosoftMangleContextImpl::mangleCXXVirtualDisplacementMap(
3937msvc_hashing_ostream MHO(Out);
3938MicrosoftCXXNameMangler Mangler(*
this, MHO);
3939Mangler.getStream() <<
"??_K";
3940Mangler.mangleName(SrcRD);
3941Mangler.getStream() <<
"$C";
3942Mangler.mangleName(DstRD);
3945voidMicrosoftMangleContextImpl::mangleCXXThrowInfo(
QualType T,
boolIsConst,
3948uint32_t NumEntries,
3950msvc_hashing_ostream MHO(Out);
3951MicrosoftCXXNameMangler Mangler(*
this, MHO);
3952Mangler.getStream() <<
"_TI";
3954Mangler.getStream() <<
'C';
3956Mangler.getStream() <<
'V';
3958Mangler.getStream() <<
'U';
3959Mangler.getStream() << NumEntries;
3960Mangler.mangleType(
T,
SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
3963voidMicrosoftMangleContextImpl::mangleCXXCatchableTypeArray(
3964 QualType T, uint32_t NumEntries, raw_ostream &Out) {
3965msvc_hashing_ostream MHO(Out);
3966MicrosoftCXXNameMangler Mangler(*
this, MHO);
3967Mangler.getStream() <<
"_CTA";
3968Mangler.getStream() << NumEntries;
3969Mangler.mangleType(
T,
SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
3972voidMicrosoftMangleContextImpl::mangleCXXCatchableType(
3974uint32_t NVOffset, int32_t VBPtrOffset, uint32_t VBIndex,
3976MicrosoftCXXNameMangler Mangler(*
this, Out);
3977Mangler.getStream() <<
"_CT";
3981llvm::raw_svector_ostream Stream(RTTIMangling);
3982msvc_hashing_ostream MHO(Stream);
3983mangleCXXRTTI(
T, MHO);
3985Mangler.getStream() << RTTIMangling;
3993 boolOmitCopyCtor = getASTContext().getLangOpts().isCompatibleWithMSVC(
3994LangOptions::MSVC2015) &&
3995!getASTContext().getLangOpts().isCompatibleWithMSVC(
3996LangOptions::MSVC2017_7);
3998 if(!OmitCopyCtor && CD) {
3999llvm::raw_svector_ostream Stream(CopyCtorMangling);
4000msvc_hashing_ostream MHO(Stream);
4003Mangler.getStream() << CopyCtorMangling;
4005Mangler.getStream() <<
Size;
4006 if(VBPtrOffset == -1) {
4008Mangler.getStream() << NVOffset;
4011Mangler.getStream() << NVOffset;
4012Mangler.getStream() << VBPtrOffset;
4013Mangler.getStream() << VBIndex;
4017voidMicrosoftMangleContextImpl::mangleCXXRTTIBaseClassDescriptor(
4018 const CXXRecordDecl*Derived, uint32_t NVOffset, int32_t VBPtrOffset,
4019uint32_t VBTableOffset, uint32_t Flags, raw_ostream &Out) {
4020msvc_hashing_ostream MHO(Out);
4021MicrosoftCXXNameMangler Mangler(*
this, MHO);
4022Mangler.getStream() <<
"??_R1";
4023Mangler.mangleNumber(NVOffset);
4024Mangler.mangleNumber(VBPtrOffset);
4025Mangler.mangleNumber(VBTableOffset);
4026Mangler.mangleNumber(Flags);
4027Mangler.mangleName(Derived);
4028Mangler.getStream() <<
"8";
4031voidMicrosoftMangleContextImpl::mangleCXXRTTIBaseClassArray(
4033msvc_hashing_ostream MHO(Out);
4034MicrosoftCXXNameMangler Mangler(*
this, MHO);
4035Mangler.getStream() <<
"??_R2";
4036Mangler.mangleName(Derived);
4037Mangler.getStream() <<
"8";
4040voidMicrosoftMangleContextImpl::mangleCXXRTTIClassHierarchyDescriptor(
4042msvc_hashing_ostream MHO(Out);
4043MicrosoftCXXNameMangler Mangler(*
this, MHO);
4044Mangler.getStream() <<
"??_R3";
4045Mangler.mangleName(Derived);
4046Mangler.getStream() <<
"8";
4049voidMicrosoftMangleContextImpl::mangleCXXRTTICompleteObjectLocator(
4057llvm::raw_svector_ostream Stream(VFTableMangling);
4058mangleCXXVFTable(Derived, BasePath, Stream);
4060 if(VFTableMangling.starts_with(
"??@")) {
4061assert(VFTableMangling.ends_with(
"@"));
4062Out << VFTableMangling <<
"??_R4@";
4066assert(VFTableMangling.starts_with(
"??_7") ||
4067VFTableMangling.starts_with(
"??_S"));
4069Out <<
"??_R4"<< VFTableMangling.str().drop_front(4);
4072voidMicrosoftMangleContextImpl::mangleSEHFilterExpression(
4073 GlobalDeclEnclosingDecl, raw_ostream &Out) {
4074msvc_hashing_ostream MHO(Out);
4075MicrosoftCXXNameMangler Mangler(*
this, MHO);
4080Mangler.getStream() <<
"?filt$"<< SEHFilterIds[EnclosingDecl]++ <<
"@0@";
4081Mangler.mangleName(EnclosingDecl);
4084voidMicrosoftMangleContextImpl::mangleSEHFinallyBlock(
4085 GlobalDeclEnclosingDecl, raw_ostream &Out) {
4086msvc_hashing_ostream MHO(Out);
4087MicrosoftCXXNameMangler Mangler(*
this, MHO);
4092Mangler.getStream() <<
"?fin$"<< SEHFinallyIds[EnclosingDecl]++ <<
"@0@";
4093Mangler.mangleName(EnclosingDecl);
4096voidMicrosoftMangleContextImpl::mangleCanonicalTypeName(
4097 QualType T, raw_ostream &Out,
boolNormalizeIntegers =
false) {
4100MicrosoftCXXNameMangler Mangler(*
this, Out);
4101Mangler.getStream() <<
'?';
4102Mangler.mangleType(
T.getCanonicalType(),
SourceRange());
4105voidMicrosoftMangleContextImpl::mangleReferenceTemporary(
4106 const VarDecl*VD,
unsignedManglingNumber, raw_ostream &Out) {
4107msvc_hashing_ostream MHO(Out);
4108MicrosoftCXXNameMangler Mangler(*
this, MHO);
4110Mangler.getStream() <<
"?";
4111Mangler.mangleSourceName(
"$RT"+ llvm::utostr(ManglingNumber));
4112Mangler.mangle(VD,
"");
4115voidMicrosoftMangleContextImpl::mangleThreadSafeStaticGuardVariable(
4116 const VarDecl*VD,
unsignedGuardNum, raw_ostream &Out) {
4117msvc_hashing_ostream MHO(Out);
4118MicrosoftCXXNameMangler Mangler(*
this, MHO);
4120Mangler.getStream() <<
"?";
4121Mangler.mangleSourceName(
"$TSS"+ llvm::utostr(GuardNum));
4122Mangler.mangleNestedName(VD);
4123Mangler.getStream() <<
"@4HA";
4126voidMicrosoftMangleContextImpl::mangleStaticGuardVariable(
const VarDecl*VD,
4138msvc_hashing_ostream MHO(Out);
4139MicrosoftCXXNameMangler Mangler(*
this, MHO);
4143Mangler.getStream() << (VD->
getTLSKind() ?
"??__J":
"??_B");
4145Mangler.getStream() <<
"?$S1@";
4147 unsignedScopeDepth = 0;
4148 if(Visible && !getNextDiscriminator(VD, ScopeDepth))
4152Mangler.mangle(VD,
"");
4154Mangler.mangleNestedName(VD);
4155Mangler.getStream() << (Visible ?
"@5":
"@4IA");
4157Mangler.mangleNumber(ScopeDepth);
4160voidMicrosoftMangleContextImpl::mangleInitFiniStub(
const VarDecl*
D,
4163msvc_hashing_ostream MHO(Out);
4164MicrosoftCXXNameMangler Mangler(*
this, MHO);
4165Mangler.getStream() <<
"??__"<< CharCode;
4166 if(
D->isStaticDataMember()) {
4167Mangler.getStream() <<
'?';
4168Mangler.mangleName(
D);
4169Mangler.mangleVariableEncoding(
D);
4170Mangler.getStream() <<
"@@";
4172Mangler.mangleName(
D);
4176Mangler.getStream() <<
"YAXXZ";
4179voidMicrosoftMangleContextImpl::mangleDynamicInitializer(
const VarDecl*
D,
4182mangleInitFiniStub(
D,
'E', Out);
4186MicrosoftMangleContextImpl::mangleDynamicAtExitDestructor(
const VarDecl*
D,
4189mangleInitFiniStub(
D,
'F', Out);
4192voidMicrosoftMangleContextImpl::mangleStringLiteral(
const StringLiteral*SL,
4213MicrosoftCXXNameMangler Mangler(*
this, Out);
4214Mangler.getStream() <<
"??_C@_";
4222 unsignedStringLength =
4223getASTContext().getAsConstantArrayType(SL->
getType())->getZExtSize();
4228Mangler.getStream() <<
'1';
4230Mangler.getStream() <<
'0';
4234Mangler.mangleNumber(StringByteLength);
4236 autoGetLittleEndianByte = [&SL](
unsignedIndex) {
4238 if(Index / CharByteWidth >= SL->
getLength())
4239 return static_cast<char>(0);
4241 unsignedOffsetInCodeUnit = Index % CharByteWidth;
4242 return static_cast<char>((CodeUnit >> (8 * OffsetInCodeUnit)) & 0xff);
4245 autoGetBigEndianByte = [&SL](
unsignedIndex) {
4247 if(Index / CharByteWidth >= SL->
getLength())
4248 return static_cast<char>(0);
4250 unsignedOffsetInCodeUnit = (CharByteWidth - 1) - (Index % CharByteWidth);
4251 return static_cast<char>((CodeUnit >> (8 * OffsetInCodeUnit)) & 0xff);
4256 for(
unsignedI = 0,
E= StringByteLength; I !=
E; ++I)
4257JC.update(GetLittleEndianByte(I));
4261Mangler.mangleNumber(JC.getCRC());
4267 autoMangleByte = [&Mangler](
charByte) {
4275Mangler.getStream() << Byte;
4276}
else if(
isLetter(Byte & 0x7f)) {
4277Mangler.getStream() <<
'?'<<
static_cast<char>(Byte & 0x7f);
4279 const charSpecialChars[] = {
',',
'/',
'\\',
':',
'.',
4280 ' ',
'\n',
'\t',
'\'',
'-'};
4281 const char*Pos = llvm::find(SpecialChars, Byte);
4282 if(Pos != std::end(SpecialChars)) {
4283Mangler.getStream() <<
'?'<< (Pos - std::begin(SpecialChars));
4285Mangler.getStream() <<
"?$";
4286Mangler.getStream() <<
static_cast<char>(
'A'+ ((Byte >> 4) & 0xf));
4287Mangler.getStream() <<
static_cast<char>(
'A'+ (Byte & 0xf));
4293 unsignedMaxBytesToMangle = SL->
isWide() ? 64U : 32U;
4294 unsignedNumBytesToMangle = std::min(MaxBytesToMangle, StringByteLength);
4295 for(
unsignedI = 0; I != NumBytesToMangle; ++I) {
4297MangleByte(GetBigEndianByte(I));
4299MangleByte(GetLittleEndianByte(I));
4302Mangler.getStream() <<
'@';
4308manglePointerCVQualifiers(Quals);
4309manglePointerExtQualifiers(Quals, PointeeType);
4313mangleFunctionType(FPT,
nullptr,
true);
4317mangleAutoReturnType(PointeeType, QMM_Drop);
4321voidMicrosoftCXXNameMangler::mangleAutoReturnType(
const PointerType*
T,
4325 "Unexpected address space mangling required");
4327manglePointerCVQualifiers(Quals);
4328manglePointerExtQualifiers(Quals, PointeeType);
4332mangleFunctionType(FPT);
4334mangleAutoReturnType(PointeeType, QMM_Mangle);
4343manglePointerExtQualifiers(Quals, PointeeType);
4344mangleAutoReturnType(PointeeType, QMM_Mangle);
4352manglePointerExtQualifiers(Quals, PointeeType);
4353mangleAutoReturnType(PointeeType, QMM_Mangle);
4359 return newMicrosoftMangleContextImpl(Context, Diags, IsAux);
Enums/classes describing ABI related information about constructors, destructors and thunks.
Defines the clang::ASTContext interface.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines OpenMP nodes for declarative directives.
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
static unsigned getCharWidth(tok::TokenKind kind, const TargetInfo &Target)
llvm::MachO::Record Record
static GlobalDecl isTemplate(GlobalDecl GD, const TemplateArgumentList *&TemplateArgs)
static ValueDecl * getAsArrayToPointerDecayedDecl(QualType T, const APValue &V)
If value V (with type T) represents a decayed pointer to the first element of an array,...
static void mangleThunkThisAdjustment(AccessSpecifier AS, const ThisAdjustment &Adjustment, MicrosoftCXXNameMangler &Mangler, raw_ostream &Out)
Defines the SourceManager interface.
A non-discriminated union of a base, field, or array index.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
@ Indeterminate
This object has an indeterminate value (C++ [basic.indet]).
@ None
There is no such object (it's outside its lifetime).
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
SourceManager & getSourceManager()
unsigned getManglingNumber(const NamedDecl *ND, bool ForAuxTarget=false) const
TypedefNameDecl * getTypedefNameForUnnamedTagDecl(const TagDecl *TD)
const LangOptions & getLangOpts() const
bool addressSpaceMapManglingFor(LangAS AS) const
const clang::PrintingPolicy & getPrintingPolicy() const
DeclaratorDecl * getDeclaratorForUnnamedTagDecl(const TagDecl *TD)
unsigned getTargetAddressSpace(LangAS AS) const
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
CharUnits getVBPtrOffset() const
getVBPtrOffset - Get the offset for virtual base table pointer.
Represents a constant array type that does not decay to a pointer when used as a function parameter.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getElementType() const
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
A fixed int type of a specified bitwidth.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
This class is used for builtin types like 'int'.
Represents a base class of a C++ class.
Represents a C++ constructor within a class.
Represents a C++ destructor within a class.
Represents a static or instance method of a struct/union/class.
bool isImplicitObjectMemberFunction() const
[C++2b][dcl.fct]/p7 An implicit object member function is a non-static member function without an exp...
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Represents a C++ struct/union/class.
Decl * getLambdaContextDecl() const
Retrieve the declaration that provides additional context for a lambda, when the normal declaration c...
bool isLambda() const
Determine whether this class describes a lambda function object.
unsigned getLambdaManglingNumber() const
If this is the closure type of a lambda expression, retrieve the number to be used for name mangling ...
CXXRecordDecl * getMostRecentNonInjectedDecl()
MSInheritanceModel getMSInheritanceModel() const
Returns the inheritance model used for this record.
bool nullFieldOffsetIsZero() const
In the Microsoft C++ ABI, use zero for the field offset of a null data member pointer if we can guara...
CharUnits - This is an opaque type for sizes expressed in character units.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Represents a class template specialization, which refers to a class template with a given set of temp...
Complex values, per C99 6.2.5p11.
Represents the canonical version of C arrays with a specified constant size.
llvm::APInt getSize() const
Return the constant array size as an APInt.
Represents a concrete matrix type with constant number of rows and columns.
Represents a pointer type decayed from an array or function type.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isTranslationUnit() const
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool isFunctionOrMethod() const
Decl - This represents one declaration (or definition), e.g.
SourceLocation getLocation() const
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
The name of a declaration.
@ CXXConversionFunctionName
Represents a ValueDecl that came out of a declarator.
Represents the type decltype(expr) (C++11).
A decomposition declaration.
Represents a C++17 deduced template specialization type.
Represents an extended address space qualifier where the input address space value is dependent.
Represents a qualified type name for which the type name is dependent.
Represents an array type in C++ whose size is a value-dependent expression.
SourceRange getBracketsRange() const
Expr * getSizeExpr() const
Represents an extended vector type where either the type or size is dependent.
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
Represents a template specialization type whose template cannot be resolved, e.g.
Represents a vector type where either the type or size is dependent.
A little helper class used to produce diagnostics.
Concrete class used by the front-end to report problems and issues.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
This represents one expression.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc=nullptr) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
ExtVectorType - Extended vector type.
Represents a member of a struct/union/class.
Represents a function declaration or definition.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
bool isExternC() const
Determines whether this function is a function with external, C linkage.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Represents a prototype with parameter type info, e.g.
unsigned getNumParams() const
Qualifiers getMethodQuals() const
QualType getParamType(unsigned i) const
CanThrowResult canThrow() const
Determine whether this function type has a non-throwing exception specification.
bool isVariadic() const
Whether this function prototype is variadic.
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
FunctionType - C99 6.7.5.3 - Function Declarators.
CallingConv getCallConv() const
QualType getReturnType() const
GlobalDecl - represents a global declaration.
CXXCtorType getCtorType() const
KernelReferenceKind getKernelReferenceKind() const
GlobalDecl getWithDecl(const Decl *D)
CXXDtorType getDtorType() const
const Decl * getDecl() const
One of these records is kept for each identifier that is lexed.
Represents a C array with an unspecified size.
The injected class name of a C++ class template or class template partial specialization.
An lvalue reference type, per C++11 [dcl.ref].
bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const
virtual void mangleCXXDtorThunk(const CXXDestructorDecl *DD, CXXDtorType Type, const ThunkInfo &Thunk, bool ElideOverrideInfo, raw_ostream &)=0
virtual void mangleCXXRTTI(QualType T, raw_ostream &)=0
virtual std::string getLambdaString(const CXXRecordDecl *Lambda)=0
virtual bool shouldMangleStringLiteral(const StringLiteral *SL)=0
ASTContext & getASTContext() const
virtual void mangleDynamicAtExitDestructor(const VarDecl *D, raw_ostream &)=0
virtual void mangleSEHFilterExpression(GlobalDecl EnclosingDecl, raw_ostream &Out)=0
virtual void mangleThunk(const CXXMethodDecl *MD, const ThunkInfo &Thunk, bool ElideOverrideInfo, raw_ostream &)=0
virtual void mangleCanonicalTypeName(QualType T, raw_ostream &, bool NormalizeIntegers=false)=0
Generates a unique string for an externally visible type for use with TBAA or type uniquing.
virtual void mangleStringLiteral(const StringLiteral *SL, raw_ostream &)=0
virtual void mangleCXXName(GlobalDecl GD, raw_ostream &)=0
virtual void mangleReferenceTemporary(const VarDecl *D, unsigned ManglingNumber, raw_ostream &)=0
virtual bool shouldMangleCXXName(const NamedDecl *D)=0
virtual void mangleCXXRTTIName(QualType T, raw_ostream &, bool NormalizeIntegers=false)=0
virtual void mangleDynamicInitializer(const VarDecl *D, raw_ostream &)=0
virtual void mangleCXXVTable(const CXXRecordDecl *RD, raw_ostream &)=0
virtual void mangleSEHFinallyBlock(GlobalDecl EnclosingDecl, raw_ostream &Out)=0
virtual void mangleStaticGuardVariable(const VarDecl *D, raw_ostream &)=0
A pointer to member type per C++ 8.3.3 - Pointers to members.
virtual void mangleCXXVFTable(const CXXRecordDecl *Derived, ArrayRef< const CXXRecordDecl * > BasePath, raw_ostream &Out)=0
Mangle vftable symbols.
virtual void mangleVirtualMemPtrThunk(const CXXMethodDecl *MD, const MethodVFTableLocation &ML, raw_ostream &Out)=0
virtual void mangleCXXRTTICompleteObjectLocator(const CXXRecordDecl *Derived, ArrayRef< const CXXRecordDecl * > BasePath, raw_ostream &Out)=0
virtual void mangleCXXThrowInfo(QualType T, bool IsConst, bool IsVolatile, bool IsUnaligned, uint32_t NumEntries, raw_ostream &Out)=0
virtual void mangleCXXVBTable(const CXXRecordDecl *Derived, ArrayRef< const CXXRecordDecl * > BasePath, raw_ostream &Out)=0
Mangle vbtable symbols.
virtual void mangleCXXRTTIClassHierarchyDescriptor(const CXXRecordDecl *Derived, raw_ostream &Out)=0
virtual void mangleThreadSafeStaticGuardVariable(const VarDecl *VD, unsigned GuardNum, raw_ostream &Out)=0
static MicrosoftMangleContext * create(ASTContext &Context, DiagnosticsEngine &Diags, bool IsAux=false)
virtual void mangleCXXCatchableTypeArray(QualType T, uint32_t NumEntries, raw_ostream &Out)=0
virtual void mangleCXXRTTIBaseClassDescriptor(const CXXRecordDecl *Derived, uint32_t NVOffset, int32_t VBPtrOffset, uint32_t VBTableOffset, uint32_t Flags, raw_ostream &Out)=0
virtual void mangleCXXCatchableType(QualType T, const CXXConstructorDecl *CD, CXXCtorType CT, uint32_t Size, uint32_t NVOffset, int32_t VBPtrOffset, uint32_t VBIndex, raw_ostream &Out)=0
virtual void mangleCXXRTTIBaseClassArray(const CXXRecordDecl *Derived, raw_ostream &Out)=0
virtual void mangleCXXVirtualDisplacementMap(const CXXRecordDecl *SrcRD, const CXXRecordDecl *DstRD, raw_ostream &Out)=0
MethodVFTableLocation getMethodVFTableLocation(GlobalDecl GD)
This represents a decl that may have a name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
bool isExternallyVisible() const
Represent a C++ namespace.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Interfaces are the core concept in Objective-C for object oriented design.
ObjCMethodDecl - Represents an instance or class method declaration.
Represents a pointer to an Objective C object.
Represents a class type in Objective C.
Represents an Objective-C protocol declaration.
Represents a pack expansion of types.
Represents a parameter to a function.
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
PointerType - C99 6.7.5.1 - Pointer Declarators.
PrettyStackTraceDecl - If a crash occurs, indicate that it happened when doing something to a specifi...
A (possibly-)qualified type.
QualType getDesugaredType(const ASTContext &Context) const
Return the specified type with any "sugar" removed from the type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
void * getAsOpaquePtr() const
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
The collection of all-type qualifiers we support.
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_None
There is no lifetime qualification on this type.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
bool hasUnaligned() const
bool hasAddressSpace() const
bool hasObjCLifetime() const
ObjCLifetime getObjCLifetime() const
Qualifiers withoutObjCLifetime() const
LangAS getAddressSpace() const
An rvalue reference type, per C++11 [dcl.ref].
field_range fields() const
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
QualType getPointeeType() const
Encodes a location in the source.
This class handles loading and caching of source files into memory.
A trivial tuple used to represent a source range.
SourceLocation getBegin() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
const char * getStmtClassName() const
StringLiteral - This represents a string literal expression, e.g.
unsigned getLength() const
uint32_t getCodeUnit(size_t i) const
unsigned getCharByteWidth() const
Represents the result of substituting a set of types for a template type parameter pack.
Represents the declaration of a struct/union/class/enum.
TypedefNameDecl * getTypedefNameForAnonDecl() const
TagKind getTagKind() const
A template argument list.
unsigned size() const
Retrieve the number of template arguments in this template argument list.
Represents a template argument.
ArrayRef< TemplateArgument > getPackAsArray() const
Return the array of arguments in this template argument pack.
QualType getStructuralValueType() const
Get the type of a StructuralValue.
QualType getParamTypeForDecl() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
QualType getNonTypeTemplateArgumentType() const
If this is a non-type template argument, get its type.
QualType getAsType() const
Retrieve the type for a type template argument.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
QualType getIntegralType() const
Retrieve the type of the integral value.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
const APValue & getAsStructuralValue() const
Get the value of a StructuralValue.
The base class of all kinds of template declarations (e.g., class, function, etc.).
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
Represents a type template specialization; the template must be a class template, a type alias templa...
Represents a typeof (or typeof) expression (a C23 feature and GCC extension) or a typeof_unqual expre...
Represents typeof(type), a C23 feature and GCC extension, or `typeof_unqual(type),...
The base class of the type hierarchy.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isBlockPointerType() const
bool isPointerType() const
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type.
bool isMemberDataPointerType() const
bool isMemberPointerType() const
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type.
bool isFunctionType() const
bool isAnyPointerType() const
TypeClass getTypeClass() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isRecordType() const
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
Base class for declarations which introduce a typedef-name.
A unary type transform, which is a type constructed from another.
Represents the dependent type named by a dependently-scoped typename using declaration,...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
TLSKind getTLSKind() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isStaticDataMember() const
Determines whether this is a static data member.
bool isStaticLocal() const
Returns true if a variable with function scope is a static local variable.
bool isExternC() const
Determines whether this variable is a variable with external, C linkage.
Represents a variable template specialization, which refers to a variable template with a given set o...
Represents a C array with a specified size that is not an integer-constant-expression.
Represents a GCC generic vector type.
Defines the clang::TargetInfo interface.
The JSON file list parser is used to communicate input to InstallAPI.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
@ NUM_OVERLOADED_OPERATORS
CXXCtorType
C++ constructor types.
@ Ctor_DefaultClosure
Default closure variant of a ctor.
@ Ctor_CopyingClosure
Copying closure variant of a ctor.
@ Ctor_Complete
Complete object ctor.
LLVM_READONLY bool isAsciiIdentifierContinue(unsigned char c)
RefQualifierKind
The kind of C++11 ref-qualifier associated with a function type.
@ RQ_None
No ref-qualifier was provided.
@ RQ_LValue
An lvalue ref-qualifier was provided (&).
@ RQ_RValue
An rvalue ref-qualifier was provided (&&).
bool inheritanceModelHasNVOffsetField(bool IsMemberFunction, MSInheritanceModel Inheritance)
LanguageLinkage
Describes the different kinds of language linkage (C++ [dcl.link]) that an entity may have.
bool inheritanceModelHasVBPtrOffsetField(MSInheritanceModel Inheritance)
LLVM_READONLY bool isLetter(unsigned char c)
Return true if this character is an ASCII letter: [a-zA-Z].
bool inheritanceModelHasVBTableOffsetField(MSInheritanceModel Inheritance)
CXXDtorType
C++ destructor types.
@ Dtor_Comdat
The COMDAT used for dtors.
@ Dtor_Base
Base object dtor.
@ Dtor_Complete
Complete object dtor.
@ Dtor_Deleting
Deleting dtor.
TagTypeKind
The kind of a tag type.
LangAS
Defines the address space values used by the address space qualifier of QualType.
bool isPtrSizeAddressSpace(LangAS AS)
const FunctionProtoType * T
MSInheritanceModel
Assigned inheritance model for a class in the MS C++ ABI.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Diagnostic wrappers for TextAPI types for error reporting.
const CXXRecordDecl * VBase
If nonnull, holds the last vbase which contains the vfptr that the method definition is adjusted to.
CharUnits VFPtrOffset
This is the offset of the vfptr from the start of the last vbase, or the complete type if there are n...
uint64_t VBTableIndex
If nonzero, holds the vbtable index of the virtual base with the vfptr.
uint64_t Index
Method's index in the vftable.
A this pointer adjustment.
union clang::ThisAdjustment::VirtualAdjustment Virtual
int64_t NonVirtual
The non-virtual adjustment from the derived object to its nearest virtual base.
The this pointer adjustment as well as an optional return adjustment for a thunk.
ThisAdjustment This
The this pointer adjustment.
const CXXMethodDecl * Method
Holds a pointer to the overridden method this thunk is for, if needed by the ABI to distinguish diffe...
ReturnAdjustment Return
The return adjustment.
int32_t VtordispOffset
The offset of the vtordisp (in bytes), relative to the ECX.
int32_t VBOffsetOffset
The offset (in bytes) of the vbase offset in the vbtable.
int32_t VBPtrOffset
The offset of the vbptr of the derived class (in bytes), relative to the ECX after vtordisp adjustmen...
struct clang::ThisAdjustment::VirtualAdjustment::@195 Microsoft
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4