Home | History | Annotate | Download | only in src
      1 //===------------------------ private_typeinfo.h --------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 #ifndef __PRIVATE_TYPEINFO_H_
     11 #define __PRIVATE_TYPEINFO_H_
     12 
     13 #include <typeinfo>
     14 #include <cstddef>
     15 
     16 namespace __cxxabiv1
     17 {
     18 
     19 #pragma GCC visibility push(hidden)
     20 
     21 class __attribute__ ((__visibility__("default"))) __shim_type_info
     22     : public std::type_info
     23 {
     24 public:
     25      __attribute__ ((__visibility__("hidden"))) virtual ~__shim_type_info();
     26 
     27      __attribute__ ((__visibility__("hidden"))) virtual void noop1() const;
     28      __attribute__ ((__visibility__("hidden"))) virtual void noop2() const;
     29      __attribute__ ((__visibility__("hidden"))) virtual bool can_catch(const __shim_type_info* thrown_type, void*& adjustedPtr) const = 0;
     30 };
     31 
     32 class __attribute__ ((__visibility__("default"))) __fundamental_type_info
     33     : public __shim_type_info
     34 {
     35 public:
     36     __attribute__ ((__visibility__("hidden"))) virtual ~__fundamental_type_info();
     37     __attribute__ ((__visibility__("hidden"))) virtual bool can_catch(const __shim_type_info*, void*&) const;
     38 };
     39 
     40 class __attribute__ ((__visibility__("default"))) __array_type_info
     41     : public __shim_type_info
     42 {
     43 public:
     44     __attribute__ ((__visibility__("hidden"))) virtual ~__array_type_info();
     45     __attribute__ ((__visibility__("hidden"))) virtual bool can_catch(const __shim_type_info*, void*&) const;
     46 };
     47 
     48 class __attribute__ ((__visibility__("default"))) __function_type_info
     49     : public __shim_type_info
     50 {
     51 public:
     52     __attribute__ ((__visibility__("hidden"))) virtual ~__function_type_info();
     53     __attribute__ ((__visibility__("hidden"))) virtual bool can_catch(const __shim_type_info*, void*&) const;
     54 };
     55 
     56 class __attribute__ ((__visibility__("default"))) __enum_type_info
     57     : public __shim_type_info
     58 {
     59 public:
     60     __attribute__ ((__visibility__("hidden"))) virtual ~__enum_type_info();
     61     __attribute__ ((__visibility__("hidden"))) virtual bool can_catch(const __shim_type_info*, void*&) const;
     62 };
     63 
     64 enum
     65 {
     66     unknown = 0,
     67     public_path,
     68     not_public_path,
     69     yes,
     70     no
     71 };
     72 
     73 class __attribute__ ((__visibility__("default"))) __class_type_info;
     74 
     75 struct __dynamic_cast_info
     76 {
     77 // const data supplied to the search:
     78 
     79     const __class_type_info* dst_type;
     80     const void* static_ptr;
     81     const __class_type_info* static_type;
     82     std::ptrdiff_t src2dst_offset;
     83 
     84 // Data that represents the answer:
     85 
     86     // pointer to a dst_type which has (static_ptr, static_type) above it
     87     const void* dst_ptr_leading_to_static_ptr;
     88     // pointer to a dst_type which does not have (static_ptr, static_type) above it
     89     const void* dst_ptr_not_leading_to_static_ptr;
     90 
     91     // The following three paths are either unknown, public_path or not_public_path.
     92     // access of path from dst_ptr_leading_to_static_ptr to (static_ptr, static_type)
     93     int path_dst_ptr_to_static_ptr;
     94     // access of path from (dynamic_ptr, dynamic_type) to (static_ptr, static_type)
     95     //    when there is no dst_type along the path
     96     int path_dynamic_ptr_to_static_ptr;
     97     // access of path from (dynamic_ptr, dynamic_type) to dst_type
     98     //    (not used if there is a (static_ptr, static_type) above a dst_type).
     99     int path_dynamic_ptr_to_dst_ptr;
    100 
    101     // Number of dst_types below (static_ptr, static_type)
    102     int number_to_static_ptr;
    103     // Number of dst_types not below (static_ptr, static_type)
    104     int number_to_dst_ptr;
    105 
    106 // Data that helps stop the search before the entire tree is searched:
    107 
    108     // is_dst_type_derived_from_static_type is either unknown, yes or no.
    109     int is_dst_type_derived_from_static_type;
    110     // Number of dst_type in tree.  If 0, then that means unknown.
    111     int number_of_dst_type;
    112     // communicates to a dst_type node that (static_ptr, static_type) was found
    113     //    above it.
    114     bool found_our_static_ptr;
    115     // communicates to a dst_type node that a static_type was found
    116     //    above it, but it wasn't (static_ptr, static_type)
    117     bool found_any_static_type;
    118     // Set whenever a search can be stopped
    119     bool search_done;
    120 };
    121 
    122 // Has no base class
    123 class __attribute__ ((__visibility__("default"))) __class_type_info
    124     : public __shim_type_info
    125 {
    126 public:
    127     __attribute__ ((__visibility__("hidden"))) virtual ~__class_type_info();
    128 
    129     __attribute__ ((__visibility__("hidden")))
    130         void process_static_type_above_dst(__dynamic_cast_info*, const void*, const void*, int) const;
    131     __attribute__ ((__visibility__("hidden")))
    132         void process_static_type_below_dst(__dynamic_cast_info*, const void*, int) const;
    133     __attribute__ ((__visibility__("hidden")))
    134         void process_found_base_class(__dynamic_cast_info*, void*, int) const;
    135     __attribute__ ((__visibility__("hidden")))
    136         virtual void search_above_dst(__dynamic_cast_info*, const void*, const void*, int, bool) const;
    137     __attribute__ ((__visibility__("hidden")))
    138         virtual void search_below_dst(__dynamic_cast_info*, const void*, int, bool) const;
    139     __attribute__ ((__visibility__("hidden")))
    140         virtual bool can_catch(const __shim_type_info*, void*&) const;
    141     __attribute__ ((__visibility__("hidden")))
    142         virtual void has_unambiguous_public_base(__dynamic_cast_info*, void*, int) const;
    143 };
    144 
    145 // Has one non-virtual public base class at offset zero
    146 class __attribute__ ((__visibility__("default"))) __si_class_type_info
    147     : public __class_type_info
    148 {
    149 public:
    150     const __class_type_info* __base_type;
    151 
    152     __attribute__ ((__visibility__("hidden"))) virtual ~__si_class_type_info();
    153 
    154     __attribute__ ((__visibility__("hidden")))
    155         virtual void search_above_dst(__dynamic_cast_info*, const void*, const void*, int, bool) const;
    156     __attribute__ ((__visibility__("hidden")))
    157         virtual void search_below_dst(__dynamic_cast_info*, const void*, int, bool) const;
    158     __attribute__ ((__visibility__("hidden")))
    159         virtual void has_unambiguous_public_base(__dynamic_cast_info*, void*, int) const;
    160 };
    161 
    162 struct __base_class_type_info
    163 {
    164 public:
    165     const __class_type_info* __base_type;
    166     long __offset_flags;
    167 
    168     enum __offset_flags_masks
    169     {
    170         __virtual_mask = 0x1,
    171         __public_mask  = 0x2, // base is public
    172         __offset_shift = 8
    173     };
    174 
    175     void search_above_dst(__dynamic_cast_info*, const void*, const void*, int, bool) const;
    176     void search_below_dst(__dynamic_cast_info*, const void*, int, bool) const;
    177     void has_unambiguous_public_base(__dynamic_cast_info*, void*, int) const;
    178 };
    179 
    180 // Has one or more base classes
    181 class __attribute__ ((__visibility__("default"))) __vmi_class_type_info
    182     : public __class_type_info
    183 {
    184 public:
    185     unsigned int __flags;
    186     unsigned int __base_count;
    187     __base_class_type_info __base_info[1];
    188 
    189     enum __flags_masks
    190     {
    191         __non_diamond_repeat_mask = 0x1,  // has two or more distinct base class
    192                                           //    objects of the same type
    193         __diamond_shaped_mask     = 0x2   // has base class object with two or
    194                                           //    more derived objects
    195     };
    196 
    197     __attribute__ ((__visibility__("hidden"))) virtual ~__vmi_class_type_info();
    198 
    199     __attribute__ ((__visibility__("hidden")))
    200         virtual void search_above_dst(__dynamic_cast_info*, const void*, const void*, int, bool) const;
    201     __attribute__ ((__visibility__("hidden")))
    202         virtual void search_below_dst(__dynamic_cast_info*, const void*, int, bool) const;
    203     __attribute__ ((__visibility__("hidden")))
    204         virtual void has_unambiguous_public_base(__dynamic_cast_info*, void*, int) const;
    205 };
    206 
    207 class __attribute__ ((__visibility__("default"))) __pbase_type_info
    208     : public __shim_type_info
    209 {
    210 public:
    211     unsigned int __flags;
    212     const __shim_type_info* __pointee;
    213 
    214     enum __masks
    215     {
    216         __const_mask            = 0x1,
    217         __volatile_mask         = 0x2,
    218         __restrict_mask         = 0x4,
    219         __incomplete_mask       = 0x8,
    220         __incomplete_class_mask = 0x10
    221     };
    222 
    223     __attribute__ ((__visibility__("hidden"))) virtual ~__pbase_type_info();
    224     __attribute__ ((__visibility__("hidden"))) virtual bool can_catch(const __shim_type_info*, void*&) const;
    225 };
    226 
    227 class __attribute__ ((__visibility__("default"))) __pointer_type_info
    228     : public __pbase_type_info
    229 {
    230 public:
    231     __attribute__ ((__visibility__("hidden"))) virtual ~__pointer_type_info();
    232     __attribute__ ((__visibility__("hidden"))) virtual bool can_catch(const __shim_type_info*, void*&) const;
    233     __attribute__ ((__visibility__("hidden"))) bool can_catch_nested(const __shim_type_info*) const;
    234 };
    235 
    236 class __attribute__ ((__visibility__("default"))) __pointer_to_member_type_info
    237     : public __pbase_type_info
    238 {
    239 public:
    240     const __class_type_info* __context;
    241 
    242     __attribute__ ((__visibility__("hidden"))) virtual ~__pointer_to_member_type_info();
    243     __attribute__ ((__visibility__("hidden"))) virtual bool can_catch(const __shim_type_info*, void*&) const;
    244     __attribute__ ((__visibility__("hidden"))) bool can_catch_nested(const __shim_type_info*) const;
    245 };
    246 
    247 #pragma GCC visibility pop
    248 
    249 }  // __cxxabiv1
    250 
    251 #endif  // __PRIVATE_TYPEINFO_H_
    252