blob: 87b77673925f5da3824b56ca390e6479793d842f [file] [log] [blame]
Charles Davis071cc7d2010-08-16 03:33:14 +00001//===------- MicrosoftCXXABI.cpp - AST support for the Microsoft C++ ABI --===//
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++ AST support targetting the Microsoft Visual C++
11// ABI.
12//
13//===----------------------------------------------------------------------===//
14
15#include "CXXABI.h"
16#include "clang/AST/ASTContext.h"
17#include "clang/AST/Type.h"
18#include "clang/AST/DeclCXX.h"
19
20using namespace clang;
21
22namespace {
23class MicrosoftCXXABI : public CXXABI {
24 ASTContext &Context;
25public:
26 MicrosoftCXXABI(ASTContext &Ctx) : Context(Ctx) { }
27
28 unsigned getMemberPointerSize(const MemberPointerType *MPT) const;
29};
30}
31
32unsigned MicrosoftCXXABI::getMemberPointerSize(const MemberPointerType *MPT) const {
33 QualType Pointee = MPT->getPointeeType();
34 CXXRecordDecl *RD = MPT->getClass()->getAsCXXRecordDecl();
35 if (RD->getNumVBases() > 0) {
36 if (Pointee->isFunctionType())
37 return 3;
38 else
39 return 2;
40 } else if (RD->getNumBases() > 1 && Pointee->isFunctionType())
41 return 2;
42 return 1;
43}
44
45CXXABI *clang::CreateMicrosoftCXXABI(ASTContext &Ctx) {
46 return new MicrosoftCXXABI(Ctx);
47}
48