| Charles Davis | 53c59df | 2010-08-16 03:33:14 +0000 | [diff] [blame] | 1 | //===----- CXXABI.h - Interface to C++ ABIs ---------------------*- C++ -*-===// |
| 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 an abstract class for C++ AST support. Concrete |
| 11 | // subclasses of this implement AST support for specific C++ ABIs. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| Benjamin Kramer | 2f5db8b | 2014-08-13 16:25:19 +0000 | [diff] [blame] | 15 | #ifndef LLVM_CLANG_LIB_AST_CXXABI_H |
| 16 | #define LLVM_CLANG_LIB_AST_CXXABI_H |
| Charles Davis | 53c59df | 2010-08-16 03:33:14 +0000 | [diff] [blame] | 17 | |
| Charles Davis | 31575f7 | 2010-10-29 03:25:11 +0000 | [diff] [blame] | 18 | #include "clang/AST/Type.h" |
| 19 | |
| Charles Davis | 53c59df | 2010-08-16 03:33:14 +0000 | [diff] [blame] | 20 | namespace clang { |
| 21 | |
| 22 | class ASTContext; |
| David Majnemer | e7a818f | 2015-03-06 18:53:55 +0000 | [diff] [blame] | 23 | class CXXConstructorDecl; |
| David Majnemer | 0035052 | 2015-08-31 18:48:39 +0000 | [diff] [blame] | 24 | class DeclaratorDecl; |
| David Majnemer | dfa6d20 | 2015-03-11 18:36:39 +0000 | [diff] [blame] | 25 | class Expr; |
| Charles Davis | 53c59df | 2010-08-16 03:33:14 +0000 | [diff] [blame] | 26 | class MemberPointerType; |
| Reid Kleckner | d8110b6 | 2013-09-10 20:14:30 +0000 | [diff] [blame] | 27 | class MangleNumberingContext; |
| Charles Davis | 53c59df | 2010-08-16 03:33:14 +0000 | [diff] [blame] | 28 | |
| 29 | /// Implements C++ ABI-specific semantic analysis functions. |
| 30 | class CXXABI { |
| 31 | public: |
| 32 | virtual ~CXXABI(); |
| 33 | |
| Reid Kleckner | 3a52abf | 2013-03-28 20:02:56 +0000 | [diff] [blame] | 34 | /// Returns the width and alignment of a member pointer in bits. |
| 35 | virtual std::pair<uint64_t, unsigned> |
| 36 | getMemberPointerWidthAndAlign(const MemberPointerType *MPT) const = 0; |
| Charles Davis | 31575f7 | 2010-10-29 03:25:11 +0000 | [diff] [blame] | 37 | |
| 38 | /// Returns the default calling convention for C++ methods. |
| Timur Iskhodzhanov | c5098ad | 2012-07-12 09:50:54 +0000 | [diff] [blame] | 39 | virtual CallingConv getDefaultMethodCallConv(bool isVariadic) const = 0; |
| Anders Carlsson | 60a6263 | 2010-11-25 01:51:53 +0000 | [diff] [blame] | 40 | |
| Reid Kleckner | d8110b6 | 2013-09-10 20:14:30 +0000 | [diff] [blame] | 41 | /// Returns whether the given class is nearly empty, with just virtual |
| 42 | /// pointers and no data except possibly virtual bases. |
| Anders Carlsson | 60a6263 | 2010-11-25 01:51:53 +0000 | [diff] [blame] | 43 | virtual bool isNearlyEmpty(const CXXRecordDecl *RD) const = 0; |
| Reid Kleckner | d8110b6 | 2013-09-10 20:14:30 +0000 | [diff] [blame] | 44 | |
| 45 | /// Returns a new mangling number context for this C++ ABI. |
| Justin Lebar | 20ebffc | 2016-10-10 16:26:19 +0000 | [diff] [blame^] | 46 | virtual std::unique_ptr<MangleNumberingContext> |
| 47 | createMangleNumberingContext() const = 0; |
| David Majnemer | e7a818f | 2015-03-06 18:53:55 +0000 | [diff] [blame] | 48 | |
| 49 | /// Adds a mapping from class to copy constructor for this C++ ABI. |
| 50 | virtual void addCopyConstructorForExceptionObject(CXXRecordDecl *, |
| 51 | CXXConstructorDecl *) = 0; |
| 52 | |
| 53 | /// Retrieves the mapping from class to copy constructor for this C++ ABI. |
| 54 | virtual const CXXConstructorDecl * |
| 55 | getCopyConstructorForExceptionObject(CXXRecordDecl *) = 0; |
| David Majnemer | dfa6d20 | 2015-03-11 18:36:39 +0000 | [diff] [blame] | 56 | |
| 57 | virtual void addDefaultArgExprForConstructor(const CXXConstructorDecl *CD, |
| 58 | unsigned ParmIdx, Expr *DAE) = 0; |
| 59 | |
| 60 | virtual Expr *getDefaultArgExprForConstructor(const CXXConstructorDecl *CD, |
| 61 | unsigned ParmIdx) = 0; |
| David Majnemer | 0035052 | 2015-08-31 18:48:39 +0000 | [diff] [blame] | 62 | |
| 63 | virtual void addTypedefNameForUnnamedTagDecl(TagDecl *TD, |
| 64 | TypedefNameDecl *DD) = 0; |
| 65 | |
| 66 | virtual TypedefNameDecl * |
| 67 | getTypedefNameForUnnamedTagDecl(const TagDecl *TD) = 0; |
| 68 | |
| 69 | virtual void addDeclaratorForUnnamedTagDecl(TagDecl *TD, |
| 70 | DeclaratorDecl *DD) = 0; |
| 71 | |
| 72 | virtual DeclaratorDecl *getDeclaratorForUnnamedTagDecl(const TagDecl *TD) = 0; |
| Charles Davis | 53c59df | 2010-08-16 03:33:14 +0000 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | /// Creates an instance of a C++ ABI class. |
| Charles Davis | 53c59df | 2010-08-16 03:33:14 +0000 | [diff] [blame] | 76 | CXXABI *CreateItaniumCXXABI(ASTContext &Ctx); |
| 77 | CXXABI *CreateMicrosoftCXXABI(ASTContext &Ctx); |
| Alexander Kornienko | ab9db51 | 2015-06-22 23:07:51 +0000 | [diff] [blame] | 78 | } |
| Charles Davis | 53c59df | 2010-08-16 03:33:14 +0000 | [diff] [blame] | 79 | |
| 80 | #endif |