blob: 31cb369187266cd41ed0d722515e7d04814d9a00 [file] [log] [blame]
Charles Davis53c59df2010-08-16 03:33:14 +00001//===----- CXXABI.h - Interface to C++ ABIs ---------------------*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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 Davis53c59df2010-08-16 03:33:14 +00006//
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 Kramer2f5db8b2014-08-13 16:25:19 +000014#ifndef LLVM_CLANG_LIB_AST_CXXABI_H
15#define LLVM_CLANG_LIB_AST_CXXABI_H
Charles Davis53c59df2010-08-16 03:33:14 +000016
Charles Davis31575f72010-10-29 03:25:11 +000017#include "clang/AST/Type.h"
18
Charles Davis53c59df2010-08-16 03:33:14 +000019namespace clang {
20
21class ASTContext;
David Majnemere7a818f2015-03-06 18:53:55 +000022class CXXConstructorDecl;
David Majnemer00350522015-08-31 18:48:39 +000023class DeclaratorDecl;
David Majnemerdfa6d202015-03-11 18:36:39 +000024class Expr;
Charles Davis53c59df2010-08-16 03:33:14 +000025class MemberPointerType;
Reid Klecknerd8110b62013-09-10 20:14:30 +000026class MangleNumberingContext;
Charles Davis53c59df2010-08-16 03:33:14 +000027
28/// Implements C++ ABI-specific semantic analysis functions.
29class CXXABI {
30public:
31 virtual ~CXXABI();
32
Erich Keane8a6b7402017-11-30 16:37:02 +000033 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 Davis31575f72010-10-29 03:25:11 +000043
44 /// Returns the default calling convention for C++ methods.
Timur Iskhodzhanovc5098ad2012-07-12 09:50:54 +000045 virtual CallingConv getDefaultMethodCallConv(bool isVariadic) const = 0;
Anders Carlsson60a62632010-11-25 01:51:53 +000046
Reid Klecknerd8110b62013-09-10 20:14:30 +000047 /// Returns whether the given class is nearly empty, with just virtual
48 /// pointers and no data except possibly virtual bases.
Anders Carlsson60a62632010-11-25 01:51:53 +000049 virtual bool isNearlyEmpty(const CXXRecordDecl *RD) const = 0;
Reid Klecknerd8110b62013-09-10 20:14:30 +000050
51 /// Returns a new mangling number context for this C++ ABI.
Justin Lebar20ebffc2016-10-10 16:26:19 +000052 virtual std::unique_ptr<MangleNumberingContext>
53 createMangleNumberingContext() const = 0;
David Majnemere7a818f2015-03-06 18:53:55 +000054
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 Majnemerdfa6d202015-03-11 18:36:39 +000062
David Majnemer00350522015-08-31 18:48:39 +000063 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 Davis53c59df2010-08-16 03:33:14 +000073};
74
75/// Creates an instance of a C++ ABI class.
Charles Davis53c59df2010-08-16 03:33:14 +000076CXXABI *CreateItaniumCXXABI(ASTContext &Ctx);
77CXXABI *CreateMicrosoftCXXABI(ASTContext &Ctx);
Alexander Kornienkoab9db512015-06-22 23:07:51 +000078}
Charles Davis53c59df2010-08-16 03:33:14 +000079
80#endif