29 #include "llvm/ADT/StringExtras.h" 30 #include "llvm/Support/CRC.h" 31 #include "llvm/Support/MD5.h" 32 #include "llvm/Support/MathExtras.h" 33 #include "llvm/Support/StringSaver.h" 34 #include "llvm/Support/xxhash.h" 36 using namespace clang;
40 struct msvc_hashing_ostream :
public llvm::raw_svector_ostream {
44 msvc_hashing_ostream(raw_ostream &OS)
45 :
llvm::raw_svector_ostream(Buffer), OS(OS) {}
46 ~msvc_hashing_ostream()
override {
47 StringRef MangledName = str();
48 bool StartsWithEscape = MangledName.startswith(
"\01");
50 MangledName = MangledName.drop_front(1);
51 if (MangledName.size() <= 4096) {
57 llvm::MD5::MD5Result Hash;
58 Hasher.update(MangledName);
62 llvm::MD5::stringifyResult(Hash, HexString);
66 OS <<
"??@" << HexString <<
'@';
71 getLambdaDefaultArgumentDeclContext(
const Decl *D) {
72 if (
const auto *RD = dyn_cast<CXXRecordDecl>(D))
74 if (
const auto *Parm =
75 dyn_cast_or_null<ParmVarDecl>(RD->getLambdaContextDecl()))
76 return Parm->getDeclContext();
89 if (
const auto *LDADC = getLambdaDefaultArgumentDeclContext(D))
93 if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
95 dyn_cast_or_null<ParmVarDecl>(BD->getBlockManglingContextDecl()))
96 return ContextParam->getDeclContext();
100 if (isa<CapturedDecl>(DC) || isa<OMPDeclareReductionDecl>(DC) ||
101 isa<OMPDeclareMapperDecl>(DC)) {
102 return getEffectiveDeclContext(cast<Decl>(DC));
109 return getEffectiveDeclContext(cast<Decl>(DC));
113 if (
const auto *FTD = dyn_cast<FunctionTemplateDecl>(ND))
116 const auto *FD = cast<FunctionDecl>(ND);
117 if (
const auto *FTD = FD->getPrimaryTemplate())
126 typedef std::pair<const DeclContext *, IdentifierInfo *> DiscriminatorKeyTy;
127 llvm::DenseMap<DiscriminatorKeyTy, unsigned> Discriminator;
128 llvm::DenseMap<const NamedDecl *, unsigned> Uniquifier;
129 llvm::DenseMap<const CXXRecordDecl *, unsigned> LambdaIds;
130 llvm::DenseMap<const NamedDecl *, unsigned> SEHFilterIds;
131 llvm::DenseMap<const NamedDecl *, unsigned> SEHFinallyIds;
136 bool shouldMangleCXXName(
const NamedDecl *D)
override;
137 bool shouldMangleStringLiteral(
const StringLiteral *SL)
override;
138 void mangleCXXName(
const NamedDecl *D, raw_ostream &Out)
override;
141 raw_ostream &Out)
override;
143 raw_ostream &)
override;
146 raw_ostream &)
override;
149 raw_ostream &Out)
override;
152 raw_ostream &Out)
override;
153 void mangleCXXVirtualDisplacementMap(
const CXXRecordDecl *SrcRD,
155 raw_ostream &Out)
override;
156 void mangleCXXThrowInfo(
QualType T,
bool IsConst,
bool IsVolatile,
157 bool IsUnaligned, uint32_t NumEntries,
158 raw_ostream &Out)
override;
159 void mangleCXXCatchableTypeArray(
QualType T, uint32_t NumEntries,
160 raw_ostream &Out)
override;
163 int32_t VBPtrOffset, uint32_t VBIndex,
164 raw_ostream &Out)
override;
165 void mangleCXXRTTI(
QualType T, raw_ostream &Out)
override;
166 void mangleCXXRTTIName(
QualType T, raw_ostream &Out)
override;
167 void mangleCXXRTTIBaseClassDescriptor(
const CXXRecordDecl *Derived,
168 uint32_t NVOffset, int32_t VBPtrOffset,
169 uint32_t VBTableOffset, uint32_t Flags,
170 raw_ostream &Out)
override;
171 void mangleCXXRTTIBaseClassArray(
const CXXRecordDecl *Derived,
172 raw_ostream &Out)
override;
173 void mangleCXXRTTIClassHierarchyDescriptor(
const CXXRecordDecl *Derived,
174 raw_ostream &Out)
override;
176 mangleCXXRTTICompleteObjectLocator(
const CXXRecordDecl *Derived,
178 raw_ostream &Out)
override;
179 void mangleTypeName(
QualType T, raw_ostream &)
override;
181 raw_ostream &)
override;
183 raw_ostream &)
override;
184 void mangleReferenceTemporary(
const VarDecl *,
unsigned ManglingNumber,
185 raw_ostream &)
override;
186 void mangleStaticGuardVariable(
const VarDecl *D, raw_ostream &Out)
override;
187 void mangleThreadSafeStaticGuardVariable(
const VarDecl *D,
unsigned GuardNum,
188 raw_ostream &Out)
override;
189 void mangleDynamicInitializer(
const VarDecl *D, raw_ostream &Out)
override;
190 void mangleDynamicAtExitDestructor(
const VarDecl *D,
191 raw_ostream &Out)
override;
192 void mangleSEHFilterExpression(
const NamedDecl *EnclosingDecl,
193 raw_ostream &Out)
override;
194 void mangleSEHFinallyBlock(
const NamedDecl *EnclosingDecl,
195 raw_ostream &Out)
override;
196 void mangleStringLiteral(
const StringLiteral *SL, raw_ostream &Out)
override;
197 bool getNextDiscriminator(
const NamedDecl *ND,
unsigned &disc) {
198 const DeclContext *DC = getEffectiveDeclContext(ND);
204 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND)) {
205 if (RD->isLambda()) {
213 disc = getASTContext().getManglingNumber(ND);
218 if (
const TagDecl *Tag = dyn_cast<TagDecl>(ND)) {
219 if (!Tag->hasNameForLinkage() &&
220 !getASTContext().getDeclaratorForUnnamedTagDecl(Tag) &&
221 !getASTContext().getTypedefNameForUnnamedTagDecl(Tag))
226 unsigned &discriminator = Uniquifier[ND];
228 discriminator = ++Discriminator[std::make_pair(DC, ND->
getIdentifier())];
229 disc = discriminator + 1;
234 assert(RD->
isLambda() &&
"RD must be a lambda!");
237 "RD must not have a mangling number!");
238 std::pair<llvm::DenseMap<const CXXRecordDecl *, unsigned>::iterator,
bool>
239 Result = LambdaIds.insert(std::make_pair(RD, LambdaIds.size()));
240 return Result.first->second;
245 StringRef getAnonymousNamespaceHash()
const {
246 return AnonymousNamespaceHash;
250 void mangleInitFiniStub(
const VarDecl *D,
char CharCode, raw_ostream &Out);
255 class MicrosoftCXXNameMangler {
256 MicrosoftMangleContextImpl &Context;
263 unsigned StructorType;
266 BackRefVec NameBackReferences;
268 typedef llvm::DenseMap<const void *, unsigned> ArgBackRefMap;
269 ArgBackRefMap FunArgBackReferences;
270 ArgBackRefMap TemplateArgBackReferences;
272 typedef llvm::DenseMap<const void *, StringRef> TemplateArgStringMap;
273 TemplateArgStringMap TemplateArgStrings;
274 llvm::StringSaver TemplateArgStringStorage;
275 llvm::BumpPtrAllocator TemplateArgStringStorageAlloc;
277 typedef std::set<std::pair<int, bool>> PassObjectSizeArgsSet;
278 PassObjectSizeArgsSet PassObjectSizeArgs;
280 ASTContext &getASTContext()
const {
return Context.getASTContext(); }
282 const bool PointersAre64Bit;
285 enum QualifierMangleMode { QMM_Drop, QMM_Mangle, QMM_Escape, QMM_Result };
287 MicrosoftCXXNameMangler(MicrosoftMangleContextImpl &
C, raw_ostream &Out_)
288 : Context(C), Out(Out_), Structor(nullptr), StructorType(-1),
289 TemplateArgStringStorage(TemplateArgStringStorageAlloc),
290 PointersAre64Bit(C.getASTContext().getTargetInfo().getPointerWidth(0) ==
293 MicrosoftCXXNameMangler(MicrosoftMangleContextImpl &
C, raw_ostream &Out_,
295 : Context(C), Out(Out_), Structor(getStructor(D)), StructorType(Type),
296 TemplateArgStringStorage(TemplateArgStringStorageAlloc),
297 PointersAre64Bit(C.getASTContext().getTargetInfo().getPointerWidth(0) ==
300 MicrosoftCXXNameMangler(MicrosoftMangleContextImpl &
C, raw_ostream &Out_,
302 : Context(C), Out(Out_), Structor(getStructor(D)), StructorType(Type),
303 TemplateArgStringStorage(TemplateArgStringStorageAlloc),
304 PointersAre64Bit(C.getASTContext().getTargetInfo().getPointerWidth(0) ==
307 raw_ostream &getStream()
const {
return Out; }
309 void mangle(
const NamedDecl *D, StringRef Prefix =
"?");
311 void mangleFunctionEncoding(
const FunctionDecl *FD,
bool ShouldMangle);
312 void mangleVariableEncoding(
const VarDecl *VD);
318 void mangleNumber(int64_t Number);
320 void mangleArtificialTagType(
TagTypeKind TK, StringRef UnqualifiedName,
324 QualifierMangleMode QMM = QMM_Mangle);
327 bool ForceThisQuals =
false,
328 bool MangleExceptionSpec =
true);
329 void mangleNestedName(
const NamedDecl *ND);
332 bool isStructorDecl(
const NamedDecl *ND)
const {
333 return ND == Structor || getStructor(ND) == Structor;
343 void mangleUnqualifiedName(
const NamedDecl *ND) {
347 void mangleSourceName(StringRef Name);
350 void mangleQualifiers(
Qualifiers Quals,
bool IsMember);
352 void manglePointerCVQualifiers(
Qualifiers Quals);
355 void mangleUnscopedTemplateName(
const TemplateDecl *ND);
362 void manglePassObjectSizeArg(
const PassObjectSizeAttr *POSA);
364 bool isArtificialTagType(
QualType T)
const;
367 #define ABSTRACT_TYPE(CLASS, PARENT) 368 #define NON_CANONICAL_TYPE(CLASS, PARENT) 369 #define TYPE(CLASS, PARENT) void mangleType(const CLASS##Type *T, \ 372 #include "clang/AST/TypeNodes.inc" 374 #undef NON_CANONICAL_TYPE 377 void mangleType(
const TagDecl *TD);
378 void mangleDecayedArrayType(
const ArrayType *T);
379 void mangleArrayType(
const ArrayType *T);
383 void mangleIntegerLiteral(
const llvm::APSInt &Number,
bool IsBoolean);
384 void mangleExpression(
const Expr *E);
400 MicrosoftMangleContextImpl::MicrosoftMangleContextImpl(
ASTContext &Context,
420 uint32_t TruncatedHash = uint32_t(xxHash64(FE->getName()));
421 AnonymousNamespaceHash = llvm::utohexstr(TruncatedHash);
424 AnonymousNamespaceHash =
"0";
428 bool MicrosoftMangleContextImpl::shouldMangleCXXName(
const NamedDecl *D) {
429 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
432 if (FD->hasAttr<OverloadableAttr>())
444 if (FD->isMSVCRTEntryPoint())
458 if (!getASTContext().getLangOpts().CPlusPlus)
462 if (VD && !isa<DecompositionDecl>(D)) {
468 const DeclContext *DC = getEffectiveDeclContext(D);
472 DC = getEffectiveParentContext(DC);
475 !isa<VarTemplateSpecializationDecl>(D) &&
484 MicrosoftMangleContextImpl::shouldMangleStringLiteral(
const StringLiteral *SL) {
488 void MicrosoftCXXNameMangler::mangle(
const NamedDecl *D, StringRef Prefix) {
499 mangleFunctionEncoding(FD, Context.shouldMangleDeclName(FD));
500 else if (
const VarDecl *VD = dyn_cast<VarDecl>(D))
501 mangleVariableEncoding(VD);
503 llvm_unreachable(
"Tried to mangle unexpected NamedDecl!");
506 void MicrosoftCXXNameMangler::mangleFunctionEncoding(
const FunctionDecl *FD,
530 mangleFunctionClass(FD);
532 mangleFunctionType(FT, FD,
false,
false);
538 void MicrosoftCXXNameMangler::mangleVariableEncoding(
const VarDecl *VD) {
569 mangleType(Ty, SR, QMM_Drop);
570 manglePointerExtQualifiers(
573 mangleQualifiers(MPT->getPointeeType().getQualifiers(),
true);
576 mangleName(MPT->getClass()->getAsCXXRecordDecl());
579 }
else if (
const ArrayType *AT = getASTContext().getAsArrayType(Ty)) {
581 mangleDecayedArrayType(AT);
582 if (AT->getElementType()->isArrayType())
587 mangleType(Ty, SR, QMM_Drop);
592 void MicrosoftCXXNameMangler::mangleMemberDataPointer(
const CXXRecordDecl *RD,
599 int64_t VBTableOffset;
602 FieldOffset = getASTContext().getFieldOffset(VD);
603 assert(FieldOffset % getASTContext().
getCharWidth() == 0 &&
604 "cannot take address of bitfield");
605 FieldOffset /= getASTContext().getCharWidth();
609 if (IM == MSInheritanceModel::Virtual)
610 FieldOffset -= getASTContext().getOffsetOfBaseWithVBPtr(RD).getQuantity();
619 case MSInheritanceModel::Single: Code =
'0';
break;
620 case MSInheritanceModel::Multiple: Code =
'0';
break;
621 case MSInheritanceModel::Virtual: Code =
'F';
break;
622 case MSInheritanceModel::Unspecified: Code =
'G';
break;
627 mangleNumber(FieldOffset);
635 mangleNumber(VBTableOffset);
639 MicrosoftCXXNameMangler::mangleMemberFunctionPointer(
const CXXRecordDecl *RD,
650 case MSInheritanceModel::Single: Code =
'1';
break;
651 case MSInheritanceModel::Multiple: Code =
'H';
break;
652 case MSInheritanceModel::Virtual: Code =
'I';
break;
653 case MSInheritanceModel::Unspecified: Code =
'J';
break;
658 uint64_t NVOffset = 0;
659 uint64_t VBTableOffset = 0;
660 uint64_t VBPtrOffset = 0;
662 Out <<
'$' << Code <<
'?';
665 cast<MicrosoftVTableContext>(getASTContext().getVTableContext());
668 mangleVirtualMemPtrThunk(MD, ML);
669 NVOffset = ML.VFPtrOffset.getQuantity();
670 VBTableOffset = ML.VBTableIndex * 4;
672 const ASTRecordLayout &Layout = getASTContext().getASTRecordLayout(RD);
677 mangleFunctionEncoding(MD,
true);
680 if (VBTableOffset == 0 && IM == MSInheritanceModel::Virtual)
681 NVOffset -= getASTContext().getOffsetOfBaseWithVBPtr(RD).getQuantity();
684 if (IM == MSInheritanceModel::Single) {
688 if (IM == MSInheritanceModel::Unspecified)
694 mangleNumber(static_cast<uint32_t>(NVOffset));
696 mangleNumber(VBPtrOffset);
698 mangleNumber(VBTableOffset);
701 void MicrosoftCXXNameMangler::mangleVirtualMemPtrThunk(
704 CharUnits PointerWidth = getASTContext().toCharUnitsFromBits(
705 getASTContext().getTargetInfo().getPointerWidth(0));
711 mangleNumber(OffsetInVFTable);
716 void MicrosoftCXXNameMangler::mangleName(
const NamedDecl *ND) {
720 mangleUnqualifiedName(ND);
722 mangleNestedName(ND);
728 void MicrosoftCXXNameMangler::mangleNumber(int64_t Number) {
735 uint64_t
Value =
static_cast<uint64_t
>(Number);
743 else if (Value >= 1 && Value <= 10)
749 char EncodedNumberBuffer[
sizeof(uint64_t) * 2];
752 for (; Value != 0; Value >>= 4)
753 *I++ =
'A' + (Value & 0xf);
754 Out.write(I.base(), I - BufferRef.rbegin());
762 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
771 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
772 TemplateArgs = &Spec->getTemplateArgs();
773 return Spec->getSpecializedTemplate();
778 dyn_cast<VarTemplateSpecializationDecl>(ND)) {
779 TemplateArgs = &Spec->getTemplateArgs();
780 return Spec->getSpecializedTemplate();
786 void MicrosoftCXXNameMangler::mangleUnqualifiedName(
const NamedDecl *ND,
799 if (isa<FunctionTemplateDecl>(TD)) {
800 mangleTemplateInstantiationName(TD, *TemplateArgs);
823 ArgBackRefMap::iterator Found = TemplateArgBackReferences.find(ND);
824 if (Found == TemplateArgBackReferences.end()) {
826 TemplateArgStringMap::iterator Found = TemplateArgStrings.find(ND);
827 if (Found == TemplateArgStrings.end()) {
830 llvm::raw_svector_ostream Stream(TemplateMangling);
831 MicrosoftCXXNameMangler Extra(Context, Stream);
832 Extra.mangleTemplateInstantiationName(TD, *TemplateArgs);
835 mangleSourceName(TemplateMangling);
839 BackRefVec::iterator StringFound =
840 llvm::find(NameBackReferences, TemplateMangling);
841 if (StringFound != NameBackReferences.end()) {
842 TemplateArgBackReferences[ND] =
843 StringFound - NameBackReferences.begin();
845 TemplateArgStrings[ND] =
846 TemplateArgStringStorage.save(TemplateMangling.str());
849 Out << Found->second <<
'@';
852 Out << Found->second;
860 mangleSourceName(II->getName());
865 assert(ND &&
"mangling empty name without declaration");
868 if (NS->isAnonymousNamespace()) {
869 Out <<
"?A0x" << Context.getAnonymousNamespaceHash() <<
'@';
879 Name += llvm::utostr(Context.getAnonymousStructId(DD) + 1);
880 mangleSourceName(Name);
884 if (
const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
887 assert(RD &&
"expected variable decl to have a record type");
893 Name += llvm::utostr(Context.getAnonymousStructId(RD) + 1);
894 mangleSourceName(Name.str());
899 const TagDecl *TD = cast<TagDecl>(ND);
902 "Typedef should not be in another decl context!");
904 "Typedef was not named!");
909 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(TD)) {
910 if (Record->isLambda()) {
913 Decl *LambdaContextDecl = Record->getLambdaContextDecl();
914 unsigned LambdaManglingNumber = Record->getLambdaManglingNumber();
917 dyn_cast_or_null<ParmVarDecl>(LambdaContextDecl);
922 unsigned DefaultArgNo =
924 Name += llvm::utostr(DefaultArgNo);
928 if (LambdaManglingNumber)
929 LambdaId = LambdaManglingNumber;
931 LambdaId = Context.getLambdaId(Record);
933 Name += llvm::utostr(LambdaId);
936 mangleSourceName(Name);
940 if (LambdaManglingNumber && LambdaContextDecl) {
941 if ((isa<VarDecl>(LambdaContextDecl) ||
942 isa<FieldDecl>(LambdaContextDecl)) &&
944 mangleUnqualifiedName(cast<NamedDecl>(LambdaContextDecl));
956 Name +=
"<unnamed-type-";
957 Name += DD->getName();
963 Name +=
"<unnamed-type-";
964 Name += TND->getName();
965 }
else if (isa<EnumDecl>(TD) &&
966 cast<EnumDecl>(TD)->enumerator_begin() !=
967 cast<EnumDecl>(TD)->enumerator_end()) {
969 auto *ED = cast<EnumDecl>(TD);
970 Name +=
"<unnamed-enum-";
971 Name += ED->enumerator_begin()->getName();
974 Name +=
"<unnamed-type-$S";
975 Name += llvm::utostr(Context.getAnonymousStructId(TD) + 1);
978 mangleSourceName(Name.str());
982 case DeclarationName::ObjCZeroArgSelector:
983 case DeclarationName::ObjCOneArgSelector:
984 case DeclarationName::ObjCMultiArgSelector: {
989 mangleSourceName(Name.str());
993 case DeclarationName::CXXConstructorName:
994 if (isStructorDecl(ND)) {
1007 case DeclarationName::CXXDestructorName:
1008 if (isStructorDecl(ND))
1011 mangleCXXDtorType(static_cast<CXXDtorType>(StructorType));
1018 case DeclarationName::CXXConversionFunctionName:
1024 case DeclarationName::CXXOperatorName:
1028 case DeclarationName::CXXLiteralOperatorName: {
1034 case DeclarationName::CXXDeductionGuideName:
1035 llvm_unreachable(
"Can't mangle a deduction guide name!");
1037 case DeclarationName::CXXUsingDirective:
1038 llvm_unreachable(
"Can't mangle a using directive name!");
1044 void MicrosoftCXXNameMangler::mangleNestedName(
const NamedDecl *ND) {
1045 const DeclContext *DC = getEffectiveDeclContext(ND);
1047 if (isa<TagDecl>(ND) || isa<VarDecl>(ND)) {
1049 if (Context.getNextDiscriminator(ND, Disc)) {
1056 if (
const BlockDecl *BD = dyn_cast<BlockDecl>(DC)) {
1058 [](StringRef Name,
const unsigned Discriminator,
1059 const unsigned ParameterDiscriminator) -> std::string {
1061 llvm::raw_string_ostream Stream(Buffer);
1064 Stream <<
'_' << Discriminator;
1065 if (ParameterDiscriminator)
1066 Stream <<
'_' << ParameterDiscriminator;
1067 return Stream.str();
1070 unsigned Discriminator = BD->getBlockManglingNumber();
1072 Discriminator = Context.getBlockId(BD,
false);
1077 unsigned ParameterDiscriminator = 0;
1078 if (
const auto *MC = BD->getBlockManglingContextDecl())
1079 if (
const auto *
P = dyn_cast<ParmVarDecl>(MC))
1080 if (
const auto *F = dyn_cast<FunctionDecl>(
P->getDeclContext()))
1081 ParameterDiscriminator =
1082 F->getNumParams() -
P->getFunctionScopeIndex();
1084 DC = getEffectiveDeclContext(BD);
1087 mangleSourceName(Discriminate(
"_block_invoke", Discriminator,
1088 ParameterDiscriminator));
1093 if (
const auto *MC = BD->getBlockManglingContextDecl())
1094 if (!isa<ParmVarDecl>(MC))
1095 if (
const auto *ND = dyn_cast<NamedDecl>(MC))
1096 mangleUnqualifiedName(ND);
1100 if (
const auto *RD = dyn_cast<RecordDecl>(DC))
1109 if (PointersAre64Bit)
1113 Discriminate(
"__block_literal", Discriminator,
1114 ParameterDiscriminator));
1119 if (isa<RecordDecl>(DC))
1122 }
else if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(DC)) {
1123 mangleObjCMethodName(Method);
1124 }
else if (isa<NamedDecl>(DC)) {
1125 ND = cast<NamedDecl>(DC);
1126 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
1130 mangleUnqualifiedName(ND);
1133 if (
const auto *LDADC = getLambdaDefaultArgumentDeclContext(ND)) {
1143 void MicrosoftCXXNameMangler::mangleCXXDtorType(
CXXDtorType T) {
1158 llvm_unreachable(
"not expecting a COMDAT");
1160 llvm_unreachable(
"Unsupported dtor type?");
1169 case OO_New: Out <<
"?2";
break;
1171 case OO_Delete: Out <<
"?3";
break;
1173 case OO_Equal: Out <<
"?4";
break;
1175 case OO_GreaterGreater: Out <<
"?5";
break;
1177 case OO_LessLess: Out <<
"?6";
break;
1179 case OO_Exclaim: Out <<
"?7";
break;
1181 case OO_EqualEqual: Out <<
"?8";
break;
1183 case OO_ExclaimEqual: Out <<
"?9";
break;
1185 case OO_Subscript: Out <<
"?A";
break;
1188 case OO_Arrow: Out <<
"?C";
break;
1190 case OO_Star: Out <<
"?D";
break;
1192 case OO_PlusPlus: Out <<
"?E";
break;
1194 case OO_MinusMinus: Out <<
"?F";
break;
1196 case OO_Minus: Out <<
"?G";
break;
1198 case OO_Plus: Out <<
"?H";
break;
1200 case OO_Amp: Out <<
"?I";
break;
1202 case OO_ArrowStar: Out <<
"?J";
break;
1204 case OO_Slash: Out <<
"?K";
break;
1206 case OO_Percent: Out <<
"?L";
break;
1208 case OO_Less: Out <<
"?M";
break;
1210 case OO_LessEqual: Out <<
"?N";
break;
1212 case OO_Greater: Out <<
"?O";
break;
1214 case OO_GreaterEqual: Out <<
"?P";
break;
1216 case OO_Comma: Out <<
"?Q";
break;
1218 case OO_Call: Out <<
"?R";
break;
1220 case OO_Tilde: Out <<
"?S";
break;
1222 case OO_Caret: Out <<
"?T";
break;
1224 case OO_Pipe: Out <<
"?U";
break;
1226 case OO_AmpAmp: Out <<
"?V";
break;
1228 case OO_PipePipe: Out <<
"?W";
break;
1230 case OO_StarEqual: Out <<
"?X";
break;
1232 case OO_PlusEqual: Out <<
"?Y";
break;
1234 case OO_MinusEqual: Out <<
"?Z";
break;
1236 case OO_SlashEqual: Out <<
"?_0";
break;
1238 case OO_PercentEqual: Out <<
"?_1";
break;
1240 case OO_GreaterGreaterEqual: Out <<
"?_2";
break;
1242 case OO_LessLessEqual: Out <<
"?_3";
break;
1244 case OO_AmpEqual: Out <<
"?_4";
break;
1246 case OO_PipeEqual: Out <<
"?_5";
break;
1248 case OO_CaretEqual: Out <<
"?_6";
break;
1277 case OO_Array_New: Out <<
"?_U";
break;
1279 case OO_Array_Delete: Out <<
"?_V";
break;
1281 case OO_Coawait: Out <<
"?__L";
break;
1283 case OO_Spaceship: Out <<
"?__M";
break;
1285 case OO_Conditional: {
1288 "cannot mangle this conditional operator yet");
1289 Diags.
Report(Loc, DiagID);
1295 llvm_unreachable(
"Not an overloaded operator");
1299 void MicrosoftCXXNameMangler::mangleSourceName(StringRef Name) {
1301 BackRefVec::iterator Found = llvm::find(NameBackReferences, Name);
1302 if (Found == NameBackReferences.end()) {
1303 if (NameBackReferences.size() < 10)
1304 NameBackReferences.push_back(Name);
1307 Out << (Found - NameBackReferences.begin());
1311 void MicrosoftCXXNameMangler::mangleObjCMethodName(
const ObjCMethodDecl *MD) {
1312 Context.mangleObjCMethodName(MD, Out);
1315 void MicrosoftCXXNameMangler::mangleTemplateInstantiationName(
1322 ArgBackRefMap OuterFunArgsContext;
1323 ArgBackRefMap OuterTemplateArgsContext;
1324 BackRefVec OuterTemplateContext;
1325 PassObjectSizeArgsSet OuterPassObjectSizeArgs;
1326 NameBackReferences.swap(OuterTemplateContext);
1327 FunArgBackReferences.swap(OuterFunArgsContext);
1328 TemplateArgBackReferences.swap(OuterTemplateArgsContext);
1329 PassObjectSizeArgs.swap(OuterPassObjectSizeArgs);
1331 mangleUnscopedTemplateName(TD);
1332 mangleTemplateArgs(TD, TemplateArgs);
1335 NameBackReferences.swap(OuterTemplateContext);
1336 FunArgBackReferences.swap(OuterFunArgsContext);
1337 TemplateArgBackReferences.swap(OuterTemplateArgsContext);
1338 PassObjectSizeArgs.swap(OuterPassObjectSizeArgs);
1342 MicrosoftCXXNameMangler::mangleUnscopedTemplateName(
const TemplateDecl *TD) {
1345 mangleUnqualifiedName(TD);
1348 void MicrosoftCXXNameMangler::mangleIntegerLiteral(
const llvm::APSInt &Value,
1353 if (IsBoolean && Value.getBoolValue())
1355 else if (Value.isSigned())
1356 mangleNumber(Value.getSExtValue());
1358 mangleNumber(Value.getZExtValue());
1361 void MicrosoftCXXNameMangler::mangleExpression(
const Expr *E) {
1374 if (UO->getOpcode() == UO_AddrOf)
1375 UE = dyn_cast<CXXUuidofExpr>(UO->getSubExpr());
1393 std::string Name =
"_GUID_" + Uuid.lower();
1394 std::replace(Name.begin(), Name.end(),
'-',
'_');
1396 mangleSourceName(Name);
1402 mangleArtificialTagType(
TTK_Struct,
"__s_GUID");
1416 void MicrosoftCXXNameMangler::mangleTemplateArgs(
1420 assert(TPL->
size() == TemplateArgs.
size() &&
1421 "size mismatch between args and parms!");
1423 for (
size_t i = 0; i < TemplateArgs.
size(); ++i) {
1427 if (i > 0 && TA.
getKind() == TemplateArgument::Pack &&
1428 TemplateArgs[i - 1].getKind() == TemplateArgument::Pack)
1431 mangleTemplateArg(TD, TA, TPL->
getParam(i));
1435 void MicrosoftCXXNameMangler::mangleTemplateArg(
const TemplateDecl *TD,
1449 llvm_unreachable(
"Can't mangle null template arguments!");
1450 case TemplateArgument::TemplateExpansion:
1451 llvm_unreachable(
"Can't mangle template expansion arguments!");
1457 case TemplateArgument::Declaration: {
1459 if (isa<FieldDecl>(ND) || isa<IndirectFieldDecl>(ND)) {
1460 mangleMemberDataPointer(cast<CXXRecordDecl>(ND->
getDeclContext())
1461 ->getMostRecentNonInjectedDecl(),
1462 cast<ValueDecl>(ND));
1463 }
else if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
1466 mangleMemberFunctionPointer(
1471 mangleFunctionEncoding(FD,
true);
1478 case TemplateArgument::Integral:
1482 case TemplateArgument::NullPtr: {
1485 const CXXRecordDecl *RD = MPT->getMostRecentCXXRecordDecl();
1486 if (MPT->isMemberFunctionPointerType() &&
1487 !isa<FunctionTemplateDecl>(TD)) {
1488 mangleMemberFunctionPointer(RD,
nullptr);
1491 if (MPT->isMemberDataPointer()) {
1492 if (!isa<FunctionTemplateDecl>(TD)) {
1493 mangleMemberDataPointer(RD,
nullptr);
1503 mangleIntegerLiteral(llvm::APSInt::get(-1),
false);
1508 mangleIntegerLiteral(llvm::APSInt::getUnsigned(0),
false);
1511 case TemplateArgument::Expression:
1514 case TemplateArgument::Pack: {
1516 if (TemplateArgs.empty()) {
1517 if (isa<TemplateTypeParmDecl>(Parm) ||
1518 isa<TemplateTemplateParmDecl>(Parm))
1522 LangOptions::MSVC2015)
1525 else if (isa<NonTypeTemplateParmDecl>(Parm))
1528 llvm_unreachable(
"unexpected template parameter decl!");
1531 mangleTemplateArg(TD, PA, Parm);
1535 case TemplateArgument::Template: {
1538 if (
const auto *TD = dyn_cast<TagDecl>(ND)) {
1540 }
else if (isa<TypeAliasDecl>(ND)) {
1544 llvm_unreachable(
"unexpected template template NamedDecl!");
1551 void MicrosoftCXXNameMangler::mangleObjCProtocol(
const ObjCProtocolDecl *PD) {
1553 llvm::raw_svector_ostream Stream(TemplateMangling);
1554 MicrosoftCXXNameMangler Extra(Context, Stream);
1557 Extra.mangleSourceName(
"Protocol");
1560 mangleArtificialTagType(
TTK_Struct, TemplateMangling, {
"__ObjC"});
1563 void MicrosoftCXXNameMangler::mangleObjCLifetime(
const QualType Type,
1567 llvm::raw_svector_ostream Stream(TemplateMangling);
1568 MicrosoftCXXNameMangler Extra(Context, Stream);
1572 case Qualifiers::OCL_None:
1573 case Qualifiers::OCL_ExplicitNone:
1575 case Qualifiers::OCL_Autoreleasing:
1576 Extra.mangleSourceName(
"Autoreleasing");
1578 case Qualifiers::OCL_Strong:
1579 Extra.mangleSourceName(
"Strong");
1581 case Qualifiers::OCL_Weak:
1582 Extra.mangleSourceName(
"Weak");
1585 Extra.manglePointerCVQualifiers(Quals);
1586 Extra.manglePointerExtQualifiers(Quals, Type);
1587 Extra.mangleType(Type, Range);
1589 mangleArtificialTagType(
TTK_Struct, TemplateMangling, {
"__ObjC"});
1592 void MicrosoftCXXNameMangler::mangleObjCKindOfType(
const ObjCObjectType *T,
1596 llvm::raw_svector_ostream Stream(TemplateMangling);
1597 MicrosoftCXXNameMangler Extra(Context, Stream);
1600 Extra.mangleSourceName(
"KindOf");
1602 .stripObjCKindOfType(getASTContext())
1603 ->getAs<ObjCObjectType>(),
1606 mangleArtificialTagType(
TTK_Struct, TemplateMangling, {
"__ObjC"});
1609 void MicrosoftCXXNameMangler::mangleQualifiers(
Qualifiers Quals,
1667 if (HasConst && HasVolatile) {
1669 }
else if (HasVolatile) {
1671 }
else if (HasConst) {
1677 if (HasConst && HasVolatile) {
1679 }
else if (HasVolatile) {
1681 }
else if (HasConst) {
1692 MicrosoftCXXNameMangler::mangleRefQualifier(
RefQualifierKind RefQualifier) {
1695 switch (RefQualifier) {
1709 void MicrosoftCXXNameMangler::manglePointerExtQualifiers(
Qualifiers Quals,
1712 bool is64Bit = PointeeType.
isNull() ? PointersAre64Bit :
1725 void MicrosoftCXXNameMangler::manglePointerCVQualifiers(
Qualifiers Quals) {
1733 if (HasConst && HasVolatile) {
1735 }
else if (HasVolatile) {
1737 }
else if (HasConst) {
1744 void MicrosoftCXXNameMangler::mangleFunctionArgumentType(
QualType T,
1755 QualType OriginalType = DT->getOriginalType();
1758 if (
const auto *AT = getASTContext().getAsArrayType(OriginalType))
1759 OriginalType = getASTContext().getIncompleteArrayType(
1760 AT->getElementType(), AT->getSizeModifier(),
1761 AT->getIndexTypeCVRQualifiers());
1775 ArgBackRefMap::iterator Found = FunArgBackReferences.find(TypePtr);
1777 if (Found == FunArgBackReferences.end()) {
1778 size_t OutSizeBefore = Out.tell();
1780 mangleType(T, Range, QMM_Drop);
1785 bool LongerThanOneChar = (Out.tell() - OutSizeBefore > 1);
1786 if (LongerThanOneChar && FunArgBackReferences.size() < 10) {
1787 size_t Size = FunArgBackReferences.size();
1788 FunArgBackReferences[TypePtr] = Size;
1791 Out << Found->second;
1795 void MicrosoftCXXNameMangler::manglePassObjectSizeArg(
1796 const PassObjectSizeAttr *POSA) {
1797 int Type = POSA->getType();
1798 bool Dynamic = POSA->isDynamic();
1800 auto Iter = PassObjectSizeArgs.insert({
Type, Dynamic}).first;
1801 auto *TypePtr = (
const void *)&*Iter;
1802 ArgBackRefMap::iterator Found = FunArgBackReferences.find(TypePtr);
1804 if (Found == FunArgBackReferences.end()) {
1806 Dynamic ?
"__pass_dynamic_object_size" :
"__pass_object_size";
1807 mangleArtificialTagType(
TTK_Enum, Name + llvm::utostr(Type), {
"__clang"});
1809 if (FunArgBackReferences.size() < 10) {
1810 size_t Size = FunArgBackReferences.size();
1811 FunArgBackReferences[TypePtr] = Size;
1814 Out << Found->second;
1818 void MicrosoftCXXNameMangler::mangleAddressSpaceType(
QualType T,
1836 llvm::raw_svector_ostream Stream(ASMangling);
1837 MicrosoftCXXNameMangler Extra(Context, Stream);
1843 Extra.mangleSourceName(
"_AS");
1844 Extra.mangleIntegerLiteral(llvm::APSInt::getUnsigned(TargetAS),
1849 llvm_unreachable(
"Not a language specific address space");
1850 case LangAS::opencl_global:
1851 Extra.mangleSourceName(
"_ASCLglobal");
1853 case LangAS::opencl_local:
1854 Extra.mangleSourceName(
"_ASCLlocal");
1856 case LangAS::opencl_constant:
1857 Extra.mangleSourceName(
"_ASCLconstant");
1859 case LangAS::opencl_private:
1860 Extra.mangleSourceName(
"_ASCLprivate");
1862 case LangAS::opencl_generic:
1863 Extra.mangleSourceName(
"_ASCLgeneric");
1865 case LangAS::cuda_device:
1866 Extra.mangleSourceName(
"_ASCUdevice");
1868 case LangAS::cuda_constant:
1869 Extra.mangleSourceName(
"_ASCUconstant");
1871 case LangAS::cuda_shared:
1872 Extra.mangleSourceName(
"_ASCUshared");
1874 case LangAS::ptr32_sptr:
1875 case LangAS::ptr32_uptr:
1877 llvm_unreachable(
"don't mangle ptr address spaces with _AS");
1881 Extra.mangleType(T, Range, QMM_Escape);
1883 mangleArtificialTagType(
TTK_Struct, ASMangling, {
"__clang"});
1887 QualifierMangleMode QMM) {
1893 if (
const ArrayType *AT = getASTContext().getAsArrayType(T)) {
1896 if (QMM == QMM_Mangle)
1898 else if (QMM == QMM_Escape || QMM == QMM_Result)
1900 mangleArrayType(AT);
1913 if (
const FunctionType *FT = dyn_cast<FunctionType>(T)) {
1915 mangleFunctionType(FT);
1918 mangleQualifiers(Quals,
false);
1921 if (!IsPointer && Quals) {
1923 mangleQualifiers(Quals,
false);
1931 if ((!IsPointer && Quals) || isa<TagType>(T) || isArtificialTagType(T)) {
1933 mangleQualifiers(Quals,
false);
1941 #define ABSTRACT_TYPE(CLASS, PARENT) 1942 #define NON_CANONICAL_TYPE(CLASS, PARENT) \ 1944 llvm_unreachable("can't mangle non-canonical type " #CLASS "Type"); \ 1946 #define TYPE(CLASS, PARENT) \ 1948 mangleType(cast<CLASS##Type>(ty), Quals, Range); \ 1950 #include "clang/AST/TypeNodes.inc" 1951 #undef ABSTRACT_TYPE 1952 #undef NON_CANONICAL_TYPE 1987 case BuiltinType::Void:
1990 case BuiltinType::SChar:
1993 case BuiltinType::Char_U:
1994 case BuiltinType::Char_S:
1997 case BuiltinType::UChar:
2000 case BuiltinType::Short:
2003 case BuiltinType::UShort:
2006 case BuiltinType::Int:
2009 case BuiltinType::UInt:
2012 case BuiltinType::Long:
2015 case BuiltinType::ULong:
2018 case BuiltinType::Float:
2021 case BuiltinType::Double:
2025 case BuiltinType::LongDouble:
2028 case BuiltinType::LongLong:
2031 case BuiltinType::ULongLong:
2034 case BuiltinType::Int128:
2037 case BuiltinType::UInt128:
2040 case BuiltinType::Bool:
2043 case BuiltinType::Char8:
2046 case BuiltinType::Char16:
2049 case BuiltinType::Char32:
2052 case BuiltinType::WChar_S:
2053 case BuiltinType::WChar_U:
2057 #define BUILTIN_TYPE(Id, SingletonId) 2058 #define PLACEHOLDER_TYPE(Id, SingletonId) \ 2059 case BuiltinType::Id: 2060 #include "clang/AST/BuiltinTypes.def" 2061 case BuiltinType::Dependent:
2062 llvm_unreachable(
"placeholder types shouldn't get to name mangling");
2064 case BuiltinType::ObjCId:
2065 mangleArtificialTagType(
TTK_Struct,
"objc_object");
2067 case BuiltinType::ObjCClass:
2068 mangleArtificialTagType(
TTK_Struct,
"objc_class");
2070 case BuiltinType::ObjCSel:
2071 mangleArtificialTagType(
TTK_Struct,
"objc_selector");
2074 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 2075 case BuiltinType::Id: \ 2076 Out << "PAUocl_" #ImgType "_" #Suffix "@@"; \ 2078 #include "clang/Basic/OpenCLImageTypes.def" 2079 case BuiltinType::OCLSampler:
2081 mangleArtificialTagType(
TTK_Struct,
"ocl_sampler");
2083 case BuiltinType::OCLEvent:
2085 mangleArtificialTagType(
TTK_Struct,
"ocl_event");
2087 case BuiltinType::OCLClkEvent:
2089 mangleArtificialTagType(
TTK_Struct,
"ocl_clkevent");
2091 case BuiltinType::OCLQueue:
2093 mangleArtificialTagType(
TTK_Struct,
"ocl_queue");
2095 case BuiltinType::OCLReserveID:
2097 mangleArtificialTagType(
TTK_Struct,
"ocl_reserveid");
2099 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 2100 case BuiltinType::Id: \ 2101 mangleArtificialTagType(TTK_Struct, "ocl_" #ExtType); \ 2103 #include "clang/Basic/OpenCLExtensionTypes.def" 2105 case BuiltinType::NullPtr:
2109 case BuiltinType::Float16:
2110 mangleArtificialTagType(
TTK_Struct,
"_Float16", {
"__clang"});
2113 case BuiltinType::Half:
2114 mangleArtificialTagType(
TTK_Struct,
"_Half", {
"__clang"});
2117 #define SVE_TYPE(Name, Id, SingletonId) \ 2118 case BuiltinType::Id: 2119 #include "clang/Basic/AArch64SVEACLETypes.def" 2120 case BuiltinType::ShortAccum:
2121 case BuiltinType::Accum:
2122 case BuiltinType::LongAccum:
2123 case BuiltinType::UShortAccum:
2124 case BuiltinType::UAccum:
2125 case BuiltinType::ULongAccum:
2126 case BuiltinType::ShortFract:
2127 case BuiltinType::Fract:
2128 case BuiltinType::LongFract:
2129 case BuiltinType::UShortFract:
2130 case BuiltinType::UFract:
2131 case BuiltinType::ULongFract:
2132 case BuiltinType::SatShortAccum:
2133 case BuiltinType::SatAccum:
2134 case BuiltinType::SatLongAccum:
2135 case BuiltinType::SatUShortAccum:
2136 case BuiltinType::SatUAccum:
2137 case BuiltinType::SatULongAccum:
2138 case BuiltinType::SatShortFract:
2139 case BuiltinType::SatFract:
2140 case BuiltinType::SatLongFract:
2141 case BuiltinType::SatUShortFract:
2142 case BuiltinType::SatUFract:
2143 case BuiltinType::SatULongFract:
2144 case BuiltinType::Float128: {
2163 mangleFunctionType(T,
nullptr,
true);
2166 mangleFunctionType(T);
2172 mangleFunctionType(T);
2175 void MicrosoftCXXNameMangler::mangleFunctionType(
const FunctionType *T,
2177 bool ForceThisQuals,
2178 bool MangleExceptionSpec) {
2186 bool IsInLambda =
false;
2187 bool IsStructor =
false, HasThisQuals = ForceThisQuals, IsCtorClosure =
false;
2189 if (
const CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl>(D)) {
2192 if (MD->isInstance())
2193 HasThisQuals =
true;
2194 if (isa<CXXDestructorDecl>(MD)) {
2196 }
else if (isa<CXXConstructorDecl>(MD)) {
2202 CC = getASTContext().getDefaultCallingConvention(
2211 manglePointerExtQualifiers(Quals,
QualType());
2213 mangleQualifiers(Quals,
false);
2216 mangleCallingConvention(CC);
2221 if (isa<CXXDestructorDecl>(D) && isStructorDecl(D)) {
2225 Out << (PointersAre64Bit ?
"PEAXI@Z" :
"PAXI@Z");
2234 if (IsCtorClosure) {
2244 mangleFunctionArgumentType(getASTContext().getLValueReferenceType(
2252 llvm_unreachable(
"unexpected constructor closure!");
2260 if (
const auto *AT =
2265 assert(AT->getKeyword() != AutoTypeKeyword::GNUAutoType &&
2266 "shouldn't need to mangle __auto_type!");
2267 mangleSourceName(AT->isDecltypeAuto() ?
"<decltype-auto>" :
"<auto>");
2269 }
else if (IsInLambda) {
2274 mangleType(ResultType, Range, QMM_Result);
2290 for (
unsigned I = 0, E = Proto->
getNumParams(); I != E; ++I) {
2291 mangleFunctionArgumentType(Proto->
getParamType(I), Range);
2302 manglePassObjectSizeArg(
P);
2311 if (MangleExceptionSpec && getASTContext().getLangOpts().CPlusPlus17 &&
2312 getASTContext().getLangOpts().isCompatibleWithMSVC(
2313 LangOptions::MSVC2017_5))
2314 mangleThrowSpecification(Proto);
2319 void MicrosoftCXXNameMangler::mangleFunctionClass(
const FunctionDecl *FD) {
2344 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
2345 bool IsVirtual = MD->isVirtual();
2348 if (isa<CXXDestructorDecl>(MD) && isStructorDecl(MD) &&
2354 llvm_unreachable(
"Unsupported access specifier");
2383 void MicrosoftCXXNameMangler::mangleCallingConvention(
CallingConv CC) {
2404 llvm_unreachable(
"Unsupported CC for mangling");
2407 case CC_C: Out <<
'A';
break;
2418 void MicrosoftCXXNameMangler::mangleCallingConvention(
const FunctionType *T) {
2422 void MicrosoftCXXNameMangler::mangleThrowSpecification(
2438 "cannot mangle this unresolved dependent type yet");
2448 void MicrosoftCXXNameMangler::mangleTagTypeKind(
TagTypeKind TTK) {
2467 mangleType(cast<TagType>(T)->getDecl());
2471 mangleType(cast<TagType>(T)->getDecl());
2473 void MicrosoftCXXNameMangler::mangleType(
const TagDecl *TD) {
2479 void MicrosoftCXXNameMangler::mangleArtificialTagType(
2483 mangleTagTypeKind(TK);
2486 mangleSourceName(UnqualifiedName);
2488 for (
auto I = NestedNames.rbegin(), E = NestedNames.rend(); I != E; ++I)
2489 mangleSourceName(*I);
2502 void MicrosoftCXXNameMangler::mangleDecayedArrayType(
const ArrayType *T) {
2510 llvm_unreachable(
"Should have been special cased");
2514 llvm_unreachable(
"Should have been special cased");
2518 llvm_unreachable(
"Should have been special cased");
2522 llvm_unreachable(
"Should have been special cased");
2524 void MicrosoftCXXNameMangler::mangleArrayType(
const ArrayType *T) {
2530 getASTContext().getAsConstantArrayType(ElementTy);
2531 Dimensions.push_back(CAT->
getSize());
2535 getASTContext().getAsIncompleteArrayType(ElementTy);
2540 getASTContext().getAsVariableArrayType(ElementTy);
2546 getASTContext().getAsDependentSizedArrayType(ElementTy);
2549 "cannot mangle this dependent-length array yet");
2559 mangleNumber(Dimensions.size());
2561 mangleNumber(Dimension.getLimitedValue());
2571 manglePointerCVQualifiers(Quals);
2572 manglePointerExtQualifiers(Quals, PointeeType);
2576 mangleFunctionType(FPT,
nullptr,
true);
2580 mangleType(PointeeType, Range, QMM_Drop);
2588 "cannot mangle this template type parameter type yet");
2597 "cannot mangle this substituted parameter pack yet");
2608 manglePointerCVQualifiers(Quals);
2609 manglePointerExtQualifiers(Quals, PointeeType);
2615 mangleType(PointeeType, Range);
2617 mangleAddressSpaceType(PointeeType, PointeeType.
getQualifiers(), Range);
2624 case Qualifiers::OCL_None:
2625 case Qualifiers::OCL_ExplicitNone:
2627 case Qualifiers::OCL_Autoreleasing:
2628 case Qualifiers::OCL_Strong:
2629 case Qualifiers::OCL_Weak:
2630 return mangleObjCLifetime(PointeeType, Quals, Range);
2632 manglePointerCVQualifiers(Quals);
2633 manglePointerExtQualifiers(Quals, PointeeType);
2634 mangleType(PointeeType, Range);
2645 manglePointerExtQualifiers(Quals, PointeeType);
2646 mangleType(PointeeType, Range);
2657 manglePointerExtQualifiers(Quals, PointeeType);
2658 mangleType(PointeeType, Range);
2666 llvm::raw_svector_ostream Stream(TemplateMangling);
2667 MicrosoftCXXNameMangler Extra(Context, Stream);
2669 Extra.mangleSourceName(
"_Complex");
2670 Extra.mangleType(ElementType, Range, QMM_Escape);
2672 mangleArtificialTagType(
TTK_Struct, TemplateMangling, {
"__clang"});
2680 bool MicrosoftCXXNameMangler::isArtificialTagType(
QualType T)
const {
2686 case Type::Vector: {
2698 assert(ET &&
"vectors with non-builtin elements are unsupported");
2699 uint64_t Width = getASTContext().getTypeSize(T);
2702 size_t OutSizeBefore = Out.tell();
2703 if (!isa<ExtVectorType>(T)) {
2704 if (getASTContext().getTargetInfo().getTriple().isX86()) {
2705 if (Width == 64 && ET->
getKind() == BuiltinType::LongLong) {
2706 mangleArtificialTagType(
TTK_Union,
"__m64");
2707 }
else if (Width >= 128) {
2708 if (ET->
getKind() == BuiltinType::Float)
2709 mangleArtificialTagType(
TTK_Union,
"__m" + llvm::utostr(Width));
2710 else if (ET->
getKind() == BuiltinType::LongLong)
2711 mangleArtificialTagType(
TTK_Union,
"__m" + llvm::utostr(Width) +
'i');
2712 else if (ET->
getKind() == BuiltinType::Double)
2713 mangleArtificialTagType(
TTK_Struct,
"__m" + llvm::utostr(Width) +
'd');
2718 bool IsBuiltin = Out.tell() != OutSizeBefore;
2725 llvm::raw_svector_ostream Stream(TemplateMangling);
2726 MicrosoftCXXNameMangler Extra(Context, Stream);
2728 Extra.mangleSourceName(
"__vector");
2729 Extra.mangleType(
QualType(ET, 0), Range, QMM_Escape);
2730 Extra.mangleIntegerLiteral(llvm::APSInt::getUnsigned(T->
getNumElements()),
2733 mangleArtificialTagType(
TTK_Union, TemplateMangling, {
"__clang"});
2737 void MicrosoftCXXNameMangler::mangleType(
const ExtVectorType *T,
2739 mangleType(static_cast<const VectorType *>(T), Quals, Range);
2747 "cannot mangle this dependent-sized vector type yet");
2755 "cannot mangle this dependent-sized extended vector type yet");
2765 "cannot mangle this dependent address space type yet");
2776 void MicrosoftCXXNameMangler::mangleType(
const ObjCObjectType *T,
2779 return mangleObjCKindOfType(T, Quals, Range);
2782 return mangleType(T->
getBaseType(), Range, QMM_Drop);
2784 ArgBackRefMap OuterFunArgsContext;
2785 ArgBackRefMap OuterTemplateArgsContext;
2786 BackRefVec OuterTemplateContext;
2788 FunArgBackReferences.swap(OuterFunArgsContext);
2789 TemplateArgBackReferences.swap(OuterTemplateArgsContext);
2790 NameBackReferences.swap(OuterTemplateContext);
2796 mangleSourceName(
"objc_object");
2798 mangleSourceName(
"objc_class");
2802 for (
const auto &Q : T->
quals())
2803 mangleObjCProtocol(Q);
2807 mangleType(TA, Range, QMM_Drop);
2813 FunArgBackReferences.swap(OuterFunArgsContext);
2814 TemplateArgBackReferences.swap(OuterTemplateArgsContext);
2815 NameBackReferences.swap(OuterTemplateContext);
2821 manglePointerCVQualifiers(Quals);
2822 manglePointerExtQualifiers(Quals, PointeeType);
2831 llvm_unreachable(
"Cannot mangle injected class name type.");
2838 "cannot mangle this template specialization type yet");
2847 "cannot mangle this dependent name type yet");
2852 void MicrosoftCXXNameMangler::mangleType(
2857 "cannot mangle this dependent template specialization type yet");
2866 "cannot mangle this pack expansion yet");
2875 "cannot mangle this typeof(type) yet");
2884 "cannot mangle this typeof(expression) yet");
2893 "cannot mangle this decltype() yet");
2902 "cannot mangle this unary transform type yet");
2913 "cannot mangle this 'auto' type yet");
2914 Diags.Report(Range.
getBegin(), DiagID)
2918 void MicrosoftCXXNameMangler::mangleType(
2924 "cannot mangle this deduced class template specialization type yet");
2925 Diags.Report(Range.
getBegin(), DiagID)
2934 llvm::raw_svector_ostream Stream(TemplateMangling);
2935 MicrosoftCXXNameMangler Extra(Context, Stream);
2937 Extra.mangleSourceName(
"_Atomic");
2938 Extra.mangleType(ValueType, Range, QMM_Escape);
2940 mangleArtificialTagType(
TTK_Struct, TemplateMangling, {
"__clang"});
2947 "cannot mangle this OpenCL pipe type yet");
2952 void MicrosoftMangleContextImpl::mangleCXXName(
const NamedDecl *D,
2954 assert((isa<FunctionDecl>(D) || isa<VarDecl>(D)) &&
2955 "Invalid mangleName() call, argument is not a variable or function!");
2956 assert(!isa<CXXConstructorDecl>(D) && !isa<CXXDestructorDecl>(D) &&
2957 "Invalid mangleName() call on 'structor decl!");
2960 getASTContext().getSourceManager(),
2961 "Mangling declaration");
2963 msvc_hashing_ostream MHO(Out);
2964 MicrosoftCXXNameMangler Mangler(*
this, MHO);
2965 return Mangler.mangle(D);
2994 MicrosoftCXXNameMangler &Mangler,
3001 llvm_unreachable(
"Unsupported access specifier");
3012 Out <<
'R' << AccessSpec;
3013 Mangler.mangleNumber(
3015 Mangler.mangleNumber(
3017 Mangler.mangleNumber(
3019 Mangler.mangleNumber(static_cast<uint32_t>(Adjustment.
NonVirtual));
3022 Mangler.mangleNumber(
3024 Mangler.mangleNumber(-static_cast<uint32_t>(Adjustment.
NonVirtual));
3029 llvm_unreachable(
"Unsupported access specifier");
3039 Mangler.mangleNumber(-static_cast<uint32_t>(Adjustment.
NonVirtual));
3043 llvm_unreachable(
"Unsupported access specifier");
3056 void MicrosoftMangleContextImpl::mangleVirtualMemPtrThunk(
3059 msvc_hashing_ostream MHO(Out);
3060 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3061 Mangler.getStream() <<
'?';
3062 Mangler.mangleVirtualMemPtrThunk(MD, ML);
3065 void MicrosoftMangleContextImpl::mangleThunk(
const CXXMethodDecl *MD,
3068 msvc_hashing_ostream MHO(Out);
3069 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3070 Mangler.getStream() <<
'?';
3071 Mangler.mangleName(MD);
3080 assert(Thunk.
Method !=
nullptr &&
3081 "Thunk info should hold the overridee decl");
3084 Mangler.mangleFunctionType(
3088 void MicrosoftMangleContextImpl::mangleCXXDtorThunk(
3095 msvc_hashing_ostream MHO(Out);
3096 MicrosoftCXXNameMangler Mangler(*
this, MHO, DD, Type);
3097 Mangler.getStream() <<
"??_E";
3103 void MicrosoftMangleContextImpl::mangleCXXVFTable(
3110 msvc_hashing_ostream MHO(Out);
3111 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3112 if (Derived->
hasAttr<DLLImportAttr>())
3113 Mangler.getStream() <<
"??_S";
3115 Mangler.getStream() <<
"??_7";
3116 Mangler.mangleName(Derived);
3117 Mangler.getStream() <<
"6B";
3119 Mangler.mangleName(RD);
3120 Mangler.getStream() <<
'@';
3123 void MicrosoftMangleContextImpl::mangleCXXVBTable(
3130 msvc_hashing_ostream MHO(Out);
3131 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3132 Mangler.getStream() <<
"??_8";
3133 Mangler.mangleName(Derived);
3134 Mangler.getStream() <<
"7B";
3136 Mangler.mangleName(RD);
3137 Mangler.getStream() <<
'@';
3140 void MicrosoftMangleContextImpl::mangleCXXRTTI(
QualType T, raw_ostream &Out) {
3141 msvc_hashing_ostream MHO(Out);
3142 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3143 Mangler.getStream() <<
"??_R0";
3144 Mangler.mangleType(T,
SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
3145 Mangler.getStream() <<
"@8";
3148 void MicrosoftMangleContextImpl::mangleCXXRTTIName(
QualType T,
3150 MicrosoftCXXNameMangler Mangler(*
this, Out);
3151 Mangler.getStream() <<
'.';
3152 Mangler.mangleType(T,
SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
3155 void MicrosoftMangleContextImpl::mangleCXXVirtualDisplacementMap(
3157 msvc_hashing_ostream MHO(Out);
3158 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3159 Mangler.getStream() <<
"??_K";
3160 Mangler.mangleName(SrcRD);
3161 Mangler.getStream() <<
"$C";
3162 Mangler.mangleName(DstRD);
3165 void MicrosoftMangleContextImpl::mangleCXXThrowInfo(
QualType T,
bool IsConst,
3168 uint32_t NumEntries,
3170 msvc_hashing_ostream MHO(Out);
3171 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3172 Mangler.getStream() <<
"_TI";
3174 Mangler.getStream() <<
'C';
3176 Mangler.getStream() <<
'V';
3178 Mangler.getStream() <<
'U';
3179 Mangler.getStream() << NumEntries;
3180 Mangler.mangleType(T,
SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
3183 void MicrosoftMangleContextImpl::mangleCXXCatchableTypeArray(
3184 QualType T, uint32_t NumEntries, raw_ostream &Out) {
3185 msvc_hashing_ostream MHO(Out);
3186 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3187 Mangler.getStream() <<
"_CTA";
3188 Mangler.getStream() << NumEntries;
3189 Mangler.mangleType(T,
SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
3192 void MicrosoftMangleContextImpl::mangleCXXCatchableType(
3194 uint32_t NVOffset, int32_t VBPtrOffset, uint32_t VBIndex,
3196 MicrosoftCXXNameMangler Mangler(*
this, Out);
3197 Mangler.getStream() <<
"_CT";
3201 llvm::raw_svector_ostream Stream(RTTIMangling);
3202 msvc_hashing_ostream MHO(Stream);
3203 mangleCXXRTTI(T, MHO);
3205 Mangler.getStream() << RTTIMangling;
3213 bool OmitCopyCtor = getASTContext().getLangOpts().isCompatibleWithMSVC(
3214 LangOptions::MSVC2015) &&
3215 !getASTContext().getLangOpts().isCompatibleWithMSVC(
3216 LangOptions::MSVC2017_7);
3218 if (!OmitCopyCtor && CD) {
3219 llvm::raw_svector_ostream Stream(CopyCtorMangling);
3220 msvc_hashing_ostream MHO(Stream);
3221 mangleCXXCtor(CD, CT, MHO);
3223 Mangler.getStream() << CopyCtorMangling;
3225 Mangler.getStream() << Size;
3226 if (VBPtrOffset == -1) {
3228 Mangler.getStream() << NVOffset;
3231 Mangler.getStream() << NVOffset;
3232 Mangler.getStream() << VBPtrOffset;
3233 Mangler.getStream() << VBIndex;
3237 void MicrosoftMangleContextImpl::mangleCXXRTTIBaseClassDescriptor(
3238 const CXXRecordDecl *Derived, uint32_t NVOffset, int32_t VBPtrOffset,
3239 uint32_t VBTableOffset, uint32_t Flags, raw_ostream &Out) {
3240 msvc_hashing_ostream MHO(Out);
3241 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3242 Mangler.getStream() <<
"??_R1";
3243 Mangler.mangleNumber(NVOffset);
3244 Mangler.mangleNumber(VBPtrOffset);
3245 Mangler.mangleNumber(VBTableOffset);
3246 Mangler.mangleNumber(Flags);
3247 Mangler.mangleName(Derived);
3248 Mangler.getStream() <<
"8";
3251 void MicrosoftMangleContextImpl::mangleCXXRTTIBaseClassArray(
3253 msvc_hashing_ostream MHO(Out);
3254 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3255 Mangler.getStream() <<
"??_R2";
3256 Mangler.mangleName(Derived);
3257 Mangler.getStream() <<
"8";
3260 void MicrosoftMangleContextImpl::mangleCXXRTTIClassHierarchyDescriptor(
3262 msvc_hashing_ostream MHO(Out);
3263 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3264 Mangler.getStream() <<
"??_R3";
3265 Mangler.mangleName(Derived);
3266 Mangler.getStream() <<
"8";
3269 void MicrosoftMangleContextImpl::mangleCXXRTTICompleteObjectLocator(
3277 llvm::raw_svector_ostream Stream(VFTableMangling);
3278 mangleCXXVFTable(Derived, BasePath, Stream);
3280 if (VFTableMangling.startswith(
"??@")) {
3281 assert(VFTableMangling.endswith(
"@"));
3282 Out << VFTableMangling <<
"??_R4@";
3286 assert(VFTableMangling.startswith(
"??_7") ||
3287 VFTableMangling.startswith(
"??_S"));
3289 Out <<
"??_R4" << StringRef(VFTableMangling).drop_front(4);
3292 void MicrosoftMangleContextImpl::mangleSEHFilterExpression(
3293 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
3294 msvc_hashing_ostream MHO(Out);
3295 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3300 Mangler.getStream() <<
"?filt$" << SEHFilterIds[EnclosingDecl]++ <<
"@0@";
3301 Mangler.mangleName(EnclosingDecl);
3304 void MicrosoftMangleContextImpl::mangleSEHFinallyBlock(
3305 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
3306 msvc_hashing_ostream MHO(Out);
3307 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3312 Mangler.getStream() <<
"?fin$" << SEHFinallyIds[EnclosingDecl]++ <<
"@0@";
3313 Mangler.mangleName(EnclosingDecl);
3316 void MicrosoftMangleContextImpl::mangleTypeName(
QualType T, raw_ostream &Out) {
3319 MicrosoftCXXNameMangler Mangler(*
this, Out);
3320 Mangler.getStream() <<
'?';
3327 msvc_hashing_ostream MHO(Out);
3328 MicrosoftCXXNameMangler mangler(*
this, MHO, D, Type);
3335 msvc_hashing_ostream MHO(Out);
3336 MicrosoftCXXNameMangler mangler(*
this, MHO, D, Type);
3340 void MicrosoftMangleContextImpl::mangleReferenceTemporary(
3341 const VarDecl *VD,
unsigned ManglingNumber, raw_ostream &Out) {
3342 msvc_hashing_ostream MHO(Out);
3343 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3345 Mangler.getStream() <<
"?$RT" << ManglingNumber <<
'@';
3346 Mangler.mangle(VD,
"");
3349 void MicrosoftMangleContextImpl::mangleThreadSafeStaticGuardVariable(
3350 const VarDecl *VD,
unsigned GuardNum, raw_ostream &Out) {
3351 msvc_hashing_ostream MHO(Out);
3352 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3354 Mangler.getStream() <<
"?$TSS" << GuardNum <<
'@';
3355 Mangler.mangleNestedName(VD);
3356 Mangler.getStream() <<
"@4HA";
3359 void MicrosoftMangleContextImpl::mangleStaticGuardVariable(
const VarDecl *VD,
3371 msvc_hashing_ostream MHO(Out);
3372 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3376 Mangler.getStream() << (VD->
getTLSKind() ?
"??__J" :
"??_B");
3378 Mangler.getStream() <<
"?$S1@";
3380 unsigned ScopeDepth = 0;
3381 if (Visible && !getNextDiscriminator(VD, ScopeDepth))
3385 Mangler.mangle(VD,
"");
3387 Mangler.mangleNestedName(VD);
3388 Mangler.getStream() << (Visible ?
"@5" :
"@4IA");
3390 Mangler.mangleNumber(ScopeDepth);
3393 void MicrosoftMangleContextImpl::mangleInitFiniStub(
const VarDecl *D,
3396 msvc_hashing_ostream MHO(Out);
3397 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3398 Mangler.getStream() <<
"??__" << CharCode;
3400 Mangler.getStream() <<
'?';
3401 Mangler.mangleName(D);
3402 Mangler.mangleVariableEncoding(D);
3403 Mangler.getStream() <<
"@@";
3405 Mangler.mangleName(D);
3409 Mangler.getStream() <<
"YAXXZ";
3412 void MicrosoftMangleContextImpl::mangleDynamicInitializer(
const VarDecl *D,
3415 mangleInitFiniStub(D,
'E', Out);
3419 MicrosoftMangleContextImpl::mangleDynamicAtExitDestructor(
const VarDecl *D,
3422 mangleInitFiniStub(D,
'F', Out);
3425 void MicrosoftMangleContextImpl::mangleStringLiteral(
const StringLiteral *SL,
3446 MicrosoftCXXNameMangler Mangler(*
this, Out);
3447 Mangler.getStream() <<
"??_C@_";
3455 unsigned StringLength = getASTContext()
3456 .getAsConstantArrayType(SL->
getType())
3463 Mangler.getStream() <<
'1';
3465 Mangler.getStream() <<
'0';
3469 Mangler.mangleNumber(StringByteLength);
3471 auto GetLittleEndianByte = [&SL](
unsigned Index) {
3473 if (Index / CharByteWidth >= SL->
getLength())
3474 return static_cast<char>(0);
3475 uint32_t CodeUnit = SL->
getCodeUnit(Index / CharByteWidth);
3476 unsigned OffsetInCodeUnit = Index % CharByteWidth;
3477 return static_cast<char>((CodeUnit >> (8 * OffsetInCodeUnit)) & 0xff);
3480 auto GetBigEndianByte = [&SL](
unsigned Index) {
3482 if (Index / CharByteWidth >= SL->
getLength())
3483 return static_cast<char>(0);
3484 uint32_t CodeUnit = SL->
getCodeUnit(Index / CharByteWidth);
3485 unsigned OffsetInCodeUnit = (CharByteWidth - 1) - (Index % CharByteWidth);
3486 return static_cast<char>((CodeUnit >> (8 * OffsetInCodeUnit)) & 0xff);
3491 for (
unsigned I = 0, E = StringByteLength; I != E; ++I)
3492 JC.update(GetLittleEndianByte(I));
3496 Mangler.mangleNumber(JC.getCRC());
3502 auto MangleByte = [&Mangler](
char Byte) {
3510 Mangler.getStream() << Byte;
3511 }
else if (
isLetter(Byte & 0x7f)) {
3512 Mangler.getStream() <<
'?' <<
static_cast<char>(Byte & 0x7f);
3514 const char SpecialChars[] = {
',',
'/',
'\\',
':',
'.',
3515 ' ',
'\n',
'\t',
'\'',
'-'};
3516 const char *Pos = llvm::find(SpecialChars, Byte);
3517 if (Pos != std::end(SpecialChars)) {
3518 Mangler.getStream() <<
'?' << (Pos - std::begin(SpecialChars));
3520 Mangler.getStream() <<
"?$";
3521 Mangler.getStream() <<
static_cast<char>(
'A' + ((Byte >> 4) & 0xf));
3522 Mangler.getStream() <<
static_cast<char>(
'A' + (Byte & 0xf));
3528 unsigned MaxBytesToMangle = SL->
isWide() ? 64U : 32U;
3529 unsigned NumBytesToMangle =
std::min(MaxBytesToMangle, StringByteLength);
3530 for (
unsigned I = 0; I != NumBytesToMangle; ++I) {
3532 MangleByte(GetBigEndianByte(I));
3534 MangleByte(GetLittleEndianByte(I));
3537 Mangler.getStream() <<
'@';
3542 return new MicrosoftMangleContextImpl(Context, Diags);
Defines the clang::ASTContext interface.
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it's either not been deduced or was deduce...
Represents a function declaration or definition.
StringRef getName(const PrintingPolicy &Policy) const
PointerType - C99 6.7.5.1 - Pointer Declarators.
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
QualType getPointeeType() const
Represents the dependent type named by a dependently-scoped typename using declaration, e.g.
A (possibly-)qualified type.
bool isBlockPointerType() const
bool isMemberPointerType() const
bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const
bool isExternC() const
Determines whether this function is a function with external, C linkage.
static void mangleThunkThisAdjustment(AccessSpecifier AS, const ThisAdjustment &Adjustment, MicrosoftCXXNameMangler &Mangler, raw_ostream &Out)
ArrayRef< TemplateArgument > getPackAsArray() const
Return the array of arguments in this template argument pack.
QualType getDesugaredType(const ASTContext &Context) const
Return the specified type with any "sugar" removed from the type.
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
FunctionType - C99 6.7.5.3 - Function Declarators.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
Represents a qualified type name for which the type name is dependent.
unsigned size() const
Retrieve the number of template arguments in this template argument list.
Decl - This represents one declaration (or definition), e.g.
bool isVariadic() const
Whether this function prototype is variadic.
Defines the C++ template declaration subclasses.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
The base class of the type hierarchy.
int64_t NonVirtual
The non-virtual adjustment from the derived object to its nearest virtual base.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Represent a C++ namespace.
NamedDecl * getParam(unsigned Idx)
QualType withConst() const
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Represents a C++ constructor within a class.
Default closure variant of a ctor.
QualType getElementType() const
Represents a variable declaration or definition.
unsigned getNumParams() const
const T * getAs() const
Member-template getAs<specific type>'.
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
Represents a C++17 deduced template specialization type.
A this pointer adjustment.
The "__interface" keyword.
Represents a variable template specialization, which refers to a variable template with a given set o...
ObjCMethodDecl - Represents an instance or class method declaration.
const CXXMethodDecl * Method
Holds a pointer to the overridden method this thunk is for, if needed by the ABI to distinguish diffe...
Stores a list of template parameters for a TemplateDecl and its derived classes.
Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
QualType getIntegralType() const
Retrieve the type of the integral value.
The collection of all-type qualifiers we support.
bool isVariableArrayType() const
bool isDependentSizedArrayType() const
const char * getStmtClassName() const
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
int32_t VBOffsetOffset
The offset (in bytes) of the vbase offset in the vbtable.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
One of these records is kept for each identifier that is lexed.
Represents a class template specialization, which refers to a class template with a given set of temp...
Represents a class type in Objective C.
QualType getPointeeType() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
LLVM_READONLY bool isLetter(unsigned char c)
Return true if this character is an ASCII letter: [a-zA-Z].
NameKind getNameKind() const
Determine what kind of name this is.
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
bool isReferenceType() const
bool addressSpaceMapManglingFor(LangAS AS) const
Represents the result of substituting a set of types for a template type parameter pack...
The this pointer adjustment as well as an optional return adjustment for a thunk. ...
unsigned getCharByteWidth() const
QualType getParamTypeForDecl() const
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
An rvalue reference type, per C++11 [dcl.ref].
unsigned getLength() const
An lvalue ref-qualifier was provided (&).
TagKind getTagKind() const
CharUnits - This is an opaque type for sizes expressed in character units.
ArrayRef< QualType > getTypeArgs() const
Retrieve the type arguments of this object type (semantically).
bool hasAddressSpace() const
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
Concrete class used by the front-end to report problems and issues.
Represents a typeof (or typeof) expression (a GCC extension).
MSInheritanceModel
Assigned inheritance model for a class in the MS C++ ABI.
const clang::PrintingPolicy & getPrintingPolicy() const
LangAS getAddressSpace() const
const Type * getClass() const
bool isLambda() const
Determine whether this class describes a lambda function object.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Enums/classes describing ABI related information about constructors, destructors and thunks...
Represents an Objective-C protocol declaration.
void * getAsOpaquePtr() const
ObjCInterfaceDecl * getInterface() const
Gets the interface declaration for this object type, if the base type really is an interface...
Expr * getSizeExpr() const
Represents an extended vector type where either the type or size is dependent.
CXXRecordDecl * getMostRecentNonInjectedDecl()
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
Represents a K&R-style 'int foo()' function, which has no information available about its arguments...
bool isExternC() const
Determines whether this variable is a variable with external, C linkage.
unsigned getLambdaManglingNumber() const
If this is the closure type of a lambda expression, retrieve the number to be used for name mangling ...
QualType getBaseType() const
Gets the base type of this object type.
bool inheritanceModelHasVBTableOffsetField(MSInheritanceModel Inheritance)
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a prototype with parameter type info, e.g.
Represents a ValueDecl that came out of a declarator.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
Represents an array type in C++ whose size is a value-dependent expression.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
CXXDtorType
C++ destructor types.
QualType getElementType() const
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
QualType getPointeeType() const
const FileEntry * getFileEntryForID(FileID FID) const
Returns the FileEntry record for the provided FileID.
const T * castAs() const
Member-template castAs<specific type>.
Represents a C++ destructor within a class.
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
ObjCLifetime getObjCLifetime() const
DeclContext * getDeclContext()
uint32_t getCodeUnit(size_t i) const
TLSKind getTLSKind() const
Represents the type decltype(expr) (C++11).
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type...
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
bool isFunctionOrMethod() const
DeclContext * getParent()
getParent - Returns the containing DeclContext.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Represents a GCC generic vector type.
An lvalue reference type, per C++11 [dcl.ref].
CharUnits getVBPtrOffset() const
getVBPtrOffset - Get the offset for virtual base table pointer.
static const TemplateDecl * isTemplate(const NamedDecl *ND, const TemplateArgumentList *&TemplateArgs)
The result type of a method or function.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
The COMDAT used for dtors.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
GlobalDecl - represents a global declaration.
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
struct clang::ThisAdjustment::VirtualAdjustment::@138 Microsoft
QualType getCanonicalType() const
bool isSpecialized() const
Determine whether this object type is "specialized", meaning that it has type arguments.
Encodes a location in the source.
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
QualType getReturnType() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
Represents typeof(type), a GCC extension.
Interfaces are the core concept in Objective-C for object oriented design.
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...
QualType getElementType() const
Represents a vector type where either the type or size is dependent.
Cached information about one file (either on disk or in the virtual file system). ...
Represents a static or instance method of a struct/union/class.
TypedefNameDecl * getTypedefNameForUnnamedTagDecl(const TagDecl *TD)
No ref-qualifier was provided.
const ParmVarDecl * getParamDecl(unsigned i) const
This file defines OpenMP nodes for declarative directives.
Qualifiers getMethodQuals() const
Qualifiers withoutObjCLifetime() const
bool isAnyPointerType() const
RefQualifierKind
The kind of C++11 ref-qualifier associated with a function type.
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
TypeClass getTypeClass() const
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
An rvalue ref-qualifier was provided (&&).
SourceRange getBracketsRange() const
bool isPtrSizeAddressSpace(LangAS AS)
Represents a pointer type decayed from an array or function type.
CXXCtorType
C++ constructor types.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
The injected class name of a C++ class template or class template partial specialization.
Represents a pack expansion of types.
StringRef getName() const
Return the actual identifier string.
Base class for declarations which introduce a typedef-name.
Represents a template argument.
Optional< types::ID > Type
TagTypeKind
The kind of a tag type.
Dataflow Directional Tag Classes.
ThisAdjustment This
The this pointer adjustment.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
uint64_t Index
Method's index in the vftable.
The base class of all kinds of template declarations (e.g., class, function, etc.).
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
AccessSpecifier getAccess() const
A decomposition declaration.
FileID getMainFileID() const
Returns the FileID of the main source file.
std::unique_ptr< DiagnosticConsumer > create(StringRef OutputFile, DiagnosticOptions *Diags, bool MergeChildRecords=false)
Returns a DiagnosticConsumer that serializes diagnostics to a bitcode file.
The name of a declaration.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined...
bool isBooleanType() const
LLVM_READONLY bool isIdentifierBody(unsigned char c, bool AllowDollar=false)
Returns true if this is a body character of a C identifier, which is [a-zA-Z0-9_].
bool isKindOfType() const
Whether this ia a "__kindof" type (semantically).
A pointer to member type per C++ 8.3.3 - Pointers to members.
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return true if this expression is a valid integer constant expression...
bool hasObjCLifetime() const
union clang::ThisAdjustment::VirtualAdjustment Virtual
Represents a pointer to an Objective C object.
Not an overloaded operator.
bool isIncompleteArrayType() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Complex values, per C99 6.2.5p11.
Indicates that the tracking object is a descendant of a referenced-counted OSObject, used in the Darwin kernel.
CanThrowResult canThrow() const
Determine whether this function type has a non-throwing exception specification.
const llvm::APInt & getSize() const
bool isFunctionType() const
bool isStaticLocal() const
Returns true if a variable with function scope is a static local variable.
ExtVectorType - Extended vector type.
DeclaratorDecl * getDeclaratorForUnnamedTagDecl(const TagDecl *TD)
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
ReturnAdjustment Return
The return adjustment.
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
bool isConstantArrayType() const
SourceManager & getSourceManager()
A template argument list.
StringRef getUuidStr() const
ArgKind getKind() const
Return the kind of stored template argument.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
QualType getParamType(unsigned i) const
CallingConv getCallConv() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
TypedefNameDecl * getTypedefNameForAnonDecl() const
bool hasUnaligned() const
Represents a C++ struct/union/class.
Represents a template specialization type whose template cannot be resolved, e.g. ...
Represents a C array with an unspecified size.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
int32_t VtordispOffset
The offset of the vtordisp (in bytes), relative to the ECX.
static unsigned getCharWidth(tok::TokenKind kind, const TargetInfo &Target)
This class is used for builtin types like 'int'.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
__DEVICE__ int min(int __a, int __b)
bool inheritanceModelHasNVOffsetField(bool IsMemberFunction, MSInheritanceModel Inheritance)
Copying closure variant of a ctor.
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
unsigned getNumElements() const
QualType getAsType() const
Retrieve the type for a type template argument.
MethodVFTableLocation getMethodVFTableLocation(GlobalDecl GD)
Represents an extended address space qualifier where the input address space value is dependent...
Represents a type template specialization; the template must be a class template, a type alias templa...
bool isPointerType() const
bool Null(InterpState &S, CodePtr OpPC)
bool isStaticDataMember() const
Determines whether this is a static data member.
IdentifierInfo * getCXXLiteralIdentifier() const
If this name is the name of a literal operator, retrieve the identifier associated with it...
A trivial tuple used to represent a source range.
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
This represents a decl that may have a name.
bool isTranslationUnit() const
Represents a C array with a specified size that is not an integer-constant-expression.
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
bool nullFieldOffsetIsZero() const
In the Microsoft C++ ABI, use zero for the field offset of a null data member pointer if we can guara...
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
unsigned getTargetAddressSpace(QualType T) const
Expr * IgnoreParenNoopCasts(const ASTContext &Ctx) LLVM_READONLY
Skip past any parenthese and casts which do not change the value (including ptr->int casts of the sam...
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
SourceLocation getBegin() const
MSInheritanceModel getMSInheritanceModel() const
Returns the inheritance model used for this record.
int32_t VBPtrOffset
The offset of the vbptr of the derived class (in bytes), relative to the ECX after vtordisp adjustmen...
const LangOptions & getLangOpts() const
bool inheritanceModelHasVBPtrOffsetField(MSInheritanceModel Inheritance)
Represents the canonical version of C arrays with a specified constant size.
This class handles loading and caching of source files into memory.
bool hasLinkage() const
Determine whether this declaration has linkage.
SourceLocation getLocation() const
QualType getPointeeType() const
bool isExternallyVisible() const
PrettyStackTraceDecl - If a crash occurs, indicate that it happened when doing something to a specifi...
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.