30 #include "llvm/ADT/StringExtras.h" 31 #include "llvm/Support/JamCRC.h" 32 #include "llvm/Support/xxhash.h" 33 #include "llvm/Support/MD5.h" 34 #include "llvm/Support/MathExtras.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 return getEffectiveDeclContext(cast<Decl>(DC));
108 return getEffectiveDeclContext(cast<Decl>(DC));
112 if (
const auto *FTD = dyn_cast<FunctionTemplateDecl>(ND))
115 const auto *FD = cast<FunctionDecl>(ND);
116 if (
const auto *FTD = FD->getPrimaryTemplate())
125 typedef std::pair<const DeclContext *, IdentifierInfo *> DiscriminatorKeyTy;
126 llvm::DenseMap<DiscriminatorKeyTy, unsigned> Discriminator;
127 llvm::DenseMap<const NamedDecl *, unsigned> Uniquifier;
128 llvm::DenseMap<const CXXRecordDecl *, unsigned> LambdaIds;
129 llvm::DenseMap<const NamedDecl *, unsigned> SEHFilterIds;
130 llvm::DenseMap<const NamedDecl *, unsigned> SEHFinallyIds;
135 bool shouldMangleCXXName(
const NamedDecl *D)
override;
136 bool shouldMangleStringLiteral(
const StringLiteral *SL)
override;
137 void mangleCXXName(
const NamedDecl *D, raw_ostream &Out)
override;
140 raw_ostream &Out)
override;
142 raw_ostream &)
override;
145 raw_ostream &)
override;
148 raw_ostream &Out)
override;
151 raw_ostream &Out)
override;
152 void mangleCXXVirtualDisplacementMap(
const CXXRecordDecl *SrcRD,
154 raw_ostream &Out)
override;
155 void mangleCXXThrowInfo(
QualType T,
bool IsConst,
bool IsVolatile,
156 bool IsUnaligned, uint32_t NumEntries,
157 raw_ostream &Out)
override;
158 void mangleCXXCatchableTypeArray(
QualType T, uint32_t NumEntries,
159 raw_ostream &Out)
override;
162 int32_t VBPtrOffset, uint32_t VBIndex,
163 raw_ostream &Out)
override;
164 void mangleCXXRTTI(
QualType T, raw_ostream &Out)
override;
165 void mangleCXXRTTIName(
QualType T, raw_ostream &Out)
override;
166 void mangleCXXRTTIBaseClassDescriptor(
const CXXRecordDecl *Derived,
167 uint32_t NVOffset, int32_t VBPtrOffset,
168 uint32_t VBTableOffset, uint32_t Flags,
169 raw_ostream &Out)
override;
170 void mangleCXXRTTIBaseClassArray(
const CXXRecordDecl *Derived,
171 raw_ostream &Out)
override;
172 void mangleCXXRTTIClassHierarchyDescriptor(
const CXXRecordDecl *Derived,
173 raw_ostream &Out)
override;
175 mangleCXXRTTICompleteObjectLocator(
const CXXRecordDecl *Derived,
177 raw_ostream &Out)
override;
178 void mangleTypeName(
QualType T, raw_ostream &)
override;
180 raw_ostream &)
override;
182 raw_ostream &)
override;
183 void mangleReferenceTemporary(
const VarDecl *,
unsigned ManglingNumber,
184 raw_ostream &)
override;
185 void mangleStaticGuardVariable(
const VarDecl *D, raw_ostream &Out)
override;
186 void mangleThreadSafeStaticGuardVariable(
const VarDecl *D,
unsigned GuardNum,
187 raw_ostream &Out)
override;
188 void mangleDynamicInitializer(
const VarDecl *D, raw_ostream &Out)
override;
189 void mangleDynamicAtExitDestructor(
const VarDecl *D,
190 raw_ostream &Out)
override;
191 void mangleSEHFilterExpression(
const NamedDecl *EnclosingDecl,
192 raw_ostream &Out)
override;
193 void mangleSEHFinallyBlock(
const NamedDecl *EnclosingDecl,
194 raw_ostream &Out)
override;
195 void mangleStringLiteral(
const StringLiteral *SL, raw_ostream &Out)
override;
196 bool getNextDiscriminator(
const NamedDecl *ND,
unsigned &disc) {
197 const DeclContext *DC = getEffectiveDeclContext(ND);
203 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND)) {
204 if (RD->isLambda()) {
212 disc = getASTContext().getManglingNumber(ND);
217 if (
const TagDecl *Tag = dyn_cast<TagDecl>(ND)) {
218 if (!Tag->hasNameForLinkage() &&
219 !getASTContext().getDeclaratorForUnnamedTagDecl(Tag) &&
220 !getASTContext().getTypedefNameForUnnamedTagDecl(Tag))
225 unsigned &discriminator = Uniquifier[ND];
227 discriminator = ++Discriminator[std::make_pair(DC, ND->
getIdentifier())];
228 disc = discriminator + 1;
233 assert(RD->
isLambda() &&
"RD must be a lambda!");
236 "RD must not have a mangling number!");
237 std::pair<llvm::DenseMap<const CXXRecordDecl *, unsigned>::iterator,
bool>
238 Result = LambdaIds.insert(std::make_pair(RD, LambdaIds.size()));
239 return Result.first->second;
244 StringRef getAnonymousNamespaceHash()
const {
245 return AnonymousNamespaceHash;
249 void mangleInitFiniStub(
const VarDecl *D,
char CharCode, raw_ostream &Out);
254 class MicrosoftCXXNameMangler {
255 MicrosoftMangleContextImpl &Context;
265 BackRefVec NameBackReferences;
267 typedef llvm::DenseMap<const void *, unsigned> ArgBackRefMap;
268 ArgBackRefMap TypeBackReferences;
270 typedef std::set<int> PassObjectSizeArgsSet;
271 PassObjectSizeArgsSet PassObjectSizeArgs;
273 ASTContext &getASTContext()
const {
return Context.getASTContext(); }
277 const bool PointersAre64Bit;
280 enum QualifierMangleMode { QMM_Drop, QMM_Mangle, QMM_Escape, QMM_Result };
282 MicrosoftCXXNameMangler(MicrosoftMangleContextImpl &
C, raw_ostream &Out_)
283 : Context(C), Out(Out_), Structor(nullptr), StructorType(-1),
284 PointersAre64Bit(C.getASTContext().getTargetInfo().getPointerWidth(0) ==
287 MicrosoftCXXNameMangler(MicrosoftMangleContextImpl &
C, raw_ostream &Out_,
289 : Context(C), Out(Out_), Structor(getStructor(D)), StructorType(Type),
290 PointersAre64Bit(C.getASTContext().getTargetInfo().getPointerWidth(0) ==
293 MicrosoftCXXNameMangler(MicrosoftMangleContextImpl &
C, raw_ostream &Out_,
295 : Context(C), Out(Out_), Structor(getStructor(D)), StructorType(Type),
296 PointersAre64Bit(C.getASTContext().getTargetInfo().getPointerWidth(0) ==
299 raw_ostream &getStream()
const {
return Out; }
301 void mangle(
const NamedDecl *D, StringRef Prefix =
"?");
303 void mangleFunctionEncoding(
const FunctionDecl *FD,
bool ShouldMangle);
304 void mangleVariableEncoding(
const VarDecl *VD);
310 void mangleNumber(int64_t Number);
312 void mangleArtificalTagType(
TagTypeKind TK, StringRef UnqualifiedName,
315 QualifierMangleMode QMM = QMM_Mangle);
318 bool ForceThisQuals =
false);
319 void mangleNestedName(
const NamedDecl *ND);
322 bool isStructorDecl(
const NamedDecl *ND)
const {
323 return ND == Structor || getStructor(ND) == Structor;
326 void mangleUnqualifiedName(
const NamedDecl *ND) {
330 void mangleSourceName(StringRef Name);
333 void mangleQualifiers(
Qualifiers Quals,
bool IsMember);
335 void manglePointerCVQualifiers(
Qualifiers Quals);
338 void mangleUnscopedTemplateName(
const TemplateDecl *ND);
345 void manglePassObjectSizeArg(
const PassObjectSizeAttr *POSA);
347 bool isArtificialTagType(
QualType T)
const;
350 #define ABSTRACT_TYPE(CLASS, PARENT) 351 #define NON_CANONICAL_TYPE(CLASS, PARENT) 352 #define TYPE(CLASS, PARENT) void mangleType(const CLASS##Type *T, \ 355 #include "clang/AST/TypeNodes.def" 357 #undef NON_CANONICAL_TYPE 360 void mangleType(
const TagDecl *TD);
361 void mangleDecayedArrayType(
const ArrayType *T);
362 void mangleArrayType(
const ArrayType *T);
366 void mangleIntegerLiteral(
const llvm::APSInt &Number,
bool IsBoolean);
367 void mangleExpression(
const Expr *E);
381 MicrosoftMangleContextImpl::MicrosoftMangleContextImpl(
ASTContext &Context,
401 uint32_t TruncatedHash = uint32_t(xxHash64(FE->getName()));
402 AnonymousNamespaceHash = llvm::utohexstr(TruncatedHash);
405 AnonymousNamespaceHash =
"0";
409 bool MicrosoftMangleContextImpl::shouldMangleCXXName(
const NamedDecl *D) {
410 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
413 if (FD->hasAttr<OverloadableAttr>())
425 if (FD->isMSVCRTEntryPoint())
439 if (!getASTContext().getLangOpts().CPlusPlus)
443 if (VD && !isa<DecompositionDecl>(D)) {
449 const DeclContext *DC = getEffectiveDeclContext(D);
453 DC = getEffectiveParentContext(DC);
456 !isa<VarTemplateSpecializationDecl>(D) &&
465 MicrosoftMangleContextImpl::shouldMangleStringLiteral(
const StringLiteral *SL) {
469 void MicrosoftCXXNameMangler::mangle(
const NamedDecl *D, StringRef Prefix) {
480 mangleFunctionEncoding(FD, Context.shouldMangleDeclName(FD));
481 else if (
const VarDecl *VD = dyn_cast<VarDecl>(D))
482 mangleVariableEncoding(VD);
483 else if (!isa<ObjCInterfaceDecl>(D))
484 llvm_unreachable(
"Tried to mangle unexpected NamedDecl!");
487 void MicrosoftCXXNameMangler::mangleFunctionEncoding(
const FunctionDecl *FD,
511 mangleFunctionClass(FD);
513 mangleFunctionType(FT, FD);
519 void MicrosoftCXXNameMangler::mangleVariableEncoding(
const VarDecl *VD) {
550 mangleType(Ty, SR, QMM_Drop);
551 manglePointerExtQualifiers(
554 mangleQualifiers(MPT->getPointeeType().getQualifiers(),
true);
557 mangleName(MPT->getClass()->getAsCXXRecordDecl());
560 }
else if (
const ArrayType *AT = getASTContext().getAsArrayType(Ty)) {
562 mangleDecayedArrayType(AT);
563 if (AT->getElementType()->isArrayType())
568 mangleType(Ty, SR, QMM_Drop);
573 void MicrosoftCXXNameMangler::mangleMemberDataPointer(
const CXXRecordDecl *RD,
580 int64_t VBTableOffset;
583 FieldOffset = getASTContext().getFieldOffset(VD);
584 assert(FieldOffset % getASTContext().
getCharWidth() == 0 &&
585 "cannot take address of bitfield");
586 FieldOffset /= getASTContext().getCharWidth();
590 if (IM == MSInheritanceAttr::Keyword_virtual_inheritance)
591 FieldOffset -= getASTContext().getOffsetOfBaseWithVBPtr(RD).getQuantity();
600 case MSInheritanceAttr::Keyword_single_inheritance: Code =
'0';
break;
601 case MSInheritanceAttr::Keyword_multiple_inheritance: Code =
'0';
break;
602 case MSInheritanceAttr::Keyword_virtual_inheritance: Code =
'F';
break;
603 case MSInheritanceAttr::Keyword_unspecified_inheritance: Code =
'G';
break;
608 mangleNumber(FieldOffset);
613 if (MSInheritanceAttr::hasVBPtrOffsetField(IM))
615 if (MSInheritanceAttr::hasVBTableOffsetField(IM))
616 mangleNumber(VBTableOffset);
620 MicrosoftCXXNameMangler::mangleMemberFunctionPointer(
const CXXRecordDecl *RD,
631 case MSInheritanceAttr::Keyword_single_inheritance: Code =
'1';
break;
632 case MSInheritanceAttr::Keyword_multiple_inheritance: Code =
'H';
break;
633 case MSInheritanceAttr::Keyword_virtual_inheritance: Code =
'I';
break;
634 case MSInheritanceAttr::Keyword_unspecified_inheritance: Code =
'J';
break;
639 uint64_t NVOffset = 0;
640 uint64_t VBTableOffset = 0;
641 uint64_t VBPtrOffset = 0;
643 Out <<
'$' << Code <<
'?';
646 cast<MicrosoftVTableContext>(getASTContext().getVTableContext());
649 mangleVirtualMemPtrThunk(MD, ML);
650 NVOffset = ML.VFPtrOffset.getQuantity();
651 VBTableOffset = ML.VBTableIndex * 4;
653 const ASTRecordLayout &Layout = getASTContext().getASTRecordLayout(RD);
658 mangleFunctionEncoding(MD,
true);
661 if (VBTableOffset == 0 &&
662 IM == MSInheritanceAttr::Keyword_virtual_inheritance)
663 NVOffset -= getASTContext().getOffsetOfBaseWithVBPtr(RD).getQuantity();
666 if (IM == MSInheritanceAttr::Keyword_single_inheritance) {
670 if (IM == MSInheritanceAttr::Keyword_unspecified_inheritance)
675 if (MSInheritanceAttr::hasNVOffsetField(
true, IM))
676 mangleNumber(static_cast<uint32_t>(NVOffset));
677 if (MSInheritanceAttr::hasVBPtrOffsetField(IM))
678 mangleNumber(VBPtrOffset);
679 if (MSInheritanceAttr::hasVBTableOffsetField(IM))
680 mangleNumber(VBTableOffset);
683 void MicrosoftCXXNameMangler::mangleVirtualMemPtrThunk(
686 CharUnits PointerWidth = getASTContext().toCharUnitsFromBits(
687 getASTContext().getTargetInfo().getPointerWidth(0));
693 mangleNumber(OffsetInVFTable);
698 void MicrosoftCXXNameMangler::mangleName(
const NamedDecl *ND) {
702 mangleUnqualifiedName(ND);
704 mangleNestedName(ND);
710 void MicrosoftCXXNameMangler::mangleNumber(int64_t Number) {
717 uint64_t
Value =
static_cast<uint64_t
>(Number);
725 else if (Value >= 1 && Value <= 10)
731 char EncodedNumberBuffer[
sizeof(uint64_t) * 2];
734 for (; Value != 0; Value >>= 4)
735 *I++ =
'A' + (Value & 0xf);
736 Out.write(I.base(), I - BufferRef.rbegin());
744 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
753 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
754 TemplateArgs = &Spec->getTemplateArgs();
755 return Spec->getSpecializedTemplate();
760 dyn_cast<VarTemplateSpecializationDecl>(ND)) {
761 TemplateArgs = &Spec->getTemplateArgs();
762 return Spec->getSpecializedTemplate();
768 void MicrosoftCXXNameMangler::mangleUnqualifiedName(
const NamedDecl *ND,
781 if (isa<FunctionTemplateDecl>(TD)) {
782 mangleTemplateInstantiationName(TD, *TemplateArgs);
803 llvm::raw_svector_ostream Stream(TemplateMangling);
804 MicrosoftCXXNameMangler Extra(Context, Stream);
805 Extra.mangleTemplateInstantiationName(TD, *TemplateArgs);
807 mangleSourceName(TemplateMangling);
812 case DeclarationName::Identifier: {
814 mangleSourceName(II->getName());
819 assert(ND &&
"mangling empty name without declaration");
822 if (NS->isAnonymousNamespace()) {
823 Out <<
"?A0x" << Context.getAnonymousNamespaceHash() <<
'@';
833 for (
auto *BD : DD->bindings()) {
836 Name += BD->getDeclName().getAsIdentifierInfo()->getName();
839 mangleSourceName(Name);
843 if (
const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
846 assert(RD &&
"expected variable decl to have a record type");
852 Name += llvm::utostr(Context.getAnonymousStructId(RD) + 1);
853 mangleSourceName(Name.str());
858 const TagDecl *TD = cast<TagDecl>(ND);
861 "Typedef should not be in another decl context!");
863 "Typedef was not named!");
868 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(TD)) {
869 if (Record->isLambda()) {
872 Decl *LambdaContextDecl = Record->getLambdaContextDecl();
873 unsigned LambdaManglingNumber = Record->getLambdaManglingNumber();
876 dyn_cast_or_null<ParmVarDecl>(LambdaContextDecl);
881 unsigned DefaultArgNo =
883 Name += llvm::utostr(DefaultArgNo);
887 if (LambdaManglingNumber)
888 LambdaId = LambdaManglingNumber;
890 LambdaId = Context.getLambdaId(Record);
892 Name += llvm::utostr(LambdaId);
895 mangleSourceName(Name);
899 if (LambdaManglingNumber && LambdaContextDecl) {
900 if ((isa<VarDecl>(LambdaContextDecl) ||
901 isa<FieldDecl>(LambdaContextDecl)) &&
903 mangleUnqualifiedName(cast<NamedDecl>(LambdaContextDecl));
915 Name +=
"<unnamed-type-";
916 Name += DD->getName();
922 Name +=
"<unnamed-type-";
923 Name += TND->getName();
924 }
else if (isa<EnumDecl>(TD) &&
925 cast<EnumDecl>(TD)->enumerator_begin() !=
926 cast<EnumDecl>(TD)->enumerator_end()) {
928 auto *ED = cast<EnumDecl>(TD);
929 Name +=
"<unnamed-enum-";
930 Name += ED->enumerator_begin()->getName();
933 Name +=
"<unnamed-type-$S";
934 Name += llvm::utostr(Context.getAnonymousStructId(TD) + 1);
937 mangleSourceName(Name.str());
941 case DeclarationName::ObjCZeroArgSelector:
942 case DeclarationName::ObjCOneArgSelector:
943 case DeclarationName::ObjCMultiArgSelector: {
948 mangleSourceName(Name.str());
952 case DeclarationName::CXXConstructorName:
953 if (isStructorDecl(ND)) {
966 case DeclarationName::CXXDestructorName:
967 if (isStructorDecl(ND))
970 mangleCXXDtorType(static_cast<CXXDtorType>(StructorType));
977 case DeclarationName::CXXConversionFunctionName:
983 case DeclarationName::CXXOperatorName:
987 case DeclarationName::CXXLiteralOperatorName: {
993 case DeclarationName::CXXDeductionGuideName:
994 llvm_unreachable(
"Can't mangle a deduction guide name!");
996 case DeclarationName::CXXUsingDirective:
997 llvm_unreachable(
"Can't mangle a using directive name!");
1003 void MicrosoftCXXNameMangler::mangleNestedName(
const NamedDecl *ND) {
1004 const DeclContext *DC = getEffectiveDeclContext(ND);
1006 if (isa<TagDecl>(ND) || isa<VarDecl>(ND)) {
1008 if (Context.getNextDiscriminator(ND, Disc)) {
1015 if (
const BlockDecl *BD = dyn_cast<BlockDecl>(DC)) {
1017 [](StringRef Name,
const unsigned Discriminator,
1018 const unsigned ParameterDiscriminator) -> std::string {
1020 llvm::raw_string_ostream Stream(Buffer);
1023 Stream <<
'_' << Discriminator;
1024 if (ParameterDiscriminator)
1025 Stream <<
'_' << ParameterDiscriminator;
1026 return Stream.str();
1029 unsigned Discriminator = BD->getBlockManglingNumber();
1031 Discriminator = Context.getBlockId(BD,
false);
1036 unsigned ParameterDiscriminator = 0;
1037 if (
const auto *MC = BD->getBlockManglingContextDecl())
1038 if (
const auto *
P = dyn_cast<ParmVarDecl>(MC))
1039 if (
const auto *F = dyn_cast<FunctionDecl>(
P->getDeclContext()))
1040 ParameterDiscriminator =
1041 F->getNumParams() -
P->getFunctionScopeIndex();
1043 DC = getEffectiveDeclContext(BD);
1046 mangleSourceName(Discriminate(
"_block_invoke", Discriminator,
1047 ParameterDiscriminator));
1052 if (
const auto *MC = BD->getBlockManglingContextDecl())
1053 if (!isa<ParmVarDecl>(MC))
1054 if (
const auto *ND = dyn_cast<NamedDecl>(MC))
1055 mangleUnqualifiedName(ND);
1059 if (
const auto *RD = dyn_cast<RecordDecl>(DC))
1068 if (PointersAre64Bit)
1072 Discriminate(
"__block_literal", Discriminator,
1073 ParameterDiscriminator));
1078 if (isa<RecordDecl>(DC))
1081 }
else if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(DC)) {
1082 mangleObjCMethodName(Method);
1083 }
else if (isa<NamedDecl>(DC)) {
1084 ND = cast<NamedDecl>(DC);
1085 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
1089 mangleUnqualifiedName(ND);
1092 if (
const auto *LDADC = getLambdaDefaultArgumentDeclContext(ND)) {
1102 void MicrosoftCXXNameMangler::mangleCXXDtorType(
CXXDtorType T) {
1117 llvm_unreachable(
"not expecting a COMDAT");
1119 llvm_unreachable(
"Unsupported dtor type?");
1128 case OO_New: Out <<
"?2";
break;
1130 case OO_Delete: Out <<
"?3";
break;
1132 case OO_Equal: Out <<
"?4";
break;
1134 case OO_GreaterGreater: Out <<
"?5";
break;
1136 case OO_LessLess: Out <<
"?6";
break;
1138 case OO_Exclaim: Out <<
"?7";
break;
1140 case OO_EqualEqual: Out <<
"?8";
break;
1142 case OO_ExclaimEqual: Out <<
"?9";
break;
1144 case OO_Subscript: Out <<
"?A";
break;
1147 case OO_Arrow: Out <<
"?C";
break;
1149 case OO_Star: Out <<
"?D";
break;
1151 case OO_PlusPlus: Out <<
"?E";
break;
1153 case OO_MinusMinus: Out <<
"?F";
break;
1155 case OO_Minus: Out <<
"?G";
break;
1157 case OO_Plus: Out <<
"?H";
break;
1159 case OO_Amp: Out <<
"?I";
break;
1161 case OO_ArrowStar: Out <<
"?J";
break;
1163 case OO_Slash: Out <<
"?K";
break;
1165 case OO_Percent: Out <<
"?L";
break;
1167 case OO_Less: Out <<
"?M";
break;
1169 case OO_LessEqual: Out <<
"?N";
break;
1171 case OO_Greater: Out <<
"?O";
break;
1173 case OO_GreaterEqual: Out <<
"?P";
break;
1175 case OO_Comma: Out <<
"?Q";
break;
1177 case OO_Call: Out <<
"?R";
break;
1179 case OO_Tilde: Out <<
"?S";
break;
1181 case OO_Caret: Out <<
"?T";
break;
1183 case OO_Pipe: Out <<
"?U";
break;
1185 case OO_AmpAmp: Out <<
"?V";
break;
1187 case OO_PipePipe: Out <<
"?W";
break;
1189 case OO_StarEqual: Out <<
"?X";
break;
1191 case OO_PlusEqual: Out <<
"?Y";
break;
1193 case OO_MinusEqual: Out <<
"?Z";
break;
1195 case OO_SlashEqual: Out <<
"?_0";
break;
1197 case OO_PercentEqual: Out <<
"?_1";
break;
1199 case OO_GreaterGreaterEqual: Out <<
"?_2";
break;
1201 case OO_LessLessEqual: Out <<
"?_3";
break;
1203 case OO_AmpEqual: Out <<
"?_4";
break;
1205 case OO_PipeEqual: Out <<
"?_5";
break;
1207 case OO_CaretEqual: Out <<
"?_6";
break;
1236 case OO_Array_New: Out <<
"?_U";
break;
1238 case OO_Array_Delete: Out <<
"?_V";
break;
1240 case OO_Coawait: Out <<
"?__L";
break;
1242 case OO_Spaceship: {
1246 "cannot mangle this three-way comparison operator yet");
1247 Diags.
Report(Loc, DiagID);
1251 case OO_Conditional: {
1254 "cannot mangle this conditional operator yet");
1255 Diags.
Report(Loc, DiagID);
1261 llvm_unreachable(
"Not an overloaded operator");
1265 void MicrosoftCXXNameMangler::mangleSourceName(StringRef Name) {
1267 BackRefVec::iterator Found =
1268 std::find(NameBackReferences.begin(), NameBackReferences.end(), Name);
1269 if (Found == NameBackReferences.end()) {
1270 if (NameBackReferences.size() < 10)
1271 NameBackReferences.push_back(Name);
1274 Out << (Found - NameBackReferences.begin());
1278 void MicrosoftCXXNameMangler::mangleObjCMethodName(
const ObjCMethodDecl *MD) {
1279 Context.mangleObjCMethodName(MD, Out);
1282 void MicrosoftCXXNameMangler::mangleTemplateInstantiationName(
1289 ArgBackRefMap OuterArgsContext;
1290 BackRefVec OuterTemplateContext;
1291 PassObjectSizeArgsSet OuterPassObjectSizeArgs;
1292 NameBackReferences.swap(OuterTemplateContext);
1293 TypeBackReferences.swap(OuterArgsContext);
1294 PassObjectSizeArgs.swap(OuterPassObjectSizeArgs);
1296 mangleUnscopedTemplateName(TD);
1297 mangleTemplateArgs(TD, TemplateArgs);
1300 NameBackReferences.swap(OuterTemplateContext);
1301 TypeBackReferences.swap(OuterArgsContext);
1302 PassObjectSizeArgs.swap(OuterPassObjectSizeArgs);
1306 MicrosoftCXXNameMangler::mangleUnscopedTemplateName(
const TemplateDecl *TD) {
1309 mangleUnqualifiedName(TD);
1312 void MicrosoftCXXNameMangler::mangleIntegerLiteral(
const llvm::APSInt &Value,
1317 if (IsBoolean && Value.getBoolValue())
1319 else if (Value.isSigned())
1320 mangleNumber(Value.getSExtValue());
1322 mangleNumber(Value.getZExtValue());
1325 void MicrosoftCXXNameMangler::mangleExpression(
const Expr *E) {
1338 if (UO->getOpcode() == UO_AddrOf)
1339 UE = dyn_cast<CXXUuidofExpr>(UO->getSubExpr());
1357 std::string Name =
"_GUID_" + Uuid.lower();
1358 std::replace(Name.begin(), Name.end(),
'-',
'_');
1360 mangleSourceName(Name);
1366 mangleArtificalTagType(
TTK_Struct,
"__s_GUID");
1380 void MicrosoftCXXNameMangler::mangleTemplateArgs(
1384 assert(TPL->
size() == TemplateArgs.
size() &&
1385 "size mismatch between args and parms!");
1389 mangleTemplateArg(TD, TA, TPL->
getParam(Idx++));
1392 void MicrosoftCXXNameMangler::mangleTemplateArg(
const TemplateDecl *TD,
1405 case TemplateArgument::Null:
1406 llvm_unreachable(
"Can't mangle null template arguments!");
1407 case TemplateArgument::TemplateExpansion:
1408 llvm_unreachable(
"Can't mangle template expansion arguments!");
1414 case TemplateArgument::Declaration: {
1416 if (isa<FieldDecl>(ND) || isa<IndirectFieldDecl>(ND)) {
1417 mangleMemberDataPointer(cast<CXXRecordDecl>(ND->
getDeclContext())
1418 ->getMostRecentNonInjectedDecl(),
1419 cast<ValueDecl>(ND));
1420 }
else if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
1423 mangleMemberFunctionPointer(
1428 mangleFunctionEncoding(FD,
true);
1435 case TemplateArgument::Integral:
1439 case TemplateArgument::NullPtr: {
1442 const CXXRecordDecl *RD = MPT->getMostRecentCXXRecordDecl();
1443 if (MPT->isMemberFunctionPointerType() &&
1444 !isa<FunctionTemplateDecl>(TD)) {
1445 mangleMemberFunctionPointer(RD,
nullptr);
1448 if (MPT->isMemberDataPointer()) {
1449 if (!isa<FunctionTemplateDecl>(TD)) {
1450 mangleMemberDataPointer(RD,
nullptr);
1460 mangleIntegerLiteral(llvm::APSInt::get(-1),
false);
1465 mangleIntegerLiteral(llvm::APSInt::getUnsigned(0),
false);
1468 case TemplateArgument::Expression:
1471 case TemplateArgument::Pack: {
1473 if (TemplateArgs.empty()) {
1474 if (isa<TemplateTypeParmDecl>(Parm) ||
1475 isa<TemplateTemplateParmDecl>(Parm))
1479 LangOptions::MSVC2015)
1482 else if (isa<NonTypeTemplateParmDecl>(Parm))
1485 llvm_unreachable(
"unexpected template parameter decl!");
1488 mangleTemplateArg(TD, PA, Parm);
1492 case TemplateArgument::Template: {
1495 if (
const auto *TD = dyn_cast<TagDecl>(ND)) {
1497 }
else if (isa<TypeAliasDecl>(ND)) {
1501 llvm_unreachable(
"unexpected template template NamedDecl!");
1508 void MicrosoftCXXNameMangler::mangleObjCProtocol(
const ObjCProtocolDecl *PD) {
1510 llvm::raw_svector_ostream Stream(TemplateMangling);
1511 MicrosoftCXXNameMangler Extra(Context, Stream);
1514 Extra.mangleSourceName(
"Protocol");
1517 mangleArtificalTagType(
TTK_Struct, TemplateMangling, {
"__ObjC"});
1520 void MicrosoftCXXNameMangler::mangleObjCLifetime(
const QualType Type,
1524 llvm::raw_svector_ostream Stream(TemplateMangling);
1525 MicrosoftCXXNameMangler Extra(Context, Stream);
1529 case Qualifiers::OCL_None:
1530 case Qualifiers::OCL_ExplicitNone:
1532 case Qualifiers::OCL_Autoreleasing:
1533 Extra.mangleSourceName(
"Autoreleasing");
1535 case Qualifiers::OCL_Strong:
1536 Extra.mangleSourceName(
"Strong");
1538 case Qualifiers::OCL_Weak:
1539 Extra.mangleSourceName(
"Weak");
1542 Extra.manglePointerCVQualifiers(Quals);
1543 Extra.manglePointerExtQualifiers(Quals, Type);
1544 Extra.mangleType(Type, Range);
1546 mangleArtificalTagType(
TTK_Struct, TemplateMangling, {
"__ObjC"});
1549 void MicrosoftCXXNameMangler::mangleQualifiers(
Qualifiers Quals,
1607 if (HasConst && HasVolatile) {
1609 }
else if (HasVolatile) {
1611 }
else if (HasConst) {
1617 if (HasConst && HasVolatile) {
1619 }
else if (HasVolatile) {
1621 }
else if (HasConst) {
1632 MicrosoftCXXNameMangler::mangleRefQualifier(
RefQualifierKind RefQualifier) {
1635 switch (RefQualifier) {
1649 void MicrosoftCXXNameMangler::manglePointerExtQualifiers(
Qualifiers Quals,
1651 if (PointersAre64Bit &&
1663 void MicrosoftCXXNameMangler::manglePointerCVQualifiers(
Qualifiers Quals) {
1671 if (HasConst && HasVolatile) {
1673 }
else if (HasVolatile) {
1675 }
else if (HasConst) {
1682 void MicrosoftCXXNameMangler::mangleArgumentType(
QualType T,
1693 QualType OriginalType = DT->getOriginalType();
1696 if (
const auto *AT = getASTContext().getAsArrayType(OriginalType))
1697 OriginalType = getASTContext().getIncompleteArrayType(
1698 AT->getElementType(), AT->getSizeModifier(),
1699 AT->getIndexTypeCVRQualifiers());
1713 ArgBackRefMap::iterator Found = TypeBackReferences.find(TypePtr);
1715 if (Found == TypeBackReferences.end()) {
1716 size_t OutSizeBefore = Out.tell();
1718 mangleType(T, Range, QMM_Drop);
1723 bool LongerThanOneChar = (Out.tell() - OutSizeBefore > 1);
1724 if (LongerThanOneChar && TypeBackReferences.size() < 10) {
1725 size_t Size = TypeBackReferences.size();
1726 TypeBackReferences[TypePtr] = Size;
1729 Out << Found->second;
1733 void MicrosoftCXXNameMangler::manglePassObjectSizeArg(
1734 const PassObjectSizeAttr *POSA) {
1735 int Type = POSA->getType();
1737 auto Iter = PassObjectSizeArgs.insert(Type).first;
1738 auto *TypePtr = (
const void *)&*Iter;
1739 ArgBackRefMap::iterator Found = TypeBackReferences.find(TypePtr);
1741 if (Found == TypeBackReferences.end()) {
1742 mangleArtificalTagType(
TTK_Enum,
"__pass_object_size" + llvm::utostr(Type),
1745 if (TypeBackReferences.size() < 10) {
1746 size_t Size = TypeBackReferences.size();
1747 TypeBackReferences[TypePtr] = Size;
1750 Out << Found->second;
1755 QualifierMangleMode QMM) {
1760 if (
const ArrayType *AT = getASTContext().getAsArrayType(T)) {
1763 if (QMM == QMM_Mangle)
1765 else if (QMM == QMM_Escape || QMM == QMM_Result)
1767 mangleArrayType(AT);
1780 if (
const FunctionType *FT = dyn_cast<FunctionType>(T)) {
1782 mangleFunctionType(FT);
1785 mangleQualifiers(Quals,
false);
1788 if (!IsPointer && Quals) {
1790 mangleQualifiers(Quals,
false);
1798 if ((!IsPointer && Quals) || isa<TagType>(T) || isArtificialTagType(T)) {
1800 mangleQualifiers(Quals,
false);
1808 #define ABSTRACT_TYPE(CLASS, PARENT) 1809 #define NON_CANONICAL_TYPE(CLASS, PARENT) \ 1811 llvm_unreachable("can't mangle non-canonical type " #CLASS "Type"); \ 1813 #define TYPE(CLASS, PARENT) \ 1815 mangleType(cast<CLASS##Type>(ty), Quals, Range); \ 1817 #include "clang/AST/TypeNodes.def" 1818 #undef ABSTRACT_TYPE 1819 #undef NON_CANONICAL_TYPE 1853 case BuiltinType::Void:
1856 case BuiltinType::SChar:
1859 case BuiltinType::Char_U:
1860 case BuiltinType::Char_S:
1863 case BuiltinType::UChar:
1866 case BuiltinType::Short:
1869 case BuiltinType::UShort:
1872 case BuiltinType::Int:
1875 case BuiltinType::UInt:
1878 case BuiltinType::Long:
1881 case BuiltinType::ULong:
1884 case BuiltinType::Float:
1887 case BuiltinType::Double:
1891 case BuiltinType::LongDouble:
1894 case BuiltinType::LongLong:
1897 case BuiltinType::ULongLong:
1900 case BuiltinType::Int128:
1903 case BuiltinType::UInt128:
1906 case BuiltinType::Bool:
1909 case BuiltinType::Char16:
1912 case BuiltinType::Char32:
1915 case BuiltinType::WChar_S:
1916 case BuiltinType::WChar_U:
1920 #define BUILTIN_TYPE(Id, SingletonId) 1921 #define PLACEHOLDER_TYPE(Id, SingletonId) \ 1922 case BuiltinType::Id: 1923 #include "clang/AST/BuiltinTypes.def" 1924 case BuiltinType::Dependent:
1925 llvm_unreachable(
"placeholder types shouldn't get to name mangling");
1927 case BuiltinType::ObjCId:
1928 mangleArtificalTagType(
TTK_Struct,
".objc_object");
1930 case BuiltinType::ObjCClass:
1931 mangleArtificalTagType(
TTK_Struct,
".objc_class");
1933 case BuiltinType::ObjCSel:
1934 mangleArtificalTagType(
TTK_Struct,
".objc_selector");
1937 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 1938 case BuiltinType::Id: \ 1939 Out << "PAUocl_" #ImgType "_" #Suffix "@@"; \ 1941 #include "clang/Basic/OpenCLImageTypes.def" 1942 case BuiltinType::OCLSampler:
1944 mangleArtificalTagType(
TTK_Struct,
"ocl_sampler");
1946 case BuiltinType::OCLEvent:
1948 mangleArtificalTagType(
TTK_Struct,
"ocl_event");
1950 case BuiltinType::OCLClkEvent:
1952 mangleArtificalTagType(
TTK_Struct,
"ocl_clkevent");
1954 case BuiltinType::OCLQueue:
1956 mangleArtificalTagType(
TTK_Struct,
"ocl_queue");
1958 case BuiltinType::OCLReserveID:
1960 mangleArtificalTagType(
TTK_Struct,
"ocl_reserveid");
1963 case BuiltinType::NullPtr:
1967 case BuiltinType::Float16:
1968 mangleArtificalTagType(
TTK_Struct,
"_Float16", {
"__clang"});
1971 case BuiltinType::Half:
1972 mangleArtificalTagType(
TTK_Struct,
"_Half", {
"__clang"});
1975 case BuiltinType::ShortAccum:
1976 case BuiltinType::Accum:
1977 case BuiltinType::LongAccum:
1978 case BuiltinType::UShortAccum:
1979 case BuiltinType::UAccum:
1980 case BuiltinType::ULongAccum:
1981 case BuiltinType::ShortFract:
1982 case BuiltinType::Fract:
1983 case BuiltinType::LongFract:
1984 case BuiltinType::UShortFract:
1985 case BuiltinType::UFract:
1986 case BuiltinType::ULongFract:
1987 case BuiltinType::SatShortAccum:
1988 case BuiltinType::SatAccum:
1989 case BuiltinType::SatLongAccum:
1990 case BuiltinType::SatUShortAccum:
1991 case BuiltinType::SatUAccum:
1992 case BuiltinType::SatULongAccum:
1993 case BuiltinType::SatShortFract:
1994 case BuiltinType::SatFract:
1995 case BuiltinType::SatLongFract:
1996 case BuiltinType::SatUShortFract:
1997 case BuiltinType::SatUFract:
1998 case BuiltinType::SatULongFract:
1999 case BuiltinType::Char8:
2000 case BuiltinType::Float128: {
2019 mangleFunctionType(T,
nullptr,
true);
2022 mangleFunctionType(T);
2028 mangleFunctionType(T);
2031 void MicrosoftCXXNameMangler::mangleFunctionType(
const FunctionType *T,
2033 bool ForceThisQuals) {
2041 bool IsInLambda =
false;
2042 bool IsStructor =
false, HasThisQuals = ForceThisQuals, IsCtorClosure =
false;
2044 if (
const CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl>(D)) {
2047 if (MD->isInstance())
2048 HasThisQuals =
true;
2049 if (isa<CXXDestructorDecl>(MD)) {
2051 }
else if (isa<CXXConstructorDecl>(MD)) {
2057 CC = getASTContext().getDefaultCallingConvention(
2066 manglePointerExtQualifiers(Quals,
QualType());
2068 mangleQualifiers(Quals,
false);
2071 mangleCallingConvention(CC);
2076 if (isa<CXXDestructorDecl>(D) && isStructorDecl(D)) {
2080 Out << (PointersAre64Bit ?
"PEAXI@Z" :
"PAXI@Z");
2089 if (IsCtorClosure) {
2099 mangleArgumentType(getASTContext().getLValueReferenceType(
2107 llvm_unreachable(
"unexpected constructor closure!");
2115 if (
const auto *AT =
2120 assert(AT->getKeyword() != AutoTypeKeyword::GNUAutoType &&
2121 "shouldn't need to mangle __auto_type!");
2122 mangleSourceName(AT->isDecltypeAuto() ?
"<decltype-auto>" :
"<auto>");
2124 }
else if (IsInLambda) {
2129 mangleType(ResultType, Range, QMM_Result);
2145 for (
unsigned I = 0, E = Proto->
getNumParams(); I != E; ++I) {
2157 manglePassObjectSizeArg(
P);
2166 mangleThrowSpecification(Proto);
2169 void MicrosoftCXXNameMangler::mangleFunctionClass(
const FunctionDecl *FD) {
2194 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
2195 bool IsVirtual = MD->isVirtual();
2198 if (isa<CXXDestructorDecl>(MD) && isStructorDecl(MD) &&
2204 llvm_unreachable(
"Unsupported access specifier");
2233 void MicrosoftCXXNameMangler::mangleCallingConvention(
CallingConv CC) {
2254 llvm_unreachable(
"Unsupported CC for mangling");
2257 case CC_C: Out <<
'A';
break;
2268 void MicrosoftCXXNameMangler::mangleCallingConvention(
const FunctionType *T) {
2271 void MicrosoftCXXNameMangler::mangleThrowSpecification(
2288 "cannot mangle this unresolved dependent type yet");
2298 void MicrosoftCXXNameMangler::mangleTagTypeKind(
TagTypeKind TTK) {
2317 mangleType(cast<TagType>(T)->getDecl());
2321 mangleType(cast<TagType>(T)->getDecl());
2323 void MicrosoftCXXNameMangler::mangleType(
const TagDecl *TD) {
2329 void MicrosoftCXXNameMangler::mangleArtificalTagType(
2333 mangleTagTypeKind(TK);
2336 mangleSourceName(UnqualifiedName);
2338 for (
auto I = NestedNames.rbegin(), E = NestedNames.rend(); I != E; ++I)
2339 mangleSourceName(*I);
2352 void MicrosoftCXXNameMangler::mangleDecayedArrayType(
const ArrayType *T) {
2360 llvm_unreachable(
"Should have been special cased");
2364 llvm_unreachable(
"Should have been special cased");
2368 llvm_unreachable(
"Should have been special cased");
2372 llvm_unreachable(
"Should have been special cased");
2374 void MicrosoftCXXNameMangler::mangleArrayType(
const ArrayType *T) {
2380 getASTContext().getAsConstantArrayType(ElementTy);
2381 Dimensions.push_back(CAT->
getSize());
2385 getASTContext().getAsIncompleteArrayType(ElementTy);
2386 Dimensions.push_back(llvm::APInt(32, 0));
2390 getASTContext().getAsVariableArrayType(ElementTy);
2391 Dimensions.push_back(llvm::APInt(32, 0));
2396 getASTContext().getAsDependentSizedArrayType(ElementTy);
2399 "cannot mangle this dependent-length array yet");
2409 mangleNumber(Dimensions.size());
2410 for (
const llvm::APInt &Dimension : Dimensions)
2411 mangleNumber(Dimension.getLimitedValue());
2421 manglePointerCVQualifiers(Quals);
2422 manglePointerExtQualifiers(Quals, PointeeType);
2426 mangleFunctionType(FPT,
nullptr,
true);
2430 mangleType(PointeeType, Range, QMM_Drop);
2438 "cannot mangle this template type parameter type yet");
2447 "cannot mangle this substituted parameter pack yet");
2458 manglePointerCVQualifiers(Quals);
2459 manglePointerExtQualifiers(Quals, PointeeType);
2460 mangleType(PointeeType, Range);
2467 case Qualifiers::OCL_None:
2468 case Qualifiers::OCL_ExplicitNone:
2470 case Qualifiers::OCL_Autoreleasing:
2471 case Qualifiers::OCL_Strong:
2472 case Qualifiers::OCL_Weak:
2473 return mangleObjCLifetime(PointeeType, Quals, Range);
2475 manglePointerCVQualifiers(Quals);
2476 manglePointerExtQualifiers(Quals, PointeeType);
2477 mangleType(PointeeType, Range);
2488 manglePointerExtQualifiers(Quals, PointeeType);
2489 mangleType(PointeeType, Range);
2500 manglePointerExtQualifiers(Quals, PointeeType);
2501 mangleType(PointeeType, Range);
2509 llvm::raw_svector_ostream Stream(TemplateMangling);
2510 MicrosoftCXXNameMangler Extra(Context, Stream);
2512 Extra.mangleSourceName(
"_Complex");
2513 Extra.mangleType(ElementType, Range, QMM_Escape);
2515 mangleArtificalTagType(
TTK_Struct, TemplateMangling, {
"__clang"});
2523 bool MicrosoftCXXNameMangler::isArtificialTagType(
QualType T)
const {
2529 case Type::Vector: {
2541 assert(ET &&
"vectors with non-builtin elements are unsupported");
2542 uint64_t Width = getASTContext().getTypeSize(T);
2545 size_t OutSizeBefore = Out.tell();
2546 llvm::Triple::ArchType AT =
2547 getASTContext().getTargetInfo().getTriple().getArch();
2548 if (AT == llvm::Triple::x86 || AT == llvm::Triple::x86_64) {
2549 if (Width == 64 && ET->
getKind() == BuiltinType::LongLong) {
2550 mangleArtificalTagType(
TTK_Union,
"__m64");
2551 }
else if (Width >= 128) {
2552 if (ET->
getKind() == BuiltinType::Float)
2553 mangleArtificalTagType(
TTK_Union,
"__m" + llvm::utostr(Width));
2554 else if (ET->
getKind() == BuiltinType::LongLong)
2555 mangleArtificalTagType(
TTK_Union,
"__m" + llvm::utostr(Width) +
'i');
2556 else if (ET->
getKind() == BuiltinType::Double)
2557 mangleArtificalTagType(
TTK_Struct,
"__m" + llvm::utostr(Width) +
'd');
2561 bool IsBuiltin = Out.tell() != OutSizeBefore;
2568 llvm::raw_svector_ostream Stream(TemplateMangling);
2569 MicrosoftCXXNameMangler Extra(Context, Stream);
2571 Extra.mangleSourceName(
"__vector");
2572 Extra.mangleType(
QualType(ET, 0), Range, QMM_Escape);
2573 Extra.mangleIntegerLiteral(llvm::APSInt::getUnsigned(T->
getNumElements()),
2576 mangleArtificalTagType(
TTK_Union, TemplateMangling, {
"__clang"});
2580 void MicrosoftCXXNameMangler::mangleType(
const ExtVectorType *T,
2582 mangleType(static_cast<const VectorType *>(T), Quals, Range);
2590 "cannot mangle this dependent-sized vector type yet");
2598 "cannot mangle this dependent-sized extended vector type yet");
2608 "cannot mangle this dependent address space type yet");
2617 mangle(T->
getDecl(),
".objc_cls_");
2623 return mangleType(T->
getBaseType(), Range, QMM_Drop);
2625 ArgBackRefMap OuterArgsContext;
2626 BackRefVec OuterTemplateContext;
2628 TypeBackReferences.swap(OuterArgsContext);
2629 NameBackReferences.swap(OuterTemplateContext);
2635 mangleSourceName(
".objc_object");
2637 mangleSourceName(
".objc_class");
2641 for (
const auto &Q : T->
quals())
2642 mangleObjCProtocol(Q);
2647 TypeBackReferences.swap(OuterArgsContext);
2648 NameBackReferences.swap(OuterTemplateContext);
2654 manglePointerCVQualifiers(Quals);
2655 manglePointerExtQualifiers(Quals, PointeeType);
2664 llvm_unreachable(
"Cannot mangle injected class name type.");
2671 "cannot mangle this template specialization type yet");
2680 "cannot mangle this dependent name type yet");
2685 void MicrosoftCXXNameMangler::mangleType(
2690 "cannot mangle this dependent template specialization type yet");
2699 "cannot mangle this pack expansion yet");
2708 "cannot mangle this typeof(type) yet");
2717 "cannot mangle this typeof(expression) yet");
2726 "cannot mangle this decltype() yet");
2735 "cannot mangle this unary transform type yet");
2746 "cannot mangle this 'auto' type yet");
2747 Diags.Report(Range.
getBegin(), DiagID)
2751 void MicrosoftCXXNameMangler::mangleType(
2757 "cannot mangle this deduced class template specialization type yet");
2758 Diags.Report(Range.
getBegin(), DiagID)
2767 llvm::raw_svector_ostream Stream(TemplateMangling);
2768 MicrosoftCXXNameMangler Extra(Context, Stream);
2770 Extra.mangleSourceName(
"_Atomic");
2771 Extra.mangleType(ValueType, Range, QMM_Escape);
2773 mangleArtificalTagType(
TTK_Struct, TemplateMangling, {
"__clang"});
2780 "cannot mangle this OpenCL pipe type yet");
2785 void MicrosoftMangleContextImpl::mangleCXXName(
const NamedDecl *D,
2787 assert((isa<FunctionDecl>(D) || isa<VarDecl>(D)) &&
2788 "Invalid mangleName() call, argument is not a variable or function!");
2789 assert(!isa<CXXConstructorDecl>(D) && !isa<CXXDestructorDecl>(D) &&
2790 "Invalid mangleName() call on 'structor decl!");
2793 getASTContext().getSourceManager(),
2794 "Mangling declaration");
2796 msvc_hashing_ostream MHO(Out);
2797 MicrosoftCXXNameMangler Mangler(*
this, MHO);
2798 return Mangler.mangle(D);
2827 MicrosoftCXXNameMangler &Mangler,
2834 llvm_unreachable(
"Unsupported access specifier");
2845 Out <<
'R' << AccessSpec;
2846 Mangler.mangleNumber(
2848 Mangler.mangleNumber(
2850 Mangler.mangleNumber(
2852 Mangler.mangleNumber(static_cast<uint32_t>(Adjustment.
NonVirtual));
2855 Mangler.mangleNumber(
2857 Mangler.mangleNumber(-static_cast<uint32_t>(Adjustment.
NonVirtual));
2862 llvm_unreachable(
"Unsupported access specifier");
2872 Mangler.mangleNumber(-static_cast<uint32_t>(Adjustment.
NonVirtual));
2876 llvm_unreachable(
"Unsupported access specifier");
2889 void MicrosoftMangleContextImpl::mangleVirtualMemPtrThunk(
2892 msvc_hashing_ostream MHO(Out);
2893 MicrosoftCXXNameMangler Mangler(*
this, MHO);
2894 Mangler.getStream() <<
'?';
2895 Mangler.mangleVirtualMemPtrThunk(MD, ML);
2898 void MicrosoftMangleContextImpl::mangleThunk(
const CXXMethodDecl *MD,
2901 msvc_hashing_ostream MHO(Out);
2902 MicrosoftCXXNameMangler Mangler(*
this, MHO);
2903 Mangler.getStream() <<
'?';
2904 Mangler.mangleName(MD);
2907 assert(Thunk.
Method !=
nullptr &&
2908 "Thunk info should hold the overridee decl");
2911 Mangler.mangleFunctionType(
2915 void MicrosoftMangleContextImpl::mangleCXXDtorThunk(
2922 msvc_hashing_ostream MHO(Out);
2923 MicrosoftCXXNameMangler Mangler(*
this, MHO, DD, Type);
2924 Mangler.getStream() <<
"??_E";
2930 void MicrosoftMangleContextImpl::mangleCXXVFTable(
2937 msvc_hashing_ostream MHO(Out);
2938 MicrosoftCXXNameMangler Mangler(*
this, MHO);
2939 if (Derived->
hasAttr<DLLImportAttr>())
2940 Mangler.getStream() <<
"??_S";
2942 Mangler.getStream() <<
"??_7";
2943 Mangler.mangleName(Derived);
2944 Mangler.getStream() <<
"6B";
2946 Mangler.mangleName(RD);
2947 Mangler.getStream() <<
'@';
2950 void MicrosoftMangleContextImpl::mangleCXXVBTable(
2957 msvc_hashing_ostream MHO(Out);
2958 MicrosoftCXXNameMangler Mangler(*
this, MHO);
2959 Mangler.getStream() <<
"??_8";
2960 Mangler.mangleName(Derived);
2961 Mangler.getStream() <<
"7B";
2963 Mangler.mangleName(RD);
2964 Mangler.getStream() <<
'@';
2967 void MicrosoftMangleContextImpl::mangleCXXRTTI(
QualType T, raw_ostream &Out) {
2968 msvc_hashing_ostream MHO(Out);
2969 MicrosoftCXXNameMangler Mangler(*
this, MHO);
2970 Mangler.getStream() <<
"??_R0";
2971 Mangler.mangleType(T,
SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
2972 Mangler.getStream() <<
"@8";
2975 void MicrosoftMangleContextImpl::mangleCXXRTTIName(
QualType T,
2977 MicrosoftCXXNameMangler Mangler(*
this, Out);
2978 Mangler.getStream() <<
'.';
2979 Mangler.mangleType(T,
SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
2982 void MicrosoftMangleContextImpl::mangleCXXVirtualDisplacementMap(
2984 msvc_hashing_ostream MHO(Out);
2985 MicrosoftCXXNameMangler Mangler(*
this, MHO);
2986 Mangler.getStream() <<
"??_K";
2987 Mangler.mangleName(SrcRD);
2988 Mangler.getStream() <<
"$C";
2989 Mangler.mangleName(DstRD);
2992 void MicrosoftMangleContextImpl::mangleCXXThrowInfo(
QualType T,
bool IsConst,
2995 uint32_t NumEntries,
2997 msvc_hashing_ostream MHO(Out);
2998 MicrosoftCXXNameMangler Mangler(*
this, MHO);
2999 Mangler.getStream() <<
"_TI";
3001 Mangler.getStream() <<
'C';
3003 Mangler.getStream() <<
'V';
3005 Mangler.getStream() <<
'U';
3006 Mangler.getStream() << NumEntries;
3007 Mangler.mangleType(T,
SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
3010 void MicrosoftMangleContextImpl::mangleCXXCatchableTypeArray(
3011 QualType T, uint32_t NumEntries, raw_ostream &Out) {
3012 msvc_hashing_ostream MHO(Out);
3013 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3014 Mangler.getStream() <<
"_CTA";
3015 Mangler.getStream() << NumEntries;
3016 Mangler.mangleType(T,
SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
3019 void MicrosoftMangleContextImpl::mangleCXXCatchableType(
3021 uint32_t NVOffset, int32_t VBPtrOffset, uint32_t VBIndex,
3023 MicrosoftCXXNameMangler Mangler(*
this, Out);
3024 Mangler.getStream() <<
"_CT";
3028 llvm::raw_svector_ostream Stream(RTTIMangling);
3029 msvc_hashing_ostream MHO(Stream);
3030 mangleCXXRTTI(T, MHO);
3032 Mangler.getStream() << RTTIMangling;
3037 if (!getASTContext().getLangOpts().isCompatibleWithMSVC(
3038 LangOptions::MSVC2015) &&
3040 llvm::raw_svector_ostream Stream(CopyCtorMangling);
3041 msvc_hashing_ostream MHO(Stream);
3042 mangleCXXCtor(CD, CT, MHO);
3044 Mangler.getStream() << CopyCtorMangling;
3046 Mangler.getStream() << Size;
3047 if (VBPtrOffset == -1) {
3049 Mangler.getStream() << NVOffset;
3052 Mangler.getStream() << NVOffset;
3053 Mangler.getStream() << VBPtrOffset;
3054 Mangler.getStream() << VBIndex;
3058 void MicrosoftMangleContextImpl::mangleCXXRTTIBaseClassDescriptor(
3059 const CXXRecordDecl *Derived, uint32_t NVOffset, int32_t VBPtrOffset,
3060 uint32_t VBTableOffset, uint32_t Flags, raw_ostream &Out) {
3061 msvc_hashing_ostream MHO(Out);
3062 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3063 Mangler.getStream() <<
"??_R1";
3064 Mangler.mangleNumber(NVOffset);
3065 Mangler.mangleNumber(VBPtrOffset);
3066 Mangler.mangleNumber(VBTableOffset);
3067 Mangler.mangleNumber(Flags);
3068 Mangler.mangleName(Derived);
3069 Mangler.getStream() <<
"8";
3072 void MicrosoftMangleContextImpl::mangleCXXRTTIBaseClassArray(
3074 msvc_hashing_ostream MHO(Out);
3075 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3076 Mangler.getStream() <<
"??_R2";
3077 Mangler.mangleName(Derived);
3078 Mangler.getStream() <<
"8";
3081 void MicrosoftMangleContextImpl::mangleCXXRTTIClassHierarchyDescriptor(
3083 msvc_hashing_ostream MHO(Out);
3084 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3085 Mangler.getStream() <<
"??_R3";
3086 Mangler.mangleName(Derived);
3087 Mangler.getStream() <<
"8";
3090 void MicrosoftMangleContextImpl::mangleCXXRTTICompleteObjectLocator(
3098 llvm::raw_svector_ostream Stream(VFTableMangling);
3099 mangleCXXVFTable(Derived, BasePath, Stream);
3101 if (VFTableMangling.startswith(
"??@")) {
3102 assert(VFTableMangling.endswith(
"@"));
3103 Out << VFTableMangling <<
"??_R4@";
3107 assert(VFTableMangling.startswith(
"??_7") ||
3108 VFTableMangling.startswith(
"??_S"));
3110 Out <<
"??_R4" << StringRef(VFTableMangling).drop_front(4);
3113 void MicrosoftMangleContextImpl::mangleSEHFilterExpression(
3114 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
3115 msvc_hashing_ostream MHO(Out);
3116 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3121 Mangler.getStream() <<
"?filt$" << SEHFilterIds[EnclosingDecl]++ <<
"@0@";
3122 Mangler.mangleName(EnclosingDecl);
3125 void MicrosoftMangleContextImpl::mangleSEHFinallyBlock(
3126 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
3127 msvc_hashing_ostream MHO(Out);
3128 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3133 Mangler.getStream() <<
"?fin$" << SEHFinallyIds[EnclosingDecl]++ <<
"@0@";
3134 Mangler.mangleName(EnclosingDecl);
3137 void MicrosoftMangleContextImpl::mangleTypeName(
QualType T, raw_ostream &Out) {
3140 MicrosoftCXXNameMangler Mangler(*
this, Out);
3141 Mangler.getStream() <<
'?';
3148 msvc_hashing_ostream MHO(Out);
3149 MicrosoftCXXNameMangler mangler(*
this, MHO, D, Type);
3156 msvc_hashing_ostream MHO(Out);
3157 MicrosoftCXXNameMangler mangler(*
this, MHO, D, Type);
3161 void MicrosoftMangleContextImpl::mangleReferenceTemporary(
3162 const VarDecl *VD,
unsigned ManglingNumber, raw_ostream &Out) {
3163 msvc_hashing_ostream MHO(Out);
3164 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3166 Mangler.getStream() <<
"?$RT" << ManglingNumber <<
'@';
3167 Mangler.mangle(VD,
"");
3170 void MicrosoftMangleContextImpl::mangleThreadSafeStaticGuardVariable(
3171 const VarDecl *VD,
unsigned GuardNum, raw_ostream &Out) {
3172 msvc_hashing_ostream MHO(Out);
3173 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3175 Mangler.getStream() <<
"?$TSS" << GuardNum <<
'@';
3176 Mangler.mangleNestedName(VD);
3177 Mangler.getStream() <<
"@4HA";
3180 void MicrosoftMangleContextImpl::mangleStaticGuardVariable(
const VarDecl *VD,
3192 msvc_hashing_ostream MHO(Out);
3193 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3197 Mangler.getStream() << (VD->
getTLSKind() ?
"??__J" :
"??_B");
3199 Mangler.getStream() <<
"?$S1@";
3201 unsigned ScopeDepth = 0;
3202 if (Visible && !getNextDiscriminator(VD, ScopeDepth))
3206 Mangler.mangle(VD,
"");
3208 Mangler.mangleNestedName(VD);
3209 Mangler.getStream() << (Visible ?
"@5" :
"@4IA");
3211 Mangler.mangleNumber(ScopeDepth);
3214 void MicrosoftMangleContextImpl::mangleInitFiniStub(
const VarDecl *D,
3217 msvc_hashing_ostream MHO(Out);
3218 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3219 Mangler.getStream() <<
"??__" << CharCode;
3220 Mangler.mangleName(D);
3222 Mangler.mangleVariableEncoding(D);
3223 Mangler.getStream() <<
'@';
3227 Mangler.getStream() <<
"YAXXZ";
3230 void MicrosoftMangleContextImpl::mangleDynamicInitializer(
const VarDecl *D,
3233 mangleInitFiniStub(D,
'E', Out);
3237 MicrosoftMangleContextImpl::mangleDynamicAtExitDestructor(
const VarDecl *D,
3240 mangleInitFiniStub(D,
'F', Out);
3243 void MicrosoftMangleContextImpl::mangleStringLiteral(
const StringLiteral *SL,
3264 MicrosoftCXXNameMangler Mangler(*
this, Out);
3265 Mangler.getStream() <<
"??_C@_";
3273 unsigned StringLength = getASTContext()
3274 .getAsConstantArrayType(SL->
getType())
3281 Mangler.getStream() <<
'1';
3283 Mangler.getStream() <<
'0';
3287 Mangler.mangleNumber(StringByteLength);
3289 auto GetLittleEndianByte = [&SL](
unsigned Index) {
3291 if (Index / CharByteWidth >= SL->
getLength())
3292 return static_cast<char>(0);
3293 uint32_t CodeUnit = SL->
getCodeUnit(Index / CharByteWidth);
3294 unsigned OffsetInCodeUnit = Index % CharByteWidth;
3295 return static_cast<char>((CodeUnit >> (8 * OffsetInCodeUnit)) & 0xff);
3298 auto GetBigEndianByte = [&SL](
unsigned Index) {
3300 if (Index / CharByteWidth >= SL->
getLength())
3301 return static_cast<char>(0);
3302 uint32_t CodeUnit = SL->
getCodeUnit(Index / CharByteWidth);
3303 unsigned OffsetInCodeUnit = (CharByteWidth - 1) - (Index % CharByteWidth);
3304 return static_cast<char>((CodeUnit >> (8 * OffsetInCodeUnit)) & 0xff);
3309 for (
unsigned I = 0, E = StringByteLength; I != E; ++I)
3310 JC.update(GetLittleEndianByte(I));
3314 Mangler.mangleNumber(JC.getCRC());
3320 auto MangleByte = [&Mangler](
char Byte) {
3328 Mangler.getStream() << Byte;
3329 }
else if (
isLetter(Byte & 0x7f)) {
3330 Mangler.getStream() <<
'?' <<
static_cast<char>(Byte & 0x7f);
3332 const char SpecialChars[] = {
',',
'/',
'\\',
':',
'.',
3333 ' ',
'\n',
'\t',
'\'',
'-'};
3335 std::find(std::begin(SpecialChars), std::end(SpecialChars), Byte);
3336 if (Pos != std::end(SpecialChars)) {
3337 Mangler.getStream() <<
'?' << (Pos - std::begin(SpecialChars));
3339 Mangler.getStream() <<
"?$";
3340 Mangler.getStream() <<
static_cast<char>(
'A' + ((Byte >> 4) & 0xf));
3341 Mangler.getStream() <<
static_cast<char>(
'A' + (Byte & 0xf));
3347 unsigned MaxBytesToMangle = SL->
isWide() ? 64U : 32U;
3348 unsigned NumBytesToMangle =
std::min(MaxBytesToMangle, StringByteLength);
3349 for (
unsigned I = 0; I != NumBytesToMangle; ++I) {
3351 MangleByte(GetBigEndianByte(I));
3353 MangleByte(GetLittleEndianByte(I));
3356 Mangler.getStream() <<
'@';
3361 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.
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.
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
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.
Defines the C++ template declaration subclasses.
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
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>'.
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].
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
bool isReferenceType() 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
unsigned getTypeQuals() 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.
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
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...
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
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.
Expr * IgnoreParenNoopCasts(ASTContext &Ctx) LLVM_READONLY
IgnoreParenNoopCasts - Ignore parentheses and casts that do not change the value (including ptr->int ...
Represents a ValueDecl that came out of a declarator.
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
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
Pepresents 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 ...
Expr - 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
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
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
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
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.
IdentifierInfo * getCXXLiteralIdentifier() const
getCXXLiteralIdentifier - If this name is the name of a literal operator, retrieve the identifier ass...
QualType getCanonicalType() const
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 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.
static void mangleThunkThisAdjustment(const CXXMethodDecl *MD, const ThisAdjustment &Adjustment, MicrosoftCXXNameMangler &Mangler, raw_ostream &Out)
Base class for declarations which introduce a typedef-name.
Represents a template argument.
TagTypeKind
The kind of a tag type.
struct clang::ThisAdjustment::VirtualAdjustment::@120 Microsoft
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.
DeclarationName - The name of a declaration.
const CXXRecordDecl * getParent() const
Returns 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_].
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.
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...
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
__DEVICE__ int min(int __a, int __b)
bool isStaticDataMember() const
Determines whether this is a static data member.
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 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.