| Charles Davis | 53c59df | 2010-08-16 03:33:14 +0000 | [diff] [blame] | 1 | //===----- CXXABI.h - Interface to C++ ABIs ---------------------*- C++ -*-===// |
| 2 | // |
| Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| Charles Davis | 53c59df | 2010-08-16 03:33:14 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This provides an abstract class for C++ AST support. Concrete |
| 10 | // subclasses of this implement AST support for specific C++ ABIs. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| Benjamin Kramer | 2f5db8b | 2014-08-13 16:25:19 +0000 | [diff] [blame] | 14 | #ifndef LLVM_CLANG_LIB_AST_CXXABI_H |
| 15 | #define LLVM_CLANG_LIB_AST_CXXABI_H |
| Charles Davis | 53c59df | 2010-08-16 03:33:14 +0000 | [diff] [blame] | 16 | |
| Charles Davis | 31575f7 | 2010-10-29 03:25:11 +0000 | [diff] [blame] | 17 | #include "clang/AST/Type.h" |
| 18 | |
| Charles Davis | 53c59df | 2010-08-16 03:33:14 +0000 | [diff] [blame] | 19 | namespace clang { |
| 20 | |
| 21 | class ASTContext; |
| David Majnemer | e7a818f | 2015-03-06 18:53:55 +0000 | [diff] [blame] | 22 | class CXXConstructorDecl; |
| David Majnemer | 0035052 | 2015-08-31 18:48:39 +0000 | [diff] [blame] | 23 | class DeclaratorDecl; |
| David Majnemer | dfa6d20 | 2015-03-11 18:36:39 +0000 | [diff] [blame] | 24 | class Expr; |
| Charles Davis | 53c59df | 2010-08-16 03:33:14 +0000 | [diff] [blame] | 25 | class MemberPointerType; |
| Reid Kleckner | d8110b6 | 2013-09-10 20:14:30 +0000 | [diff] [blame] | 26 | class MangleNumberingContext; |
| Charles Davis | 53c59df | 2010-08-16 03:33:14 +0000 | [diff] [blame] | 27 | |
| 28 | /// Implements C++ ABI-specific semantic analysis functions. |
| 29 | class CXXABI { |
| 30 | public: |
| 31 | virtual ~CXXABI(); |
| 32 | |
| Erich Keane | 8a6b740 | 2017-11-30 16:37:02 +0000 | [diff] [blame] | 33 | struct MemberPointerInfo { |
| 34 | uint64_t Width; |
| 35 | unsigned Align; |
| 36 | bool HasPadding; |
| 37 | }; |
| 38 | |
| 39 | /// Returns the width and alignment of a member pointer in bits, as well as |
| 40 | /// whether it has padding. |
| 41 | virtual MemberPointerInfo |
| 42 | getMemberPointerInfo(const MemberPointerType *MPT) const = 0; |
| Charles Davis | 31575f7 | 2010-10-29 03:25:11 +0000 | [diff] [blame] | 43 | |
| 44 | /// Returns the default calling convention for C++ methods. |
| Timur Iskhodzhanov | c5098ad | 2012-07-12 09:50:54 +0000 | [diff] [blame] | 45 | virtual CallingConv getDefaultMethodCallConv(bool isVariadic) const = 0; |
| Anders Carlsson | 60a6263 | 2010-11-25 01:51:53 +0000 | [diff] [blame] | 46 | |
| Reid Kleckner | d8110b6 | 2013-09-10 20:14:30 +0000 | [diff] [blame] | 47 | /// Returns whether the given class is nearly empty, with just virtual |
| 48 | /// pointers and no data except possibly virtual bases. |
| Anders Carlsson | 60a6263 | 2010-11-25 01:51:53 +0000 | [diff] [blame] | 49 | virtual bool isNearlyEmpty(const CXXRecordDecl *RD) const = 0; |
| Reid Kleckner | d8110b6 | 2013-09-10 20:14:30 +0000 | [diff] [blame] | 50 | |
| 51 | /// Returns a new mangling number context for this C++ ABI. |
| Justin Lebar | 20ebffc | 2016-10-10 16:26:19 +0000 | [diff] [blame] | 52 | virtual std::unique_ptr<MangleNumberingContext> |
| 53 | createMangleNumberingContext() const = 0; |
| David Majnemer | e7a818f | 2015-03-06 18:53:55 +0000 | [diff] [blame] | 54 | |
| 55 | /// Adds a mapping from class to copy constructor for this C++ ABI. |
| 56 | virtual void addCopyConstructorForExceptionObject(CXXRecordDecl *, |
| 57 | CXXConstructorDecl *) = 0; |
| 58 | |
| 59 | /// Retrieves the mapping from class to copy constructor for this C++ ABI. |
| 60 | virtual const CXXConstructorDecl * |
| 61 | getCopyConstructorForExceptionObject(CXXRecordDecl *) = 0; |
| David Majnemer | dfa6d20 | 2015-03-11 18:36:39 +0000 | [diff] [blame] | 62 | |
| David Majnemer | 0035052 | 2015-08-31 18:48:39 +0000 | [diff] [blame] | 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 |