33 llvm::DenseMap<const Type *, unsigned> ManglingNumbers;
34 unsigned LambdaManglingNumber = 0;
35 unsigned StaticLocalNumber = 0;
36 unsigned StaticThreadlocalNumber = 0;
39 MicrosoftNumberingContext() =
default;
41 unsigned getManglingNumber(
const CXXMethodDecl *CallOperator)
override {
42 return ++LambdaManglingNumber;
45 unsigned getManglingNumber(
const BlockDecl *BD)
override {
46 const Type *Ty =
nullptr;
47 return ++ManglingNumbers[Ty];
50 unsigned getStaticLocalNumber(
const VarDecl *VD)
override {
52 return ++StaticThreadlocalNumber;
53 return ++StaticLocalNumber;
56 unsigned getManglingNumber(
const VarDecl *VD,
57 unsigned MSLocalManglingNumber)
override {
58 return MSLocalManglingNumber;
61 unsigned getManglingNumber(
const TagDecl *TD,
62 unsigned MSLocalManglingNumber)
override {
63 return MSLocalManglingNumber;
67class MSHIPNumberingContext :
public MicrosoftNumberingContext {
68 std::unique_ptr<MangleNumberingContext> DeviceCtx;
71 using MicrosoftNumberingContext::getManglingNumber;
72 MSHIPNumberingContext(MangleContext *DeviceMangler) {
76 unsigned getDeviceManglingNumber(
const CXXMethodDecl *CallOperator)
override {
77 return DeviceCtx->getManglingNumber(CallOperator);
80 unsigned getManglingNumber(
const TagDecl *TD,
81 unsigned MSLocalManglingNumber)
override {
82 unsigned DeviceN = DeviceCtx->getManglingNumber(TD, MSLocalManglingNumber);
84 MicrosoftNumberingContext::getManglingNumber(TD, MSLocalManglingNumber);
85 if (DeviceN > 0xFFFF || HostN > 0xFFFF) {
89 return (DeviceN << 16) | HostN;
93class MSSYCLNumberingContext :
public MicrosoftNumberingContext {
94 std::unique_ptr<MangleNumberingContext> DeviceCtx;
97 MSSYCLNumberingContext(MangleContext *DeviceMangler) {
101 unsigned getDeviceManglingNumber(
const CXXMethodDecl *CallOperator)
override {
102 return DeviceCtx->getManglingNumber(CallOperator);
106class MicrosoftCXXABI :
public CXXABI {
108 llvm::SmallDenseMap<CXXRecordDecl *, CXXConstructorDecl *> RecordToCopyCtor;
110 llvm::SmallDenseMap<TagDecl *, DeclaratorDecl *>
111 UnnamedTagDeclToDeclaratorDecl;
112 llvm::SmallDenseMap<TagDecl *, TypedefNameDecl *>
113 UnnamedTagDeclToTypedefNameDecl;
117 std::unique_ptr<MangleContext> DeviceMangler;
120 MicrosoftCXXABI(ASTContext &Ctx) : Context(Ctx) {
121 if (Context.getLangOpts().CUDA && Context.getAuxTargetInfo()) {
122 assert(Context.getTargetInfo().getCXXABI().isMicrosoft() &&
123 Context.getAuxTargetInfo()->getCXXABI().isItaniumFamily() &&
124 "Unexpected combination of C++ ABIs.");
126 Context.createMangleContext(Context.getAuxTargetInfo()));
128 else if (Context.getLangOpts().isSYCL()) {
130 ItaniumMangleContext::create(Context, Context.getDiagnostics()));
135 getMemberPointerInfo(
const MemberPointerType *MPT)
const override;
137 CallingConv getDefaultMethodCallConv(
bool isVariadic)
const override {
139 Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86)
141 return Context.getTargetInfo().getDefaultCallingConv();
144 bool isNearlyEmpty(
const CXXRecordDecl *RD)
const override {
145 llvm_unreachable(
"unapplicable to the MS ABI");
148 const CXXConstructorDecl *
149 getCopyConstructorForExceptionObject(CXXRecordDecl *RD)
override {
150 return RecordToCopyCtor[RD];
154 addCopyConstructorForExceptionObject(CXXRecordDecl *RD,
155 CXXConstructorDecl *CD)
override {
156 assert(CD !=
nullptr);
157 assert(RecordToCopyCtor[RD] ==
nullptr || RecordToCopyCtor[RD] == CD);
158 RecordToCopyCtor[RD] = CD;
161 void addTypedefNameForUnnamedTagDecl(TagDecl *TD,
162 TypedefNameDecl *DD)
override {
165 TypedefNameDecl *&I = UnnamedTagDeclToTypedefNameDecl[TD];
170 TypedefNameDecl *getTypedefNameForUnnamedTagDecl(
const TagDecl *TD)
override {
171 return UnnamedTagDeclToTypedefNameDecl.lookup(
175 void addDeclaratorForUnnamedTagDecl(TagDecl *TD,
176 DeclaratorDecl *DD)
override {
179 DeclaratorDecl *&I = UnnamedTagDeclToDeclaratorDecl[TD];
184 DeclaratorDecl *getDeclaratorForUnnamedTagDecl(
const TagDecl *TD)
override {
185 return UnnamedTagDeclToDeclaratorDecl.lookup(
189 std::unique_ptr<MangleNumberingContext>
190 createMangleNumberingContext()
const override {
191 if (Context.getLangOpts().CUDA && Context.getAuxTargetInfo()) {
192 assert(DeviceMangler &&
"Missing device mangler");
193 return std::make_unique<MSHIPNumberingContext>(DeviceMangler.get());
194 }
else if (Context.getLangOpts().isSYCL()) {
195 assert(DeviceMangler &&
"Missing device mangler");
196 return std::make_unique<MSSYCLNumberingContext>(DeviceMangler.get());
199 return std::make_unique<MicrosoftNumberingContext>();
233 assert(IA &&
"Expected MSInheritanceAttr on the CXXRecordDecl!");
234 return IA->getInheritanceModel();
245 return VDA->getVtorDispMode();
278static std::pair<unsigned, unsigned>
295 return std::make_pair(Ptrs, Ints);
304 unsigned IntSize =
Target.getIntWidth();
308 MemberPointerInfo MPI;
309 MPI.HasPadding =
false;
310 MPI.Width = Ptrs * PtrSize + Ints * IntSize;
315 if (Ptrs + Ints > 1 &&
Target.getTriple().isArch32Bit())
320 MPI.Align =
Target.getIntAlign();
322 if (
Target.getTriple().isArch64Bit()) {
323 MPI.Width = llvm::alignTo(MPI.Width, MPI.Align);
324 MPI.HasPadding = MPI.Width != (Ptrs * PtrSize + Ints * IntSize);
330 return new MicrosoftCXXABI(Ctx);
Defines the clang::ASTContext interface.
static bool usesMultipleInheritanceModel(const CXXRecordDecl *RD)
static std::pair< unsigned, unsigned > getMSMemberPointerSlots(const MemberPointerType *MPT)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
#define CXXABI(Name, Str)
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const LangOptions & getLangOpts() const
DiagnosticsEngine & getDiagnostics() const
const TargetInfo & getTargetInfo() const
Implements C++ ABI-specific semantic analysis functions.
QualType getType() const
Retrieves the type of the base class.
Represents a C++ struct/union/class.
bool isParsingBaseSpecifiers() const
bool isPolymorphic() const
Whether this class is polymorphic (C++ [class.virtual]), which means that the class contains or inher...
unsigned getNumBases() const
Retrieves the number of base classes of this class.
base_class_iterator bases_begin()
MSInheritanceModel getMSInheritanceModel() const
Returns the inheritance model used for this record.
bool nullFieldOffsetIsZero() const
In the Microsoft C++ ABI, use zero for the field offset of a null data member pointer if we can guara...
bool hasDefinition() const
MSInheritanceModel calculateInheritanceModel() const
Calculate what the inheritance model would be for this class.
MSVtorDispMode getMSVtorDispMode() const
Controls when vtordisps will be emitted if this record is used as a virtual base.
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
ASTContext & getASTContext() const LLVM_READONLY
SourceLocation getLocation() const
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
A pointer to member type per C++ 8.3.3 - Pointers to members.
CXXRecordDecl * getMostRecentCXXRecordDecl() const
Note: this can trigger extra deserialization when external AST sources are used.
bool isMemberFunctionPointer() const
Returns true if the member type (i.e.
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Exposes information about the current target.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
TypedefNameDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this typedef-name.
TLSKind getTLSKind() const
Defines the clang::TargetInfo interface.
The JSON file list parser is used to communicate input to InstallAPI.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(const_cast< Expr * >(T -> getSizeExpr())))
std::unique_ptr< MangleNumberingContext > createItaniumNumberingContext(MangleContext *)
CXXABI * CreateMicrosoftCXXABI(ASTContext &Ctx)
bool inheritanceModelHasNVOffsetField(bool IsMemberFunction, MSInheritanceModel Inheritance)
bool inheritanceModelHasOnlyOneField(bool IsMemberFunction, MSInheritanceModel Inheritance)
bool inheritanceModelHasVBPtrOffsetField(MSInheritanceModel Inheritance)
bool inheritanceModelHasVBTableOffsetField(MSInheritanceModel Inheritance)
MSVtorDispMode
In the Microsoft ABI, this controls the placement of virtual displacement members used to implement v...
@ Type
The name was classified as a type.
MSInheritanceModel
Assigned inheritance model for a class in the MS C++ ABI.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
U cast(CodeGen::Address addr)