//===--- MicrosoftCXXABI.cpp - Emit LLVM Code from ASTs for a Module ------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This provides C++ code generation targetting the Microsoft Visual C++ ABI. // The class in this file generates structures that follow the Microsoft // Visual C++ ABI, which is actually not very well documented at all outside // of Microsoft. // //===----------------------------------------------------------------------===// #include "CGCXXABI.h" #include "CodeGenModule.h" #include "Mangle.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclTemplate.h" #include "clang/AST/ExprCXX.h" #include "CGVTables.h" using namespace clang; using namespace CodeGen; namespace { /// MicrosoftMangleContext - Overrides the default MangleContext for the /// Microsoft Visual C++ ABI. class MicrosoftMangleContext : public MangleContext { public: MicrosoftMangleContext(ASTContext &Context, Diagnostic &Diags) : MangleContext(Context, Diags) { } virtual void mangleName(const NamedDecl *D, llvm::SmallVectorImpl &); virtual void mangleThunk(const CXXMethodDecl *MD, const ThunkInfo &Thunk, llvm::SmallVectorImpl &); virtual void mangleCXXDtorThunk(const CXXDestructorDecl *DD, CXXDtorType Type, const ThisAdjustment &ThisAdjustment, llvm::SmallVectorImpl &); virtual void mangleGuardVariable(const VarDecl *D, llvm::SmallVectorImpl &); virtual void mangleCXXVTable(const CXXRecordDecl *RD, llvm::SmallVectorImpl &); virtual void mangleCXXVTT(const CXXRecordDecl *RD, llvm::SmallVectorImpl &); virtual void mangleCXXCtorVTable(const CXXRecordDecl *RD, int64_t Offset, const CXXRecordDecl *Type, llvm::SmallVectorImpl &); virtual void mangleCXXRTTI(QualType T, llvm::SmallVectorImpl &); virtual void mangleCXXRTTIName(QualType T, llvm::SmallVectorImpl &); virtual void mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type, llvm::SmallVectorImpl &); virtual void mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type, llvm::SmallVectorImpl &); }; class MicrosoftCXXABI : public CXXABI { MicrosoftMangleContext MangleCtx; public: MicrosoftCXXABI(CodeGenModule &CGM) : MangleCtx(CGM.getContext(), CGM.getDiags()) {} MicrosoftMangleContext &getMangleContext() { return MangleCtx; } }; } void MicrosoftMangleContext::mangleName(const NamedDecl *D, llvm::SmallVectorImpl &Name) { assert(false && "Can't yet mangle names!"); } void MicrosoftMangleContext::mangleThunk(const CXXMethodDecl *MD, const ThunkInfo &Thunk, llvm::SmallVectorImpl &) { assert(false && "Can't yet mangle thunks!"); } void MicrosoftMangleContext::mangleCXXDtorThunk(const CXXDestructorDecl *DD, CXXDtorType Type, const ThisAdjustment &, llvm::SmallVectorImpl &) { assert(false && "Can't yet mangle destructor thunks!"); } void MicrosoftMangleContext::mangleGuardVariable(const VarDecl *D, llvm::SmallVectorImpl &) { assert(false && "Can't yet mangle guard variables!"); } void MicrosoftMangleContext::mangleCXXVTable(const CXXRecordDecl *RD, llvm::SmallVectorImpl &) { assert(false && "Can't yet mangle virtual tables!"); } void MicrosoftMangleContext::mangleCXXVTT(const CXXRecordDecl *RD, llvm::SmallVectorImpl &) { llvm_unreachable("The MS C++ ABI does not have virtual table tables!"); } void MicrosoftMangleContext::mangleCXXCtorVTable(const CXXRecordDecl *RD, int64_t Offset, const CXXRecordDecl *Type, llvm::SmallVectorImpl &) { llvm_unreachable("The MS C++ ABI does not have constructor vtables!"); } void MicrosoftMangleContext::mangleCXXRTTI(QualType T, llvm::SmallVectorImpl &) { assert(false && "Can't yet mangle RTTI!"); } void MicrosoftMangleContext::mangleCXXRTTIName(QualType T, llvm::SmallVectorImpl &) { assert(false && "Can't yet mangle RTTI names!"); } void MicrosoftMangleContext::mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type, llvm::SmallVectorImpl &) { assert(false && "Can't yet mangle constructors!"); } void MicrosoftMangleContext::mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type, llvm::SmallVectorImpl &) { assert(false && "Can't yet mangle destructors!"); } CXXABI *CreateMicrosoftCXXABI(CodeGenModule &CGM) { return new MicrosoftCXXABI(CGM); }