CXXABI.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. #ifndef LLVM_CLANG_LIB_AST_CXXABI_H
  15. #define LLVM_CLANG_LIB_AST_CXXABI_H
  16. #include "clang/AST/Type.h"
  17. namespace clang {
  18. class ASTContext;
  19. class CXXConstructorDecl;
  20. class Expr;
  21. class MemberPointerType;
  22. class MangleNumberingContext;
  23. /// Implements C++ ABI-specific semantic analysis functions.
  24. class CXXABI {
  25. public:
  26. virtual ~CXXABI();
  27. /// Returns the width and alignment of a member pointer in bits.
  28. virtual std::pair<uint64_t, unsigned>
  29. getMemberPointerWidthAndAlign(const MemberPointerType *MPT) const = 0;
  30. /// Returns the default calling convention for C++ methods.
  31. virtual CallingConv getDefaultMethodCallConv(bool isVariadic) const = 0;
  32. /// Returns whether the given class is nearly empty, with just virtual
  33. /// pointers and no data except possibly virtual bases.
  34. virtual bool isNearlyEmpty(const CXXRecordDecl *RD) const = 0;
  35. /// Returns a new mangling number context for this C++ ABI.
  36. virtual MangleNumberingContext *createMangleNumberingContext() const = 0;
  37. /// Adds a mapping from class to copy constructor for this C++ ABI.
  38. virtual void addCopyConstructorForExceptionObject(CXXRecordDecl *,
  39. CXXConstructorDecl *) = 0;
  40. /// Retrieves the mapping from class to copy constructor for this C++ ABI.
  41. virtual const CXXConstructorDecl *
  42. getCopyConstructorForExceptionObject(CXXRecordDecl *) = 0;
  43. virtual void addDefaultArgExprForConstructor(const CXXConstructorDecl *CD,
  44. unsigned ParmIdx, Expr *DAE) = 0;
  45. virtual Expr *getDefaultArgExprForConstructor(const CXXConstructorDecl *CD,
  46. unsigned ParmIdx) = 0;
  47. };
  48. /// Creates an instance of a C++ ABI class.
  49. CXXABI *CreateItaniumCXXABI(ASTContext &Ctx);
  50. CXXABI *CreateMicrosoftCXXABI(ASTContext &Ctx);
  51. }
  52. #endif