23 using namespace clang;
30 llvm::DenseMap<const Type *, unsigned> ManglingNumbers;
31 unsigned LambdaManglingNumber;
32 unsigned StaticLocalNumber;
33 unsigned StaticThreadlocalNumber;
36 MicrosoftNumberingContext()
38 StaticLocalNumber(0), StaticThreadlocalNumber(0) {}
40 unsigned getManglingNumber(
const CXXMethodDecl *CallOperator)
override {
41 return ++LambdaManglingNumber;
44 unsigned getManglingNumber(
const BlockDecl *BD)
override {
45 const Type *Ty =
nullptr;
46 return ++ManglingNumbers[Ty];
49 unsigned getStaticLocalNumber(
const VarDecl *VD)
override {
51 return ++StaticThreadlocalNumber;
52 return ++StaticLocalNumber;
55 unsigned getManglingNumber(
const VarDecl *VD,
56 unsigned MSLocalManglingNumber)
override {
57 return MSLocalManglingNumber;
60 unsigned getManglingNumber(
const TagDecl *TD,
61 unsigned MSLocalManglingNumber)
override {
62 return MSLocalManglingNumber;
66 class MicrosoftCXXABI :
public CXXABI {
68 llvm::SmallDenseMap<CXXRecordDecl *, CXXConstructorDecl *> RecordToCopyCtor;
70 llvm::SmallDenseMap<TagDecl *, DeclaratorDecl *>
71 UnnamedTagDeclToDeclaratorDecl;
72 llvm::SmallDenseMap<TagDecl *, TypedefNameDecl *>
73 UnnamedTagDeclToTypedefNameDecl;
76 MicrosoftCXXABI(
ASTContext &Ctx) : Context(Ctx) { }
81 CallingConv getDefaultMethodCallConv(
bool isVariadic)
const override {
89 llvm_unreachable(
"unapplicable to the MS ABI");
93 getCopyConstructorForExceptionObject(
CXXRecordDecl *RD)
override {
94 return RecordToCopyCtor[RD];
100 assert(CD !=
nullptr);
101 assert(RecordToCopyCtor[RD] ==
nullptr || RecordToCopyCtor[RD] == CD);
102 RecordToCopyCtor[RD] = CD;
105 void addTypedefNameForUnnamedTagDecl(
TagDecl *TD,
115 return UnnamedTagDeclToTypedefNameDecl.lookup(
119 void addDeclaratorForUnnamedTagDecl(
TagDecl *TD,
129 return UnnamedTagDeclToDeclaratorDecl.lookup(
133 std::unique_ptr<MangleNumberingContext>
134 createMangleNumberingContext()
const override {
135 return llvm::make_unique<MicrosoftNumberingContext>();
159 return MSInheritanceAttr::Keyword_unspecified_inheritance;
160 if (getNumVBases() > 0)
161 return MSInheritanceAttr::Keyword_virtual_inheritance;
163 return MSInheritanceAttr::Keyword_multiple_inheritance;
164 return MSInheritanceAttr::Keyword_single_inheritance;
167 MSInheritanceAttr::Spelling
169 MSInheritanceAttr *IA = getAttr<MSInheritanceAttr>();
170 assert(IA &&
"Expected MSInheritanceAttr on the CXXRecordDecl!");
171 return IA->getSemanticSpelling();
175 if (MSVtorDispAttr *VDA = getAttr<MSVtorDispAttr>())
176 return VDA->getVtorDispMode();
177 return MSVtorDispAttr::Mode(getASTContext().getLangOpts().VtorDispMode);
209 static std::pair<unsigned, unsigned>
222 if (MSInheritanceAttr::hasVBPtrOffsetField(Inheritance))
224 if (MSInheritanceAttr::hasVBTableOffsetField(Inheritance))
226 return std::make_pair(Ptrs, Ints);
239 MemberPointerInfo MPI;
240 MPI.HasPadding =
false;
241 MPI.Width = Ptrs * PtrSize + Ints * IntSize;
246 if (Ptrs + Ints > 1 && Target.
getTriple().isArch32Bit())
254 MPI.Width = llvm::alignTo(MPI.Width, MPI.Align);
255 MPI.HasPadding = MPI.Width != (Ptrs * PtrSize + Ints * IntSize);
261 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.
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.
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.