1 //===--- MicrosoftCXXABI.cpp - Emit LLVM Code from ASTs for a Module ------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This provides C++ code generation targeting 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
15 //===----------------------------------------------------------------------===//
18 #include "CodeGenModule.h"
19 #include "clang/AST/Decl.h"
20 #include "clang/AST/DeclCXX.h"
22 using namespace clang;
23 using namespace CodeGen;
27 class MicrosoftCXXABI : public CGCXXABI {
29 MicrosoftCXXABI(CodeGenModule &CGM) : CGCXXABI(CGM) {}
31 void BuildConstructorSignature(const CXXConstructorDecl *Ctor,
34 llvm::SmallVectorImpl<CanQualType> &ArgTys) {
35 // 'this' is already in place
36 // TODO: 'for base' flag
39 void BuildDestructorSignature(const CXXDestructorDecl *Ctor,
42 llvm::SmallVectorImpl<CanQualType> &ArgTys) {
43 // 'this' is already in place
44 // TODO: 'for base' flag
47 void BuildInstanceFunctionParams(CodeGenFunction &CGF,
49 FunctionArgList &Params) {
50 BuildThisParam(CGF, Params);
51 // TODO: 'for base' flag
54 void EmitInstanceFunctionProlog(CodeGenFunction &CGF) {
56 // TODO: 'for base' flag
59 // ==== Notes on array cookies =========
61 // MSVC seems to only use cookies when the class has a destructor; a
62 // two-argument usual array deallocation function isn't sufficient.
64 // For example, this code prints "100" and "1":
67 // void *operator new[](size_t sz) {
68 // printf("%u\n", sz);
71 // void operator delete[](void *p, size_t sz) {
72 // printf("%u\n", sz);
80 // Whereas it prints "104" and "104" if you give A a destructor.
85 CGCXXABI *clang::CodeGen::CreateMicrosoftCXXABI(CodeGenModule &CGM) {
86 return new MicrosoftCXXABI(CGM);