32 llvm::DenseMap<const Type *, unsigned> ManglingNumbers;
33 unsigned LambdaManglingNumber = 0;
34 unsigned StaticLocalNumber = 0;
35 unsigned StaticThreadlocalNumber = 0;
38 MicrosoftNumberingContext() =
default;
41 return ++LambdaManglingNumber;
45 const Type *Ty =
nullptr;
46 return ++ManglingNumbers[Ty];
51 return ++StaticThreadlocalNumber;
52 return ++StaticLocalNumber;
56 unsigned MSLocalManglingNumber)
override {
57 return MSLocalManglingNumber;
61 unsigned MSLocalManglingNumber)
override {
62 return MSLocalManglingNumber;
66class MSHIPNumberingContext :
public MicrosoftNumberingContext {
67 std::unique_ptr<MangleNumberingContext> DeviceCtx;
70 using MicrosoftNumberingContext::getManglingNumber;
75 unsigned getDeviceManglingNumber(
const CXXMethodDecl *CallOperator)
override {
76 return DeviceCtx->getManglingNumber(CallOperator);
79 unsigned getManglingNumber(
const TagDecl *TD,
80 unsigned MSLocalManglingNumber)
override {
81 unsigned DeviceN = DeviceCtx->getManglingNumber(TD, MSLocalManglingNumber);
83 MicrosoftNumberingContext::getManglingNumber(TD, MSLocalManglingNumber);
84 if (DeviceN > 0xFFFF || HostN > 0xFFFF) {
90 return (DeviceN << 16) | HostN;
94class MSSYCLNumberingContext :
public MicrosoftNumberingContext {
95 std::unique_ptr<MangleNumberingContext> DeviceCtx;
102 unsigned getDeviceManglingNumber(
const CXXMethodDecl *CallOperator)
override {
103 return DeviceCtx->getManglingNumber(CallOperator);
107class MicrosoftCXXABI :
public CXXABI {
109 llvm::SmallDenseMap<CXXRecordDecl *, CXXConstructorDecl *> RecordToCopyCtor;
111 llvm::SmallDenseMap<TagDecl *, DeclaratorDecl *>
112 UnnamedTagDeclToDeclaratorDecl;
113 llvm::SmallDenseMap<TagDecl *, TypedefNameDecl *>
114 UnnamedTagDeclToTypedefNameDecl;
118 std::unique_ptr<MangleContext> DeviceMangler;
121 MicrosoftCXXABI(
ASTContext &Ctx) : Context(Ctx) {
125 "Unexpected combination of C++ ABIs.");
146 llvm_unreachable(
"unapplicable to the MS ABI");
151 return RecordToCopyCtor[RD];
157 assert(CD !=
nullptr);
158 assert(RecordToCopyCtor[RD] ==
nullptr || RecordToCopyCtor[RD] == CD);
159 RecordToCopyCtor[RD] = CD;
172 return UnnamedTagDeclToTypedefNameDecl.lookup(
186 return UnnamedTagDeclToDeclaratorDecl.lookup(
190 std::unique_ptr<MangleNumberingContext>
193 assert(DeviceMangler &&
"Missing device mangler");
194 return std::make_unique<MSHIPNumberingContext>(DeviceMangler.get());
196 assert(DeviceMangler &&
"Missing device mangler");
197 return std::make_unique<MSSYCLNumberingContext>(DeviceMangler.get());
200 return std::make_unique<MicrosoftNumberingContext>();
233 MSInheritanceAttr *IA = getAttr<MSInheritanceAttr>();
234 assert(IA &&
"Expected MSInheritanceAttr on the CXXRecordDecl!");
235 return IA->getInheritanceModel();
245 if (MSVtorDispAttr *VDA = getAttr<MSVtorDispAttr>())
246 return VDA->getVtorDispMode();
279static std::pair<unsigned, unsigned>
296 return std::make_pair(Ptrs, Ints);
305 unsigned IntSize =
Target.getIntWidth();
309 MemberPointerInfo MPI;
310 MPI.HasPadding =
false;
311 MPI.Width = Ptrs * PtrSize + Ints * IntSize;
316 if (Ptrs + Ints > 1 &&
Target.getTriple().isArch32Bit())
321 MPI.Align =
Target.getIntAlign();
323 if (
Target.getTriple().isArch64Bit()) {
324 MPI.Width = llvm::alignTo(MPI.Width, MPI.Align);
325 MPI.HasPadding = MPI.Width != (Ptrs * PtrSize + Ints * IntSize);
331 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....
llvm::MachO::Target Target
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
MangleContext * createMangleContext(const TargetInfo *T=nullptr)
If T is null pointer, assume the target in ASTContext.
const LangOptions & getLangOpts() const
const TargetInfo * getAuxTargetInfo() const
DiagnosticsEngine & getDiagnostics() const
const TargetInfo & getTargetInfo() const
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Implements C++ ABI-specific semantic analysis functions.
virtual void addTypedefNameForUnnamedTagDecl(TagDecl *TD, TypedefNameDecl *DD)=0
virtual MemberPointerInfo getMemberPointerInfo(const MemberPointerType *MPT) const =0
Returns the width and alignment of a member pointer in bits, as well as whether it has padding.
virtual std::unique_ptr< MangleNumberingContext > createMangleNumberingContext() const =0
Returns a new mangling number context for this C++ ABI.
virtual CallingConv getDefaultMethodCallConv(bool isVariadic) const =0
Returns the default calling convention for C++ methods.
virtual void addDeclaratorForUnnamedTagDecl(TagDecl *TD, DeclaratorDecl *DD)=0
virtual TypedefNameDecl * getTypedefNameForUnnamedTagDecl(const TagDecl *TD)=0
virtual const CXXConstructorDecl * getCopyConstructorForExceptionObject(CXXRecordDecl *)=0
Retrieves the mapping from class to copy constructor for this C++ ABI.
virtual void addCopyConstructorForExceptionObject(CXXRecordDecl *, CXXConstructorDecl *)=0
Adds a mapping from class to copy constructor for this C++ ABI.
virtual DeclaratorDecl * getDeclaratorForUnnamedTagDecl(const TagDecl *TD)=0
virtual bool isNearlyEmpty(const CXXRecordDecl *RD) const =0
Returns whether the given class is nearly empty, with just virtual pointers and no data except possib...
QualType getType() const
Retrieves the type of the base class.
Represents a C++ constructor within a class.
Represents a static or instance method of a struct/union/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.
Represents a ValueDecl that came out of a declarator.
Concrete class used by the front-end to report problems and issues.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
static ItaniumMangleContext * create(ASTContext &Context, DiagnosticsEngine &Diags, bool IsAux=false)
MangleContext - Context for tracking state which persists across multiple calls to the C++ name mangl...
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
virtual unsigned getManglingNumber(const CXXMethodDecl *CallOperator)=0
Retrieve the mangling number of a new lambda expression with the given call operator within this cont...
virtual unsigned getStaticLocalNumber(const VarDecl *VD)=0
Static locals are numbered by source order.
A pointer to member type per C++ 8.3.3 - Pointers to members.
CXXRecordDecl * getMostRecentCXXRecordDecl() const
bool isMemberFunctionPointer() const
Returns true if the member type (i.e.
Represents the declaration of a struct/union/class/enum.
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
bool isItaniumFamily() const
Does this ABI generally fall into the Itanium family of ABIs?
Exposes information about the current target.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
uint64_t getPointerWidth(LangAS AddrSpace) const
Return the width of pointers on this target, for the specified address space.
virtual CallingConv getDefaultCallingConv() const
Gets the default calling convention for the given target and declaration context.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
The base class of the type hierarchy.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Base class for declarations which introduce a typedef-name.
TypedefNameDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this typedef-name.
Represents a variable declaration or definition.
TLSKind getTLSKind() const
Defines the clang::TargetInfo interface.
The JSON file list parser is used to communicate input to InstallAPI.
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...
MSInheritanceModel
Assigned inheritance model for a class in the MS C++ ABI.
CallingConv
CallingConv - Specifies the calling convention that a function uses.