Go to the documentation of this file.
25 using namespace clang;
32 llvm::DenseMap<const Type *, unsigned> ManglingNumbers;
33 unsigned LambdaManglingNumber;
34 unsigned StaticLocalNumber;
35 unsigned StaticThreadlocalNumber;
38 MicrosoftNumberingContext()
39 : LambdaManglingNumber(0), StaticLocalNumber(0),
40 StaticThreadlocalNumber(0) {}
42 unsigned getManglingNumber(
const CXXMethodDecl *CallOperator)
override {
43 return ++LambdaManglingNumber;
46 unsigned getManglingNumber(
const BlockDecl *BD)
override {
47 const Type *Ty =
nullptr;
48 return ++ManglingNumbers[Ty];
51 unsigned getStaticLocalNumber(
const VarDecl *VD)
override {
53 return ++StaticThreadlocalNumber;
54 return ++StaticLocalNumber;
57 unsigned getManglingNumber(
const VarDecl *VD,
58 unsigned MSLocalManglingNumber)
override {
59 return MSLocalManglingNumber;
62 unsigned getManglingNumber(
const TagDecl *TD,
63 unsigned MSLocalManglingNumber)
override {
64 return MSLocalManglingNumber;
68 class MSHIPNumberingContext :
public MicrosoftNumberingContext {
69 std::unique_ptr<MangleNumberingContext> DeviceCtx;
72 using MicrosoftNumberingContext::getManglingNumber;
77 unsigned getDeviceManglingNumber(
const CXXMethodDecl *CallOperator)
override {
78 return DeviceCtx->getManglingNumber(CallOperator);
81 unsigned getManglingNumber(
const TagDecl *TD,
82 unsigned MSLocalManglingNumber)
override {
83 unsigned DeviceN = DeviceCtx->getManglingNumber(TD, MSLocalManglingNumber);
85 MicrosoftNumberingContext::getManglingNumber(TD, MSLocalManglingNumber);
86 if (DeviceN > 0xFFFF || HostN > 0xFFFF) {
92 return (DeviceN << 16) | HostN;
96 class MSSYCLNumberingContext :
public MicrosoftNumberingContext {
97 std::unique_ptr<MangleNumberingContext> DeviceCtx;
104 unsigned getDeviceManglingNumber(
const CXXMethodDecl *CallOperator)
override {
105 return DeviceCtx->getManglingNumber(CallOperator);
109 class MicrosoftCXXABI :
public CXXABI {
111 llvm::SmallDenseMap<CXXRecordDecl *, CXXConstructorDecl *> RecordToCopyCtor;
113 llvm::SmallDenseMap<TagDecl *, DeclaratorDecl *>
114 UnnamedTagDeclToDeclaratorDecl;
115 llvm::SmallDenseMap<TagDecl *, TypedefNameDecl *>
116 UnnamedTagDeclToTypedefNameDecl;
120 std::unique_ptr<MangleContext> DeviceMangler;
123 MicrosoftCXXABI(
ASTContext &Ctx) : Context(Ctx) {
127 "Unexpected combination of C++ ABIs.");
140 CallingConv getDefaultMethodCallConv(
bool isVariadic)
const override {
148 llvm_unreachable(
"unapplicable to the MS ABI");
152 getCopyConstructorForExceptionObject(
CXXRecordDecl *RD)
override {
153 return RecordToCopyCtor[RD];
159 assert(CD !=
nullptr);
160 assert(RecordToCopyCtor[RD] ==
nullptr || RecordToCopyCtor[RD] == CD);
161 RecordToCopyCtor[RD] = CD;
164 void addTypedefNameForUnnamedTagDecl(
TagDecl *TD,
174 return UnnamedTagDeclToTypedefNameDecl.lookup(
178 void addDeclaratorForUnnamedTagDecl(
TagDecl *TD,
188 return UnnamedTagDeclToDeclaratorDecl.lookup(
192 std::unique_ptr<MangleNumberingContext>
193 createMangleNumberingContext()
const override {
195 assert(DeviceMangler &&
"Missing device mangler");
196 return std::make_unique<MSHIPNumberingContext>(DeviceMangler.get());
198 assert(DeviceMangler &&
"Missing device mangler");
199 return std::make_unique<MSSYCLNumberingContext>(DeviceMangler.get());
202 return std::make_unique<MicrosoftNumberingContext>();
235 MSInheritanceAttr *IA = getAttr<MSInheritanceAttr>();
236 assert(IA &&
"Expected MSInheritanceAttr on the CXXRecordDecl!");
237 return IA->getInheritanceModel();
247 if (MSVtorDispAttr *VDA = getAttr<MSVtorDispAttr>())
248 return VDA->getVtorDispMode();
281 static std::pair<unsigned, unsigned>
298 return std::make_pair(Ptrs, Ints);
306 unsigned PtrSize =
Target.getPointerWidth(0);
307 unsigned IntSize =
Target.getIntWidth();
311 MemberPointerInfo MPI;
312 MPI.HasPadding =
false;
313 MPI.Width = Ptrs * PtrSize + Ints * IntSize;
318 if (Ptrs + Ints > 1 &&
Target.getTriple().isArch32Bit())
321 MPI.Align =
Target.getPointerAlign(0);
323 MPI.Align =
Target.getIntAlign();
325 if (
Target.getTriple().isArch64Bit()) {
326 MPI.Width = llvm::alignTo(MPI.Width, MPI.Align);
327 MPI.HasPadding = MPI.Width != (Ptrs * PtrSize + Ints * IntSize);
333 return new MicrosoftCXXABI(Ctx);
ASTContext & getASTContext() const LLVM_READONLY
Represents a C++ constructor within a class.
QualType getType() const
Retrieves the type of the base class.
TLSKind getTLSKind() const
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
Concrete class used by the front-end to report problems and issues.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
bool isItaniumFamily() const
Does this ABI generally fall into the Itanium family of ABIs?
Exposes information about the current target.
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
const TargetInfo * getAuxTargetInfo() const
MangleContext * createMangleContext(const TargetInfo *T=nullptr)
If T is null pointer, assume the target in ASTContext.
bool isMemberFunctionPointer() const
Returns true if the member type (i.e.
MSVtorDispMode
In the Microsoft ABI, this controls the placement of virtual displacement members used to implement v...
The base class of the type hierarchy.
virtual CallingConv getDefaultCallingConv() const
Gets the default calling convention for the given target and declaration context.
MangleContext - Context for tracking state which persists across multiple calls to the C++ name mangl...
Represents a block literal declaration, which is like an unnamed FunctionDecl.
bool isParsingBaseSpecifiers() const
bool inheritanceModelHasVBTableOffsetField(MSInheritanceModel Inheritance)
MSVtorDispMode getMSVtorDispMode() const
Controls when vtordisps will be emitted if this record is used as a virtual base.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
unsigned getNumBases() const
Retrieves the number of base classes of this class.
TypedefNameDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this typedef-name.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Represents a variable declaration or definition.
Represents the declaration of a struct/union/class/enum.
Implements C++ ABI-specific semantic analysis functions.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
CXXABI * CreateMicrosoftCXXABI(ASTContext &Ctx)
MSInheritanceModel getMSInheritanceModel() const
Returns the inheritance model used for this record.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
Represents a C++ struct/union/class.
bool inheritanceModelHasNVOffsetField(bool IsMemberFunction, MSInheritanceModel Inheritance)
static bool usesMultipleInheritanceModel(const CXXRecordDecl *RD)
bool nullFieldOffsetIsZero() const
In the Microsoft C++ ABI, use zero for the field offset of a null data member pointer if we can guara...
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
Represents a ValueDecl that came out of a declarator.
bool inheritanceModelHasVBPtrOffsetField(MSInheritanceModel Inheritance)
const TargetInfo & getTargetInfo() const
A pointer to member type per C++ 8.3.3 - Pointers to members.
static std::pair< unsigned, unsigned > getMSMemberPointerSlots(const MemberPointerType *MPT)
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
bool inheritanceModelHasOnlyOneField(bool IsMemberFunction, MSInheritanceModel Inheritance)
static ItaniumMangleContext * create(ASTContext &Context, DiagnosticsEngine &Diags, bool IsAux=false)
MSInheritanceModel calculateInheritanceModel() const
Calculate what the inheritance model would be for this class.
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
base_class_iterator bases_begin()
bool hasDefinition() const
MSInheritanceModel
Assigned inheritance model for a class in the MS C++ ABI.
Base class for declarations which introduce a typedef-name.
bool isPolymorphic() const
Whether this class is polymorphic (C++ [class.virtual]), which means that the class contains or inher...
CXXRecordDecl * getMostRecentCXXRecordDecl() const
SourceLocation getLocation() const
const LangOptions & getLangOpts() const
std::unique_ptr< MangleNumberingContext > createItaniumNumberingContext(MangleContext *)
DiagnosticsEngine & getDiagnostics() const
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Represents a static or instance method of a struct/union/class.