blob: cf809991de601ee58616ea27af6f18a12675002f [file] [log] [blame]
Charles Davisc3926642010-06-09 23:25:41 +00001//===--- MicrosoftCXXABI.cpp - Emit LLVM Code from ASTs for a Module ------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This provides C++ code generation targetting the Microsoft Visual C++ ABI.
11// The class in this file generates structures that follow the Microsoft
12// Visual C++ ABI, which is actually not very well documented at all outside
13// of Microsoft.
14//
15//===----------------------------------------------------------------------===//
16
17#include "CGCXXABI.h"
18#include "CodeGenModule.h"
19#include "Mangle.h"
20#include "clang/AST/ASTContext.h"
21#include "clang/AST/Decl.h"
22#include "clang/AST/DeclCXX.h"
23#include "clang/AST/DeclTemplate.h"
24#include "clang/AST/ExprCXX.h"
25#include "CGVTables.h"
26
27using namespace clang;
28using namespace CodeGen;
29
30namespace {
31
32/// MicrosoftMangleContext - Overrides the default MangleContext for the
33/// Microsoft Visual C++ ABI.
34class MicrosoftMangleContext : public MangleContext {
35public:
36 MicrosoftMangleContext(ASTContext &Context,
37 Diagnostic &Diags) : MangleContext(Context, Diags) { }
38 virtual void mangleName(const NamedDecl *D, llvm::SmallVectorImpl<char> &);
39 virtual void mangleThunk(const CXXMethodDecl *MD,
40 const ThunkInfo &Thunk,
41 llvm::SmallVectorImpl<char> &);
42 virtual void mangleCXXDtorThunk(const CXXDestructorDecl *DD, CXXDtorType Type,
43 const ThisAdjustment &ThisAdjustment,
44 llvm::SmallVectorImpl<char> &);
45 virtual void mangleGuardVariable(const VarDecl *D,
46 llvm::SmallVectorImpl<char> &);
47 virtual void mangleCXXVTable(const CXXRecordDecl *RD,
48 llvm::SmallVectorImpl<char> &);
49 virtual void mangleCXXVTT(const CXXRecordDecl *RD,
50 llvm::SmallVectorImpl<char> &);
51 virtual void mangleCXXCtorVTable(const CXXRecordDecl *RD, int64_t Offset,
52 const CXXRecordDecl *Type,
53 llvm::SmallVectorImpl<char> &);
54 virtual void mangleCXXRTTI(QualType T, llvm::SmallVectorImpl<char> &);
55 virtual void mangleCXXRTTIName(QualType T, llvm::SmallVectorImpl<char> &);
56 virtual void mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type,
57 llvm::SmallVectorImpl<char> &);
58 virtual void mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type,
59 llvm::SmallVectorImpl<char> &);
60};
61
62class MicrosoftCXXABI : public CXXABI {
63 MicrosoftMangleContext MangleCtx;
64public:
65 MicrosoftCXXABI(CodeGenModule &CGM)
66 : MangleCtx(CGM.getContext(), CGM.getDiags()) {}
67
68 MicrosoftMangleContext &getMangleContext() {
69 return MangleCtx;
70 }
71};
72
73}
74
75void MicrosoftMangleContext::mangleName(const NamedDecl *D,
76 llvm::SmallVectorImpl<char> &Name) {
77 assert(false && "Can't yet mangle names!");
78}
79void MicrosoftMangleContext::mangleThunk(const CXXMethodDecl *MD,
80 const ThunkInfo &Thunk,
81 llvm::SmallVectorImpl<char> &) {
82 assert(false && "Can't yet mangle thunks!");
83}
84void MicrosoftMangleContext::mangleCXXDtorThunk(const CXXDestructorDecl *DD,
85 CXXDtorType Type,
86 const ThisAdjustment &,
87 llvm::SmallVectorImpl<char> &) {
88 assert(false && "Can't yet mangle destructor thunks!");
89}
90void MicrosoftMangleContext::mangleGuardVariable(const VarDecl *D,
91 llvm::SmallVectorImpl<char> &) {
92 assert(false && "Can't yet mangle guard variables!");
93}
94void MicrosoftMangleContext::mangleCXXVTable(const CXXRecordDecl *RD,
95 llvm::SmallVectorImpl<char> &) {
96 assert(false && "Can't yet mangle virtual tables!");
97}
98void MicrosoftMangleContext::mangleCXXVTT(const CXXRecordDecl *RD,
99 llvm::SmallVectorImpl<char> &) {
100 llvm_unreachable("The MS C++ ABI does not have virtual table tables!");
101}
102void MicrosoftMangleContext::mangleCXXCtorVTable(const CXXRecordDecl *RD,
103 int64_t Offset,
104 const CXXRecordDecl *Type,
105 llvm::SmallVectorImpl<char> &) {
106 llvm_unreachable("The MS C++ ABI does not have constructor vtables!");
107}
108void MicrosoftMangleContext::mangleCXXRTTI(QualType T,
109 llvm::SmallVectorImpl<char> &) {
110 assert(false && "Can't yet mangle RTTI!");
111}
112void MicrosoftMangleContext::mangleCXXRTTIName(QualType T,
113 llvm::SmallVectorImpl<char> &) {
114 assert(false && "Can't yet mangle RTTI names!");
115}
116void MicrosoftMangleContext::mangleCXXCtor(const CXXConstructorDecl *D,
117 CXXCtorType Type,
118 llvm::SmallVectorImpl<char> &) {
119 assert(false && "Can't yet mangle constructors!");
120}
121void MicrosoftMangleContext::mangleCXXDtor(const CXXDestructorDecl *D,
122 CXXDtorType Type,
123 llvm::SmallVectorImpl<char> &) {
124 assert(false && "Can't yet mangle destructors!");
125}
126
127CXXABI *CreateMicrosoftCXXABI(CodeGenModule &CGM) {
128 return new MicrosoftCXXABI(CGM);
129}
130