24 using namespace clang;
31 llvm::DenseMap<const Type *, unsigned> ManglingNumbers;
32 unsigned LambdaManglingNumber;
33 unsigned StaticLocalNumber;
34 unsigned StaticThreadlocalNumber;
37 MicrosoftNumberingContext()
39 StaticLocalNumber(0), StaticThreadlocalNumber(0) {}
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;
67 class MicrosoftCXXABI :
public CXXABI {
69 llvm::SmallDenseMap<CXXRecordDecl *, CXXConstructorDecl *> RecordToCopyCtor;
71 llvm::SmallDenseMap<TagDecl *, DeclaratorDecl *>
72 UnnamedTagDeclToDeclaratorDecl;
73 llvm::SmallDenseMap<TagDecl *, TypedefNameDecl *>
74 UnnamedTagDeclToTypedefNameDecl;
77 MicrosoftCXXABI(
ASTContext &Ctx) : Context(Ctx) { }
82 CallingConv getDefaultMethodCallConv(
bool isVariadic)
const override {
90 llvm_unreachable(
"unapplicable to the MS ABI");
94 getCopyConstructorForExceptionObject(
CXXRecordDecl *RD)
override {
95 return RecordToCopyCtor[RD];
101 assert(CD !=
nullptr);
102 assert(RecordToCopyCtor[RD] ==
nullptr || RecordToCopyCtor[RD] == CD);
103 RecordToCopyCtor[RD] = CD;
106 void addTypedefNameForUnnamedTagDecl(
TagDecl *TD,
116 return UnnamedTagDeclToTypedefNameDecl.lookup(
120 void addDeclaratorForUnnamedTagDecl(
TagDecl *TD,
130 return UnnamedTagDeclToDeclaratorDecl.lookup(
134 std::unique_ptr<MangleNumberingContext>
135 createMangleNumberingContext()
const override {
136 return std::make_unique<MicrosoftNumberingContext>();
161 if (getNumVBases() > 0)
169 MSInheritanceAttr *IA = getAttr<MSInheritanceAttr>();
170 assert(IA &&
"Expected MSInheritanceAttr on the CXXRecordDecl!");
171 return IA->getInheritanceModel();
176 getMSInheritanceModel()) ||
181 if (MSVtorDispAttr *VDA = getAttr<MSVtorDispAttr>())
182 return VDA->getVtorDispMode();
183 return getASTContext().getLangOpts().getVtorDispMode();
215 static std::pair<unsigned, unsigned>
232 return std::make_pair(Ptrs, Ints);
245 MemberPointerInfo MPI;
246 MPI.HasPadding =
false;
247 MPI.Width = Ptrs * PtrSize + Ints * IntSize;
252 if (Ptrs + Ints > 1 && Target.
getTriple().isArch32Bit())
260 MPI.Width = llvm::alignTo(MPI.Width, MPI.Align);
261 MPI.HasPadding = MPI.Width != (Ptrs * PtrSize + Ints * IntSize);
267 return new MicrosoftCXXABI(Ctx);
Defines the clang::ASTContext interface.
MSVtorDispMode
In the Microsoft ABI, this controls the placement of virtual displacement members used to implement v...
CXXABI * CreateMicrosoftCXXABI(ASTContext &Ctx)
MSVtorDispMode getMSVtorDispMode() const
Controls when vtordisps will be emitted if this record is used as a virtual base. ...
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
unsigned getNumBases() const
Retrieves the number of base classes of this class.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
C Language Family Type Representation.
The base class of the type hierarchy.
const TargetInfo & getTargetInfo() const
Represents a C++ constructor within a class.
Represents a variable declaration or definition.
uint64_t getPointerWidth(unsigned AddrSpace) const
Return the width of pointers on this target, for the specified address space.
unsigned getIntAlign() const
MSInheritanceModel calculateInheritanceModel() const
Calculate what the inheritance model would be for this class.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
bool inheritanceModelHasOnlyOneField(bool IsMemberFunction, MSInheritanceModel Inheritance)
TypedefNameDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this typedef-name.
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
MSInheritanceModel
Assigned inheritance model for a class in the MS C++ ABI.
base_class_iterator bases_begin()
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
bool inheritanceModelHasVBTableOffsetField(MSInheritanceModel Inheritance)
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a ValueDecl that came out of a declarator.
Exposes information about the current target.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
unsigned getIntWidth() const
getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for this target, in bits.
virtual CallingConv getDefaultCallingConv() const
Gets the default calling convention for the given target and declaration context. ...
TLSKind getTLSKind() const
bool isPolymorphic() const
Whether this class is polymorphic (C++ [class.virtual]), which means that the class contains or inher...
static bool hasDefinition(const ObjCObjectPointerType *ObjPtr)
Implements C++ ABI-specific semantic analysis functions.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
static bool usesMultipleInheritanceModel(const CXXRecordDecl *RD)
Represents the declaration of a struct/union/class/enum.
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Represents a static or instance method of a struct/union/class.
Base class for declarations which introduce a typedef-name.
CXXRecordDecl * getMostRecentCXXRecordDecl() const
Dataflow Directional Tag Classes.
A pointer to member type per C++ 8.3.3 - Pointers to members.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
Represents a C++ struct/union/class.
bool isMemberFunctionPointer() const
Returns true if the member type (i.e.
bool inheritanceModelHasNVOffsetField(bool IsMemberFunction, MSInheritanceModel Inheritance)
uint64_t getPointerAlign(unsigned AddrSpace) const
Defines the clang::TargetInfo interface.
bool nullFieldOffsetIsZero() const
In the Microsoft C++ ABI, use zero for the field offset of a null data member pointer if we can guara...
MSInheritanceModel getMSInheritanceModel() const
Returns the inheritance model used for this record.
bool inheritanceModelHasVBPtrOffsetField(MSInheritanceModel Inheritance)
static std::pair< unsigned, unsigned > getMSMemberPointerSlots(const MemberPointerType *MPT)
QualType getType() const
Retrieves the type of the base class.