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 mangleArtificialTagType(
TagTypeKind TK, StringRef UnqualifiedName,
316 QualifierMangleMode QMM = QMM_Mangle);
319 bool ForceThisQuals =
false,
320 bool MangleExceptionSpec =
true);
321 void mangleNestedName(
const NamedDecl *ND);
324 bool isStructorDecl(
const NamedDecl *ND)
const {
325 return ND == Structor || getStructor(ND) == Structor;
328 void mangleUnqualifiedName(
const NamedDecl *ND) {
332 void mangleSourceName(StringRef Name);
335 void mangleQualifiers(
Qualifiers Quals,
bool IsMember);
337 void manglePointerCVQualifiers(
Qualifiers Quals);
340 void mangleUnscopedTemplateName(
const TemplateDecl *ND);
347 void manglePassObjectSizeArg(
const PassObjectSizeAttr *POSA);
349 bool isArtificialTagType(
QualType T)
const;
352 #define ABSTRACT_TYPE(CLASS, PARENT) 353 #define NON_CANONICAL_TYPE(CLASS, PARENT) 354 #define TYPE(CLASS, PARENT) void mangleType(const CLASS##Type *T, \ 357 #include "clang/AST/TypeNodes.def" 359 #undef NON_CANONICAL_TYPE 362 void mangleType(
const TagDecl *TD);
363 void mangleDecayedArrayType(
const ArrayType *T);
364 void mangleArrayType(
const ArrayType *T);
368 void mangleIntegerLiteral(
const llvm::APSInt &Number,
bool IsBoolean);
369 void mangleExpression(
const Expr *E);
385 MicrosoftMangleContextImpl::MicrosoftMangleContextImpl(
ASTContext &Context,
405 uint32_t TruncatedHash = uint32_t(xxHash64(FE->getName()));
406 AnonymousNamespaceHash = llvm::utohexstr(TruncatedHash);
409 AnonymousNamespaceHash =
"0";
413 bool MicrosoftMangleContextImpl::shouldMangleCXXName(
const NamedDecl *D) {
414 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
417 if (FD->hasAttr<OverloadableAttr>())
429 if (FD->isMSVCRTEntryPoint())
443 if (!getASTContext().getLangOpts().CPlusPlus)
447 if (VD && !isa<DecompositionDecl>(D)) {
453 const DeclContext *DC = getEffectiveDeclContext(D);
457 DC = getEffectiveParentContext(DC);
460 !isa<VarTemplateSpecializationDecl>(D) &&
469 MicrosoftMangleContextImpl::shouldMangleStringLiteral(
const StringLiteral *SL) {
473 void MicrosoftCXXNameMangler::mangle(
const NamedDecl *D, StringRef Prefix) {
484 mangleFunctionEncoding(FD, Context.shouldMangleDeclName(FD));
485 else if (
const VarDecl *VD = dyn_cast<VarDecl>(D))
486 mangleVariableEncoding(VD);
488 llvm_unreachable(
"Tried to mangle unexpected NamedDecl!");
491 void MicrosoftCXXNameMangler::mangleFunctionEncoding(
const FunctionDecl *FD,
515 mangleFunctionClass(FD);
517 mangleFunctionType(FT, FD,
false,
false);
523 void MicrosoftCXXNameMangler::mangleVariableEncoding(
const VarDecl *VD) {
554 mangleType(Ty, SR, QMM_Drop);
555 manglePointerExtQualifiers(
558 mangleQualifiers(MPT->getPointeeType().getQualifiers(),
true);
561 mangleName(MPT->getClass()->getAsCXXRecordDecl());
564 }
else if (
const ArrayType *AT = getASTContext().getAsArrayType(Ty)) {
566 mangleDecayedArrayType(AT);
567 if (AT->getElementType()->isArrayType())
572 mangleType(Ty, SR, QMM_Drop);
577 void MicrosoftCXXNameMangler::mangleMemberDataPointer(
const CXXRecordDecl *RD,
584 int64_t VBTableOffset;
587 FieldOffset = getASTContext().getFieldOffset(VD);
588 assert(FieldOffset % getASTContext().
getCharWidth() == 0 &&
589 "cannot take address of bitfield");
590 FieldOffset /= getASTContext().getCharWidth();
594 if (IM == MSInheritanceAttr::Keyword_virtual_inheritance)
595 FieldOffset -= getASTContext().getOffsetOfBaseWithVBPtr(RD).getQuantity();
604 case MSInheritanceAttr::Keyword_single_inheritance: Code =
'0';
break;
605 case MSInheritanceAttr::Keyword_multiple_inheritance: Code =
'0';
break;
606 case MSInheritanceAttr::Keyword_virtual_inheritance: Code =
'F';
break;
607 case MSInheritanceAttr::Keyword_unspecified_inheritance: Code =
'G';
break;
612 mangleNumber(FieldOffset);
617 if (MSInheritanceAttr::hasVBPtrOffsetField(IM))
619 if (MSInheritanceAttr::hasVBTableOffsetField(IM))
620 mangleNumber(VBTableOffset);
624 MicrosoftCXXNameMangler::mangleMemberFunctionPointer(
const CXXRecordDecl *RD,
635 case MSInheritanceAttr::Keyword_single_inheritance: Code =
'1';
break;
636 case MSInheritanceAttr::Keyword_multiple_inheritance: Code =
'H';
break;
637 case MSInheritanceAttr::Keyword_virtual_inheritance: Code =
'I';
break;
638 case MSInheritanceAttr::Keyword_unspecified_inheritance: Code =
'J';
break;
643 uint64_t NVOffset = 0;
644 uint64_t VBTableOffset = 0;
645 uint64_t VBPtrOffset = 0;
647 Out <<
'$' << Code <<
'?';
650 cast<MicrosoftVTableContext>(getASTContext().getVTableContext());
653 mangleVirtualMemPtrThunk(MD, ML);
654 NVOffset = ML.VFPtrOffset.getQuantity();
655 VBTableOffset = ML.VBTableIndex * 4;
657 const ASTRecordLayout &Layout = getASTContext().getASTRecordLayout(RD);
662 mangleFunctionEncoding(MD,
true);
665 if (VBTableOffset == 0 &&
666 IM == MSInheritanceAttr::Keyword_virtual_inheritance)
667 NVOffset -= getASTContext().getOffsetOfBaseWithVBPtr(RD).getQuantity();
670 if (IM == MSInheritanceAttr::Keyword_single_inheritance) {
674 if (IM == MSInheritanceAttr::Keyword_unspecified_inheritance)
679 if (MSInheritanceAttr::hasNVOffsetField(
true, IM))
680 mangleNumber(static_cast<uint32_t>(NVOffset));
681 if (MSInheritanceAttr::hasVBPtrOffsetField(IM))
682 mangleNumber(VBPtrOffset);
683 if (MSInheritanceAttr::hasVBTableOffsetField(IM))
684 mangleNumber(VBTableOffset);
687 void MicrosoftCXXNameMangler::mangleVirtualMemPtrThunk(
690 CharUnits PointerWidth = getASTContext().toCharUnitsFromBits(
691 getASTContext().getTargetInfo().getPointerWidth(0));
697 mangleNumber(OffsetInVFTable);
702 void MicrosoftCXXNameMangler::mangleName(
const NamedDecl *ND) {
706 mangleUnqualifiedName(ND);
708 mangleNestedName(ND);
714 void MicrosoftCXXNameMangler::mangleNumber(int64_t Number) {
721 uint64_t
Value =
static_cast<uint64_t
>(Number);
729 else if (Value >= 1 && Value <= 10)
735 char EncodedNumberBuffer[
sizeof(uint64_t) * 2];
738 for (; Value != 0; Value >>= 4)
739 *I++ =
'A' + (Value & 0xf);
740 Out.write(I.base(), I - BufferRef.rbegin());
748 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
757 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
758 TemplateArgs = &Spec->getTemplateArgs();
759 return Spec->getSpecializedTemplate();
764 dyn_cast<VarTemplateSpecializationDecl>(ND)) {
765 TemplateArgs = &Spec->getTemplateArgs();
766 return Spec->getSpecializedTemplate();
772 void MicrosoftCXXNameMangler::mangleUnqualifiedName(
const NamedDecl *ND,
785 if (isa<FunctionTemplateDecl>(TD)) {
786 mangleTemplateInstantiationName(TD, *TemplateArgs);
807 llvm::raw_svector_ostream Stream(TemplateMangling);
808 MicrosoftCXXNameMangler Extra(Context, Stream);
809 Extra.mangleTemplateInstantiationName(TD, *TemplateArgs);
811 mangleSourceName(TemplateMangling);
818 mangleSourceName(II->getName());
823 assert(ND &&
"mangling empty name without declaration");
826 if (NS->isAnonymousNamespace()) {
827 Out <<
"?A0x" << Context.getAnonymousNamespaceHash() <<
'@';
837 for (
auto *BD : DD->bindings()) {
840 Name += BD->getDeclName().getAsIdentifierInfo()->getName();
843 mangleSourceName(Name);
847 if (
const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
850 assert(RD &&
"expected variable decl to have a record type");
856 Name += llvm::utostr(Context.getAnonymousStructId(RD) + 1);
857 mangleSourceName(Name.str());
862 const TagDecl *TD = cast<TagDecl>(ND);
865 "Typedef should not be in another decl context!");
867 "Typedef was not named!");
872 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(TD)) {
873 if (Record->isLambda()) {
876 Decl *LambdaContextDecl = Record->getLambdaContextDecl();
877 unsigned LambdaManglingNumber = Record->getLambdaManglingNumber();
880 dyn_cast_or_null<ParmVarDecl>(LambdaContextDecl);
885 unsigned DefaultArgNo =
887 Name += llvm::utostr(DefaultArgNo);
891 if (LambdaManglingNumber)
892 LambdaId = LambdaManglingNumber;
894 LambdaId = Context.getLambdaId(Record);
896 Name += llvm::utostr(LambdaId);
899 mangleSourceName(Name);
903 if (LambdaManglingNumber && LambdaContextDecl) {
904 if ((isa<VarDecl>(LambdaContextDecl) ||
905 isa<FieldDecl>(LambdaContextDecl)) &&
907 mangleUnqualifiedName(cast<NamedDecl>(LambdaContextDecl));
919 Name +=
"<unnamed-type-";
920 Name += DD->getName();
926 Name +=
"<unnamed-type-";
927 Name += TND->getName();
928 }
else if (isa<EnumDecl>(TD) &&
929 cast<EnumDecl>(TD)->enumerator_begin() !=
930 cast<EnumDecl>(TD)->enumerator_end()) {
932 auto *ED = cast<EnumDecl>(TD);
933 Name +=
"<unnamed-enum-";
934 Name += ED->enumerator_begin()->getName();
937 Name +=
"<unnamed-type-$S";
938 Name += llvm::utostr(Context.getAnonymousStructId(TD) + 1);
941 mangleSourceName(Name.str());
945 case DeclarationName::ObjCZeroArgSelector:
946 case DeclarationName::ObjCOneArgSelector:
947 case DeclarationName::ObjCMultiArgSelector: {
952 mangleSourceName(Name.str());
956 case DeclarationName::CXXConstructorName:
957 if (isStructorDecl(ND)) {
970 case DeclarationName::CXXDestructorName:
971 if (isStructorDecl(ND))
974 mangleCXXDtorType(static_cast<CXXDtorType>(StructorType));
981 case DeclarationName::CXXConversionFunctionName:
987 case DeclarationName::CXXOperatorName:
991 case DeclarationName::CXXLiteralOperatorName: {
997 case DeclarationName::CXXDeductionGuideName:
998 llvm_unreachable(
"Can't mangle a deduction guide name!");
1000 case DeclarationName::CXXUsingDirective:
1001 llvm_unreachable(
"Can't mangle a using directive name!");
1007 void MicrosoftCXXNameMangler::mangleNestedName(
const NamedDecl *ND) {
1008 const DeclContext *DC = getEffectiveDeclContext(ND);
1010 if (isa<TagDecl>(ND) || isa<VarDecl>(ND)) {
1012 if (Context.getNextDiscriminator(ND, Disc)) {
1019 if (
const BlockDecl *BD = dyn_cast<BlockDecl>(DC)) {
1021 [](StringRef Name,
const unsigned Discriminator,
1022 const unsigned ParameterDiscriminator) -> std::string {
1024 llvm::raw_string_ostream Stream(Buffer);
1027 Stream <<
'_' << Discriminator;
1028 if (ParameterDiscriminator)
1029 Stream <<
'_' << ParameterDiscriminator;
1030 return Stream.str();
1033 unsigned Discriminator = BD->getBlockManglingNumber();
1035 Discriminator = Context.getBlockId(BD,
false);
1040 unsigned ParameterDiscriminator = 0;
1041 if (
const auto *MC = BD->getBlockManglingContextDecl())
1042 if (
const auto *
P = dyn_cast<ParmVarDecl>(MC))
1043 if (
const auto *F = dyn_cast<FunctionDecl>(
P->getDeclContext()))
1044 ParameterDiscriminator =
1045 F->getNumParams() -
P->getFunctionScopeIndex();
1047 DC = getEffectiveDeclContext(BD);
1050 mangleSourceName(Discriminate(
"_block_invoke", Discriminator,
1051 ParameterDiscriminator));
1056 if (
const auto *MC = BD->getBlockManglingContextDecl())
1057 if (!isa<ParmVarDecl>(MC))
1058 if (
const auto *ND = dyn_cast<NamedDecl>(MC))
1059 mangleUnqualifiedName(ND);
1063 if (
const auto *RD = dyn_cast<RecordDecl>(DC))
1072 if (PointersAre64Bit)
1076 Discriminate(
"__block_literal", Discriminator,
1077 ParameterDiscriminator));
1082 if (isa<RecordDecl>(DC))
1085 }
else if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(DC)) {
1086 mangleObjCMethodName(Method);
1087 }
else if (isa<NamedDecl>(DC)) {
1088 ND = cast<NamedDecl>(DC);
1089 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
1093 mangleUnqualifiedName(ND);
1096 if (
const auto *LDADC = getLambdaDefaultArgumentDeclContext(ND)) {
1106 void MicrosoftCXXNameMangler::mangleCXXDtorType(
CXXDtorType T) {
1121 llvm_unreachable(
"not expecting a COMDAT");
1123 llvm_unreachable(
"Unsupported dtor type?");
1132 case OO_New: Out <<
"?2";
break;
1134 case OO_Delete: Out <<
"?3";
break;
1136 case OO_Equal: Out <<
"?4";
break;
1138 case OO_GreaterGreater: Out <<
"?5";
break;
1140 case OO_LessLess: Out <<
"?6";
break;
1142 case OO_Exclaim: Out <<
"?7";
break;
1144 case OO_EqualEqual: Out <<
"?8";
break;
1146 case OO_ExclaimEqual: Out <<
"?9";
break;
1148 case OO_Subscript: Out <<
"?A";
break;
1151 case OO_Arrow: Out <<
"?C";
break;
1153 case OO_Star: Out <<
"?D";
break;
1155 case OO_PlusPlus: Out <<
"?E";
break;
1157 case OO_MinusMinus: Out <<
"?F";
break;
1159 case OO_Minus: Out <<
"?G";
break;
1161 case OO_Plus: Out <<
"?H";
break;
1163 case OO_Amp: Out <<
"?I";
break;
1165 case OO_ArrowStar: Out <<
"?J";
break;
1167 case OO_Slash: Out <<
"?K";
break;
1169 case OO_Percent: Out <<
"?L";
break;
1171 case OO_Less: Out <<
"?M";
break;
1173 case OO_LessEqual: Out <<
"?N";
break;
1175 case OO_Greater: Out <<
"?O";
break;
1177 case OO_GreaterEqual: Out <<
"?P";
break;
1179 case OO_Comma: Out <<
"?Q";
break;
1181 case OO_Call: Out <<
"?R";
break;
1183 case OO_Tilde: Out <<
"?S";
break;
1185 case OO_Caret: Out <<
"?T";
break;
1187 case OO_Pipe: Out <<
"?U";
break;
1189 case OO_AmpAmp: Out <<
"?V";
break;
1191 case OO_PipePipe: Out <<
"?W";
break;
1193 case OO_StarEqual: Out <<
"?X";
break;
1195 case OO_PlusEqual: Out <<
"?Y";
break;
1197 case OO_MinusEqual: Out <<
"?Z";
break;
1199 case OO_SlashEqual: Out <<
"?_0";
break;
1201 case OO_PercentEqual: Out <<
"?_1";
break;
1203 case OO_GreaterGreaterEqual: Out <<
"?_2";
break;
1205 case OO_LessLessEqual: Out <<
"?_3";
break;
1207 case OO_AmpEqual: Out <<
"?_4";
break;
1209 case OO_PipeEqual: Out <<
"?_5";
break;
1211 case OO_CaretEqual: Out <<
"?_6";
break;
1240 case OO_Array_New: Out <<
"?_U";
break;
1242 case OO_Array_Delete: Out <<
"?_V";
break;
1244 case OO_Coawait: Out <<
"?__L";
break;
1246 case OO_Spaceship: {
1250 "cannot mangle this three-way comparison operator yet");
1251 Diags.
Report(Loc, DiagID);
1255 case OO_Conditional: {
1258 "cannot mangle this conditional operator yet");
1259 Diags.
Report(Loc, DiagID);
1265 llvm_unreachable(
"Not an overloaded operator");
1269 void MicrosoftCXXNameMangler::mangleSourceName(StringRef Name) {
1271 BackRefVec::iterator Found =
1272 std::find(NameBackReferences.begin(), NameBackReferences.end(), Name);
1273 if (Found == NameBackReferences.end()) {
1274 if (NameBackReferences.size() < 10)
1275 NameBackReferences.push_back(Name);
1278 Out << (Found - NameBackReferences.begin());
1282 void MicrosoftCXXNameMangler::mangleObjCMethodName(
const ObjCMethodDecl *MD) {
1283 Context.mangleObjCMethodName(MD, Out);
1286 void MicrosoftCXXNameMangler::mangleTemplateInstantiationName(
1293 ArgBackRefMap OuterArgsContext;
1294 BackRefVec OuterTemplateContext;
1295 PassObjectSizeArgsSet OuterPassObjectSizeArgs;
1296 NameBackReferences.swap(OuterTemplateContext);
1297 TypeBackReferences.swap(OuterArgsContext);
1298 PassObjectSizeArgs.swap(OuterPassObjectSizeArgs);
1300 mangleUnscopedTemplateName(TD);
1301 mangleTemplateArgs(TD, TemplateArgs);
1304 NameBackReferences.swap(OuterTemplateContext);
1305 TypeBackReferences.swap(OuterArgsContext);
1306 PassObjectSizeArgs.swap(OuterPassObjectSizeArgs);
1310 MicrosoftCXXNameMangler::mangleUnscopedTemplateName(
const TemplateDecl *TD) {
1313 mangleUnqualifiedName(TD);
1316 void MicrosoftCXXNameMangler::mangleIntegerLiteral(
const llvm::APSInt &Value,
1321 if (IsBoolean && Value.getBoolValue())
1323 else if (Value.isSigned())
1324 mangleNumber(Value.getSExtValue());
1326 mangleNumber(Value.getZExtValue());
1329 void MicrosoftCXXNameMangler::mangleExpression(
const Expr *E) {
1342 if (UO->getOpcode() == UO_AddrOf)
1343 UE = dyn_cast<CXXUuidofExpr>(UO->getSubExpr());
1361 std::string Name =
"_GUID_" + Uuid.lower();
1362 std::replace(Name.begin(), Name.end(),
'-',
'_');
1364 mangleSourceName(Name);
1370 mangleArtificialTagType(
TTK_Struct,
"__s_GUID");
1384 void MicrosoftCXXNameMangler::mangleTemplateArgs(
1388 assert(TPL->
size() == TemplateArgs.
size() &&
1389 "size mismatch between args and parms!");
1391 for (
size_t i = 0; i < TemplateArgs.
size(); ++i) {
1395 if (i > 0 && TA.
getKind() == TemplateArgument::Pack &&
1396 TemplateArgs[i - 1].getKind() == TemplateArgument::Pack)
1399 mangleTemplateArg(TD, TA, TPL->
getParam(i));
1403 void MicrosoftCXXNameMangler::mangleTemplateArg(
const TemplateDecl *TD,
1416 case TemplateArgument::Null:
1417 llvm_unreachable(
"Can't mangle null template arguments!");
1418 case TemplateArgument::TemplateExpansion:
1419 llvm_unreachable(
"Can't mangle template expansion arguments!");
1425 case TemplateArgument::Declaration: {
1427 if (isa<FieldDecl>(ND) || isa<IndirectFieldDecl>(ND)) {
1428 mangleMemberDataPointer(cast<CXXRecordDecl>(ND->
getDeclContext())
1429 ->getMostRecentNonInjectedDecl(),
1430 cast<ValueDecl>(ND));
1431 }
else if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
1434 mangleMemberFunctionPointer(
1439 mangleFunctionEncoding(FD,
true);
1446 case TemplateArgument::Integral:
1450 case TemplateArgument::NullPtr: {
1453 const CXXRecordDecl *RD = MPT->getMostRecentCXXRecordDecl();
1454 if (MPT->isMemberFunctionPointerType() &&
1455 !isa<FunctionTemplateDecl>(TD)) {
1456 mangleMemberFunctionPointer(RD,
nullptr);
1459 if (MPT->isMemberDataPointer()) {
1460 if (!isa<FunctionTemplateDecl>(TD)) {
1461 mangleMemberDataPointer(RD,
nullptr);
1471 mangleIntegerLiteral(llvm::APSInt::get(-1),
false);
1476 mangleIntegerLiteral(llvm::APSInt::getUnsigned(0),
false);
1479 case TemplateArgument::Expression:
1482 case TemplateArgument::Pack: {
1484 if (TemplateArgs.empty()) {
1485 if (isa<TemplateTypeParmDecl>(Parm) ||
1486 isa<TemplateTemplateParmDecl>(Parm))
1490 LangOptions::MSVC2015)
1493 else if (isa<NonTypeTemplateParmDecl>(Parm))
1496 llvm_unreachable(
"unexpected template parameter decl!");
1499 mangleTemplateArg(TD, PA, Parm);
1503 case TemplateArgument::Template: {
1506 if (
const auto *TD = dyn_cast<TagDecl>(ND)) {
1508 }
else if (isa<TypeAliasDecl>(ND)) {
1512 llvm_unreachable(
"unexpected template template NamedDecl!");
1519 void MicrosoftCXXNameMangler::mangleObjCProtocol(
const ObjCProtocolDecl *PD) {
1521 llvm::raw_svector_ostream Stream(TemplateMangling);
1522 MicrosoftCXXNameMangler Extra(Context, Stream);
1525 Extra.mangleSourceName(
"Protocol");
1528 mangleArtificialTagType(
TTK_Struct, TemplateMangling, {
"__ObjC"});
1531 void MicrosoftCXXNameMangler::mangleObjCLifetime(
const QualType Type,
1535 llvm::raw_svector_ostream Stream(TemplateMangling);
1536 MicrosoftCXXNameMangler Extra(Context, Stream);
1540 case Qualifiers::OCL_None:
1541 case Qualifiers::OCL_ExplicitNone:
1543 case Qualifiers::OCL_Autoreleasing:
1544 Extra.mangleSourceName(
"Autoreleasing");
1546 case Qualifiers::OCL_Strong:
1547 Extra.mangleSourceName(
"Strong");
1549 case Qualifiers::OCL_Weak:
1550 Extra.mangleSourceName(
"Weak");
1553 Extra.manglePointerCVQualifiers(Quals);
1554 Extra.manglePointerExtQualifiers(Quals, Type);
1555 Extra.mangleType(Type, Range);
1557 mangleArtificialTagType(
TTK_Struct, TemplateMangling, {
"__ObjC"});
1560 void MicrosoftCXXNameMangler::mangleObjCKindOfType(
const ObjCObjectType *T,
1564 llvm::raw_svector_ostream Stream(TemplateMangling);
1565 MicrosoftCXXNameMangler Extra(Context, Stream);
1568 Extra.mangleSourceName(
"KindOf");
1570 .stripObjCKindOfType(getASTContext())
1571 ->getAs<ObjCObjectType>(),
1574 mangleArtificialTagType(
TTK_Struct, TemplateMangling, {
"__ObjC"});
1577 void MicrosoftCXXNameMangler::mangleQualifiers(
Qualifiers Quals,
1635 if (HasConst && HasVolatile) {
1637 }
else if (HasVolatile) {
1639 }
else if (HasConst) {
1645 if (HasConst && HasVolatile) {
1647 }
else if (HasVolatile) {
1649 }
else if (HasConst) {
1660 MicrosoftCXXNameMangler::mangleRefQualifier(
RefQualifierKind RefQualifier) {
1663 switch (RefQualifier) {
1677 void MicrosoftCXXNameMangler::manglePointerExtQualifiers(
Qualifiers Quals,
1679 if (PointersAre64Bit &&
1691 void MicrosoftCXXNameMangler::manglePointerCVQualifiers(
Qualifiers Quals) {
1699 if (HasConst && HasVolatile) {
1701 }
else if (HasVolatile) {
1703 }
else if (HasConst) {
1710 void MicrosoftCXXNameMangler::mangleArgumentType(
QualType T,
1721 QualType OriginalType = DT->getOriginalType();
1724 if (
const auto *AT = getASTContext().getAsArrayType(OriginalType))
1725 OriginalType = getASTContext().getIncompleteArrayType(
1726 AT->getElementType(), AT->getSizeModifier(),
1727 AT->getIndexTypeCVRQualifiers());
1741 ArgBackRefMap::iterator Found = TypeBackReferences.find(TypePtr);
1743 if (Found == TypeBackReferences.end()) {
1744 size_t OutSizeBefore = Out.tell();
1746 mangleType(T, Range, QMM_Drop);
1751 bool LongerThanOneChar = (Out.tell() - OutSizeBefore > 1);
1752 if (LongerThanOneChar && TypeBackReferences.size() < 10) {
1753 size_t Size = TypeBackReferences.size();
1754 TypeBackReferences[TypePtr] = Size;
1757 Out << Found->second;
1761 void MicrosoftCXXNameMangler::manglePassObjectSizeArg(
1762 const PassObjectSizeAttr *POSA) {
1763 int Type = POSA->getType();
1765 auto Iter = PassObjectSizeArgs.insert(Type).first;
1766 auto *TypePtr = (
const void *)&*Iter;
1767 ArgBackRefMap::iterator Found = TypeBackReferences.find(TypePtr);
1769 if (Found == TypeBackReferences.end()) {
1770 mangleArtificialTagType(
TTK_Enum,
"__pass_object_size" + llvm::utostr(Type),
1773 if (TypeBackReferences.size() < 10) {
1774 size_t Size = TypeBackReferences.size();
1775 TypeBackReferences[TypePtr] = Size;
1778 Out << Found->second;
1782 void MicrosoftCXXNameMangler::mangleAddressSpaceType(
QualType T,
1800 llvm::raw_svector_ostream Stream(ASMangling);
1801 MicrosoftCXXNameMangler Extra(Context, Stream);
1807 Extra.mangleSourceName(
"_AS");
1808 Extra.mangleIntegerLiteral(llvm::APSInt::getUnsigned(TargetAS),
1813 llvm_unreachable(
"Not a language specific address space");
1814 case LangAS::opencl_global:
1815 Extra.mangleSourceName(
"_ASCLglobal");
1817 case LangAS::opencl_local:
1818 Extra.mangleSourceName(
"_ASCLlocal");
1820 case LangAS::opencl_constant:
1821 Extra.mangleSourceName(
"_ASCLconstant");
1823 case LangAS::opencl_private:
1824 Extra.mangleSourceName(
"_ASCLprivate");
1826 case LangAS::opencl_generic:
1827 Extra.mangleSourceName(
"_ASCLgeneric");
1829 case LangAS::cuda_device:
1830 Extra.mangleSourceName(
"_ASCUdevice");
1832 case LangAS::cuda_constant:
1833 Extra.mangleSourceName(
"_ASCUconstant");
1835 case LangAS::cuda_shared:
1836 Extra.mangleSourceName(
"_ASCUshared");
1841 Extra.mangleType(T, Range, QMM_Escape);
1843 mangleArtificialTagType(
TTK_Struct, ASMangling, {
"__clang"});
1847 QualifierMangleMode QMM) {
1853 if (
const ArrayType *AT = getASTContext().getAsArrayType(T)) {
1856 if (QMM == QMM_Mangle)
1858 else if (QMM == QMM_Escape || QMM == QMM_Result)
1860 mangleArrayType(AT);
1873 if (
const FunctionType *FT = dyn_cast<FunctionType>(T)) {
1875 mangleFunctionType(FT);
1878 mangleQualifiers(Quals,
false);
1881 if (!IsPointer && Quals) {
1883 mangleQualifiers(Quals,
false);
1891 if ((!IsPointer && Quals) || isa<TagType>(T) || isArtificialTagType(T)) {
1893 mangleQualifiers(Quals,
false);
1901 #define ABSTRACT_TYPE(CLASS, PARENT) 1902 #define NON_CANONICAL_TYPE(CLASS, PARENT) \ 1904 llvm_unreachable("can't mangle non-canonical type " #CLASS "Type"); \ 1906 #define TYPE(CLASS, PARENT) \ 1908 mangleType(cast<CLASS##Type>(ty), Quals, Range); \ 1910 #include "clang/AST/TypeNodes.def" 1911 #undef ABSTRACT_TYPE 1912 #undef NON_CANONICAL_TYPE 1946 case BuiltinType::Void:
1949 case BuiltinType::SChar:
1952 case BuiltinType::Char_U:
1953 case BuiltinType::Char_S:
1956 case BuiltinType::UChar:
1959 case BuiltinType::Short:
1962 case BuiltinType::UShort:
1965 case BuiltinType::Int:
1968 case BuiltinType::UInt:
1971 case BuiltinType::Long:
1974 case BuiltinType::ULong:
1977 case BuiltinType::Float:
1980 case BuiltinType::Double:
1984 case BuiltinType::LongDouble:
1987 case BuiltinType::LongLong:
1990 case BuiltinType::ULongLong:
1993 case BuiltinType::Int128:
1996 case BuiltinType::UInt128:
1999 case BuiltinType::Bool:
2002 case BuiltinType::Char16:
2005 case BuiltinType::Char32:
2008 case BuiltinType::WChar_S:
2009 case BuiltinType::WChar_U:
2013 #define BUILTIN_TYPE(Id, SingletonId) 2014 #define PLACEHOLDER_TYPE(Id, SingletonId) \ 2015 case BuiltinType::Id: 2016 #include "clang/AST/BuiltinTypes.def" 2017 case BuiltinType::Dependent:
2018 llvm_unreachable(
"placeholder types shouldn't get to name mangling");
2020 case BuiltinType::ObjCId:
2021 mangleArtificialTagType(
TTK_Struct,
"objc_object");
2023 case BuiltinType::ObjCClass:
2024 mangleArtificialTagType(
TTK_Struct,
"objc_class");
2026 case BuiltinType::ObjCSel:
2027 mangleArtificialTagType(
TTK_Struct,
"objc_selector");
2030 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 2031 case BuiltinType::Id: \ 2032 Out << "PAUocl_" #ImgType "_" #Suffix "@@"; \ 2034 #include "clang/Basic/OpenCLImageTypes.def" 2035 case BuiltinType::OCLSampler:
2037 mangleArtificialTagType(
TTK_Struct,
"ocl_sampler");
2039 case BuiltinType::OCLEvent:
2041 mangleArtificialTagType(
TTK_Struct,
"ocl_event");
2043 case BuiltinType::OCLClkEvent:
2045 mangleArtificialTagType(
TTK_Struct,
"ocl_clkevent");
2047 case BuiltinType::OCLQueue:
2049 mangleArtificialTagType(
TTK_Struct,
"ocl_queue");
2051 case BuiltinType::OCLReserveID:
2053 mangleArtificialTagType(
TTK_Struct,
"ocl_reserveid");
2055 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 2056 case BuiltinType::Id: \ 2057 mangleArtificialTagType(TTK_Struct, "ocl_" #ExtType); \ 2059 #include "clang/Basic/OpenCLExtensionTypes.def" 2061 case BuiltinType::NullPtr:
2065 case BuiltinType::Float16:
2066 mangleArtificialTagType(
TTK_Struct,
"_Float16", {
"__clang"});
2069 case BuiltinType::Half:
2070 mangleArtificialTagType(
TTK_Struct,
"_Half", {
"__clang"});
2073 case BuiltinType::ShortAccum:
2074 case BuiltinType::Accum:
2075 case BuiltinType::LongAccum:
2076 case BuiltinType::UShortAccum:
2077 case BuiltinType::UAccum:
2078 case BuiltinType::ULongAccum:
2079 case BuiltinType::ShortFract:
2080 case BuiltinType::Fract:
2081 case BuiltinType::LongFract:
2082 case BuiltinType::UShortFract:
2083 case BuiltinType::UFract:
2084 case BuiltinType::ULongFract:
2085 case BuiltinType::SatShortAccum:
2086 case BuiltinType::SatAccum:
2087 case BuiltinType::SatLongAccum:
2088 case BuiltinType::SatUShortAccum:
2089 case BuiltinType::SatUAccum:
2090 case BuiltinType::SatULongAccum:
2091 case BuiltinType::SatShortFract:
2092 case BuiltinType::SatFract:
2093 case BuiltinType::SatLongFract:
2094 case BuiltinType::SatUShortFract:
2095 case BuiltinType::SatUFract:
2096 case BuiltinType::SatULongFract:
2097 case BuiltinType::Char8:
2098 case BuiltinType::Float128: {
2117 mangleFunctionType(T,
nullptr,
true);
2120 mangleFunctionType(T);
2126 mangleFunctionType(T);
2129 void MicrosoftCXXNameMangler::mangleFunctionType(
const FunctionType *T,
2131 bool ForceThisQuals,
2132 bool MangleExceptionSpec) {
2140 bool IsInLambda =
false;
2141 bool IsStructor =
false, HasThisQuals = ForceThisQuals, IsCtorClosure =
false;
2143 if (
const CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl>(D)) {
2146 if (MD->isInstance())
2147 HasThisQuals =
true;
2148 if (isa<CXXDestructorDecl>(MD)) {
2150 }
else if (isa<CXXConstructorDecl>(MD)) {
2156 CC = getASTContext().getDefaultCallingConvention(
2165 manglePointerExtQualifiers(Quals,
QualType());
2167 mangleQualifiers(Quals,
false);
2170 mangleCallingConvention(CC);
2175 if (isa<CXXDestructorDecl>(D) && isStructorDecl(D)) {
2179 Out << (PointersAre64Bit ?
"PEAXI@Z" :
"PAXI@Z");
2188 if (IsCtorClosure) {
2198 mangleArgumentType(getASTContext().getLValueReferenceType(
2206 llvm_unreachable(
"unexpected constructor closure!");
2214 if (
const auto *AT =
2219 assert(AT->getKeyword() != AutoTypeKeyword::GNUAutoType &&
2220 "shouldn't need to mangle __auto_type!");
2221 mangleSourceName(AT->isDecltypeAuto() ?
"<decltype-auto>" :
"<auto>");
2223 }
else if (IsInLambda) {
2228 mangleType(ResultType, Range, QMM_Result);
2244 for (
unsigned I = 0, E = Proto->
getNumParams(); I != E; ++I) {
2256 manglePassObjectSizeArg(
P);
2265 if (MangleExceptionSpec && getASTContext().getLangOpts().CPlusPlus17 &&
2266 getASTContext().getLangOpts().isCompatibleWithMSVC(
2267 LangOptions::MSVC2017_5))
2268 mangleThrowSpecification(Proto);
2273 void MicrosoftCXXNameMangler::mangleFunctionClass(
const FunctionDecl *FD) {
2298 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
2299 bool IsVirtual = MD->isVirtual();
2302 if (isa<CXXDestructorDecl>(MD) && isStructorDecl(MD) &&
2308 llvm_unreachable(
"Unsupported access specifier");
2337 void MicrosoftCXXNameMangler::mangleCallingConvention(
CallingConv CC) {
2358 llvm_unreachable(
"Unsupported CC for mangling");
2361 case CC_C: Out <<
'A';
break;
2372 void MicrosoftCXXNameMangler::mangleCallingConvention(
const FunctionType *T) {
2376 void MicrosoftCXXNameMangler::mangleThrowSpecification(
2392 "cannot mangle this unresolved dependent type yet");
2402 void MicrosoftCXXNameMangler::mangleTagTypeKind(
TagTypeKind TTK) {
2421 mangleType(cast<TagType>(T)->getDecl());
2425 mangleType(cast<TagType>(T)->getDecl());
2427 void MicrosoftCXXNameMangler::mangleType(
const TagDecl *TD) {
2433 void MicrosoftCXXNameMangler::mangleArtificialTagType(
2437 mangleTagTypeKind(TK);
2440 mangleSourceName(UnqualifiedName);
2442 for (
auto I = NestedNames.rbegin(), E = NestedNames.rend(); I != E; ++I)
2443 mangleSourceName(*I);
2456 void MicrosoftCXXNameMangler::mangleDecayedArrayType(
const ArrayType *T) {
2464 llvm_unreachable(
"Should have been special cased");
2468 llvm_unreachable(
"Should have been special cased");
2472 llvm_unreachable(
"Should have been special cased");
2476 llvm_unreachable(
"Should have been special cased");
2478 void MicrosoftCXXNameMangler::mangleArrayType(
const ArrayType *T) {
2484 getASTContext().getAsConstantArrayType(ElementTy);
2485 Dimensions.push_back(CAT->
getSize());
2489 getASTContext().getAsIncompleteArrayType(ElementTy);
2490 Dimensions.push_back(llvm::APInt(32, 0));
2494 getASTContext().getAsVariableArrayType(ElementTy);
2495 Dimensions.push_back(llvm::APInt(32, 0));
2500 getASTContext().getAsDependentSizedArrayType(ElementTy);
2503 "cannot mangle this dependent-length array yet");
2513 mangleNumber(Dimensions.size());
2514 for (
const llvm::APInt &Dimension : Dimensions)
2515 mangleNumber(Dimension.getLimitedValue());
2525 manglePointerCVQualifiers(Quals);
2526 manglePointerExtQualifiers(Quals, PointeeType);
2530 mangleFunctionType(FPT,
nullptr,
true);
2534 mangleType(PointeeType, Range, QMM_Drop);
2542 "cannot mangle this template type parameter type yet");
2551 "cannot mangle this substituted parameter pack yet");
2562 manglePointerCVQualifiers(Quals);
2563 manglePointerExtQualifiers(Quals, PointeeType);
2566 mangleAddressSpaceType(PointeeType, PointeeType.
getQualifiers(), Range);
2568 mangleType(PointeeType, Range);
2575 case Qualifiers::OCL_None:
2576 case Qualifiers::OCL_ExplicitNone:
2578 case Qualifiers::OCL_Autoreleasing:
2579 case Qualifiers::OCL_Strong:
2580 case Qualifiers::OCL_Weak:
2581 return mangleObjCLifetime(PointeeType, Quals, Range);
2583 manglePointerCVQualifiers(Quals);
2584 manglePointerExtQualifiers(Quals, PointeeType);
2585 mangleType(PointeeType, Range);
2596 manglePointerExtQualifiers(Quals, PointeeType);
2597 mangleType(PointeeType, Range);
2608 manglePointerExtQualifiers(Quals, PointeeType);
2609 mangleType(PointeeType, Range);
2617 llvm::raw_svector_ostream Stream(TemplateMangling);
2618 MicrosoftCXXNameMangler Extra(Context, Stream);
2620 Extra.mangleSourceName(
"_Complex");
2621 Extra.mangleType(ElementType, Range, QMM_Escape);
2623 mangleArtificialTagType(
TTK_Struct, TemplateMangling, {
"__clang"});
2631 bool MicrosoftCXXNameMangler::isArtificialTagType(
QualType T)
const {
2637 case Type::Vector: {
2649 assert(ET &&
"vectors with non-builtin elements are unsupported");
2650 uint64_t Width = getASTContext().getTypeSize(T);
2653 size_t OutSizeBefore = Out.tell();
2654 if (!isa<ExtVectorType>(T)) {
2655 llvm::Triple::ArchType AT =
2656 getASTContext().getTargetInfo().getTriple().getArch();
2657 if (AT == llvm::Triple::x86 || AT == llvm::Triple::x86_64) {
2658 if (Width == 64 && ET->
getKind() == BuiltinType::LongLong) {
2659 mangleArtificialTagType(
TTK_Union,
"__m64");
2660 }
else if (Width >= 128) {
2661 if (ET->
getKind() == BuiltinType::Float)
2662 mangleArtificialTagType(
TTK_Union,
"__m" + llvm::utostr(Width));
2663 else if (ET->
getKind() == BuiltinType::LongLong)
2664 mangleArtificialTagType(
TTK_Union,
"__m" + llvm::utostr(Width) +
'i');
2665 else if (ET->
getKind() == BuiltinType::Double)
2666 mangleArtificialTagType(
TTK_Struct,
"__m" + llvm::utostr(Width) +
'd');
2671 bool IsBuiltin = Out.tell() != OutSizeBefore;
2678 llvm::raw_svector_ostream Stream(TemplateMangling);
2679 MicrosoftCXXNameMangler Extra(Context, Stream);
2681 Extra.mangleSourceName(
"__vector");
2682 Extra.mangleType(
QualType(ET, 0), Range, QMM_Escape);
2683 Extra.mangleIntegerLiteral(llvm::APSInt::getUnsigned(T->
getNumElements()),
2686 mangleArtificialTagType(
TTK_Union, TemplateMangling, {
"__clang"});
2690 void MicrosoftCXXNameMangler::mangleType(
const ExtVectorType *T,
2692 mangleType(static_cast<const VectorType *>(T), Quals, Range);
2700 "cannot mangle this dependent-sized vector type yet");
2708 "cannot mangle this dependent-sized extended vector type yet");
2718 "cannot mangle this dependent address space type yet");
2729 void MicrosoftCXXNameMangler::mangleType(
const ObjCObjectType *T,
2732 return mangleObjCKindOfType(T, Quals, Range);
2735 return mangleType(T->
getBaseType(), Range, QMM_Drop);
2737 ArgBackRefMap OuterArgsContext;
2738 BackRefVec OuterTemplateContext;
2740 TypeBackReferences.swap(OuterArgsContext);
2741 NameBackReferences.swap(OuterTemplateContext);
2747 mangleSourceName(
"objc_object");
2749 mangleSourceName(
"objc_class");
2753 for (
const auto &Q : T->
quals())
2754 mangleObjCProtocol(Q);
2758 mangleType(TA, Range, QMM_Drop);
2764 TypeBackReferences.swap(OuterArgsContext);
2765 NameBackReferences.swap(OuterTemplateContext);
2771 manglePointerCVQualifiers(Quals);
2772 manglePointerExtQualifiers(Quals, PointeeType);
2781 llvm_unreachable(
"Cannot mangle injected class name type.");
2788 "cannot mangle this template specialization type yet");
2797 "cannot mangle this dependent name type yet");
2802 void MicrosoftCXXNameMangler::mangleType(
2807 "cannot mangle this dependent template specialization type yet");
2816 "cannot mangle this pack expansion yet");
2825 "cannot mangle this typeof(type) yet");
2834 "cannot mangle this typeof(expression) yet");
2843 "cannot mangle this decltype() yet");
2852 "cannot mangle this unary transform type yet");
2863 "cannot mangle this 'auto' type yet");
2864 Diags.Report(Range.
getBegin(), DiagID)
2868 void MicrosoftCXXNameMangler::mangleType(
2874 "cannot mangle this deduced class template specialization type yet");
2875 Diags.Report(Range.
getBegin(), DiagID)
2884 llvm::raw_svector_ostream Stream(TemplateMangling);
2885 MicrosoftCXXNameMangler Extra(Context, Stream);
2887 Extra.mangleSourceName(
"_Atomic");
2888 Extra.mangleType(ValueType, Range, QMM_Escape);
2890 mangleArtificialTagType(
TTK_Struct, TemplateMangling, {
"__clang"});
2897 "cannot mangle this OpenCL pipe type yet");
2902 void MicrosoftMangleContextImpl::mangleCXXName(
const NamedDecl *D,
2904 assert((isa<FunctionDecl>(D) || isa<VarDecl>(D)) &&
2905 "Invalid mangleName() call, argument is not a variable or function!");
2906 assert(!isa<CXXConstructorDecl>(D) && !isa<CXXDestructorDecl>(D) &&
2907 "Invalid mangleName() call on 'structor decl!");
2910 getASTContext().getSourceManager(),
2911 "Mangling declaration");
2913 msvc_hashing_ostream MHO(Out);
2914 MicrosoftCXXNameMangler Mangler(*
this, MHO);
2915 return Mangler.mangle(D);
2944 MicrosoftCXXNameMangler &Mangler,
2951 llvm_unreachable(
"Unsupported access specifier");
2962 Out <<
'R' << AccessSpec;
2963 Mangler.mangleNumber(
2965 Mangler.mangleNumber(
2967 Mangler.mangleNumber(
2969 Mangler.mangleNumber(static_cast<uint32_t>(Adjustment.
NonVirtual));
2972 Mangler.mangleNumber(
2974 Mangler.mangleNumber(-static_cast<uint32_t>(Adjustment.
NonVirtual));
2979 llvm_unreachable(
"Unsupported access specifier");
2989 Mangler.mangleNumber(-static_cast<uint32_t>(Adjustment.
NonVirtual));
2993 llvm_unreachable(
"Unsupported access specifier");
3006 void MicrosoftMangleContextImpl::mangleVirtualMemPtrThunk(
3009 msvc_hashing_ostream MHO(Out);
3010 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3011 Mangler.getStream() <<
'?';
3012 Mangler.mangleVirtualMemPtrThunk(MD, ML);
3015 void MicrosoftMangleContextImpl::mangleThunk(
const CXXMethodDecl *MD,
3018 msvc_hashing_ostream MHO(Out);
3019 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3020 Mangler.getStream() <<
'?';
3021 Mangler.mangleName(MD);
3030 assert(Thunk.
Method !=
nullptr &&
3031 "Thunk info should hold the overridee decl");
3034 Mangler.mangleFunctionType(
3038 void MicrosoftMangleContextImpl::mangleCXXDtorThunk(
3045 msvc_hashing_ostream MHO(Out);
3046 MicrosoftCXXNameMangler Mangler(*
this, MHO, DD, Type);
3047 Mangler.getStream() <<
"??_E";
3053 void MicrosoftMangleContextImpl::mangleCXXVFTable(
3060 msvc_hashing_ostream MHO(Out);
3061 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3062 if (Derived->
hasAttr<DLLImportAttr>())
3063 Mangler.getStream() <<
"??_S";
3065 Mangler.getStream() <<
"??_7";
3066 Mangler.mangleName(Derived);
3067 Mangler.getStream() <<
"6B";
3069 Mangler.mangleName(RD);
3070 Mangler.getStream() <<
'@';
3073 void MicrosoftMangleContextImpl::mangleCXXVBTable(
3080 msvc_hashing_ostream MHO(Out);
3081 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3082 Mangler.getStream() <<
"??_8";
3083 Mangler.mangleName(Derived);
3084 Mangler.getStream() <<
"7B";
3086 Mangler.mangleName(RD);
3087 Mangler.getStream() <<
'@';
3090 void MicrosoftMangleContextImpl::mangleCXXRTTI(
QualType T, raw_ostream &Out) {
3091 msvc_hashing_ostream MHO(Out);
3092 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3093 Mangler.getStream() <<
"??_R0";
3094 Mangler.mangleType(T,
SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
3095 Mangler.getStream() <<
"@8";
3098 void MicrosoftMangleContextImpl::mangleCXXRTTIName(
QualType T,
3100 MicrosoftCXXNameMangler Mangler(*
this, Out);
3101 Mangler.getStream() <<
'.';
3102 Mangler.mangleType(T,
SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
3105 void MicrosoftMangleContextImpl::mangleCXXVirtualDisplacementMap(
3107 msvc_hashing_ostream MHO(Out);
3108 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3109 Mangler.getStream() <<
"??_K";
3110 Mangler.mangleName(SrcRD);
3111 Mangler.getStream() <<
"$C";
3112 Mangler.mangleName(DstRD);
3115 void MicrosoftMangleContextImpl::mangleCXXThrowInfo(
QualType T,
bool IsConst,
3118 uint32_t NumEntries,
3120 msvc_hashing_ostream MHO(Out);
3121 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3122 Mangler.getStream() <<
"_TI";
3124 Mangler.getStream() <<
'C';
3126 Mangler.getStream() <<
'V';
3128 Mangler.getStream() <<
'U';
3129 Mangler.getStream() << NumEntries;
3130 Mangler.mangleType(T,
SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
3133 void MicrosoftMangleContextImpl::mangleCXXCatchableTypeArray(
3134 QualType T, uint32_t NumEntries, raw_ostream &Out) {
3135 msvc_hashing_ostream MHO(Out);
3136 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3137 Mangler.getStream() <<
"_CTA";
3138 Mangler.getStream() << NumEntries;
3139 Mangler.mangleType(T,
SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
3142 void MicrosoftMangleContextImpl::mangleCXXCatchableType(
3144 uint32_t NVOffset, int32_t VBPtrOffset, uint32_t VBIndex,
3146 MicrosoftCXXNameMangler Mangler(*
this, Out);
3147 Mangler.getStream() <<
"_CT";
3151 llvm::raw_svector_ostream Stream(RTTIMangling);
3152 msvc_hashing_ostream MHO(Stream);
3153 mangleCXXRTTI(T, MHO);
3155 Mangler.getStream() << RTTIMangling;
3160 if (!getASTContext().getLangOpts().isCompatibleWithMSVC(
3161 LangOptions::MSVC2015) &&
3163 llvm::raw_svector_ostream Stream(CopyCtorMangling);
3164 msvc_hashing_ostream MHO(Stream);
3165 mangleCXXCtor(CD, CT, MHO);
3167 Mangler.getStream() << CopyCtorMangling;
3169 Mangler.getStream() << Size;
3170 if (VBPtrOffset == -1) {
3172 Mangler.getStream() << NVOffset;
3175 Mangler.getStream() << NVOffset;
3176 Mangler.getStream() << VBPtrOffset;
3177 Mangler.getStream() << VBIndex;
3181 void MicrosoftMangleContextImpl::mangleCXXRTTIBaseClassDescriptor(
3182 const CXXRecordDecl *Derived, uint32_t NVOffset, int32_t VBPtrOffset,
3183 uint32_t VBTableOffset, uint32_t Flags, raw_ostream &Out) {
3184 msvc_hashing_ostream MHO(Out);
3185 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3186 Mangler.getStream() <<
"??_R1";
3187 Mangler.mangleNumber(NVOffset);
3188 Mangler.mangleNumber(VBPtrOffset);
3189 Mangler.mangleNumber(VBTableOffset);
3190 Mangler.mangleNumber(Flags);
3191 Mangler.mangleName(Derived);
3192 Mangler.getStream() <<
"8";
3195 void MicrosoftMangleContextImpl::mangleCXXRTTIBaseClassArray(
3197 msvc_hashing_ostream MHO(Out);
3198 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3199 Mangler.getStream() <<
"??_R2";
3200 Mangler.mangleName(Derived);
3201 Mangler.getStream() <<
"8";
3204 void MicrosoftMangleContextImpl::mangleCXXRTTIClassHierarchyDescriptor(
3206 msvc_hashing_ostream MHO(Out);
3207 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3208 Mangler.getStream() <<
"??_R3";
3209 Mangler.mangleName(Derived);
3210 Mangler.getStream() <<
"8";
3213 void MicrosoftMangleContextImpl::mangleCXXRTTICompleteObjectLocator(
3221 llvm::raw_svector_ostream Stream(VFTableMangling);
3222 mangleCXXVFTable(Derived, BasePath, Stream);
3224 if (VFTableMangling.startswith(
"??@")) {
3225 assert(VFTableMangling.endswith(
"@"));
3226 Out << VFTableMangling <<
"??_R4@";
3230 assert(VFTableMangling.startswith(
"??_7") ||
3231 VFTableMangling.startswith(
"??_S"));
3233 Out <<
"??_R4" << StringRef(VFTableMangling).drop_front(4);
3236 void MicrosoftMangleContextImpl::mangleSEHFilterExpression(
3237 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
3238 msvc_hashing_ostream MHO(Out);
3239 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3244 Mangler.getStream() <<
"?filt$" << SEHFilterIds[EnclosingDecl]++ <<
"@0@";
3245 Mangler.mangleName(EnclosingDecl);
3248 void MicrosoftMangleContextImpl::mangleSEHFinallyBlock(
3249 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
3250 msvc_hashing_ostream MHO(Out);
3251 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3256 Mangler.getStream() <<
"?fin$" << SEHFinallyIds[EnclosingDecl]++ <<
"@0@";
3257 Mangler.mangleName(EnclosingDecl);
3260 void MicrosoftMangleContextImpl::mangleTypeName(
QualType T, raw_ostream &Out) {
3263 MicrosoftCXXNameMangler Mangler(*
this, Out);
3264 Mangler.getStream() <<
'?';
3271 msvc_hashing_ostream MHO(Out);
3272 MicrosoftCXXNameMangler mangler(*
this, MHO, D, Type);
3279 msvc_hashing_ostream MHO(Out);
3280 MicrosoftCXXNameMangler mangler(*
this, MHO, D, Type);
3284 void MicrosoftMangleContextImpl::mangleReferenceTemporary(
3285 const VarDecl *VD,
unsigned ManglingNumber, raw_ostream &Out) {
3286 msvc_hashing_ostream MHO(Out);
3287 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3289 Mangler.getStream() <<
"?$RT" << ManglingNumber <<
'@';
3290 Mangler.mangle(VD,
"");
3293 void MicrosoftMangleContextImpl::mangleThreadSafeStaticGuardVariable(
3294 const VarDecl *VD,
unsigned GuardNum, raw_ostream &Out) {
3295 msvc_hashing_ostream MHO(Out);
3296 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3298 Mangler.getStream() <<
"?$TSS" << GuardNum <<
'@';
3299 Mangler.mangleNestedName(VD);
3300 Mangler.getStream() <<
"@4HA";
3303 void MicrosoftMangleContextImpl::mangleStaticGuardVariable(
const VarDecl *VD,
3315 msvc_hashing_ostream MHO(Out);
3316 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3320 Mangler.getStream() << (VD->
getTLSKind() ?
"??__J" :
"??_B");
3322 Mangler.getStream() <<
"?$S1@";
3324 unsigned ScopeDepth = 0;
3325 if (Visible && !getNextDiscriminator(VD, ScopeDepth))
3329 Mangler.mangle(VD,
"");
3331 Mangler.mangleNestedName(VD);
3332 Mangler.getStream() << (Visible ?
"@5" :
"@4IA");
3334 Mangler.mangleNumber(ScopeDepth);
3337 void MicrosoftMangleContextImpl::mangleInitFiniStub(
const VarDecl *D,
3340 msvc_hashing_ostream MHO(Out);
3341 MicrosoftCXXNameMangler Mangler(*
this, MHO);
3342 Mangler.getStream() <<
"??__" << CharCode;
3344 Mangler.getStream() <<
'?';
3345 Mangler.mangleName(D);
3346 Mangler.mangleVariableEncoding(D);
3347 Mangler.getStream() <<
"@@";
3349 Mangler.mangleName(D);
3353 Mangler.getStream() <<
"YAXXZ";
3356 void MicrosoftMangleContextImpl::mangleDynamicInitializer(
const VarDecl *D,
3359 mangleInitFiniStub(D,
'E', Out);
3363 MicrosoftMangleContextImpl::mangleDynamicAtExitDestructor(
const VarDecl *D,
3366 mangleInitFiniStub(D,
'F', Out);
3369 void MicrosoftMangleContextImpl::mangleStringLiteral(
const StringLiteral *SL,
3390 MicrosoftCXXNameMangler Mangler(*
this, Out);
3391 Mangler.getStream() <<
"??_C@_";
3399 unsigned StringLength = getASTContext()
3400 .getAsConstantArrayType(SL->
getType())
3407 Mangler.getStream() <<
'1';
3409 Mangler.getStream() <<
'0';
3413 Mangler.mangleNumber(StringByteLength);
3415 auto GetLittleEndianByte = [&SL](
unsigned Index) {
3417 if (Index / CharByteWidth >= SL->
getLength())
3418 return static_cast<char>(0);
3419 uint32_t CodeUnit = SL->
getCodeUnit(Index / CharByteWidth);
3420 unsigned OffsetInCodeUnit = Index % CharByteWidth;
3421 return static_cast<char>((CodeUnit >> (8 * OffsetInCodeUnit)) & 0xff);
3424 auto GetBigEndianByte = [&SL](
unsigned Index) {
3426 if (Index / CharByteWidth >= SL->
getLength())
3427 return static_cast<char>(0);
3428 uint32_t CodeUnit = SL->
getCodeUnit(Index / CharByteWidth);
3429 unsigned OffsetInCodeUnit = (CharByteWidth - 1) - (Index % CharByteWidth);
3430 return static_cast<char>((CodeUnit >> (8 * OffsetInCodeUnit)) & 0xff);
3435 for (
unsigned I = 0, E = StringByteLength; I != E; ++I)
3436 JC.update(GetLittleEndianByte(I));
3440 Mangler.mangleNumber(JC.getCRC());
3446 auto MangleByte = [&Mangler](
char Byte) {
3454 Mangler.getStream() << Byte;
3455 }
else if (
isLetter(Byte & 0x7f)) {
3456 Mangler.getStream() <<
'?' <<
static_cast<char>(Byte & 0x7f);
3458 const char SpecialChars[] = {
',',
'/',
'\\',
':',
'.',
3459 ' ',
'\n',
'\t',
'\'',
'-'};
3461 std::find(std::begin(SpecialChars), std::end(SpecialChars), Byte);
3462 if (Pos != std::end(SpecialChars)) {
3463 Mangler.getStream() <<
'?' << (Pos - std::begin(SpecialChars));
3465 Mangler.getStream() <<
"?$";
3466 Mangler.getStream() <<
static_cast<char>(
'A' + ((Byte >> 4) & 0xf));
3467 Mangler.getStream() <<
static_cast<char>(
'A' + (Byte & 0xf));
3473 unsigned MaxBytesToMangle = SL->
isWide() ? 64U : 32U;
3474 unsigned NumBytesToMangle =
std::min(MaxBytesToMangle, StringByteLength);
3475 for (
unsigned I = 0; I != NumBytesToMangle; ++I) {
3477 MangleByte(GetBigEndianByte(I));
3479 MangleByte(GetLittleEndianByte(I));
3482 Mangler.getStream() <<
'@';
3487 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.
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.
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...
Qualifiers getTypeQuals() const
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.
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 ...
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 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
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_].
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...
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.
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
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.
struct clang::ThisAdjustment::VirtualAdjustment::@134 Microsoft
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.