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(); }
284 const bool PointersAre64Bit;
287 enum QualifierMangleMode { QMM_Drop, QMM_Mangle, QMM_Escape, QMM_Result };
289 MicrosoftCXXNameMangler(MicrosoftMangleContextImpl &
C, raw_ostream &Out_)
290 : Context(C), Out(Out_), Structor(nullptr), StructorType(-1),
291 TemplateArgStringStorage(TemplateArgStringStorageAlloc),
292 PointersAre64Bit(C.getASTContext().getTargetInfo().getPointerWidth(0) ==
295 MicrosoftCXXNameMangler(MicrosoftMangleContextImpl &
C, raw_ostream &Out_,
297 : Context(C), Out(Out_), Structor(getStructor(D)), StructorType(Type),
298 TemplateArgStringStorage(TemplateArgStringStorageAlloc),
299 PointersAre64Bit(C.getASTContext().getTargetInfo().getPointerWidth(0) ==
302 MicrosoftCXXNameMangler(MicrosoftMangleContextImpl &
C, raw_ostream &Out_,
304 : Context(C), Out(Out_), Structor(getStructor(D)), StructorType(Type),
305 TemplateArgStringStorage(TemplateArgStringStorageAlloc),
306 PointersAre64Bit(C.getASTContext().getTargetInfo().getPointerWidth(0) ==
309 raw_ostream &getStream()
const {
return Out; }
311 void mangle(
const NamedDecl *D, StringRef Prefix =
"?");
313 void mangleFunctionEncoding(
const FunctionDecl *FD,
bool ShouldMangle);
314 void mangleVariableEncoding(
const VarDecl *VD);
320 void mangleNumber(int64_t Number);
322 void mangleArtificialTagType(
TagTypeKind TK, StringRef UnqualifiedName,
326 QualifierMangleMode QMM = QMM_Mangle);
329 bool ForceThisQuals =
false,
330 bool MangleExceptionSpec =
true);
331 void mangleNestedName(
const NamedDecl *ND);
334 bool isStructorDecl(
const NamedDecl *ND)
const {
335 return ND == Structor || getStructor(ND) == Structor;
338 void mangleUnqualifiedName(
const NamedDecl *ND) {
342 void mangleSourceName(StringRef Name);
345 void mangleQualifiers(
Qualifiers Quals,
bool IsMember);
347 void manglePointerCVQualifiers(
Qualifiers Quals);
350 void mangleUnscopedTemplateName(
const TemplateDecl *ND);
357 void manglePassObjectSizeArg(
const PassObjectSizeAttr *POSA);
359 bool isArtificialTagType(
QualType T)
const;
362 #define ABSTRACT_TYPE(CLASS, PARENT) 363 #define NON_CANONICAL_TYPE(CLASS, PARENT) 364 #define TYPE(CLASS, PARENT) void mangleType(const CLASS##Type *T, \ 367 #include "clang/AST/TypeNodes.inc" 369 #undef NON_CANONICAL_TYPE 372 void mangleType(
const TagDecl *TD);
373 void mangleDecayedArrayType(
const ArrayType *T);
374 void mangleArrayType(
const ArrayType *T);
378 void mangleIntegerLiteral(
const llvm::APSInt &Number,
bool IsBoolean);
379 void mangleExpression(
const Expr *E);
395 MicrosoftMangleContextImpl::MicrosoftMangleContextImpl(
ASTContext &Context,
415 uint32_t TruncatedHash = uint32_t(xxHash64(FE->getName()));
416 AnonymousNamespaceHash = llvm::utohexstr(TruncatedHash);
419 AnonymousNamespaceHash =
"0";
423 bool MicrosoftMangleContextImpl::shouldMangleCXXName(
const NamedDecl *D) {
424 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
427 if (FD->hasAttr<OverloadableAttr>())
439 if (FD->isMSVCRTEntryPoint())
453 if (!getASTContext().getLangOpts().CPlusPlus)
457 if (VD && !isa<DecompositionDecl>(D)) {
463 const DeclContext *DC = getEffectiveDeclContext(D);
467 DC = getEffectiveParentContext(DC);
470 !isa<VarTemplateSpecializationDecl>(D) &&
479 MicrosoftMangleContextImpl::shouldMangleStringLiteral(
const StringLiteral *SL) {
483 void MicrosoftCXXNameMangler::mangle(
const NamedDecl *D, StringRef Prefix) {
494 mangleFunctionEncoding(FD, Context.shouldMangleDeclName(FD));
495 else if (
const VarDecl *VD = dyn_cast<VarDecl>(D))
496 mangleVariableEncoding(VD);
498 llvm_unreachable(
"Tried to mangle unexpected NamedDecl!");
501 void MicrosoftCXXNameMangler::mangleFunctionEncoding(
const FunctionDecl *FD,
525 mangleFunctionClass(FD);
527 mangleFunctionType(FT, FD,
false,
false);
533 void MicrosoftCXXNameMangler::mangleVariableEncoding(
const VarDecl *VD) {
564 mangleType(Ty, SR, QMM_Drop);
565 manglePointerExtQualifiers(
568 mangleQualifiers(MPT->getPointeeType().getQualifiers(),
true);
571 mangleName(MPT->getClass()->getAsCXXRecordDecl());
574 }
else if (
const ArrayType *AT = getASTContext().getAsArrayType(Ty)) {
576 mangleDecayedArrayType(AT);
577 if (AT->getElementType()->isArrayType())
582 mangleType(Ty, SR, QMM_Drop);
587 void MicrosoftCXXNameMangler::mangleMemberDataPointer(
const CXXRecordDecl *RD,
594 int64_t VBTableOffset;
597 FieldOffset = getASTContext().getFieldOffset(VD);
598 assert(FieldOffset % getASTContext().
getCharWidth() == 0 &&
599 "cannot take address of bitfield");
600 FieldOffset /= getASTContext().getCharWidth();
604 if (IM == MSInheritanceAttr::Keyword_virtual_inheritance)
605 FieldOffset -= getASTContext().getOffsetOfBaseWithVBPtr(RD).getQuantity();
614 case MSInheritanceAttr::Keyword_single_inheritance: Code =
'0';
break;
615 case MSInheritanceAttr::Keyword_multiple_inheritance: Code =
'0';
break;
616 case MSInheritanceAttr::Keyword_virtual_inheritance: Code =
'F';
break;
617 case MSInheritanceAttr::Keyword_unspecified_inheritance: Code =
'G';
break;
618 case MSInheritanceAttr::SpellingNotCalculated:
619 llvm_unreachable(
"not reachable");
624 mangleNumber(FieldOffset);
629 if (MSInheritanceAttr::hasVBPtrOffsetField(IM))
631 if (MSInheritanceAttr::hasVBTableOffsetField(IM))
632 mangleNumber(VBTableOffset);
636 MicrosoftCXXNameMangler::mangleMemberFunctionPointer(
const CXXRecordDecl *RD,
647 case MSInheritanceAttr::Keyword_single_inheritance: Code =
'1';
break;
648 case MSInheritanceAttr::Keyword_multiple_inheritance: Code =
'H';
break;
649 case MSInheritanceAttr::Keyword_virtual_inheritance: Code =
'I';
break;
650 case MSInheritanceAttr::Keyword_unspecified_inheritance: Code =
'J';
break;
651 case MSInheritanceAttr::SpellingNotCalculated:
652 llvm_unreachable(
"not reachable");
657 uint64_t NVOffset = 0;
658 uint64_t VBTableOffset = 0;
659 uint64_t VBPtrOffset = 0;
661 Out <<
'$' << Code <<
'?';
664 cast<MicrosoftVTableContext>(getASTContext().getVTableContext());
667 mangleVirtualMemPtrThunk(MD, ML);
668 NVOffset = ML.VFPtrOffset.getQuantity();
669 VBTableOffset = ML.VBTableIndex * 4;
671 const ASTRecordLayout &Layout = getASTContext().getASTRecordLayout(RD);
676 mangleFunctionEncoding(MD,
true);
679 if (VBTableOffset == 0 &&
680 IM == MSInheritanceAttr::Keyword_virtual_inheritance)
681 NVOffset -= getASTContext().getOffsetOfBaseWithVBPtr(RD).getQuantity();
684 if (IM == MSInheritanceAttr::Keyword_single_inheritance) {
688 if (IM == MSInheritanceAttr::Keyword_unspecified_inheritance)
693 if (MSInheritanceAttr::hasNVOffsetField(
true, IM))
694 mangleNumber(static_cast<uint32_t>(NVOffset));
695 if (MSInheritanceAttr::hasVBPtrOffsetField(IM))
696 mangleNumber(VBPtrOffset);
697 if (MSInheritanceAttr::hasVBTableOffsetField(IM))
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,
1711 if (PointersAre64Bit &&
1723 void MicrosoftCXXNameMangler::manglePointerCVQualifiers(
Qualifiers Quals) {
1731 if (HasConst && HasVolatile) {
1733 }
else if (HasVolatile) {
1735 }
else if (HasConst) {
1742 void MicrosoftCXXNameMangler::mangleFunctionArgumentType(
QualType T,
1753 QualType OriginalType = DT->getOriginalType();
1756 if (
const auto *AT = getASTContext().getAsArrayType(OriginalType))
1757 OriginalType = getASTContext().getIncompleteArrayType(
1758 AT->getElementType(), AT->getSizeModifier(),
1759 AT->getIndexTypeCVRQualifiers());
1773 ArgBackRefMap::iterator Found = FunArgBackReferences.find(TypePtr);
1775 if (Found == FunArgBackReferences.end()) {
1776 size_t OutSizeBefore = Out.tell();
1778 mangleType(T, Range, QMM_Drop);
1783 bool LongerThanOneChar = (Out.tell() - OutSizeBefore > 1);
1784 if (LongerThanOneChar && FunArgBackReferences.size() < 10) {
1785 size_t Size = FunArgBackReferences.size();
1786 FunArgBackReferences[TypePtr] = Size;
1789 Out << Found->second;
1793 void MicrosoftCXXNameMangler::manglePassObjectSizeArg(
1794 const PassObjectSizeAttr *POSA) {
1795 int Type = POSA->getType();
1796 bool Dynamic = POSA->isDynamic();
1798 auto Iter = PassObjectSizeArgs.insert({
Type, Dynamic}).first;
1799 auto *TypePtr = (
const void *)&*Iter;
1800 ArgBackRefMap::iterator Found = FunArgBackReferences.find(TypePtr);
1802 if (Found == FunArgBackReferences.end()) {
1804 Dynamic ?
"__pass_dynamic_object_size" :
"__pass_object_size";
1805 mangleArtificialTagType(
TTK_Enum, Name + llvm::utostr(Type), {
"__clang"});
1807 if (FunArgBackReferences.size() < 10) {
1808 size_t Size = FunArgBackReferences.size();
1809 FunArgBackReferences[TypePtr] = Size;
1812 Out << Found->second;
1816 void MicrosoftCXXNameMangler::mangleAddressSpaceType(
QualType T,
1834 llvm::raw_svector_ostream Stream(ASMangling);
1835 MicrosoftCXXNameMangler Extra(Context, Stream);
1841 Extra.mangleSourceName(
"_AS");
1842 Extra.mangleIntegerLiteral(llvm::APSInt::getUnsigned(TargetAS),
1847 llvm_unreachable(
"Not a language specific address space");
1848 case LangAS::opencl_global:
1849 Extra.mangleSourceName(
"_ASCLglobal");
1851 case LangAS::opencl_local:
1852 Extra.mangleSourceName(
"_ASCLlocal");
1854 case LangAS::opencl_constant:
1855 Extra.mangleSourceName(
"_ASCLconstant");
1857 case LangAS::opencl_private:
1858 Extra.mangleSourceName(
"_ASCLprivate");
1860 case LangAS::opencl_generic:
1861 Extra.mangleSourceName(
"_ASCLgeneric");
1863 case LangAS::cuda_device:
1864 Extra.mangleSourceName(
"_ASCUdevice");
1866 case LangAS::cuda_constant:
1867 Extra.mangleSourceName(
"_ASCUconstant");
1869 case LangAS::cuda_shared:
1870 Extra.mangleSourceName(
"_ASCUshared");
1875 Extra.mangleType(T, Range, QMM_Escape);
1877 mangleArtificialTagType(
TTK_Struct, ASMangling, {
"__clang"});
1881 QualifierMangleMode QMM) {
1887 if (
const ArrayType *AT = getASTContext().getAsArrayType(T)) {
1890 if (QMM == QMM_Mangle)
1892 else if (QMM == QMM_Escape || QMM == QMM_Result)
1894 mangleArrayType(AT);
1907 if (
const FunctionType *FT = dyn_cast<FunctionType>(T)) {
1909 mangleFunctionType(FT);
1912 mangleQualifiers(Quals,
false);
1915 if (!IsPointer && Quals) {
1917 mangleQualifiers(Quals,
false);
1925 if ((!IsPointer && Quals) || isa<TagType>(T) || isArtificialTagType(T)) {
1927 mangleQualifiers(Quals,
false);
1935 #define ABSTRACT_TYPE(CLASS, PARENT) 1936 #define NON_CANONICAL_TYPE(CLASS, PARENT) \ 1938 llvm_unreachable("can't mangle non-canonical type " #CLASS "Type"); \ 1940 #define TYPE(CLASS, PARENT) \ 1942 mangleType(cast<CLASS##Type>(ty), Quals, Range); \ 1944 #include "clang/AST/TypeNodes.inc" 1945 #undef ABSTRACT_TYPE 1946 #undef NON_CANONICAL_TYPE 1981 case BuiltinType::Void:
1984 case BuiltinType::SChar:
1987 case BuiltinType::Char_U:
1988 case BuiltinType::Char_S:
1991 case BuiltinType::UChar:
1994 case BuiltinType::Short:
1997 case BuiltinType::UShort:
2000 case BuiltinType::Int:
2003 case BuiltinType::UInt:
2006 case BuiltinType::Long:
2009 case BuiltinType::ULong:
2012 case BuiltinType::Float:
2015 case BuiltinType::Double:
2019 case BuiltinType::LongDouble:
2022 case BuiltinType::LongLong:
2025 case BuiltinType::ULongLong:
2028 case BuiltinType::Int128:
2031 case BuiltinType::UInt128:
2034 case BuiltinType::Bool:
2037 case BuiltinType::Char8:
2040 case BuiltinType::Char16:
2043 case BuiltinType::Char32:
2046 case BuiltinType::WChar_S:
2047 case BuiltinType::WChar_U:
2051 #define BUILTIN_TYPE(Id, SingletonId) 2052 #define PLACEHOLDER_TYPE(Id, SingletonId) \ 2053 case BuiltinType::Id: 2054 #include "clang/AST/BuiltinTypes.def" 2055 case BuiltinType::Dependent:
2056 llvm_unreachable(
"placeholder types shouldn't get to name mangling");
2058 case BuiltinType::ObjCId:
2059 mangleArtificialTagType(
TTK_Struct,
"objc_object");
2061 case BuiltinType::ObjCClass:
2062 mangleArtificialTagType(
TTK_Struct,
"objc_class");
2064 case BuiltinType::ObjCSel:
2065 mangleArtificialTagType(
TTK_Struct,
"objc_selector");
2068 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 2069 case BuiltinType::Id: \ 2070 Out << "PAUocl_" #ImgType "_" #Suffix "@@"; \ 2072 #include "clang/Basic/OpenCLImageTypes.def" 2073 case BuiltinType::OCLSampler:
2075 mangleArtificialTagType(
TTK_Struct,
"ocl_sampler");
2077 case BuiltinType::OCLEvent:
2079 mangleArtificialTagType(
TTK_Struct,
"ocl_event");
2081 case BuiltinType::OCLClkEvent:
2083 mangleArtificialTagType(
TTK_Struct,
"ocl_clkevent");
2085 case BuiltinType::OCLQueue:
2087 mangleArtificialTagType(
TTK_Struct,
"ocl_queue");
2089 case BuiltinType::OCLReserveID:
2091 mangleArtificialTagType(
TTK_Struct,
"ocl_reserveid");
2093 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 2094 case BuiltinType::Id: \ 2095 mangleArtificialTagType(TTK_Struct, "ocl_" #ExtType); \ 2097 #include "clang/Basic/OpenCLExtensionTypes.def" 2099 case BuiltinType::NullPtr:
2103 case BuiltinType::Float16:
2104 mangleArtificialTagType(
TTK_Struct,
"_Float16", {
"__clang"});
2107 case BuiltinType::Half:
2108 mangleArtificialTagType(
TTK_Struct,
"_Half", {
"__clang"});
2111 #define SVE_TYPE(Name, Id, SingletonId) \ 2112 case BuiltinType::Id: 2113 #include "clang/Basic/AArch64SVEACLETypes.def" 2114 case BuiltinType::ShortAccum:
2115 case BuiltinType::Accum:
2116 case BuiltinType::LongAccum:
2117 case BuiltinType::UShortAccum:
2118 case BuiltinType::UAccum:
2119 case BuiltinType::ULongAccum:
2120 case BuiltinType::ShortFract:
2121 case BuiltinType::Fract:
2122 case BuiltinType::LongFract:
2123 case BuiltinType::UShortFract:
2124 case BuiltinType::UFract:
2125 case BuiltinType::ULongFract:
2126 case BuiltinType::SatShortAccum:
2127 case BuiltinType::SatAccum:
2128 case BuiltinType::SatLongAccum:
2129 case BuiltinType::SatUShortAccum:
2130 case BuiltinType::SatUAccum:
2131 case BuiltinType::SatULongAccum:
2132 case BuiltinType::SatShortFract:
2133 case BuiltinType::SatFract:
2134 case BuiltinType::SatLongFract:
2135 case BuiltinType::SatUShortFract:
2136 case BuiltinType::SatUFract:
2137 case BuiltinType::SatULongFract:
2138 case BuiltinType::Float128: {
2157 mangleFunctionType(T,
nullptr,
true);
2160 mangleFunctionType(T);
2166 mangleFunctionType(T);
2169 void MicrosoftCXXNameMangler::mangleFunctionType(
const FunctionType *T,
2171 bool ForceThisQuals,
2172 bool MangleExceptionSpec) {
2180 bool IsInLambda =
false;
2181 bool IsStructor =
false, HasThisQuals = ForceThisQuals, IsCtorClosure =
false;
2183 if (
const CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl>(D)) {
2186 if (MD->isInstance())
2187 HasThisQuals =
true;
2188 if (isa<CXXDestructorDecl>(MD)) {
2190 }
else if (isa<CXXConstructorDecl>(MD)) {
2196 CC = getASTContext().getDefaultCallingConvention(
2205 manglePointerExtQualifiers(Quals,
QualType());
2207 mangleQualifiers(Quals,
false);
2210 mangleCallingConvention(CC);
2215 if (isa<CXXDestructorDecl>(D) && isStructorDecl(D)) {
2219 Out << (PointersAre64Bit ?
"PEAXI@Z" :
"PAXI@Z");
2228 if (IsCtorClosure) {
2238 mangleFunctionArgumentType(getASTContext().getLValueReferenceType(
2246 llvm_unreachable(
"unexpected constructor closure!");
2254 if (
const auto *AT =
2259 assert(AT->getKeyword() != AutoTypeKeyword::GNUAutoType &&
2260 "shouldn't need to mangle __auto_type!");
2261 mangleSourceName(AT->isDecltypeAuto() ?
"<decltype-auto>" :
"<auto>");
2263 }
else if (IsInLambda) {
2268 mangleType(ResultType, Range, QMM_Result);
2284 for (
unsigned I = 0, E = Proto->
getNumParams(); I != E; ++I) {
2285 mangleFunctionArgumentType(Proto->
getParamType(I), Range);
2296 manglePassObjectSizeArg(
P);
2305 if (MangleExceptionSpec && getASTContext().getLangOpts().CPlusPlus17 &&
2306 getASTContext().getLangOpts().isCompatibleWithMSVC(
2307 LangOptions::MSVC2017_5))
2308 mangleThrowSpecification(Proto);
2313 void MicrosoftCXXNameMangler::mangleFunctionClass(
const FunctionDecl *FD) {
2338 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
2339 bool IsVirtual = MD->isVirtual();
2342 if (isa<CXXDestructorDecl>(MD) && isStructorDecl(MD) &&
2348 llvm_unreachable(
"Unsupported access specifier");
2377 void MicrosoftCXXNameMangler::mangleCallingConvention(
CallingConv CC) {
2398 llvm_unreachable(
"Unsupported CC for mangling");
2401 case CC_C: Out <<
'A';
break;
2412 void MicrosoftCXXNameMangler::mangleCallingConvention(
const FunctionType *T) {
2416 void MicrosoftCXXNameMangler::mangleThrowSpecification(
2432 "cannot mangle this unresolved dependent type yet");
2442 void MicrosoftCXXNameMangler::mangleTagTypeKind(
TagTypeKind TTK) {
2461 mangleType(cast<TagType>(T)->getDecl());
2465 mangleType(cast<TagType>(T)->getDecl());
2467 void MicrosoftCXXNameMangler::mangleType(
const TagDecl *TD) {
2473 void MicrosoftCXXNameMangler::mangleArtificialTagType(
2477 mangleTagTypeKind(TK);
2480 mangleSourceName(UnqualifiedName);
2482 for (
auto I = NestedNames.rbegin(), E = NestedNames.rend(); I != E; ++I)
2483 mangleSourceName(*I);
2496 void MicrosoftCXXNameMangler::mangleDecayedArrayType(
const ArrayType *T) {
2504 llvm_unreachable(
"Should have been special cased");
2508 llvm_unreachable(
"Should have been special cased");
2512 llvm_unreachable(
"Should have been special cased");
2516 llvm_unreachable(
"Should have been special cased");
2518 void MicrosoftCXXNameMangler::mangleArrayType(
const ArrayType *T) {
2524 getASTContext().getAsConstantArrayType(ElementTy);
2525 Dimensions.push_back(CAT->
getSize());
2529 getASTContext().getAsIncompleteArrayType(ElementTy);
2534 getASTContext().getAsVariableArrayType(ElementTy);
2540 getASTContext().getAsDependentSizedArrayType(ElementTy);
2543 "cannot mangle this dependent-length array yet");
2553 mangleNumber(Dimensions.size());
2555 mangleNumber(Dimension.getLimitedValue());
2565 manglePointerCVQualifiers(Quals);
2566 manglePointerExtQualifiers(Quals, PointeeType);
2570 mangleFunctionType(FPT,
nullptr,
true);
2574 mangleType(PointeeType, Range, QMM_Drop);
2582 "cannot mangle this template type parameter type yet");
2591 "cannot mangle this substituted parameter pack yet");
2602 manglePointerCVQualifiers(Quals);
2603 manglePointerExtQualifiers(Quals, PointeeType);
2606 mangleAddressSpaceType(PointeeType, PointeeType.
getQualifiers(), Range);
2608 mangleType(PointeeType, Range);
2615 case Qualifiers::OCL_None:
2616 case Qualifiers::OCL_ExplicitNone:
2618 case Qualifiers::OCL_Autoreleasing:
2619 case Qualifiers::OCL_Strong:
2620 case Qualifiers::OCL_Weak:
2621 return mangleObjCLifetime(PointeeType, Quals, Range);
2623 manglePointerCVQualifiers(Quals);
2624 manglePointerExtQualifiers(Quals, PointeeType);
2625 mangleType(PointeeType, Range);
2636 manglePointerExtQualifiers(Quals, PointeeType);
2637 mangleType(PointeeType, Range);
2648 manglePointerExtQualifiers(Quals, PointeeType);
2649 mangleType(PointeeType, Range);
2657 llvm::raw_svector_ostream Stream(TemplateMangling);
2658 MicrosoftCXXNameMangler Extra(Context, Stream);
2660 Extra.mangleSourceName(
"_Complex");
2661 Extra.mangleType(ElementType, Range, QMM_Escape);
2663 mangleArtificialTagType(
TTK_Struct, TemplateMangling, {
"__clang"});
2671 bool MicrosoftCXXNameMangler::isArtificialTagType(
QualType T)
const {
2677 case Type::Vector: {
2689 assert(ET &&
"vectors with non-builtin elements are unsupported");
2690 uint64_t Width = getASTContext().getTypeSize(T);
2693 size_t OutSizeBefore = Out.tell();
2694 if (!isa<ExtVectorType>(T)) {
2695 llvm::Triple::ArchType AT =
2696 getASTContext().getTargetInfo().getTriple().getArch();
2697 if (AT == llvm::Triple::x86 || AT == llvm::Triple::x86_64) {
2698 if (Width == 64 && ET->
getKind() == BuiltinType::LongLong) {
2699 mangleArtificialTagType(
TTK_Union,
"__m64");
2700 }
else if (Width >= 128) {
2701 if (ET->
getKind() == BuiltinType::Float)
2702 mangleArtificialTagType(
TTK_Union,
"__m" + llvm::utostr(Width));
2703 else if (ET->
getKind() == BuiltinType::LongLong)
2704 mangleArtificialTagType(
TTK_Union,
"__m" + llvm::utostr(Width) +
'i');
2705 else if (ET->
getKind() == BuiltinType::Double)
2706 mangleArtificialTagType(
TTK_Struct,
"__m" + llvm::utostr(Width) +
'd');
2711 bool IsBuiltin = Out.tell() != OutSizeBefore;
2718 llvm::raw_svector_ostream Stream(TemplateMangling);
2719 MicrosoftCXXNameMangler Extra(Context, Stream);
2721 Extra.mangleSourceName(
"__vector");
2722 Extra.mangleType(
QualType(ET, 0), Range, QMM_Escape);
2723 Extra.mangleIntegerLiteral(llvm::APSInt::getUnsigned(T->
getNumElements()),
2726 mangleArtificialTagType(
TTK_Union, TemplateMangling, {
"__clang"});
2730 void MicrosoftCXXNameMangler::mangleType(
const ExtVectorType *T,
2732 mangleType(static_cast<const VectorType *>(T), Quals, Range);
2740 "cannot mangle this dependent-sized vector type yet");
2748 "cannot mangle this dependent-sized extended vector type yet");
2758 "cannot mangle this dependent address space type yet");
2769 void MicrosoftCXXNameMangler::mangleType(
const ObjCObjectType *T,
2772 return mangleObjCKindOfType(T, Quals, Range);
2775 return mangleType(T->
getBaseType(), Range, QMM_Drop);
2777 ArgBackRefMap OuterFunArgsContext;
2778 ArgBackRefMap OuterTemplateArgsContext;
2779 BackRefVec OuterTemplateContext;
2781 FunArgBackReferences.swap(OuterFunArgsContext);
2782 TemplateArgBackReferences.swap(OuterTemplateArgsContext);
2783 NameBackReferences.swap(OuterTemplateContext);
2789 mangleSourceName(
"objc_object");
2791 mangleSourceName(
"objc_class");
2795 for (
const auto &Q : T->
quals())
2796 mangleObjCProtocol(Q);
2800 mangleType(TA, Range, QMM_Drop);
2806 FunArgBackReferences.swap(OuterFunArgsContext);
2807 TemplateArgBackReferences.swap(OuterTemplateArgsContext);
2808 NameBackReferences.swap(OuterTemplateContext);
2814 manglePointerCVQualifiers(Quals);
2815 manglePointerExtQualifiers(Quals, PointeeType);
2824 llvm_unreachable(
"Cannot mangle injected class name type.");
2831 "cannot mangle this template specialization type yet");
2840 "cannot mangle this dependent name type yet");
2845 void MicrosoftCXXNameMangler::mangleType(
2850 "cannot mangle this dependent template specialization type yet");
2859 "cannot mangle this pack expansion yet");
2868 "cannot mangle this typeof(type) yet");
2877 "cannot mangle this typeof(expression) yet");
2886 "cannot mangle this decltype() yet");
2895 "cannot mangle this unary transform type yet");
2906 "cannot mangle this 'auto' type yet");
2907 Diags.Report(Range.
getBegin(), DiagID)
2911 void MicrosoftCXXNameMangler::mangleType(
2917 "cannot mangle this deduced class template specialization type yet");
2918 Diags.Report(Range.
getBegin(), DiagID)
2927 llvm::raw_svector_ostream Stream(TemplateMangling);
2928 MicrosoftCXXNameMangler Extra(Context, Stream);
2930 Extra.mangleSourceName(
"_Atomic");
2931 Extra.mangleType(ValueType, Range, QMM_Escape);
2933 mangleArtificialTagType(
TTK_Struct, TemplateMangling, {
"__clang"});
2940 "cannot mangle this OpenCL pipe type yet");
2945 void MicrosoftMangleContextImpl::mangleCXXName(
const NamedDecl *D,
2947 assert((isa<FunctionDecl>(D) || isa<VarDecl>(D)) &&
2948 "Invalid mangleName() call, argument is not a variable or function!");
2949 assert(!isa<CXXConstructorDecl>(D) && !isa<CXXDestructorDecl>(D) &&
2950 "Invalid mangleName() call on 'structor decl!");
2953 getASTContext().getSourceManager(),
2954 "Mangling declaration");
2956 msvc_hashing_ostream MHO(Out);
2957 MicrosoftCXXNameMangler Mangler(*
this, MHO);
2958 return Mangler.mangle(D);
2987 MicrosoftCXXNameMangler &Mangler,
2994 llvm_unreachable(
"Unsupported access specifier");
3005 Out <<
'R' << AccessSpec;
3006 Mangler.mangleNumber(
3008 Mangler.mangleNumber(
3010 Mangler.mangleNumber(
3012 Mangler.mangleNumber(static_cast<uint32_t>(Adjustment.
NonVirtual));
3015 Mangler.mangleNumber(
3017 Mangler.mangleNumber(-static_cast<uint32_t>(Adjustment.
NonVirtual));
3022 llvm_unreachable(
"Unsupported access specifier");
3032 Mangler.mangleNumber(-static_cast<uint32_t>(Adjustment.
NonVirtual));
3036 llvm_unreachable(
"Unsupported access specifier");
3049 void MicrosoftMangleContextImpl::mangleVirtualMemPtrThunk(
3052 msvc_hashing_ostream MHO(Out);
3053 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3054 Mangler.getStream() <<
'?';
3055 Mangler.mangleVirtualMemPtrThunk(MD, ML);
3058 void MicrosoftMangleContextImpl::mangleThunk(
const CXXMethodDecl *MD,
3061 msvc_hashing_ostream MHO(Out);
3062 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3063 Mangler.getStream() <<
'?';
3064 Mangler.mangleName(MD);
3073 assert(Thunk.
Method !=
nullptr &&
3074 "Thunk info should hold the overridee decl");
3077 Mangler.mangleFunctionType(
3081 void MicrosoftMangleContextImpl::mangleCXXDtorThunk(
3088 msvc_hashing_ostream MHO(Out);
3089 MicrosoftCXXNameMangler Mangler(*
this, MHO, DD, Type);
3090 Mangler.getStream() <<
"??_E";
3096 void MicrosoftMangleContextImpl::mangleCXXVFTable(
3103 msvc_hashing_ostream MHO(Out);
3104 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3105 if (Derived->
hasAttr<DLLImportAttr>())
3106 Mangler.getStream() <<
"??_S";
3108 Mangler.getStream() <<
"??_7";
3109 Mangler.mangleName(Derived);
3110 Mangler.getStream() <<
"6B";
3112 Mangler.mangleName(RD);
3113 Mangler.getStream() <<
'@';
3116 void MicrosoftMangleContextImpl::mangleCXXVBTable(
3123 msvc_hashing_ostream MHO(Out);
3124 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3125 Mangler.getStream() <<
"??_8";
3126 Mangler.mangleName(Derived);
3127 Mangler.getStream() <<
"7B";
3129 Mangler.mangleName(RD);
3130 Mangler.getStream() <<
'@';
3133 void MicrosoftMangleContextImpl::mangleCXXRTTI(
QualType T, raw_ostream &Out) {
3134 msvc_hashing_ostream MHO(Out);
3135 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3136 Mangler.getStream() <<
"??_R0";
3137 Mangler.mangleType(T,
SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
3138 Mangler.getStream() <<
"@8";
3141 void MicrosoftMangleContextImpl::mangleCXXRTTIName(
QualType T,
3143 MicrosoftCXXNameMangler Mangler(*
this, Out);
3144 Mangler.getStream() <<
'.';
3145 Mangler.mangleType(T,
SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
3148 void MicrosoftMangleContextImpl::mangleCXXVirtualDisplacementMap(
3150 msvc_hashing_ostream MHO(Out);
3151 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3152 Mangler.getStream() <<
"??_K";
3153 Mangler.mangleName(SrcRD);
3154 Mangler.getStream() <<
"$C";
3155 Mangler.mangleName(DstRD);
3158 void MicrosoftMangleContextImpl::mangleCXXThrowInfo(
QualType T,
bool IsConst,
3161 uint32_t NumEntries,
3163 msvc_hashing_ostream MHO(Out);
3164 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3165 Mangler.getStream() <<
"_TI";
3167 Mangler.getStream() <<
'C';
3169 Mangler.getStream() <<
'V';
3171 Mangler.getStream() <<
'U';
3172 Mangler.getStream() << NumEntries;
3173 Mangler.mangleType(T,
SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
3176 void MicrosoftMangleContextImpl::mangleCXXCatchableTypeArray(
3177 QualType T, uint32_t NumEntries, raw_ostream &Out) {
3178 msvc_hashing_ostream MHO(Out);
3179 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3180 Mangler.getStream() <<
"_CTA";
3181 Mangler.getStream() << NumEntries;
3182 Mangler.mangleType(T,
SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
3185 void MicrosoftMangleContextImpl::mangleCXXCatchableType(
3187 uint32_t NVOffset, int32_t VBPtrOffset, uint32_t VBIndex,
3189 MicrosoftCXXNameMangler Mangler(*
this, Out);
3190 Mangler.getStream() <<
"_CT";
3194 llvm::raw_svector_ostream Stream(RTTIMangling);
3195 msvc_hashing_ostream MHO(Stream);
3196 mangleCXXRTTI(T, MHO);
3198 Mangler.getStream() << RTTIMangling;
3206 bool OmitCopyCtor = getASTContext().getLangOpts().isCompatibleWithMSVC(
3207 LangOptions::MSVC2015) &&
3208 !getASTContext().getLangOpts().isCompatibleWithMSVC(
3209 LangOptions::MSVC2017_7);
3211 if (!OmitCopyCtor && CD) {
3212 llvm::raw_svector_ostream Stream(CopyCtorMangling);
3213 msvc_hashing_ostream MHO(Stream);
3214 mangleCXXCtor(CD, CT, MHO);
3216 Mangler.getStream() << CopyCtorMangling;
3218 Mangler.getStream() << Size;
3219 if (VBPtrOffset == -1) {
3221 Mangler.getStream() << NVOffset;
3224 Mangler.getStream() << NVOffset;
3225 Mangler.getStream() << VBPtrOffset;
3226 Mangler.getStream() << VBIndex;
3230 void MicrosoftMangleContextImpl::mangleCXXRTTIBaseClassDescriptor(
3231 const CXXRecordDecl *Derived, uint32_t NVOffset, int32_t VBPtrOffset,
3232 uint32_t VBTableOffset, uint32_t Flags, raw_ostream &Out) {
3233 msvc_hashing_ostream MHO(Out);
3234 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3235 Mangler.getStream() <<
"??_R1";
3236 Mangler.mangleNumber(NVOffset);
3237 Mangler.mangleNumber(VBPtrOffset);
3238 Mangler.mangleNumber(VBTableOffset);
3239 Mangler.mangleNumber(Flags);
3240 Mangler.mangleName(Derived);
3241 Mangler.getStream() <<
"8";
3244 void MicrosoftMangleContextImpl::mangleCXXRTTIBaseClassArray(
3246 msvc_hashing_ostream MHO(Out);
3247 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3248 Mangler.getStream() <<
"??_R2";
3249 Mangler.mangleName(Derived);
3250 Mangler.getStream() <<
"8";
3253 void MicrosoftMangleContextImpl::mangleCXXRTTIClassHierarchyDescriptor(
3255 msvc_hashing_ostream MHO(Out);
3256 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3257 Mangler.getStream() <<
"??_R3";
3258 Mangler.mangleName(Derived);
3259 Mangler.getStream() <<
"8";
3262 void MicrosoftMangleContextImpl::mangleCXXRTTICompleteObjectLocator(
3270 llvm::raw_svector_ostream Stream(VFTableMangling);
3271 mangleCXXVFTable(Derived, BasePath, Stream);
3273 if (VFTableMangling.startswith(
"??@")) {
3274 assert(VFTableMangling.endswith(
"@"));
3275 Out << VFTableMangling <<
"??_R4@";
3279 assert(VFTableMangling.startswith(
"??_7") ||
3280 VFTableMangling.startswith(
"??_S"));
3282 Out <<
"??_R4" << StringRef(VFTableMangling).drop_front(4);
3285 void MicrosoftMangleContextImpl::mangleSEHFilterExpression(
3286 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
3287 msvc_hashing_ostream MHO(Out);
3288 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3293 Mangler.getStream() <<
"?filt$" << SEHFilterIds[EnclosingDecl]++ <<
"@0@";
3294 Mangler.mangleName(EnclosingDecl);
3297 void MicrosoftMangleContextImpl::mangleSEHFinallyBlock(
3298 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
3299 msvc_hashing_ostream MHO(Out);
3300 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3305 Mangler.getStream() <<
"?fin$" << SEHFinallyIds[EnclosingDecl]++ <<
"@0@";
3306 Mangler.mangleName(EnclosingDecl);
3309 void MicrosoftMangleContextImpl::mangleTypeName(
QualType T, raw_ostream &Out) {
3312 MicrosoftCXXNameMangler Mangler(*
this, Out);
3313 Mangler.getStream() <<
'?';
3320 msvc_hashing_ostream MHO(Out);
3321 MicrosoftCXXNameMangler mangler(*
this, MHO, D, Type);
3328 msvc_hashing_ostream MHO(Out);
3329 MicrosoftCXXNameMangler mangler(*
this, MHO, D, Type);
3333 void MicrosoftMangleContextImpl::mangleReferenceTemporary(
3334 const VarDecl *VD,
unsigned ManglingNumber, raw_ostream &Out) {
3335 msvc_hashing_ostream MHO(Out);
3336 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3338 Mangler.getStream() <<
"?$RT" << ManglingNumber <<
'@';
3339 Mangler.mangle(VD,
"");
3342 void MicrosoftMangleContextImpl::mangleThreadSafeStaticGuardVariable(
3343 const VarDecl *VD,
unsigned GuardNum, raw_ostream &Out) {
3344 msvc_hashing_ostream MHO(Out);
3345 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3347 Mangler.getStream() <<
"?$TSS" << GuardNum <<
'@';
3348 Mangler.mangleNestedName(VD);
3349 Mangler.getStream() <<
"@4HA";
3352 void MicrosoftMangleContextImpl::mangleStaticGuardVariable(
const VarDecl *VD,
3364 msvc_hashing_ostream MHO(Out);
3365 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3369 Mangler.getStream() << (VD->
getTLSKind() ?
"??__J" :
"??_B");
3371 Mangler.getStream() <<
"?$S1@";
3373 unsigned ScopeDepth = 0;
3374 if (Visible && !getNextDiscriminator(VD, ScopeDepth))
3378 Mangler.mangle(VD,
"");
3380 Mangler.mangleNestedName(VD);
3381 Mangler.getStream() << (Visible ?
"@5" :
"@4IA");
3383 Mangler.mangleNumber(ScopeDepth);
3386 void MicrosoftMangleContextImpl::mangleInitFiniStub(
const VarDecl *D,
3389 msvc_hashing_ostream MHO(Out);
3390 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3391 Mangler.getStream() <<
"??__" << CharCode;
3393 Mangler.getStream() <<
'?';
3394 Mangler.mangleName(D);
3395 Mangler.mangleVariableEncoding(D);
3396 Mangler.getStream() <<
"@@";
3398 Mangler.mangleName(D);
3402 Mangler.getStream() <<
"YAXXZ";
3405 void MicrosoftMangleContextImpl::mangleDynamicInitializer(
const VarDecl *D,
3408 mangleInitFiniStub(D,
'E', Out);
3412 MicrosoftMangleContextImpl::mangleDynamicAtExitDestructor(
const VarDecl *D,
3415 mangleInitFiniStub(D,
'F', Out);
3418 void MicrosoftMangleContextImpl::mangleStringLiteral(
const StringLiteral *SL,
3439 MicrosoftCXXNameMangler Mangler(*
this, Out);
3440 Mangler.getStream() <<
"??_C@_";
3448 unsigned StringLength = getASTContext()
3449 .getAsConstantArrayType(SL->
getType())
3456 Mangler.getStream() <<
'1';
3458 Mangler.getStream() <<
'0';
3462 Mangler.mangleNumber(StringByteLength);
3464 auto GetLittleEndianByte = [&SL](
unsigned Index) {
3466 if (Index / CharByteWidth >= SL->
getLength())
3467 return static_cast<char>(0);
3468 uint32_t CodeUnit = SL->
getCodeUnit(Index / CharByteWidth);
3469 unsigned OffsetInCodeUnit = Index % CharByteWidth;
3470 return static_cast<char>((CodeUnit >> (8 * OffsetInCodeUnit)) & 0xff);
3473 auto GetBigEndianByte = [&SL](
unsigned Index) {
3475 if (Index / CharByteWidth >= SL->
getLength())
3476 return static_cast<char>(0);
3477 uint32_t CodeUnit = SL->
getCodeUnit(Index / CharByteWidth);
3478 unsigned OffsetInCodeUnit = (CharByteWidth - 1) - (Index % CharByteWidth);
3479 return static_cast<char>((CodeUnit >> (8 * OffsetInCodeUnit)) & 0xff);
3484 for (
unsigned I = 0, E = StringByteLength; I != E; ++I)
3485 JC.update(GetLittleEndianByte(I));
3489 Mangler.mangleNumber(JC.getCRC());
3495 auto MangleByte = [&Mangler](
char Byte) {
3503 Mangler.getStream() << Byte;
3504 }
else if (
isLetter(Byte & 0x7f)) {
3505 Mangler.getStream() <<
'?' <<
static_cast<char>(Byte & 0x7f);
3507 const char SpecialChars[] = {
',',
'/',
'\\',
':',
'.',
3508 ' ',
'\n',
'\t',
'\'',
'-'};
3509 const char *Pos = llvm::find(SpecialChars, Byte);
3510 if (Pos != std::end(SpecialChars)) {
3511 Mangler.getStream() <<
'?' << (Pos - std::begin(SpecialChars));
3513 Mangler.getStream() <<
"?$";
3514 Mangler.getStream() <<
static_cast<char>(
'A' + ((Byte >> 4) & 0xf));
3515 Mangler.getStream() <<
static_cast<char>(
'A' + (Byte & 0xf));
3521 unsigned MaxBytesToMangle = SL->
isWide() ? 64U : 32U;
3522 unsigned NumBytesToMangle =
std::min(MaxBytesToMangle, StringByteLength);
3523 for (
unsigned I = 0; I != NumBytesToMangle; ++I) {
3525 MangleByte(GetBigEndianByte(I));
3527 MangleByte(GetLittleEndianByte(I));
3530 Mangler.getStream() <<
'@';
3535 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.
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.
MSInheritanceAttr::Spelling getMSInheritanceModel() const
Returns the inheritance model used for this record.
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).
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.
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.
bool nullFieldOffsetIsZero() const
In the Microsoft C++ ABI, use zero for the field offset of a null data member pointer if we can guara...
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.
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
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)
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...
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
struct clang::ThisAdjustment::VirtualAdjustment::@135 Microsoft
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
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.