10b57cec5SDimitry Andric //===----- CXXABI.h - Interface to C++ ABIs ---------------------*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric // This provides an abstract class for C++ AST support. Concrete 100b57cec5SDimitry Andric // subclasses of this implement AST support for specific C++ ABIs. 110b57cec5SDimitry Andric // 120b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 130b57cec5SDimitry Andric 140b57cec5SDimitry Andric #ifndef LLVM_CLANG_LIB_AST_CXXABI_H 150b57cec5SDimitry Andric #define LLVM_CLANG_LIB_AST_CXXABI_H 160b57cec5SDimitry Andric 170b57cec5SDimitry Andric #include "clang/AST/Type.h" 180b57cec5SDimitry Andric 190b57cec5SDimitry Andric namespace clang { 200b57cec5SDimitry Andric 210b57cec5SDimitry Andric class ASTContext; 220b57cec5SDimitry Andric class CXXConstructorDecl; 230b57cec5SDimitry Andric class DeclaratorDecl; 24*d409305fSDimitry Andric class MangleContext; 250b57cec5SDimitry Andric class MangleNumberingContext; 26*d409305fSDimitry Andric class MemberPointerType; 270b57cec5SDimitry Andric 280b57cec5SDimitry Andric /// Implements C++ ABI-specific semantic analysis functions. 290b57cec5SDimitry Andric class CXXABI { 300b57cec5SDimitry Andric public: 310b57cec5SDimitry Andric virtual ~CXXABI(); 320b57cec5SDimitry Andric 330b57cec5SDimitry Andric struct MemberPointerInfo { 340b57cec5SDimitry Andric uint64_t Width; 350b57cec5SDimitry Andric unsigned Align; 360b57cec5SDimitry Andric bool HasPadding; 370b57cec5SDimitry Andric }; 380b57cec5SDimitry Andric 390b57cec5SDimitry Andric /// Returns the width and alignment of a member pointer in bits, as well as 400b57cec5SDimitry Andric /// whether it has padding. 410b57cec5SDimitry Andric virtual MemberPointerInfo 420b57cec5SDimitry Andric getMemberPointerInfo(const MemberPointerType *MPT) const = 0; 430b57cec5SDimitry Andric 440b57cec5SDimitry Andric /// Returns the default calling convention for C++ methods. 450b57cec5SDimitry Andric virtual CallingConv getDefaultMethodCallConv(bool isVariadic) const = 0; 460b57cec5SDimitry Andric 470b57cec5SDimitry Andric /// Returns whether the given class is nearly empty, with just virtual 480b57cec5SDimitry Andric /// pointers and no data except possibly virtual bases. 490b57cec5SDimitry Andric virtual bool isNearlyEmpty(const CXXRecordDecl *RD) const = 0; 500b57cec5SDimitry Andric 510b57cec5SDimitry Andric /// Returns a new mangling number context for this C++ ABI. 520b57cec5SDimitry Andric virtual std::unique_ptr<MangleNumberingContext> 530b57cec5SDimitry Andric createMangleNumberingContext() const = 0; 540b57cec5SDimitry Andric 550b57cec5SDimitry Andric /// Adds a mapping from class to copy constructor for this C++ ABI. 560b57cec5SDimitry Andric virtual void addCopyConstructorForExceptionObject(CXXRecordDecl *, 570b57cec5SDimitry Andric CXXConstructorDecl *) = 0; 580b57cec5SDimitry Andric 590b57cec5SDimitry Andric /// Retrieves the mapping from class to copy constructor for this C++ ABI. 600b57cec5SDimitry Andric virtual const CXXConstructorDecl * 610b57cec5SDimitry Andric getCopyConstructorForExceptionObject(CXXRecordDecl *) = 0; 620b57cec5SDimitry Andric 630b57cec5SDimitry Andric virtual void addTypedefNameForUnnamedTagDecl(TagDecl *TD, 640b57cec5SDimitry Andric TypedefNameDecl *DD) = 0; 650b57cec5SDimitry Andric 660b57cec5SDimitry Andric virtual TypedefNameDecl * 670b57cec5SDimitry Andric getTypedefNameForUnnamedTagDecl(const TagDecl *TD) = 0; 680b57cec5SDimitry Andric 690b57cec5SDimitry Andric virtual void addDeclaratorForUnnamedTagDecl(TagDecl *TD, 700b57cec5SDimitry Andric DeclaratorDecl *DD) = 0; 710b57cec5SDimitry Andric 720b57cec5SDimitry Andric virtual DeclaratorDecl *getDeclaratorForUnnamedTagDecl(const TagDecl *TD) = 0; 730b57cec5SDimitry Andric }; 740b57cec5SDimitry Andric 750b57cec5SDimitry Andric /// Creates an instance of a C++ ABI class. 760b57cec5SDimitry Andric CXXABI *CreateItaniumCXXABI(ASTContext &Ctx); 770b57cec5SDimitry Andric CXXABI *CreateMicrosoftCXXABI(ASTContext &Ctx); 78*d409305fSDimitry Andric std::unique_ptr<MangleNumberingContext> 79*d409305fSDimitry Andric createItaniumNumberingContext(MangleContext *); 800b57cec5SDimitry Andric } 810b57cec5SDimitry Andric 820b57cec5SDimitry Andric #endif 83