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;
70 llvm::SmallDenseMap<std::pair<const CXXConstructorDecl *, unsigned>,
Expr *>
73 llvm::SmallDenseMap<TagDecl *, DeclaratorDecl *>
74 UnnamedTagDeclToDeclaratorDecl;
75 llvm::SmallDenseMap<TagDecl *, TypedefNameDecl *>
76 UnnamedTagDeclToTypedefNameDecl;
81 std::pair<uint64_t, unsigned>
84 CallingConv getDefaultMethodCallConv(
bool isVariadic)
const override {
92 llvm_unreachable(
"unapplicable to the MS ABI");
96 unsigned ParmIdx,
Expr *DAE)
override {
97 CtorToDefaultArgExpr[std::make_pair(CD, ParmIdx)] = DAE;
101 unsigned ParmIdx)
override {
102 return CtorToDefaultArgExpr[std::make_pair(CD, ParmIdx)];
106 getCopyConstructorForExceptionObject(
CXXRecordDecl *RD)
override {
107 return RecordToCopyCtor[RD];
113 assert(CD !=
nullptr);
114 assert(RecordToCopyCtor[RD] ==
nullptr || RecordToCopyCtor[RD] == CD);
115 RecordToCopyCtor[RD] = CD;
118 void addTypedefNameForUnnamedTagDecl(
TagDecl *TD,
128 return UnnamedTagDeclToTypedefNameDecl.lookup(
132 void addDeclaratorForUnnamedTagDecl(
TagDecl *TD,
135 DD = cast<DeclaratorDecl>(DD->getCanonicalDecl());
142 return UnnamedTagDeclToDeclaratorDecl.lookup(
147 return new MicrosoftNumberingContext();
171 return MSInheritanceAttr::Keyword_unspecified_inheritance;
173 return MSInheritanceAttr::Keyword_virtual_inheritance;
175 return MSInheritanceAttr::Keyword_multiple_inheritance;
176 return MSInheritanceAttr::Keyword_single_inheritance;
179 MSInheritanceAttr::Spelling
181 MSInheritanceAttr *IA = getAttr<MSInheritanceAttr>();
182 assert(IA &&
"Expected MSInheritanceAttr on the CXXRecordDecl!");
183 return IA->getSemanticSpelling();
187 if (MSVtorDispAttr *VDA = getAttr<MSVtorDispAttr>())
188 return VDA->getVtorDispMode();
189 return MSVtorDispAttr::Mode(getASTContext().getLangOpts().VtorDispMode);
221 static std::pair<unsigned, unsigned>
234 if (MSInheritanceAttr::hasVBPtrOffsetField(Inheritance))
236 if (MSInheritanceAttr::hasVBTableOffsetField(Inheritance))
238 return std::make_pair(Ptrs, Ints);
241 std::pair<uint64_t, unsigned> MicrosoftCXXABI::getMemberPointerWidthAndAlign(
251 uint64_t Width = Ptrs * PtrSize + Ints * IntSize;
257 if (Ptrs + Ints > 1 && Target.
getTriple().isArch32Bit())
265 Width = llvm::alignTo(Width, Align);
266 return std::make_pair(Width, Align);
270 return new MicrosoftCXXABI(Ctx);
Defines the clang::ASTContext interface.
CXXABI * CreateMicrosoftCXXABI(ASTContext &Ctx)
bool isParsingBaseSpecifiers() const
QualType getType() const
Retrieves the type of the base class.
MSInheritanceAttr::Spelling getMSInheritanceModel() const
Returns the inheritance model used for this record.
C Language Family Type Representation.
bool hasDefinition() const
The base class of the type hierarchy.
Represents a C++ constructor within a class.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
TLSKind getTLSKind() const
MSVtorDispAttr::Mode 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 ...
TypedefNameDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this typedef-name.
const TargetInfo & getTargetInfo() const
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
base_class_iterator bases_begin()
detail::InMemoryDirectory::const_iterator I
bool isMemberFunctionPointer() const
Returns true if the member type (i.e.
Represents a ValueDecl that came out of a declarator.
Exposes information about the current target.
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
Expr - This represents one expression.
MSInheritanceAttr::Spelling calculateInheritanceModel() const
Calculate what the inheritance model would be for this class.
Implements C++ ABI-specific semantic analysis functions.
unsigned getNumBases() const
Retrieves the number of base classes of this class.
unsigned getIntAlign() const
CallingConv
CallingConv - Specifies the calling convention that a function uses.
CXXRecordDecl * getMostRecentCXXRecordDecl() const
static bool usesMultipleInheritanceModel(const CXXRecordDecl *RD)
uint64_t getPointerAlign(unsigned AddrSpace) const
TagDecl - Represents the declaration of a struct/union/class/enum.
TagDecl * getCanonicalDecl() override
Represents a static or instance method of a struct/union/class.
Base class for declarations which introduce a typedef-name.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
A pointer to member type per C++ 8.3.3 - Pointers to members.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
unsigned getIntWidth() const
getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for this target, in bits.
uint64_t getPointerWidth(unsigned AddrSpace) const
Return the width of pointers on this target, for the specified address space.
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.
Defines the clang::TargetInfo interface.
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
bool isPolymorphic() const
Whether this class is polymorphic (C++ [class.virtual]), which means that the class contains or inher...
static std::pair< unsigned, unsigned > getMSMemberPointerSlots(const MemberPointerType *MPT)