blob: c3fa4666537bbf76140d03c233e27a739cfe9cc1 [file] [log] [blame]
Charles Davis071cc7d2010-08-16 03:33:14 +00001//===------- 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
John McCallee79a4c2010-08-21 22:46:04 +000014//
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//
Charles Davis071cc7d2010-08-16 03:33:14 +000018//===----------------------------------------------------------------------===//
19
20#include "CXXABI.h"
21#include "clang/AST/ASTContext.h"
22#include "clang/AST/Type.h"
23
24using namespace clang;
25
26namespace {
27class ItaniumCXXABI : public CXXABI {
John McCallee79a4c2010-08-21 22:46:04 +000028protected:
Charles Davis071cc7d2010-08-16 03:33:14 +000029 ASTContext &Context;
30public:
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};
John McCallee79a4c2010-08-21 22:46:04 +000039
40class ARMCXXABI : public ItaniumCXXABI {
41public:
42 ARMCXXABI(ASTContext &Ctx) : ItaniumCXXABI(Ctx) { }
43};
Charles Davis071cc7d2010-08-16 03:33:14 +000044}
45
46CXXABI *clang::CreateItaniumCXXABI(ASTContext &Ctx) {
47 return new ItaniumCXXABI(Ctx);
48}
49
John McCallee79a4c2010-08-21 22:46:04 +000050CXXABI *clang::CreateARMCXXABI(ASTContext &Ctx) {
51 return new ARMCXXABI(Ctx);
52}