]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/lib/AST/MicrosoftCXXABI.cpp
Import libcompiler_rt into HEAD and add Makefiles.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / lib / AST / MicrosoftCXXABI.cpp
1 //===------- 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
20 using namespace clang;
21
22 namespace {
23 class MicrosoftCXXABI : public CXXABI {
24   ASTContext &Context;
25 public:
26   MicrosoftCXXABI(ASTContext &Ctx) : Context(Ctx) { }
27
28   unsigned getMemberPointerSize(const MemberPointerType *MPT) const;
29 };
30 }
31
32 unsigned 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
45 CXXABI *clang::CreateMicrosoftCXXABI(ASTContext &Ctx) {
46   return new MicrosoftCXXABI(Ctx);
47 }
48