Charles Davis | 071cc7d | 2010-08-16 03:33:14 +0000 | [diff] [blame] | 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 |
John McCall | ee79a4c | 2010-08-21 22:46:04 +0000 | [diff] [blame] | 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 | // |
Charles Davis | 071cc7d | 2010-08-16 03:33:14 +0000 | [diff] [blame] | 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 { |
John McCall | ee79a4c | 2010-08-21 22:46:04 +0000 | [diff] [blame] | 28 | protected: |
Charles Davis | 071cc7d | 2010-08-16 03:33:14 +0000 | [diff] [blame] | 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 | }; |
John McCall | ee79a4c | 2010-08-21 22:46:04 +0000 | [diff] [blame] | 39 | |
| 40 | class ARMCXXABI : public ItaniumCXXABI { |
| 41 | public: |
| 42 | ARMCXXABI(ASTContext &Ctx) : ItaniumCXXABI(Ctx) { } |
| 43 | }; |
Charles Davis | 071cc7d | 2010-08-16 03:33:14 +0000 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | CXXABI *clang::CreateItaniumCXXABI(ASTContext &Ctx) { |
| 47 | return new ItaniumCXXABI(Ctx); |
| 48 | } |
| 49 | |
John McCall | ee79a4c | 2010-08-21 22:46:04 +0000 | [diff] [blame] | 50 | CXXABI *clang::CreateARMCXXABI(ASTContext &Ctx) { |
| 51 | return new ARMCXXABI(Ctx); |
| 52 | } |