blob: dad226474fa7ffd75c43c88fae3d2dd8efd783a9 [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 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
Reid Kleckner3a52abf2013-03-28 20:02:56 +000033 /// Returns the width and alignment of a member pointer in bits.
34 virtual std::pair<uint64_t, unsigned>
35 getMemberPointerWidthAndAlign(const MemberPointerType *MPT) const = 0;
Charles Davis31575f72010-10-29 03:25:11 +000036
37 /// Returns the default calling convention for C++ methods.
Timur Iskhodzhanovc5098ad2012-07-12 09:50:54 +000038 virtual CallingConv getDefaultMethodCallConv(bool isVariadic) const = 0;
Anders Carlsson60a62632010-11-25 01:51:53 +000039
Reid Klecknerd8110b62013-09-10 20:14:30 +000040 /// Returns whether the given class is nearly empty, with just virtual
41 /// pointers and no data except possibly virtual bases.
Anders Carlsson60a62632010-11-25 01:51:53 +000042 virtual bool isNearlyEmpty(const CXXRecordDecl *RD) const = 0;
Reid Klecknerd8110b62013-09-10 20:14:30 +000043
44 /// Returns a new mangling number context for this C++ ABI.
45 virtual MangleNumberingContext *createMangleNumberingContext() const = 0;
David Majnemere7a818f2015-03-06 18:53:55 +000046
47 /// Adds a mapping from class to copy constructor for this C++ ABI.
48 virtual void addCopyConstructorForExceptionObject(CXXRecordDecl *,
49 CXXConstructorDecl *) = 0;
50
51 /// Retrieves the mapping from class to copy constructor for this C++ ABI.
52 virtual const CXXConstructorDecl *
53 getCopyConstructorForExceptionObject(CXXRecordDecl *) = 0;
David Majnemerdfa6d202015-03-11 18:36:39 +000054
55 virtual void addDefaultArgExprForConstructor(const CXXConstructorDecl *CD,
56 unsigned ParmIdx, Expr *DAE) = 0;
57
58 virtual Expr *getDefaultArgExprForConstructor(const CXXConstructorDecl *CD,
59 unsigned ParmIdx) = 0;
Charles Davis53c59df2010-08-16 03:33:14 +000060};
61
62/// Creates an instance of a C++ ABI class.
Charles Davis53c59df2010-08-16 03:33:14 +000063CXXABI *CreateItaniumCXXABI(ASTContext &Ctx);
64CXXABI *CreateMicrosoftCXXABI(ASTContext &Ctx);
65}
66
67#endif