29 #include "llvm/ADT/StringExtras.h" 30 #include "llvm/Support/JamCRC.h" 31 #include "llvm/Support/xxhash.h" 32 #include "llvm/Support/MD5.h" 33 #include "llvm/Support/MathExtras.h" 34 #include "llvm/Support/StringSaver.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.def" 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;
622 mangleNumber(FieldOffset);
627 if (MSInheritanceAttr::hasVBPtrOffsetField(IM))
629 if (MSInheritanceAttr::hasVBTableOffsetField(IM))
630 mangleNumber(VBTableOffset);
634 MicrosoftCXXNameMangler::mangleMemberFunctionPointer(
const CXXRecordDecl *RD,
645 case MSInheritanceAttr::Keyword_single_inheritance: Code =
'1';
break;
646 case MSInheritanceAttr::Keyword_multiple_inheritance: Code =
'H';
break;
647 case MSInheritanceAttr::Keyword_virtual_inheritance: Code =
'I';
break;
648 case MSInheritanceAttr::Keyword_unspecified_inheritance: Code =
'J';
break;
653 uint64_t NVOffset = 0;
654 uint64_t VBTableOffset = 0;
655 uint64_t VBPtrOffset = 0;
657 Out <<
'$' << Code <<
'?';
660 cast<MicrosoftVTableContext>(getASTContext().getVTableContext());
663 mangleVirtualMemPtrThunk(MD, ML);
664 NVOffset = ML.VFPtrOffset.getQuantity();
665 VBTableOffset = ML.VBTableIndex * 4;
667 const ASTRecordLayout &Layout = getASTContext().getASTRecordLayout(RD);
672 mangleFunctionEncoding(MD,
true);
675 if (VBTableOffset == 0 &&
676 IM == MSInheritanceAttr::Keyword_virtual_inheritance)
677 NVOffset -= getASTContext().getOffsetOfBaseWithVBPtr(RD).getQuantity();
680 if (IM == MSInheritanceAttr::Keyword_single_inheritance) {
684 if (IM == MSInheritanceAttr::Keyword_unspecified_inheritance)
689 if (MSInheritanceAttr::hasNVOffsetField(
true, IM))
690 mangleNumber(static_cast<uint32_t>(NVOffset));
691 if (MSInheritanceAttr::hasVBPtrOffsetField(IM))
692 mangleNumber(VBPtrOffset);
693 if (MSInheritanceAttr::hasVBTableOffsetField(IM))
694 mangleNumber(VBTableOffset);
697 void MicrosoftCXXNameMangler::mangleVirtualMemPtrThunk(
700 CharUnits PointerWidth = getASTContext().toCharUnitsFromBits(
701 getASTContext().getTargetInfo().getPointerWidth(0));
707 mangleNumber(OffsetInVFTable);
712 void MicrosoftCXXNameMangler::mangleName(
const NamedDecl *ND) {
716 mangleUnqualifiedName(ND);
718 mangleNestedName(ND);
724 void MicrosoftCXXNameMangler::mangleNumber(int64_t Number) {
731 uint64_t
Value =
static_cast<uint64_t
>(Number);
739 else if (Value >= 1 && Value <= 10)
745 char EncodedNumberBuffer[
sizeof(uint64_t) * 2];
748 for (; Value != 0; Value >>= 4)
749 *I++ =
'A' + (Value & 0xf);
750 Out.write(I.base(), I - BufferRef.rbegin());
758 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
767 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
768 TemplateArgs = &Spec->getTemplateArgs();
769 return Spec->getSpecializedTemplate();
774 dyn_cast<VarTemplateSpecializationDecl>(ND)) {
775 TemplateArgs = &Spec->getTemplateArgs();
776 return Spec->getSpecializedTemplate();
782 void MicrosoftCXXNameMangler::mangleUnqualifiedName(
const NamedDecl *ND,
795 if (isa<FunctionTemplateDecl>(TD)) {
796 mangleTemplateInstantiationName(TD, *TemplateArgs);
819 ArgBackRefMap::iterator Found = TemplateArgBackReferences.find(ND);
820 if (Found == TemplateArgBackReferences.end()) {
822 TemplateArgStringMap::iterator Found = TemplateArgStrings.find(ND);
823 if (Found == TemplateArgStrings.end()) {
826 llvm::raw_svector_ostream Stream(TemplateMangling);
827 MicrosoftCXXNameMangler Extra(Context, Stream);
828 Extra.mangleTemplateInstantiationName(TD, *TemplateArgs);
831 mangleSourceName(TemplateMangling);
835 BackRefVec::iterator StringFound =
836 llvm::find(NameBackReferences, TemplateMangling);
837 if (StringFound != NameBackReferences.end()) {
838 TemplateArgBackReferences[ND] =
839 StringFound - NameBackReferences.begin();
841 TemplateArgStrings[ND] =
842 TemplateArgStringStorage.save(TemplateMangling.str());
845 Out << Found->second;
848 Out << Found->second;
856 mangleSourceName(II->getName());
861 assert(ND &&
"mangling empty name without declaration");
864 if (NS->isAnonymousNamespace()) {
865 Out <<
"?A0x" << Context.getAnonymousNamespaceHash() <<
'@';
875 for (
auto *BD : DD->bindings()) {
878 Name += BD->getDeclName().getAsIdentifierInfo()->getName();
881 mangleSourceName(Name);
885 if (
const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
888 assert(RD &&
"expected variable decl to have a record type");
894 Name += llvm::utostr(Context.getAnonymousStructId(RD) + 1);
895 mangleSourceName(Name.str());
900 const TagDecl *TD = cast<TagDecl>(ND);
903 "Typedef should not be in another decl context!");
905 "Typedef was not named!");
910 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(TD)) {
911 if (Record->isLambda()) {
914 Decl *LambdaContextDecl = Record->getLambdaContextDecl();
915 unsigned LambdaManglingNumber = Record->getLambdaManglingNumber();
918 dyn_cast_or_null<ParmVarDecl>(LambdaContextDecl);
923 unsigned DefaultArgNo =
925 Name += llvm::utostr(DefaultArgNo);
929 if (LambdaManglingNumber)
930 LambdaId = LambdaManglingNumber;
932 LambdaId = Context.getLambdaId(Record);
934 Name += llvm::utostr(LambdaId);
937 mangleSourceName(Name);
941 if (LambdaManglingNumber && LambdaContextDecl) {
942 if ((isa<VarDecl>(LambdaContextDecl) ||
943 isa<FieldDecl>(LambdaContextDecl)) &&
945 mangleUnqualifiedName(cast<NamedDecl>(LambdaContextDecl));
957 Name +=
"<unnamed-type-";
958 Name += DD->getName();
964 Name +=
"<unnamed-type-";
965 Name += TND->getName();
966 }
else if (isa<EnumDecl>(TD) &&
967 cast<EnumDecl>(TD)->enumerator_begin() !=
968 cast<EnumDecl>(TD)->enumerator_end()) {
970 auto *ED = cast<EnumDecl>(TD);
971 Name +=
"<unnamed-enum-";
972 Name += ED->enumerator_begin()->getName();
975 Name +=
"<unnamed-type-$S";
976 Name += llvm::utostr(Context.getAnonymousStructId(TD) + 1);
979 mangleSourceName(Name.str());
983 case DeclarationName::ObjCZeroArgSelector:
984 case DeclarationName::ObjCOneArgSelector:
985 case DeclarationName::ObjCMultiArgSelector: {
990 mangleSourceName(Name.str());
994 case DeclarationName::CXXConstructorName:
995 if (isStructorDecl(ND)) {
1008 case DeclarationName::CXXDestructorName:
1009 if (isStructorDecl(ND))
1012 mangleCXXDtorType(static_cast<CXXDtorType>(StructorType));
1019 case DeclarationName::CXXConversionFunctionName:
1025 case DeclarationName::CXXOperatorName:
1029 case DeclarationName::CXXLiteralOperatorName: {
1035 case DeclarationName::CXXDeductionGuideName:
1036 llvm_unreachable(
"Can't mangle a deduction guide name!");
1038 case DeclarationName::CXXUsingDirective:
1039 llvm_unreachable(
"Can't mangle a using directive name!");
1045 void MicrosoftCXXNameMangler::mangleNestedName(
const NamedDecl *ND) {
1046 const DeclContext *DC = getEffectiveDeclContext(ND);
1048 if (isa<TagDecl>(ND) || isa<VarDecl>(ND)) {
1050 if (Context.getNextDiscriminator(ND, Disc)) {
1057 if (
const BlockDecl *BD = dyn_cast<BlockDecl>(DC)) {
1059 [](StringRef Name,
const unsigned Discriminator,
1060 const unsigned ParameterDiscriminator) -> std::string {
1062 llvm::raw_string_ostream Stream(Buffer);
1065 Stream <<
'_' << Discriminator;
1066 if (ParameterDiscriminator)
1067 Stream <<
'_' << ParameterDiscriminator;
1068 return Stream.str();
1071 unsigned Discriminator = BD->getBlockManglingNumber();
1073 Discriminator = Context.getBlockId(BD,
false);
1078 unsigned ParameterDiscriminator = 0;
1079 if (
const auto *MC = BD->getBlockManglingContextDecl())
1080 if (
const auto *
P = dyn_cast<ParmVarDecl>(MC))
1081 if (
const auto *F = dyn_cast<FunctionDecl>(
P->getDeclContext()))
1082 ParameterDiscriminator =
1083 F->getNumParams() -
P->getFunctionScopeIndex();
1085 DC = getEffectiveDeclContext(BD);
1088 mangleSourceName(Discriminate(
"_block_invoke", Discriminator,
1089 ParameterDiscriminator));
1094 if (
const auto *MC = BD->getBlockManglingContextDecl())
1095 if (!isa<ParmVarDecl>(MC))
1096 if (
const auto *ND = dyn_cast<NamedDecl>(MC))
1097 mangleUnqualifiedName(ND);
1101 if (
const auto *RD = dyn_cast<RecordDecl>(DC))
1110 if (PointersAre64Bit)
1114 Discriminate(
"__block_literal", Discriminator,
1115 ParameterDiscriminator));
1120 if (isa<RecordDecl>(DC))
1123 }
else if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(DC)) {
1124 mangleObjCMethodName(Method);
1125 }
else if (isa<NamedDecl>(DC)) {
1126 ND = cast<NamedDecl>(DC);
1127 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
1131 mangleUnqualifiedName(ND);
1134 if (
const auto *LDADC = getLambdaDefaultArgumentDeclContext(ND)) {
1144 void MicrosoftCXXNameMangler::mangleCXXDtorType(
CXXDtorType T) {
1159 llvm_unreachable(
"not expecting a COMDAT");
1161 llvm_unreachable(
"Unsupported dtor type?");
1170 case OO_New: Out <<
"?2";
break;
1172 case OO_Delete: Out <<
"?3";
break;
1174 case OO_Equal: Out <<
"?4";
break;
1176 case OO_GreaterGreater: Out <<
"?5";
break;
1178 case OO_LessLess: Out <<
"?6";
break;
1180 case OO_Exclaim: Out <<
"?7";
break;
1182 case OO_EqualEqual: Out <<
"?8";
break;
1184 case OO_ExclaimEqual: Out <<
"?9";
break;
1186 case OO_Subscript: Out <<
"?A";
break;
1189 case OO_Arrow: Out <<
"?C";
break;
1191 case OO_Star: Out <<
"?D";
break;
1193 case OO_PlusPlus: Out <<
"?E";
break;
1195 case OO_MinusMinus: Out <<
"?F";
break;
1197 case OO_Minus: Out <<
"?G";
break;
1199 case OO_Plus: Out <<
"?H";
break;
1201 case OO_Amp: Out <<
"?I";
break;
1203 case OO_ArrowStar: Out <<
"?J";
break;
1205 case OO_Slash: Out <<
"?K";
break;
1207 case OO_Percent: Out <<
"?L";
break;
1209 case OO_Less: Out <<
"?M";
break;
1211 case OO_LessEqual: Out <<
"?N";
break;
1213 case OO_Greater: Out <<
"?O";
break;
1215 case OO_GreaterEqual: Out <<
"?P";
break;
1217 case OO_Comma: Out <<
"?Q";
break;
1219 case OO_Call: Out <<
"?R";
break;
1221 case OO_Tilde: Out <<
"?S";
break;
1223 case OO_Caret: Out <<
"?T";
break;
1225 case OO_Pipe: Out <<
"?U";
break;
1227 case OO_AmpAmp: Out <<
"?V";
break;
1229 case OO_PipePipe: Out <<
"?W";
break;
1231 case OO_StarEqual: Out <<
"?X";
break;
1233 case OO_PlusEqual: Out <<
"?Y";
break;
1235 case OO_MinusEqual: Out <<
"?Z";
break;
1237 case OO_SlashEqual: Out <<
"?_0";
break;
1239 case OO_PercentEqual: Out <<
"?_1";
break;
1241 case OO_GreaterGreaterEqual: Out <<
"?_2";
break;
1243 case OO_LessLessEqual: Out <<
"?_3";
break;
1245 case OO_AmpEqual: Out <<
"?_4";
break;
1247 case OO_PipeEqual: Out <<
"?_5";
break;
1249 case OO_CaretEqual: Out <<
"?_6";
break;
1278 case OO_Array_New: Out <<
"?_U";
break;
1280 case OO_Array_Delete: Out <<
"?_V";
break;
1282 case OO_Coawait: Out <<
"?__L";
break;
1284 case OO_Spaceship: Out <<
"?__M";
break;
1286 case OO_Conditional: {
1289 "cannot mangle this conditional operator yet");
1290 Diags.
Report(Loc, DiagID);
1296 llvm_unreachable(
"Not an overloaded operator");
1300 void MicrosoftCXXNameMangler::mangleSourceName(StringRef Name) {
1302 BackRefVec::iterator Found = llvm::find(NameBackReferences, Name);
1303 if (Found == NameBackReferences.end()) {
1304 if (NameBackReferences.size() < 10)
1305 NameBackReferences.push_back(Name);
1308 Out << (Found - NameBackReferences.begin());
1312 void MicrosoftCXXNameMangler::mangleObjCMethodName(
const ObjCMethodDecl *MD) {
1313 Context.mangleObjCMethodName(MD, Out);
1316 void MicrosoftCXXNameMangler::mangleTemplateInstantiationName(
1323 ArgBackRefMap OuterFunArgsContext;
1324 ArgBackRefMap OuterTemplateArgsContext;
1325 BackRefVec OuterTemplateContext;
1326 PassObjectSizeArgsSet OuterPassObjectSizeArgs;
1327 NameBackReferences.swap(OuterTemplateContext);
1328 FunArgBackReferences.swap(OuterFunArgsContext);
1329 TemplateArgBackReferences.swap(OuterTemplateArgsContext);
1330 PassObjectSizeArgs.swap(OuterPassObjectSizeArgs);
1332 mangleUnscopedTemplateName(TD);
1333 mangleTemplateArgs(TD, TemplateArgs);
1336 NameBackReferences.swap(OuterTemplateContext);
1337 FunArgBackReferences.swap(OuterFunArgsContext);
1338 TemplateArgBackReferences.swap(OuterTemplateArgsContext);
1339 PassObjectSizeArgs.swap(OuterPassObjectSizeArgs);
1343 MicrosoftCXXNameMangler::mangleUnscopedTemplateName(
const TemplateDecl *TD) {
1346 mangleUnqualifiedName(TD);
1349 void MicrosoftCXXNameMangler::mangleIntegerLiteral(
const llvm::APSInt &Value,
1354 if (IsBoolean && Value.getBoolValue())
1356 else if (Value.isSigned())
1357 mangleNumber(Value.getSExtValue());
1359 mangleNumber(Value.getZExtValue());
1362 void MicrosoftCXXNameMangler::mangleExpression(
const Expr *E) {
1375 if (UO->getOpcode() == UO_AddrOf)
1376 UE = dyn_cast<CXXUuidofExpr>(UO->getSubExpr());
1394 std::string Name =
"_GUID_" + Uuid.lower();
1395 std::replace(Name.begin(), Name.end(),
'-',
'_');
1397 mangleSourceName(Name);
1403 mangleArtificialTagType(
TTK_Struct,
"__s_GUID");
1417 void MicrosoftCXXNameMangler::mangleTemplateArgs(
1421 assert(TPL->
size() == TemplateArgs.
size() &&
1422 "size mismatch between args and parms!");
1424 for (
size_t i = 0;
i < TemplateArgs.
size(); ++
i) {
1428 if (
i > 0 && TA.
getKind() == TemplateArgument::Pack &&
1429 TemplateArgs[
i - 1].getKind() == TemplateArgument::Pack)
1432 mangleTemplateArg(TD, TA, TPL->
getParam(
i));
1436 void MicrosoftCXXNameMangler::mangleTemplateArg(
const TemplateDecl *TD,
1449 case TemplateArgument::Null:
1450 llvm_unreachable(
"Can't mangle null template arguments!");
1451 case TemplateArgument::TemplateExpansion:
1452 llvm_unreachable(
"Can't mangle template expansion arguments!");
1458 case TemplateArgument::Declaration: {
1460 if (isa<FieldDecl>(ND) || isa<IndirectFieldDecl>(ND)) {
1461 mangleMemberDataPointer(cast<CXXRecordDecl>(ND->
getDeclContext())
1462 ->getMostRecentNonInjectedDecl(),
1463 cast<ValueDecl>(ND));
1464 }
else if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
1467 mangleMemberFunctionPointer(
1472 mangleFunctionEncoding(FD,
true);
1479 case TemplateArgument::Integral:
1483 case TemplateArgument::NullPtr: {
1486 const CXXRecordDecl *RD = MPT->getMostRecentCXXRecordDecl();
1487 if (MPT->isMemberFunctionPointerType() &&
1488 !isa<FunctionTemplateDecl>(TD)) {
1489 mangleMemberFunctionPointer(RD,
nullptr);
1492 if (MPT->isMemberDataPointer()) {
1493 if (!isa<FunctionTemplateDecl>(TD)) {
1494 mangleMemberDataPointer(RD,
nullptr);
1504 mangleIntegerLiteral(llvm::APSInt::get(-1),
false);
1509 mangleIntegerLiteral(llvm::APSInt::getUnsigned(0),
false);
1512 case TemplateArgument::Expression:
1515 case TemplateArgument::Pack: {
1517 if (TemplateArgs.empty()) {
1518 if (isa<TemplateTypeParmDecl>(Parm) ||
1519 isa<TemplateTemplateParmDecl>(Parm))
1523 LangOptions::MSVC2015)
1526 else if (isa<NonTypeTemplateParmDecl>(Parm))
1529 llvm_unreachable(
"unexpected template parameter decl!");
1532 mangleTemplateArg(TD, PA, Parm);
1536 case TemplateArgument::Template: {
1539 if (
const auto *TD = dyn_cast<TagDecl>(ND)) {
1541 }
else if (isa<TypeAliasDecl>(ND)) {
1545 llvm_unreachable(
"unexpected template template NamedDecl!");
1552 void MicrosoftCXXNameMangler::mangleObjCProtocol(
const ObjCProtocolDecl *PD) {
1554 llvm::raw_svector_ostream Stream(TemplateMangling);
1555 MicrosoftCXXNameMangler Extra(Context, Stream);
1558 Extra.mangleSourceName(
"Protocol");
1561 mangleArtificialTagType(
TTK_Struct, TemplateMangling, {
"__ObjC"});
1564 void MicrosoftCXXNameMangler::mangleObjCLifetime(
const QualType Type,
1568 llvm::raw_svector_ostream Stream(TemplateMangling);
1569 MicrosoftCXXNameMangler Extra(Context, Stream);
1573 case Qualifiers::OCL_None:
1574 case Qualifiers::OCL_ExplicitNone:
1576 case Qualifiers::OCL_Autoreleasing:
1577 Extra.mangleSourceName(
"Autoreleasing");
1579 case Qualifiers::OCL_Strong:
1580 Extra.mangleSourceName(
"Strong");
1582 case Qualifiers::OCL_Weak:
1583 Extra.mangleSourceName(
"Weak");
1586 Extra.manglePointerCVQualifiers(Quals);
1587 Extra.manglePointerExtQualifiers(Quals, Type);
1588 Extra.mangleType(Type, Range);
1590 mangleArtificialTagType(
TTK_Struct, TemplateMangling, {
"__ObjC"});
1593 void MicrosoftCXXNameMangler::mangleObjCKindOfType(
const ObjCObjectType *T,
1597 llvm::raw_svector_ostream Stream(TemplateMangling);
1598 MicrosoftCXXNameMangler Extra(Context, Stream);
1601 Extra.mangleSourceName(
"KindOf");
1603 .stripObjCKindOfType(getASTContext())
1604 ->getAs<ObjCObjectType>(),
1607 mangleArtificialTagType(
TTK_Struct, TemplateMangling, {
"__ObjC"});
1610 void MicrosoftCXXNameMangler::mangleQualifiers(
Qualifiers Quals,
1668 if (HasConst && HasVolatile) {
1670 }
else if (HasVolatile) {
1672 }
else if (HasConst) {
1678 if (HasConst && HasVolatile) {
1680 }
else if (HasVolatile) {
1682 }
else if (HasConst) {
1693 MicrosoftCXXNameMangler::mangleRefQualifier(
RefQualifierKind RefQualifier) {
1696 switch (RefQualifier) {
1710 void MicrosoftCXXNameMangler::manglePointerExtQualifiers(
Qualifiers Quals,
1712 if (PointersAre64Bit &&
1724 void MicrosoftCXXNameMangler::manglePointerCVQualifiers(
Qualifiers Quals) {
1732 if (HasConst && HasVolatile) {
1734 }
else if (HasVolatile) {
1736 }
else if (HasConst) {
1743 void MicrosoftCXXNameMangler::mangleFunctionArgumentType(
QualType T,
1754 QualType OriginalType = DT->getOriginalType();
1757 if (
const auto *AT = getASTContext().getAsArrayType(OriginalType))
1758 OriginalType = getASTContext().getIncompleteArrayType(
1759 AT->getElementType(), AT->getSizeModifier(),
1760 AT->getIndexTypeCVRQualifiers());
1774 ArgBackRefMap::iterator Found = FunArgBackReferences.find(TypePtr);
1776 if (Found == FunArgBackReferences.end()) {
1777 size_t OutSizeBefore = Out.tell();
1779 mangleType(T, Range, QMM_Drop);
1784 bool LongerThanOneChar = (Out.tell() - OutSizeBefore > 1);
1785 if (LongerThanOneChar && FunArgBackReferences.size() < 10) {
1786 size_t Size = FunArgBackReferences.size();
1787 FunArgBackReferences[TypePtr] = Size;
1790 Out << Found->second;
1794 void MicrosoftCXXNameMangler::manglePassObjectSizeArg(
1795 const PassObjectSizeAttr *POSA) {
1796 int Type = POSA->getType();
1797 bool Dynamic = POSA->isDynamic();
1799 auto Iter = PassObjectSizeArgs.insert({
Type, Dynamic}).first;
1800 auto *TypePtr = (
const void *)&*Iter;
1801 ArgBackRefMap::iterator Found = FunArgBackReferences.find(TypePtr);
1803 if (Found == FunArgBackReferences.end()) {
1805 Dynamic ?
"__pass_dynamic_object_size" :
"__pass_object_size";
1806 mangleArtificialTagType(
TTK_Enum, Name + llvm::utostr(Type), {
"__clang"});
1808 if (FunArgBackReferences.size() < 10) {
1809 size_t Size = FunArgBackReferences.size();
1810 FunArgBackReferences[TypePtr] = Size;
1813 Out << Found->second;
1817 void MicrosoftCXXNameMangler::mangleAddressSpaceType(
QualType T,
1835 llvm::raw_svector_ostream Stream(ASMangling);
1836 MicrosoftCXXNameMangler Extra(Context, Stream);
1842 Extra.mangleSourceName(
"_AS");
1843 Extra.mangleIntegerLiteral(llvm::APSInt::getUnsigned(TargetAS),
1848 llvm_unreachable(
"Not a language specific address space");
1849 case LangAS::opencl_global:
1850 Extra.mangleSourceName(
"_ASCLglobal");
1852 case LangAS::opencl_local:
1853 Extra.mangleSourceName(
"_ASCLlocal");
1855 case LangAS::opencl_constant:
1856 Extra.mangleSourceName(
"_ASCLconstant");
1858 case LangAS::opencl_private:
1859 Extra.mangleSourceName(
"_ASCLprivate");
1861 case LangAS::opencl_generic:
1862 Extra.mangleSourceName(
"_ASCLgeneric");
1864 case LangAS::cuda_device:
1865 Extra.mangleSourceName(
"_ASCUdevice");
1867 case LangAS::cuda_constant:
1868 Extra.mangleSourceName(
"_ASCUconstant");
1870 case LangAS::cuda_shared:
1871 Extra.mangleSourceName(
"_ASCUshared");
1876 Extra.mangleType(T, Range, QMM_Escape);
1878 mangleArtificialTagType(
TTK_Struct, ASMangling, {
"__clang"});
1882 QualifierMangleMode QMM) {
1888 if (
const ArrayType *AT = getASTContext().getAsArrayType(T)) {
1891 if (QMM == QMM_Mangle)
1893 else if (QMM == QMM_Escape || QMM == QMM_Result)
1895 mangleArrayType(AT);
1908 if (
const FunctionType *FT = dyn_cast<FunctionType>(T)) {
1910 mangleFunctionType(FT);
1913 mangleQualifiers(Quals,
false);
1916 if (!IsPointer && Quals) {
1918 mangleQualifiers(Quals,
false);
1926 if ((!IsPointer && Quals) || isa<TagType>(T) || isArtificialTagType(T)) {
1928 mangleQualifiers(Quals,
false);
1936 #define ABSTRACT_TYPE(CLASS, PARENT) 1937 #define NON_CANONICAL_TYPE(CLASS, PARENT) \ 1939 llvm_unreachable("can't mangle non-canonical type " #CLASS "Type"); \ 1941 #define TYPE(CLASS, PARENT) \ 1943 mangleType(cast<CLASS##Type>(ty), Quals, Range); \ 1945 #include "clang/AST/TypeNodes.def" 1946 #undef ABSTRACT_TYPE 1947 #undef NON_CANONICAL_TYPE 1982 case BuiltinType::Void:
1985 case BuiltinType::SChar:
1988 case BuiltinType::Char_U:
1989 case BuiltinType::Char_S:
1992 case BuiltinType::UChar:
1995 case BuiltinType::Short:
1998 case BuiltinType::UShort:
2001 case BuiltinType::Int:
2004 case BuiltinType::UInt:
2007 case BuiltinType::Long:
2010 case BuiltinType::ULong:
2013 case BuiltinType::Float:
2016 case BuiltinType::Double:
2020 case BuiltinType::LongDouble:
2023 case BuiltinType::LongLong:
2026 case BuiltinType::ULongLong:
2029 case BuiltinType::Int128:
2032 case BuiltinType::UInt128:
2035 case BuiltinType::Bool:
2038 case BuiltinType::Char8:
2041 case BuiltinType::Char16:
2044 case BuiltinType::Char32:
2047 case BuiltinType::WChar_S:
2048 case BuiltinType::WChar_U:
2052 #define BUILTIN_TYPE(Id, SingletonId) 2053 #define PLACEHOLDER_TYPE(Id, SingletonId) \ 2054 case BuiltinType::Id: 2055 #include "clang/AST/BuiltinTypes.def" 2056 case BuiltinType::Dependent:
2057 llvm_unreachable(
"placeholder types shouldn't get to name mangling");
2059 case BuiltinType::ObjCId:
2060 mangleArtificialTagType(
TTK_Struct,
"objc_object");
2062 case BuiltinType::ObjCClass:
2063 mangleArtificialTagType(
TTK_Struct,
"objc_class");
2065 case BuiltinType::ObjCSel:
2066 mangleArtificialTagType(
TTK_Struct,
"objc_selector");
2069 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 2070 case BuiltinType::Id: \ 2071 Out << "PAUocl_" #ImgType "_" #Suffix "@@"; \ 2073 #include "clang/Basic/OpenCLImageTypes.def" 2074 case BuiltinType::OCLSampler:
2076 mangleArtificialTagType(
TTK_Struct,
"ocl_sampler");
2078 case BuiltinType::OCLEvent:
2080 mangleArtificialTagType(
TTK_Struct,
"ocl_event");
2082 case BuiltinType::OCLClkEvent:
2084 mangleArtificialTagType(
TTK_Struct,
"ocl_clkevent");
2086 case BuiltinType::OCLQueue:
2088 mangleArtificialTagType(
TTK_Struct,
"ocl_queue");
2090 case BuiltinType::OCLReserveID:
2092 mangleArtificialTagType(
TTK_Struct,
"ocl_reserveid");
2094 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 2095 case BuiltinType::Id: \ 2096 mangleArtificialTagType(TTK_Struct, "ocl_" #ExtType); \ 2098 #include "clang/Basic/OpenCLExtensionTypes.def" 2100 case BuiltinType::NullPtr:
2104 case BuiltinType::Float16:
2105 mangleArtificialTagType(
TTK_Struct,
"_Float16", {
"__clang"});
2108 case BuiltinType::Half:
2109 mangleArtificialTagType(
TTK_Struct,
"_Half", {
"__clang"});
2112 case BuiltinType::ShortAccum:
2113 case BuiltinType::Accum:
2114 case BuiltinType::LongAccum:
2115 case BuiltinType::UShortAccum:
2116 case BuiltinType::UAccum:
2117 case BuiltinType::ULongAccum:
2118 case BuiltinType::ShortFract:
2119 case BuiltinType::Fract:
2120 case BuiltinType::LongFract:
2121 case BuiltinType::UShortFract:
2122 case BuiltinType::UFract:
2123 case BuiltinType::ULongFract:
2124 case BuiltinType::SatShortAccum:
2125 case BuiltinType::SatAccum:
2126 case BuiltinType::SatLongAccum:
2127 case BuiltinType::SatUShortAccum:
2128 case BuiltinType::SatUAccum:
2129 case BuiltinType::SatULongAccum:
2130 case BuiltinType::SatShortFract:
2131 case BuiltinType::SatFract:
2132 case BuiltinType::SatLongFract:
2133 case BuiltinType::SatUShortFract:
2134 case BuiltinType::SatUFract:
2135 case BuiltinType::SatULongFract:
2136 case BuiltinType::Float128: {
2155 mangleFunctionType(T,
nullptr,
true);
2158 mangleFunctionType(T);
2164 mangleFunctionType(T);
2167 void MicrosoftCXXNameMangler::mangleFunctionType(
const FunctionType *T,
2169 bool ForceThisQuals,
2170 bool MangleExceptionSpec) {
2178 bool IsInLambda =
false;
2179 bool IsStructor =
false, HasThisQuals = ForceThisQuals, IsCtorClosure =
false;
2181 if (
const CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl>(D)) {
2184 if (MD->isInstance())
2185 HasThisQuals =
true;
2186 if (isa<CXXDestructorDecl>(MD)) {
2188 }
else if (isa<CXXConstructorDecl>(MD)) {
2194 CC = getASTContext().getDefaultCallingConvention(
2203 manglePointerExtQualifiers(Quals,
QualType());
2205 mangleQualifiers(Quals,
false);
2208 mangleCallingConvention(CC);
2213 if (isa<CXXDestructorDecl>(D) && isStructorDecl(D)) {
2217 Out << (PointersAre64Bit ?
"PEAXI@Z" :
"PAXI@Z");
2226 if (IsCtorClosure) {
2236 mangleFunctionArgumentType(getASTContext().getLValueReferenceType(
2244 llvm_unreachable(
"unexpected constructor closure!");
2252 if (
const auto *AT =
2257 assert(AT->getKeyword() != AutoTypeKeyword::GNUAutoType &&
2258 "shouldn't need to mangle __auto_type!");
2259 mangleSourceName(AT->isDecltypeAuto() ?
"<decltype-auto>" :
"<auto>");
2261 }
else if (IsInLambda) {
2266 mangleType(ResultType, Range, QMM_Result);
2282 for (
unsigned I = 0, E = Proto->
getNumParams(); I != E; ++I) {
2283 mangleFunctionArgumentType(Proto->
getParamType(I), Range);
2294 manglePassObjectSizeArg(
P);
2303 if (MangleExceptionSpec && getASTContext().getLangOpts().CPlusPlus17 &&
2304 getASTContext().getLangOpts().isCompatibleWithMSVC(
2305 LangOptions::MSVC2017_5))
2306 mangleThrowSpecification(Proto);
2311 void MicrosoftCXXNameMangler::mangleFunctionClass(
const FunctionDecl *FD) {
2336 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
2337 bool IsVirtual = MD->isVirtual();
2340 if (isa<CXXDestructorDecl>(MD) && isStructorDecl(MD) &&
2346 llvm_unreachable(
"Unsupported access specifier");
2375 void MicrosoftCXXNameMangler::mangleCallingConvention(
CallingConv CC) {
2396 llvm_unreachable(
"Unsupported CC for mangling");
2399 case CC_C: Out <<
'A';
break;
2410 void MicrosoftCXXNameMangler::mangleCallingConvention(
const FunctionType *T) {
2414 void MicrosoftCXXNameMangler::mangleThrowSpecification(
2430 "cannot mangle this unresolved dependent type yet");
2440 void MicrosoftCXXNameMangler::mangleTagTypeKind(
TagTypeKind TTK) {
2459 mangleType(cast<TagType>(T)->getDecl());
2463 mangleType(cast<TagType>(T)->getDecl());
2465 void MicrosoftCXXNameMangler::mangleType(
const TagDecl *TD) {
2471 void MicrosoftCXXNameMangler::mangleArtificialTagType(
2475 mangleTagTypeKind(TK);
2478 mangleSourceName(UnqualifiedName);
2480 for (
auto I = NestedNames.rbegin(), E = NestedNames.rend(); I != E; ++I)
2481 mangleSourceName(*I);
2494 void MicrosoftCXXNameMangler::mangleDecayedArrayType(
const ArrayType *T) {
2502 llvm_unreachable(
"Should have been special cased");
2506 llvm_unreachable(
"Should have been special cased");
2510 llvm_unreachable(
"Should have been special cased");
2514 llvm_unreachable(
"Should have been special cased");
2516 void MicrosoftCXXNameMangler::mangleArrayType(
const ArrayType *T) {
2522 getASTContext().getAsConstantArrayType(ElementTy);
2523 Dimensions.push_back(CAT->
getSize());
2527 getASTContext().getAsIncompleteArrayType(ElementTy);
2528 Dimensions.push_back(llvm::APInt(32, 0));
2532 getASTContext().getAsVariableArrayType(ElementTy);
2533 Dimensions.push_back(llvm::APInt(32, 0));
2538 getASTContext().getAsDependentSizedArrayType(ElementTy);
2541 "cannot mangle this dependent-length array yet");
2551 mangleNumber(Dimensions.size());
2552 for (
const llvm::APInt &Dimension : Dimensions)
2553 mangleNumber(Dimension.getLimitedValue());
2563 manglePointerCVQualifiers(Quals);
2564 manglePointerExtQualifiers(Quals, PointeeType);
2568 mangleFunctionType(FPT,
nullptr,
true);
2572 mangleType(PointeeType, Range, QMM_Drop);
2580 "cannot mangle this template type parameter type yet");
2589 "cannot mangle this substituted parameter pack yet");
2600 manglePointerCVQualifiers(Quals);
2601 manglePointerExtQualifiers(Quals, PointeeType);
2604 mangleAddressSpaceType(PointeeType, PointeeType.
getQualifiers(), Range);
2606 mangleType(PointeeType, Range);
2613 case Qualifiers::OCL_None:
2614 case Qualifiers::OCL_ExplicitNone:
2616 case Qualifiers::OCL_Autoreleasing:
2617 case Qualifiers::OCL_Strong:
2618 case Qualifiers::OCL_Weak:
2619 return mangleObjCLifetime(PointeeType, Quals, Range);
2621 manglePointerCVQualifiers(Quals);
2622 manglePointerExtQualifiers(Quals, PointeeType);
2623 mangleType(PointeeType, Range);
2634 manglePointerExtQualifiers(Quals, PointeeType);
2635 mangleType(PointeeType, Range);
2646 manglePointerExtQualifiers(Quals, PointeeType);
2647 mangleType(PointeeType, Range);
2655 llvm::raw_svector_ostream Stream(TemplateMangling);
2656 MicrosoftCXXNameMangler Extra(Context, Stream);
2658 Extra.mangleSourceName(
"_Complex");
2659 Extra.mangleType(ElementType, Range, QMM_Escape);
2661 mangleArtificialTagType(
TTK_Struct, TemplateMangling, {
"__clang"});
2669 bool MicrosoftCXXNameMangler::isArtificialTagType(
QualType T)
const {
2675 case Type::Vector: {
2687 assert(ET &&
"vectors with non-builtin elements are unsupported");
2688 uint64_t Width = getASTContext().getTypeSize(T);
2691 size_t OutSizeBefore = Out.tell();
2692 if (!isa<ExtVectorType>(T)) {
2693 llvm::Triple::ArchType AT =
2694 getASTContext().getTargetInfo().getTriple().getArch();
2695 if (AT == llvm::Triple::x86 || AT == llvm::Triple::x86_64) {
2696 if (Width == 64 && ET->
getKind() == BuiltinType::LongLong) {
2697 mangleArtificialTagType(
TTK_Union,
"__m64");
2698 }
else if (Width >= 128) {
2699 if (ET->
getKind() == BuiltinType::Float)
2700 mangleArtificialTagType(
TTK_Union,
"__m" + llvm::utostr(Width));
2701 else if (ET->
getKind() == BuiltinType::LongLong)
2702 mangleArtificialTagType(
TTK_Union,
"__m" + llvm::utostr(Width) +
'i');
2703 else if (ET->
getKind() == BuiltinType::Double)
2704 mangleArtificialTagType(
TTK_Struct,
"__m" + llvm::utostr(Width) +
'd');
2709 bool IsBuiltin = Out.tell() != OutSizeBefore;
2716 llvm::raw_svector_ostream Stream(TemplateMangling);
2717 MicrosoftCXXNameMangler Extra(Context, Stream);
2719 Extra.mangleSourceName(
"__vector");
2720 Extra.mangleType(
QualType(ET, 0), Range, QMM_Escape);
2721 Extra.mangleIntegerLiteral(llvm::APSInt::getUnsigned(T->
getNumElements()),
2724 mangleArtificialTagType(
TTK_Union, TemplateMangling, {
"__clang"});
2728 void MicrosoftCXXNameMangler::mangleType(
const ExtVectorType *T,
2730 mangleType(static_cast<const VectorType *>(T), Quals, Range);
2738 "cannot mangle this dependent-sized vector type yet");
2746 "cannot mangle this dependent-sized extended vector type yet");
2756 "cannot mangle this dependent address space type yet");
2767 void MicrosoftCXXNameMangler::mangleType(
const ObjCObjectType *T,
2770 return mangleObjCKindOfType(T, Quals, Range);
2773 return mangleType(T->
getBaseType(), Range, QMM_Drop);
2775 ArgBackRefMap OuterFunArgsContext;
2776 ArgBackRefMap OuterTemplateArgsContext;
2777 BackRefVec OuterTemplateContext;
2779 FunArgBackReferences.swap(OuterFunArgsContext);
2780 TemplateArgBackReferences.swap(OuterTemplateArgsContext);
2781 NameBackReferences.swap(OuterTemplateContext);
2787 mangleSourceName(
"objc_object");
2789 mangleSourceName(
"objc_class");
2793 for (
const auto &Q : T->
quals())
2794 mangleObjCProtocol(Q);
2798 mangleType(TA, Range, QMM_Drop);
2804 FunArgBackReferences.swap(OuterFunArgsContext);
2805 TemplateArgBackReferences.swap(OuterTemplateArgsContext);
2806 NameBackReferences.swap(OuterTemplateContext);
2812 manglePointerCVQualifiers(Quals);
2813 manglePointerExtQualifiers(Quals, PointeeType);
2822 llvm_unreachable(
"Cannot mangle injected class name type.");
2829 "cannot mangle this template specialization type yet");
2838 "cannot mangle this dependent name type yet");
2843 void MicrosoftCXXNameMangler::mangleType(
2848 "cannot mangle this dependent template specialization type yet");
2857 "cannot mangle this pack expansion yet");
2866 "cannot mangle this typeof(type) yet");
2875 "cannot mangle this typeof(expression) yet");
2884 "cannot mangle this decltype() yet");
2893 "cannot mangle this unary transform type yet");
2904 "cannot mangle this 'auto' type yet");
2905 Diags.Report(Range.
getBegin(), DiagID)
2909 void MicrosoftCXXNameMangler::mangleType(
2915 "cannot mangle this deduced class template specialization type yet");
2916 Diags.Report(Range.
getBegin(), DiagID)
2925 llvm::raw_svector_ostream Stream(TemplateMangling);
2926 MicrosoftCXXNameMangler Extra(Context, Stream);
2928 Extra.mangleSourceName(
"_Atomic");
2929 Extra.mangleType(ValueType, Range, QMM_Escape);
2931 mangleArtificialTagType(
TTK_Struct, TemplateMangling, {
"__clang"});
2938 "cannot mangle this OpenCL pipe type yet");
2943 void MicrosoftMangleContextImpl::mangleCXXName(
const NamedDecl *D,
2945 assert((isa<FunctionDecl>(D) || isa<VarDecl>(D)) &&
2946 "Invalid mangleName() call, argument is not a variable or function!");
2947 assert(!isa<CXXConstructorDecl>(D) && !isa<CXXDestructorDecl>(D) &&
2948 "Invalid mangleName() call on 'structor decl!");
2951 getASTContext().getSourceManager(),
2952 "Mangling declaration");
2954 msvc_hashing_ostream MHO(Out);
2955 MicrosoftCXXNameMangler Mangler(*
this, MHO);
2956 return Mangler.mangle(D);
2985 MicrosoftCXXNameMangler &Mangler,
2992 llvm_unreachable(
"Unsupported access specifier");
3003 Out <<
'R' << AccessSpec;
3004 Mangler.mangleNumber(
3006 Mangler.mangleNumber(
3008 Mangler.mangleNumber(
3010 Mangler.mangleNumber(static_cast<uint32_t>(Adjustment.
NonVirtual));
3013 Mangler.mangleNumber(
3015 Mangler.mangleNumber(-static_cast<uint32_t>(Adjustment.
NonVirtual));
3020 llvm_unreachable(
"Unsupported access specifier");
3030 Mangler.mangleNumber(-static_cast<uint32_t>(Adjustment.
NonVirtual));
3034 llvm_unreachable(
"Unsupported access specifier");
3047 void MicrosoftMangleContextImpl::mangleVirtualMemPtrThunk(
3050 msvc_hashing_ostream MHO(Out);
3051 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3052 Mangler.getStream() <<
'?';
3053 Mangler.mangleVirtualMemPtrThunk(MD, ML);
3056 void MicrosoftMangleContextImpl::mangleThunk(
const CXXMethodDecl *MD,
3059 msvc_hashing_ostream MHO(Out);
3060 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3061 Mangler.getStream() <<
'?';
3062 Mangler.mangleName(MD);
3071 assert(Thunk.
Method !=
nullptr &&
3072 "Thunk info should hold the overridee decl");
3075 Mangler.mangleFunctionType(
3079 void MicrosoftMangleContextImpl::mangleCXXDtorThunk(
3086 msvc_hashing_ostream MHO(Out);
3087 MicrosoftCXXNameMangler Mangler(*
this, MHO, DD, Type);
3088 Mangler.getStream() <<
"??_E";
3094 void MicrosoftMangleContextImpl::mangleCXXVFTable(
3101 msvc_hashing_ostream MHO(Out);
3102 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3103 if (Derived->
hasAttr<DLLImportAttr>())
3104 Mangler.getStream() <<
"??_S";
3106 Mangler.getStream() <<
"??_7";
3107 Mangler.mangleName(Derived);
3108 Mangler.getStream() <<
"6B";
3110 Mangler.mangleName(RD);
3111 Mangler.getStream() <<
'@';
3114 void MicrosoftMangleContextImpl::mangleCXXVBTable(
3121 msvc_hashing_ostream MHO(Out);
3122 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3123 Mangler.getStream() <<
"??_8";
3124 Mangler.mangleName(Derived);
3125 Mangler.getStream() <<
"7B";
3127 Mangler.mangleName(RD);
3128 Mangler.getStream() <<
'@';
3131 void MicrosoftMangleContextImpl::mangleCXXRTTI(
QualType T, raw_ostream &Out) {
3132 msvc_hashing_ostream MHO(Out);
3133 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3134 Mangler.getStream() <<
"??_R0";
3135 Mangler.mangleType(T,
SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
3136 Mangler.getStream() <<
"@8";
3139 void MicrosoftMangleContextImpl::mangleCXXRTTIName(
QualType T,
3141 MicrosoftCXXNameMangler Mangler(*
this, Out);
3142 Mangler.getStream() <<
'.';
3143 Mangler.mangleType(T,
SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
3146 void MicrosoftMangleContextImpl::mangleCXXVirtualDisplacementMap(
3148 msvc_hashing_ostream MHO(Out);
3149 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3150 Mangler.getStream() <<
"??_K";
3151 Mangler.mangleName(SrcRD);
3152 Mangler.getStream() <<
"$C";
3153 Mangler.mangleName(DstRD);
3156 void MicrosoftMangleContextImpl::mangleCXXThrowInfo(
QualType T,
bool IsConst,
3159 uint32_t NumEntries,
3161 msvc_hashing_ostream MHO(Out);
3162 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3163 Mangler.getStream() <<
"_TI";
3165 Mangler.getStream() <<
'C';
3167 Mangler.getStream() <<
'V';
3169 Mangler.getStream() <<
'U';
3170 Mangler.getStream() << NumEntries;
3171 Mangler.mangleType(T,
SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
3174 void MicrosoftMangleContextImpl::mangleCXXCatchableTypeArray(
3175 QualType T, uint32_t NumEntries, raw_ostream &Out) {
3176 msvc_hashing_ostream MHO(Out);
3177 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3178 Mangler.getStream() <<
"_CTA";
3179 Mangler.getStream() << NumEntries;
3180 Mangler.mangleType(T,
SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
3183 void MicrosoftMangleContextImpl::mangleCXXCatchableType(
3185 uint32_t NVOffset, int32_t VBPtrOffset, uint32_t VBIndex,
3187 MicrosoftCXXNameMangler Mangler(*
this, Out);
3188 Mangler.getStream() <<
"_CT";
3192 llvm::raw_svector_ostream Stream(RTTIMangling);
3193 msvc_hashing_ostream MHO(Stream);
3194 mangleCXXRTTI(T, MHO);
3196 Mangler.getStream() << RTTIMangling;
3204 bool OmitCopyCtor = getASTContext().getLangOpts().isCompatibleWithMSVC(
3205 LangOptions::MSVC2015) &&
3206 !getASTContext().getLangOpts().isCompatibleWithMSVC(
3207 LangOptions::MSVC2017_7);
3209 if (!OmitCopyCtor && CD) {
3210 llvm::raw_svector_ostream Stream(CopyCtorMangling);
3211 msvc_hashing_ostream MHO(Stream);
3212 mangleCXXCtor(CD, CT, MHO);
3214 Mangler.getStream() << CopyCtorMangling;
3216 Mangler.getStream() << Size;
3217 if (VBPtrOffset == -1) {
3219 Mangler.getStream() << NVOffset;
3222 Mangler.getStream() << NVOffset;
3223 Mangler.getStream() << VBPtrOffset;
3224 Mangler.getStream() << VBIndex;
3228 void MicrosoftMangleContextImpl::mangleCXXRTTIBaseClassDescriptor(
3229 const CXXRecordDecl *Derived, uint32_t NVOffset, int32_t VBPtrOffset,
3230 uint32_t VBTableOffset, uint32_t Flags, raw_ostream &Out) {
3231 msvc_hashing_ostream MHO(Out);
3232 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3233 Mangler.getStream() <<
"??_R1";
3234 Mangler.mangleNumber(NVOffset);
3235 Mangler.mangleNumber(VBPtrOffset);
3236 Mangler.mangleNumber(VBTableOffset);
3237 Mangler.mangleNumber(Flags);
3238 Mangler.mangleName(Derived);
3239 Mangler.getStream() <<
"8";
3242 void MicrosoftMangleContextImpl::mangleCXXRTTIBaseClassArray(
3244 msvc_hashing_ostream MHO(Out);
3245 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3246 Mangler.getStream() <<
"??_R2";
3247 Mangler.mangleName(Derived);
3248 Mangler.getStream() <<
"8";
3251 void MicrosoftMangleContextImpl::mangleCXXRTTIClassHierarchyDescriptor(
3253 msvc_hashing_ostream MHO(Out);
3254 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3255 Mangler.getStream() <<
"??_R3";
3256 Mangler.mangleName(Derived);
3257 Mangler.getStream() <<
"8";
3260 void MicrosoftMangleContextImpl::mangleCXXRTTICompleteObjectLocator(
3268 llvm::raw_svector_ostream Stream(VFTableMangling);
3269 mangleCXXVFTable(Derived, BasePath, Stream);
3271 if (VFTableMangling.startswith(
"??@")) {
3272 assert(VFTableMangling.endswith(
"@"));
3273 Out << VFTableMangling <<
"??_R4@";
3277 assert(VFTableMangling.startswith(
"??_7") ||
3278 VFTableMangling.startswith(
"??_S"));
3280 Out <<
"??_R4" << StringRef(VFTableMangling).drop_front(4);
3283 void MicrosoftMangleContextImpl::mangleSEHFilterExpression(
3284 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
3285 msvc_hashing_ostream MHO(Out);
3286 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3291 Mangler.getStream() <<
"?filt$" << SEHFilterIds[EnclosingDecl]++ <<
"@0@";
3292 Mangler.mangleName(EnclosingDecl);
3295 void MicrosoftMangleContextImpl::mangleSEHFinallyBlock(
3296 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
3297 msvc_hashing_ostream MHO(Out);
3298 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3303 Mangler.getStream() <<
"?fin$" << SEHFinallyIds[EnclosingDecl]++ <<
"@0@";
3304 Mangler.mangleName(EnclosingDecl);
3307 void MicrosoftMangleContextImpl::mangleTypeName(
QualType T, raw_ostream &Out) {
3310 MicrosoftCXXNameMangler Mangler(*
this, Out);
3311 Mangler.getStream() <<
'?';
3318 msvc_hashing_ostream MHO(Out);
3319 MicrosoftCXXNameMangler mangler(*
this, MHO, D, Type);
3326 msvc_hashing_ostream MHO(Out);
3327 MicrosoftCXXNameMangler mangler(*
this, MHO, D, Type);
3331 void MicrosoftMangleContextImpl::mangleReferenceTemporary(
3332 const VarDecl *VD,
unsigned ManglingNumber, raw_ostream &Out) {
3333 msvc_hashing_ostream MHO(Out);
3334 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3336 Mangler.getStream() <<
"?$RT" << ManglingNumber <<
'@';
3337 Mangler.mangle(VD,
"");
3340 void MicrosoftMangleContextImpl::mangleThreadSafeStaticGuardVariable(
3341 const VarDecl *VD,
unsigned GuardNum, raw_ostream &Out) {
3342 msvc_hashing_ostream MHO(Out);
3343 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3345 Mangler.getStream() <<
"?$TSS" << GuardNum <<
'@';
3346 Mangler.mangleNestedName(VD);
3347 Mangler.getStream() <<
"@4HA";
3350 void MicrosoftMangleContextImpl::mangleStaticGuardVariable(
const VarDecl *VD,
3362 msvc_hashing_ostream MHO(Out);
3363 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3367 Mangler.getStream() << (VD->
getTLSKind() ?
"??__J" :
"??_B");
3369 Mangler.getStream() <<
"?$S1@";
3371 unsigned ScopeDepth = 0;
3372 if (Visible && !getNextDiscriminator(VD, ScopeDepth))
3376 Mangler.mangle(VD,
"");
3378 Mangler.mangleNestedName(VD);
3379 Mangler.getStream() << (Visible ?
"@5" :
"@4IA");
3381 Mangler.mangleNumber(ScopeDepth);
3384 void MicrosoftMangleContextImpl::mangleInitFiniStub(
const VarDecl *D,
3387 msvc_hashing_ostream MHO(Out);
3388 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3389 Mangler.getStream() <<
"??__" << CharCode;
3391 Mangler.getStream() <<
'?';
3392 Mangler.mangleName(D);
3393 Mangler.mangleVariableEncoding(D);
3394 Mangler.getStream() <<
"@@";
3396 Mangler.mangleName(D);
3400 Mangler.getStream() <<
"YAXXZ";
3403 void MicrosoftMangleContextImpl::mangleDynamicInitializer(
const VarDecl *D,
3406 mangleInitFiniStub(D,
'E', Out);
3410 MicrosoftMangleContextImpl::mangleDynamicAtExitDestructor(
const VarDecl *D,
3413 mangleInitFiniStub(D,
'F', Out);
3416 void MicrosoftMangleContextImpl::mangleStringLiteral(
const StringLiteral *SL,
3437 MicrosoftCXXNameMangler Mangler(*
this, Out);
3438 Mangler.getStream() <<
"??_C@_";
3446 unsigned StringLength = getASTContext()
3447 .getAsConstantArrayType(SL->
getType())
3454 Mangler.getStream() <<
'1';
3456 Mangler.getStream() <<
'0';
3460 Mangler.mangleNumber(StringByteLength);
3462 auto GetLittleEndianByte = [&SL](
unsigned Index) {
3464 if (Index / CharByteWidth >= SL->
getLength())
3465 return static_cast<char>(0);
3466 uint32_t CodeUnit = SL->
getCodeUnit(Index / CharByteWidth);
3467 unsigned OffsetInCodeUnit = Index % CharByteWidth;
3468 return static_cast<char>((CodeUnit >> (8 * OffsetInCodeUnit)) & 0xff);
3471 auto GetBigEndianByte = [&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 = (CharByteWidth - 1) - (Index % CharByteWidth);
3477 return static_cast<char>((CodeUnit >> (8 * OffsetInCodeUnit)) & 0xff);
3482 for (
unsigned I = 0, E = StringByteLength; I != E; ++I)
3483 JC.update(GetLittleEndianByte(I));
3487 Mangler.mangleNumber(JC.getCRC());
3493 auto MangleByte = [&Mangler](
char Byte) {
3501 Mangler.getStream() << Byte;
3502 }
else if (
isLetter(Byte & 0x7f)) {
3503 Mangler.getStream() <<
'?' <<
static_cast<char>(Byte & 0x7f);
3505 const char SpecialChars[] = {
',',
'/',
'\\',
':',
'.',
3506 ' ',
'\n',
'\t',
'\'',
'-'};
3507 const char *Pos = llvm::find(SpecialChars, Byte);
3508 if (Pos != std::end(SpecialChars)) {
3509 Mangler.getStream() <<
'?' << (Pos - std::begin(SpecialChars));
3511 Mangler.getStream() <<
"?$";
3512 Mangler.getStream() <<
static_cast<char>(
'A' + ((Byte >> 4) & 0xf));
3513 Mangler.getStream() <<
static_cast<char>(
'A' + (Byte & 0xf));
3519 unsigned MaxBytesToMangle = SL->
isWide() ? 64U : 32U;
3520 unsigned NumBytesToMangle =
std::min(MaxBytesToMangle, StringByteLength);
3521 for (
unsigned I = 0; I != NumBytesToMangle; ++I) {
3523 MangleByte(GetBigEndianByte(I));
3525 MangleByte(GetLittleEndianByte(I));
3528 Mangler.getStream() <<
'@';
3533 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
struct clang::ThisAdjustment::VirtualAdjustment::@136 Microsoft
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 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
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.