]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/AST/ItaniumCXXABI.cpp
Vendor import of clang r114020 (from the release_28 branch):
[FreeBSD/FreeBSD.git] / lib / AST / ItaniumCXXABI.cpp
1 //===------- ItaniumCXXABI.cpp - AST support for the Itanium 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 Itanium C++ ABI, which is
11 // documented at:
12 //  http://www.codesourcery.com/public/cxx-abi/abi.html
13 //  http://www.codesourcery.com/public/cxx-abi/abi-eh.html
14 //
15 // It also supports the closely-related ARM C++ ABI, documented at:
16 // http://infocenter.arm.com/help/topic/com.arm.doc.ihi0041c/IHI0041C_cppabi.pdf
17 //
18 //===----------------------------------------------------------------------===//
19
20 #include "CXXABI.h"
21 #include "clang/AST/ASTContext.h"
22 #include "clang/AST/Type.h"
23
24 using namespace clang;
25
26 namespace {
27 class ItaniumCXXABI : public CXXABI {
28 protected:
29   ASTContext &Context;
30 public:
31   ItaniumCXXABI(ASTContext &Ctx) : Context(Ctx) { }
32
33   unsigned getMemberPointerSize(const MemberPointerType *MPT) const {
34     QualType Pointee = MPT->getPointeeType();
35     if (Pointee->isFunctionType()) return 2;
36     return 1;
37   }
38 };
39
40 class ARMCXXABI : public ItaniumCXXABI {
41 public:
42   ARMCXXABI(ASTContext &Ctx) : ItaniumCXXABI(Ctx) { }
43 };
44 }
45
46 CXXABI *clang::CreateItaniumCXXABI(ASTContext &Ctx) {
47   return new ItaniumCXXABI(Ctx);
48 }
49
50 CXXABI *clang::CreateARMCXXABI(ASTContext &Ctx) {
51   return new ARMCXXABI(Ctx);
52 }