CXXABI.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //===----- CXXABI.h - Interface to C++ ABIs ---------------------*- C++ -*-===//
  2. //
  3. // 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
  6. //
  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. #ifndef LLVM_CLANG_LIB_AST_CXXABI_H
  14. #define LLVM_CLANG_LIB_AST_CXXABI_H
  15. #include "clang/AST/Type.h"
  16. namespace clang {
  17. class ASTContext;
  18. class CXXConstructorDecl;
  19. class DeclaratorDecl;
  20. class MangleContext;
  21. class MangleNumberingContext;
  22. class MemberPointerType;
  23. /// Implements C++ ABI-specific semantic analysis functions.
  24. class CXXABI {
  25. public:
  26. virtual ~CXXABI();
  27. struct MemberPointerInfo {
  28. uint64_t Width;
  29. unsigned Align;
  30. bool HasPadding;
  31. };
  32. /// Returns the width and alignment of a member pointer in bits, as well as
  33. /// whether it has padding.
  34. virtual MemberPointerInfo
  35. getMemberPointerInfo(const MemberPointerType *MPT) const = 0;
  36. /// Returns the default calling convention for C++ methods.
  37. virtual CallingConv getDefaultMethodCallConv(bool isVariadic) const = 0;
  38. /// Returns whether the given class is nearly empty, with just virtual
  39. /// pointers and no data except possibly virtual bases.
  40. virtual bool isNearlyEmpty(const CXXRecordDecl *RD) const = 0;
  41. /// Returns a new mangling number context for this C++ ABI.
  42. virtual std::unique_ptr<MangleNumberingContext>
  43. createMangleNumberingContext() const = 0;
  44. /// Adds a mapping from class to copy constructor for this C++ ABI.
  45. virtual void addCopyConstructorForExceptionObject(CXXRecordDecl *,
  46. CXXConstructorDecl *) = 0;
  47. /// Retrieves the mapping from class to copy constructor for this C++ ABI.
  48. virtual const CXXConstructorDecl *
  49. getCopyConstructorForExceptionObject(CXXRecordDecl *) = 0;
  50. virtual void addTypedefNameForUnnamedTagDecl(TagDecl *TD,
  51. TypedefNameDecl *DD) = 0;
  52. virtual TypedefNameDecl *
  53. getTypedefNameForUnnamedTagDecl(const TagDecl *TD) = 0;
  54. virtual void addDeclaratorForUnnamedTagDecl(TagDecl *TD,
  55. DeclaratorDecl *DD) = 0;
  56. virtual DeclaratorDecl *getDeclaratorForUnnamedTagDecl(const TagDecl *TD) = 0;
  57. };
  58. /// Creates an instance of a C++ ABI class.
  59. CXXABI *CreateItaniumCXXABI(ASTContext &Ctx);
  60. CXXABI *CreateMicrosoftCXXABI(ASTContext &Ctx);
  61. std::unique_ptr<MangleNumberingContext>
  62. createItaniumNumberingContext(MangleContext *);
  63. }
  64. #endif