brintos

brintos / llvm-project-archived public Read only

0
0
Text · 9.5 KiB · 328a02e Raw
259 lines · c
1//===----------------------------------------------------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef __PRIVATE_TYPEINFO_H_10#define __PRIVATE_TYPEINFO_H_11 12#include "__cxxabi_config.h"13 14#include <typeinfo>15#include <stddef.h>16 17namespace __cxxabiv1 {18 19class _LIBCXXABI_TYPE_VIS __shim_type_info : public std::type_info {20public:21  _LIBCXXABI_HIDDEN virtual ~__shim_type_info();22 23  _LIBCXXABI_HIDDEN virtual void noop1() const;24  _LIBCXXABI_HIDDEN virtual void noop2() const;25  _LIBCXXABI_HIDDEN virtual bool can_catch(const __shim_type_info *thrown_type,26                                           void *&adjustedPtr) const = 0;27};28 29class _LIBCXXABI_TYPE_VIS __fundamental_type_info : public __shim_type_info {30public:31  _LIBCXXABI_HIDDEN virtual ~__fundamental_type_info();32  _LIBCXXABI_HIDDEN virtual bool can_catch(const __shim_type_info *,33                                           void *&) const;34};35 36class _LIBCXXABI_TYPE_VIS __array_type_info : public __shim_type_info {37public:38  _LIBCXXABI_HIDDEN virtual ~__array_type_info();39  _LIBCXXABI_HIDDEN virtual bool can_catch(const __shim_type_info *,40                                           void *&) const;41};42 43class _LIBCXXABI_TYPE_VIS __function_type_info : public __shim_type_info {44public:45  _LIBCXXABI_HIDDEN virtual ~__function_type_info();46  _LIBCXXABI_HIDDEN virtual bool can_catch(const __shim_type_info *,47                                           void *&) const;48};49 50class _LIBCXXABI_TYPE_VIS __enum_type_info : public __shim_type_info {51public:52  _LIBCXXABI_HIDDEN virtual ~__enum_type_info();53  _LIBCXXABI_HIDDEN virtual bool can_catch(const __shim_type_info *,54                                           void *&) const;55};56 57enum58{59    unknown = 0,60    public_path,61    not_public_path,62    yes,63    no64};65 66class _LIBCXXABI_TYPE_VIS __class_type_info;67 68struct _LIBCXXABI_HIDDEN __dynamic_cast_info69{70// const data supplied to the search:71 72    const __class_type_info* dst_type;73    const void* static_ptr;74    const __class_type_info* static_type;75    ptrdiff_t src2dst_offset;76 77// Data that represents the answer:78 79    // pointer to a dst_type which has (static_ptr, static_type) above it80    const void* dst_ptr_leading_to_static_ptr;81    // pointer to a dst_type which does not have (static_ptr, static_type) above it82    const void* dst_ptr_not_leading_to_static_ptr;83 84    // The following three paths are either unknown, public_path or not_public_path.85    // access of path from dst_ptr_leading_to_static_ptr to (static_ptr, static_type)86    int path_dst_ptr_to_static_ptr;87    // access of path from (dynamic_ptr, dynamic_type) to (static_ptr, static_type)88    //    when there is no dst_type along the path89    int path_dynamic_ptr_to_static_ptr;90    // access of path from (dynamic_ptr, dynamic_type) to dst_type91    //    (not used if there is a (static_ptr, static_type) above a dst_type).92    int path_dynamic_ptr_to_dst_ptr;93 94    // Number of dst_types below (static_ptr, static_type)95    int number_to_static_ptr;96    // Number of dst_types not below (static_ptr, static_type)97    int number_to_dst_ptr;98 99// Data that helps stop the search before the entire tree is searched:100 101    // is_dst_type_derived_from_static_type is either unknown, yes or no.102    int is_dst_type_derived_from_static_type;103    // Number of dst_type in tree.  If 0, then that means unknown.104    int number_of_dst_type;105    // communicates to a dst_type node that (static_ptr, static_type) was found106    //    above it.107    bool found_our_static_ptr;108    // communicates to a dst_type node that a static_type was found109    //    above it, but it wasn't (static_ptr, static_type)110    bool found_any_static_type;111    // Set whenever a search can be stopped112    bool search_done;113 114    // Data that modifies the search mechanism.115 116    // There is no object (seen when we throw a null pointer to object).117    bool have_object;118    // Virtual base119    const void* vbase_cookie;120};121 122// Has no base class123class _LIBCXXABI_TYPE_VIS __class_type_info : public __shim_type_info {124public:125  _LIBCXXABI_HIDDEN virtual ~__class_type_info();126 127  _LIBCXXABI_HIDDEN void process_static_type_above_dst(__dynamic_cast_info *,128                                                       const void *,129                                                       const void *, int) const;130  _LIBCXXABI_HIDDEN void process_static_type_below_dst(__dynamic_cast_info *,131                                                       const void *, int) const;132  _LIBCXXABI_HIDDEN void process_found_base_class(__dynamic_cast_info *, void *,133                                                  int) const;134  _LIBCXXABI_HIDDEN virtual void search_above_dst(__dynamic_cast_info *,135                                                  const void *, const void *,136                                                  int, bool) const;137  _LIBCXXABI_HIDDEN virtual void138  search_below_dst(__dynamic_cast_info *, const void *, int, bool) const;139  _LIBCXXABI_HIDDEN virtual bool can_catch(const __shim_type_info *,140                                           void *&) const;141  _LIBCXXABI_HIDDEN virtual void142  has_unambiguous_public_base(__dynamic_cast_info *, void *, int) const;143};144 145// Has one non-virtual public base class at offset zero146class _LIBCXXABI_TYPE_VIS __si_class_type_info : public __class_type_info {147public:148  const __class_type_info *__base_type;149 150  _LIBCXXABI_HIDDEN virtual ~__si_class_type_info();151 152  _LIBCXXABI_HIDDEN virtual void search_above_dst(__dynamic_cast_info *,153                                                  const void *, const void *,154                                                  int, bool) const;155  _LIBCXXABI_HIDDEN virtual void156  search_below_dst(__dynamic_cast_info *, const void *, int, bool) const;157  _LIBCXXABI_HIDDEN virtual void158  has_unambiguous_public_base(__dynamic_cast_info *, void *, int) const;159};160 161struct _LIBCXXABI_HIDDEN __base_class_type_info162{163public:164    const __class_type_info* __base_type;165    long __offset_flags;166 167    enum __offset_flags_masks168    {169        __virtual_mask = 0x1,170        __public_mask  = 0x2, // base is public171        __offset_shift = 8172    };173 174    void search_above_dst(__dynamic_cast_info*, const void*, const void*, int, bool) const;175    void search_below_dst(__dynamic_cast_info*, const void*, int, bool) const;176    void has_unambiguous_public_base(__dynamic_cast_info*, void*, int) const;177};178 179// Has one or more base classes180class _LIBCXXABI_TYPE_VIS __vmi_class_type_info : public __class_type_info {181public:182  unsigned int __flags;183  unsigned int __base_count;184  __base_class_type_info __base_info[1];185 186  enum __flags_masks {187    __non_diamond_repeat_mask = 0x1, // has two or more distinct base class188                                     //    objects of the same type189    __diamond_shaped_mask = 0x2      // has base class object with two or190                                     //    more derived objects191  };192 193  _LIBCXXABI_HIDDEN virtual ~__vmi_class_type_info();194 195  _LIBCXXABI_HIDDEN virtual void search_above_dst(__dynamic_cast_info *,196                                                  const void *, const void *,197                                                  int, bool) const;198  _LIBCXXABI_HIDDEN virtual void199  search_below_dst(__dynamic_cast_info *, const void *, int, bool) const;200  _LIBCXXABI_HIDDEN virtual void201  has_unambiguous_public_base(__dynamic_cast_info *, void *, int) const;202};203 204class _LIBCXXABI_TYPE_VIS __pbase_type_info : public __shim_type_info {205public:206  unsigned int __flags;207  const __shim_type_info *__pointee;208 209  enum __masks {210    __const_mask = 0x1,211    __volatile_mask = 0x2,212    __restrict_mask = 0x4,213    __incomplete_mask = 0x8,214    __incomplete_class_mask = 0x10,215    __transaction_safe_mask = 0x20,216    // This implements the following proposal from cxx-abi-dev (not yet part of217    // the ABI document):218    //219    //   http://sourcerytools.com/pipermail/cxx-abi-dev/2016-October/002986.html220    //221    // This is necessary for support of http://wg21.link/p0012, which permits222    // throwing noexcept function and member function pointers and catching223    // them as non-noexcept pointers.224    __noexcept_mask = 0x40,225 226    // Flags that cannot be removed by a standard conversion.227    __no_remove_flags_mask = __const_mask | __volatile_mask | __restrict_mask,228    // Flags that cannot be added by a standard conversion.229    __no_add_flags_mask = __transaction_safe_mask | __noexcept_mask230  };231 232  _LIBCXXABI_HIDDEN virtual ~__pbase_type_info();233  _LIBCXXABI_HIDDEN virtual bool can_catch(const __shim_type_info *,234                                           void *&) const;235};236 237class _LIBCXXABI_TYPE_VIS __pointer_type_info : public __pbase_type_info {238public:239  _LIBCXXABI_HIDDEN virtual ~__pointer_type_info();240  _LIBCXXABI_HIDDEN virtual bool can_catch(const __shim_type_info *,241                                           void *&) const;242  _LIBCXXABI_HIDDEN bool can_catch_nested(const __shim_type_info *) const;243};244 245class _LIBCXXABI_TYPE_VIS __pointer_to_member_type_info246    : public __pbase_type_info {247public:248  const __class_type_info *__context;249 250  _LIBCXXABI_HIDDEN virtual ~__pointer_to_member_type_info();251  _LIBCXXABI_HIDDEN virtual bool can_catch(const __shim_type_info *,252                                           void *&) const;253  _LIBCXXABI_HIDDEN bool can_catch_nested(const __shim_type_info *) const;254};255 256}  // __cxxabiv1257 258#endif // __PRIVATE_TYPEINFO_H_259