blob: 06295b58178bfcd7f40e90486cc4997e5e097fe1 [file] [log] [blame]
Charles Davis53c59df2010-08-16 03:33:14 +00001//===----- 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 Kramer2f5db8b2014-08-13 16:25:19 +000015#ifndef LLVM_CLANG_LIB_AST_CXXABI_H
16#define LLVM_CLANG_LIB_AST_CXXABI_H
Charles Davis53c59df2010-08-16 03:33:14 +000017
Charles Davis31575f72010-10-29 03:25:11 +000018#include "clang/AST/Type.h"
19
Charles Davis53c59df2010-08-16 03:33:14 +000020namespace clang {
21
22class ASTContext;
David Majnemere7a818f2015-03-06 18:53:55 +000023class CXXConstructorDecl;
David Majnemer00350522015-08-31 18:48:39 +000024class DeclaratorDecl;
David Majnemerdfa6d202015-03-11 18:36:39 +000025class Expr;
Charles Davis53c59df2010-08-16 03:33:14 +000026class MemberPointerType;
Reid Klecknerd8110b62013-09-10 20:14:30 +000027class MangleNumberingContext;
Charles Davis53c59df2010-08-16 03:33:14 +000028
29/// Implements C++ ABI-specific semantic analysis functions.
30class CXXABI {
31public:
32 virtual ~CXXABI();
33
Erich Keane8a6b7402017-11-30 16:37:02 +000034 struct MemberPointerInfo {
35 uint64_t Width;
36 unsigned Align;
37 bool HasPadding;
38 };
39
40 /// Returns the width and alignment of a member pointer in bits, as well as
41 /// whether it has padding.
42 virtual MemberPointerInfo
43 getMemberPointerInfo(const MemberPointerType *MPT) const = 0;
Charles Davis31575f72010-10-29 03:25:11 +000044
45 /// Returns the default calling convention for C++ methods.
Timur Iskhodzhanovc5098ad2012-07-12 09:50:54 +000046 virtual CallingConv getDefaultMethodCallConv(bool isVariadic) const = 0;
Anders Carlsson60a62632010-11-25 01:51:53 +000047
Reid Klecknerd8110b62013-09-10 20:14:30 +000048 /// Returns whether the given class is nearly empty, with just virtual
49 /// pointers and no data except possibly virtual bases.
Anders Carlsson60a62632010-11-25 01:51:53 +000050 virtual bool isNearlyEmpty(const CXXRecordDecl *RD) const = 0;
Reid Klecknerd8110b62013-09-10 20:14:30 +000051
52 /// Returns a new mangling number context for this C++ ABI.
Justin Lebar20ebffc2016-10-10 16:26:19 +000053 virtual std::unique_ptr<MangleNumberingContext>
54 createMangleNumberingContext() const = 0;
David Majnemere7a818f2015-03-06 18:53:55 +000055
56 /// Adds a mapping from class to copy constructor for this C++ ABI.
57 virtual void addCopyConstructorForExceptionObject(CXXRecordDecl *,
58 CXXConstructorDecl *) = 0;
59
60 /// Retrieves the mapping from class to copy constructor for this C++ ABI.
61 virtual const CXXConstructorDecl *
62 getCopyConstructorForExceptionObject(CXXRecordDecl *) = 0;
David Majnemerdfa6d202015-03-11 18:36:39 +000063
David Majnemer00350522015-08-31 18:48:39 +000064 virtual void addTypedefNameForUnnamedTagDecl(TagDecl *TD,
65 TypedefNameDecl *DD) = 0;
66
67 virtual TypedefNameDecl *
68 getTypedefNameForUnnamedTagDecl(const TagDecl *TD) = 0;
69
70 virtual void addDeclaratorForUnnamedTagDecl(TagDecl *TD,
71 DeclaratorDecl *DD) = 0;
72
73 virtual DeclaratorDecl *getDeclaratorForUnnamedTagDecl(const TagDecl *TD) = 0;
Charles Davis53c59df2010-08-16 03:33:14 +000074};
75
76/// Creates an instance of a C++ ABI class.
Charles Davis53c59df2010-08-16 03:33:14 +000077CXXABI *CreateItaniumCXXABI(ASTContext &Ctx);
78CXXABI *CreateMicrosoftCXXABI(ASTContext &Ctx);
Alexander Kornienkoab9db512015-06-22 23:07:51 +000079}
Charles Davis53c59df2010-08-16 03:33:14 +000080
81#endif