CXXABI.h revision 314564
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
15#ifndef LLVM_CLANG_LIB_AST_CXXABI_H
16#define LLVM_CLANG_LIB_AST_CXXABI_H
17
18#include "clang/AST/Type.h"
19
20namespace clang {
21
22class ASTContext;
23class CXXConstructorDecl;
24class DeclaratorDecl;
25class Expr;
26class MemberPointerType;
27class MangleNumberingContext;
28
29/// Implements C++ ABI-specific semantic analysis functions.
30class CXXABI {
31public:
32  virtual ~CXXABI();
33
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;
37
38  /// Returns the default calling convention for C++ methods.
39  virtual CallingConv getDefaultMethodCallConv(bool isVariadic) const = 0;
40
41  /// Returns whether the given class is nearly empty, with just virtual
42  /// pointers and no data except possibly virtual bases.
43  virtual bool isNearlyEmpty(const CXXRecordDecl *RD) const = 0;
44
45  /// Returns a new mangling number context for this C++ ABI.
46  virtual std::unique_ptr<MangleNumberingContext>
47  createMangleNumberingContext() const = 0;
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;
56
57  virtual void addTypedefNameForUnnamedTagDecl(TagDecl *TD,
58                                               TypedefNameDecl *DD) = 0;
59
60  virtual TypedefNameDecl *
61  getTypedefNameForUnnamedTagDecl(const TagDecl *TD) = 0;
62
63  virtual void addDeclaratorForUnnamedTagDecl(TagDecl *TD,
64                                              DeclaratorDecl *DD) = 0;
65
66  virtual DeclaratorDecl *getDeclaratorForUnnamedTagDecl(const TagDecl *TD) = 0;
67};
68
69/// Creates an instance of a C++ ABI class.
70CXXABI *CreateItaniumCXXABI(ASTContext &Ctx);
71CXXABI *CreateMicrosoftCXXABI(ASTContext &Ctx);
72}
73
74#endif
75