|
| 1 | +//===--- ItaniumRTTIBuilder.h - LLVM Backend Utilities ----------*- 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 | +#ifndef LLVM_CLANG_LIB_CODEGENSHARED_ITANIUMRTTIBUILDER_H |
| 10 | +#define LLVM_CLANG_LIB_CODEGENSHARED_ITANIUMRTTIBUILDER_H |
| 11 | + |
| 12 | +#include "clang/AST/DeclCXX.h" |
| 13 | +#include "clang/AST/TypeBase.h" |
| 14 | +#include "llvm/ADT/SmallPtrSet.h" |
| 15 | + |
| 16 | +namespace clang { |
| 17 | + |
| 18 | +namespace CodeGenShared { |
| 19 | + |
| 20 | +// Pointer type info flags. |
| 21 | +enum { |
| 22 | + /// PTI_Const - Type has const qualifier. |
| 23 | + PTI_Const = 0x1, |
| 24 | + |
| 25 | + /// PTI_Volatile - Type has volatile qualifier. |
| 26 | + PTI_Volatile = 0x2, |
| 27 | + |
| 28 | + /// PTI_Restrict - Type has restrict qualifier. |
| 29 | + PTI_Restrict = 0x4, |
| 30 | + |
| 31 | + /// PTI_Incomplete - Type is incomplete. |
| 32 | + PTI_Incomplete = 0x8, |
| 33 | + |
| 34 | + /// PTI_ContainingClassIncomplete - Containing class is incomplete. |
| 35 | + /// (in pointer to member). |
| 36 | + PTI_ContainingClassIncomplete = 0x10, |
| 37 | + |
| 38 | + /// PTI_TransactionSafe - Pointee is transaction_safe function (C++ TM TS). |
| 39 | + // PTI_TransactionSafe = 0x20, |
| 40 | + |
| 41 | + /// PTI_Noexcept - Pointee is noexcept function (C++1z). |
| 42 | + PTI_Noexcept = 0x40, |
| 43 | +}; |
| 44 | + |
| 45 | +// VMI type info flags. |
| 46 | +enum { |
| 47 | + /// VMI_NonDiamondRepeat - Class has non-diamond repeated inheritance. |
| 48 | + VMI_NonDiamondRepeat = 0x1, |
| 49 | + |
| 50 | + /// VMI_DiamondShaped - Class is diamond shaped. |
| 51 | + VMI_DiamondShaped = 0x2 |
| 52 | +}; |
| 53 | + |
| 54 | +// Base class type info flags. |
| 55 | +enum { |
| 56 | + /// BCTI_Virtual - Base class is virtual. |
| 57 | + BCTI_Virtual = 0x1, |
| 58 | + |
| 59 | + /// BCTI_Public - Base class is public. |
| 60 | + BCTI_Public = 0x2 |
| 61 | +}; |
| 62 | + |
| 63 | +/// TypeInfoIsInStandardLibrary - Given a builtin type, returns whether the type |
| 64 | +/// info for that type is defined in the standard library. |
| 65 | +bool TypeInfoIsInStandardLibrary(const BuiltinType *Ty); |
| 66 | + |
| 67 | +bool TypeInfoIsInStandardLibrary(const PointerType *PointerTy); |
| 68 | + |
| 69 | +/// IsStandardLibraryRTTIDescriptor - Returns whether the type |
| 70 | +/// information for the given type exists in the standard library. |
| 71 | +bool IsStandardLibraryRTTIDescriptor(QualType Ty); |
| 72 | + |
| 73 | +/// IsIncompleteClassType - Returns whether the given record type is incomplete. |
| 74 | +bool IsIncompleteClassType(const RecordType *RecordTy); |
| 75 | + |
| 76 | +/// ContainsIncompleteClassType - Returns whether the given type contains an |
| 77 | +/// incomplete class type. This is true if |
| 78 | +/// |
| 79 | +/// * The given type is an incomplete class type. |
| 80 | +/// * The given type is a pointer type whose pointee type contains an |
| 81 | +/// incomplete class type. |
| 82 | +/// * The given type is a member pointer type whose class is an incomplete |
| 83 | +/// class type. |
| 84 | +/// * The given type is a member pointer type whoise pointee type contains an |
| 85 | +/// incomplete class type. |
| 86 | +/// is an indirect or direct pointer to an incomplete class type. |
| 87 | +bool ContainsIncompleteClassType(QualType Ty); |
| 88 | + |
| 89 | +// CanUseSingleInheritance - Return whether the given record decl has a "single, |
| 90 | +// public, non-virtual base at offset zero (i.e. the derived class is dynamic |
| 91 | +// iff the base is)", according to Itanium C++ ABI, 2.95p6b. |
| 92 | +bool CanUseSingleInheritance(const CXXRecordDecl *RD); |
| 93 | + |
| 94 | +const char *VTableClassNameForType(const Type *Ty); |
| 95 | + |
| 96 | +/// Compute the flags for a __pbase_type_info, and remove the corresponding |
| 97 | +/// pieces from \p Type. |
| 98 | +unsigned extractPBaseFlags(ASTContext &Ctx, QualType &Type); |
| 99 | + |
| 100 | +/// SeenBases - Contains virtual and non-virtual bases seen when traversing |
| 101 | +/// a class hierarchy. |
| 102 | +struct SeenBases { |
| 103 | + llvm::SmallPtrSet<const CXXRecordDecl *, 16> NonVirtualBases; |
| 104 | + llvm::SmallPtrSet<const CXXRecordDecl *, 16> VirtualBases; |
| 105 | +}; |
| 106 | + |
| 107 | +/// ComputeVMIClassTypeInfoFlags - Compute the value of the flags member in |
| 108 | +/// abi::__vmi_class_type_info. |
| 109 | +unsigned ComputeVMIClassTypeInfoFlags(const CXXBaseSpecifier *Base, |
| 110 | + SeenBases &Bases); |
| 111 | + |
| 112 | +unsigned ComputeVMIClassTypeInfoFlags(const CXXRecordDecl *RD); |
| 113 | + |
| 114 | +} // namespace CodeGenShared |
| 115 | +} // namespace clang |
| 116 | + |
| 117 | +#endif |
0 commit comments