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 llvm::make_unique<MicrosoftNumberingContext>();
160 return MSInheritanceAttr::Keyword_unspecified_inheritance;
161 if (getNumVBases() > 0)
162 return MSInheritanceAttr::Keyword_virtual_inheritance;
164 return MSInheritanceAttr::Keyword_multiple_inheritance;
165 return MSInheritanceAttr::Keyword_single_inheritance;
168 MSInheritanceAttr::Spelling
170 MSInheritanceAttr *IA = getAttr<MSInheritanceAttr>();
171 assert(IA &&
"Expected MSInheritanceAttr on the CXXRecordDecl!");
172 return IA->getSemanticSpelling();
176 if (MSVtorDispAttr *VDA = getAttr<MSVtorDispAttr>())
177 return VDA->getVtorDispMode();
178 return MSVtorDispAttr::Mode(getASTContext().getLangOpts().VtorDispMode);
210 static std::pair<unsigned, unsigned>
223 if (MSInheritanceAttr::hasVBPtrOffsetField(Inheritance))
225 if (MSInheritanceAttr::hasVBTableOffsetField(Inheritance))
227 return std::make_pair(Ptrs, Ints);
240 MemberPointerInfo MPI;
241 MPI.HasPadding =
false;
242 MPI.Width = Ptrs * PtrSize + Ints * IntSize;
247 if (Ptrs + Ints > 1 && Target.
getTriple().isArch32Bit())
255 MPI.Width = llvm::alignTo(MPI.Width, MPI.Align);
256 MPI.HasPadding = MPI.Width != (Ptrs * PtrSize + Ints * IntSize);
262 return new MicrosoftCXXABI(Ctx);
Defines the clang::ASTContext interface.
CXXABI * CreateMicrosoftCXXABI(ASTContext &Ctx)
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.
MSInheritanceAttr::Spelling getMSInheritanceModel() const
Returns the inheritance model used for this record.
Represents a variable declaration or definition.
MSInheritanceAttr::Spelling calculateInheritanceModel() const
Calculate what the inheritance model would be for this class.
uint64_t getPointerWidth(unsigned AddrSpace) const
Return the width of pointers on this target, for the specified address space.
unsigned getIntAlign() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
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...
base_class_iterator bases_begin()
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
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.
Pepresents 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.
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.
MSVtorDispAttr::Mode getMSVtorDispMode() const
Controls when vtordisps will be emitted if this record is used as a virtual base. ...
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.
uint64_t getPointerAlign(unsigned AddrSpace) const
Defines the clang::TargetInfo interface.
static std::pair< unsigned, unsigned > getMSMemberPointerSlots(const MemberPointerType *MPT)
QualType getType() const
Retrieves the type of the base class.