Howard Hinnant | 152beb7 | 2012-01-09 17:10:00 +0000 | [diff] [blame] | 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> |
Howard Hinnant | f877d21 | 2012-01-11 23:49:18 +0000 | [diff] [blame] | 14 | #include <cstddef> |
Howard Hinnant | 152beb7 | 2012-01-09 17:10:00 +0000 | [diff] [blame] | 15 | |
| 16 | namespace __cxxabiv1 |
| 17 | { |
| 18 | |
| 19 | class __fundamental_type_info |
| 20 | : public std::type_info |
| 21 | { |
| 22 | public: |
| 23 | virtual ~__fundamental_type_info(); |
| 24 | }; |
| 25 | |
| 26 | class __array_type_info |
| 27 | : public std::type_info |
| 28 | { |
| 29 | public: |
| 30 | virtual ~__array_type_info(); |
| 31 | }; |
| 32 | |
| 33 | class __function_type_info |
| 34 | : public std::type_info |
| 35 | { |
| 36 | public: |
| 37 | virtual ~__function_type_info(); |
| 38 | }; |
| 39 | |
| 40 | class __enum_type_info |
| 41 | : public std::type_info |
| 42 | { |
| 43 | public: |
| 44 | virtual ~__enum_type_info(); |
| 45 | }; |
| 46 | |
Howard Hinnant | f877d21 | 2012-01-11 23:49:18 +0000 | [diff] [blame] | 47 | enum |
| 48 | { |
| 49 | unknown = 0, |
| 50 | public_path, |
Howard Hinnant | 1309366 | 2012-01-16 00:13:46 +0000 | [diff] [blame] | 51 | not_public_path, |
| 52 | yes, |
| 53 | no |
Howard Hinnant | f877d21 | 2012-01-11 23:49:18 +0000 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | class __class_type_info; |
| 57 | |
| 58 | struct __dynamic_cast_info |
| 59 | { |
Howard Hinnant | cc614df | 2012-01-16 17:06:51 +0000 | [diff] [blame^] | 60 | // const data supplied to the search: |
Howard Hinnant | f877d21 | 2012-01-11 23:49:18 +0000 | [diff] [blame] | 61 | |
| 62 | const __class_type_info* const dst_type; |
| 63 | const void* const static_ptr; |
| 64 | const __class_type_info* const static_type; |
| 65 | const std::ptrdiff_t src2dst_offset; |
| 66 | |
Howard Hinnant | cc614df | 2012-01-16 17:06:51 +0000 | [diff] [blame^] | 67 | // Data that represents the answer: |
Howard Hinnant | f877d21 | 2012-01-11 23:49:18 +0000 | [diff] [blame] | 68 | |
| 69 | // pointer to a dst_type which has (static_ptr, static_type) above it |
| 70 | const void* dst_ptr_leading_to_static_ptr; |
| 71 | // pointer to a dst_type which does not have (static_ptr, static_type) above it |
| 72 | const void* dst_ptr_not_leading_to_static_ptr; |
Howard Hinnant | cc614df | 2012-01-16 17:06:51 +0000 | [diff] [blame^] | 73 | |
| 74 | // The following three paths are either unknown, public_path or not_public_path. |
Howard Hinnant | f877d21 | 2012-01-11 23:49:18 +0000 | [diff] [blame] | 75 | // access of path from dst_ptr_leading_to_static_ptr to (static_ptr, static_type) |
| 76 | int path_dst_ptr_to_static_ptr; |
| 77 | // access of path from (dynamic_ptr, dynamic_type) to (static_ptr, static_type) |
| 78 | // when there is no dst_type along the path |
| 79 | int path_dynamic_ptr_to_static_ptr; |
| 80 | // access of path from (dynamic_ptr, dynamic_type) to dst_type |
| 81 | // (not used if there is a (static_ptr, static_type) above a dst_type). |
| 82 | int path_dynamic_ptr_to_dst_ptr; |
Howard Hinnant | cc614df | 2012-01-16 17:06:51 +0000 | [diff] [blame^] | 83 | |
Howard Hinnant | f877d21 | 2012-01-11 23:49:18 +0000 | [diff] [blame] | 84 | // Number of dst_types below (static_ptr, static_type) |
| 85 | int number_to_static_ptr; |
| 86 | // Number of dst_types not below (static_ptr, static_type) |
| 87 | int number_to_dst_ptr; |
Howard Hinnant | cc614df | 2012-01-16 17:06:51 +0000 | [diff] [blame^] | 88 | |
| 89 | // Data that helps stop the search before the entire tree is searched: |
| 90 | |
| 91 | // is_dst_type_derived_from_static_type is either unknown, yes or no. |
Howard Hinnant | 1309366 | 2012-01-16 00:13:46 +0000 | [diff] [blame] | 92 | int is_dst_type_derived_from_static_type; |
| 93 | // Number of dst_type in tree. If 0, then that means unknown. |
| 94 | int number_of_dst_type; |
Howard Hinnant | f877d21 | 2012-01-11 23:49:18 +0000 | [diff] [blame] | 95 | // communicates to a dst_type node that (static_ptr, static_type) was found |
| 96 | // above it. |
Howard Hinnant | 1309366 | 2012-01-16 00:13:46 +0000 | [diff] [blame] | 97 | bool found_our_static_ptr; |
| 98 | // communicates to a dst_type node that a static_type was found |
| 99 | // above it, but it wasn't (static_ptr, static_type) |
| 100 | bool found_any_static_type; |
| 101 | // Set whenever a search can be stopped |
| 102 | bool search_done; |
Howard Hinnant | f877d21 | 2012-01-11 23:49:18 +0000 | [diff] [blame] | 103 | }; |
| 104 | |
Howard Hinnant | 16650b5 | 2012-01-11 00:11:17 +0000 | [diff] [blame] | 105 | // Has no base class |
Howard Hinnant | 152beb7 | 2012-01-09 17:10:00 +0000 | [diff] [blame] | 106 | class __class_type_info |
| 107 | : public std::type_info |
| 108 | { |
| 109 | public: |
| 110 | virtual ~__class_type_info(); |
Howard Hinnant | 16650b5 | 2012-01-11 00:11:17 +0000 | [diff] [blame] | 111 | |
Howard Hinnant | 1309366 | 2012-01-16 00:13:46 +0000 | [diff] [blame] | 112 | void process_static_type_above_dst(__dynamic_cast_info*, const void*, const void*, int) const; |
| 113 | void process_static_type_below_dst(__dynamic_cast_info*, const void*, int) const; |
| 114 | virtual void search_above_dst(__dynamic_cast_info*, const void*, const void*, int) const; |
| 115 | virtual void search_below_dst(__dynamic_cast_info*, const void*, int) const; |
Howard Hinnant | 152beb7 | 2012-01-09 17:10:00 +0000 | [diff] [blame] | 116 | }; |
| 117 | |
Howard Hinnant | 16650b5 | 2012-01-11 00:11:17 +0000 | [diff] [blame] | 118 | // Has one non-virtual public base class at offset zero |
Howard Hinnant | 152beb7 | 2012-01-09 17:10:00 +0000 | [diff] [blame] | 119 | class __si_class_type_info |
| 120 | : public __class_type_info |
| 121 | { |
| 122 | public: |
| 123 | const __class_type_info* __base_type; |
| 124 | |
| 125 | virtual ~__si_class_type_info(); |
Howard Hinnant | 16650b5 | 2012-01-11 00:11:17 +0000 | [diff] [blame] | 126 | |
Howard Hinnant | 1309366 | 2012-01-16 00:13:46 +0000 | [diff] [blame] | 127 | virtual void search_above_dst(__dynamic_cast_info*, const void*, const void*, int) const; |
| 128 | virtual void search_below_dst(__dynamic_cast_info*, const void*, int) const; |
Howard Hinnant | 152beb7 | 2012-01-09 17:10:00 +0000 | [diff] [blame] | 129 | }; |
| 130 | |
| 131 | struct __base_class_type_info |
| 132 | { |
| 133 | public: |
| 134 | const __class_type_info* __base_type; |
| 135 | long __offset_flags; |
| 136 | |
| 137 | enum __offset_flags_masks |
| 138 | { |
| 139 | __virtual_mask = 0x1, |
Howard Hinnant | 16650b5 | 2012-01-11 00:11:17 +0000 | [diff] [blame] | 140 | __public_mask = 0x2, // base is public |
Howard Hinnant | 152beb7 | 2012-01-09 17:10:00 +0000 | [diff] [blame] | 141 | __offset_shift = 8 |
| 142 | }; |
Howard Hinnant | 16650b5 | 2012-01-11 00:11:17 +0000 | [diff] [blame] | 143 | |
Howard Hinnant | 1309366 | 2012-01-16 00:13:46 +0000 | [diff] [blame] | 144 | void search_above_dst(__dynamic_cast_info*, const void*, const void*, int) const; |
| 145 | void search_below_dst(__dynamic_cast_info*, const void*, int) const; |
Howard Hinnant | 152beb7 | 2012-01-09 17:10:00 +0000 | [diff] [blame] | 146 | }; |
| 147 | |
Howard Hinnant | 16650b5 | 2012-01-11 00:11:17 +0000 | [diff] [blame] | 148 | // Has one or more base classes |
Howard Hinnant | 152beb7 | 2012-01-09 17:10:00 +0000 | [diff] [blame] | 149 | class __vmi_class_type_info |
| 150 | : public __class_type_info |
| 151 | { |
| 152 | public: |
| 153 | unsigned int __flags; |
| 154 | unsigned int __base_count; |
| 155 | __base_class_type_info __base_info[1]; |
| 156 | |
| 157 | enum __flags_masks |
| 158 | { |
Howard Hinnant | 16650b5 | 2012-01-11 00:11:17 +0000 | [diff] [blame] | 159 | __non_diamond_repeat_mask = 0x1, // has two or more distinct base class |
| 160 | // objects of the same type |
| 161 | __diamond_shaped_mask = 0x2 // has base class object with two or |
| 162 | // more derived objects |
Howard Hinnant | 152beb7 | 2012-01-09 17:10:00 +0000 | [diff] [blame] | 163 | }; |
| 164 | |
| 165 | virtual ~__vmi_class_type_info(); |
Howard Hinnant | 16650b5 | 2012-01-11 00:11:17 +0000 | [diff] [blame] | 166 | |
Howard Hinnant | 1309366 | 2012-01-16 00:13:46 +0000 | [diff] [blame] | 167 | virtual void search_above_dst(__dynamic_cast_info*, const void*, const void*, int) const; |
| 168 | virtual void search_below_dst(__dynamic_cast_info*, const void*, int) const; |
Howard Hinnant | 152beb7 | 2012-01-09 17:10:00 +0000 | [diff] [blame] | 169 | }; |
| 170 | |
| 171 | class __pbase_type_info |
| 172 | : public std::type_info |
| 173 | { |
| 174 | public: |
| 175 | unsigned int __flags; |
| 176 | const std::type_info* __pointee; |
| 177 | |
| 178 | enum __masks |
| 179 | { |
| 180 | __const_mask = 0x1, |
| 181 | __volatile_mask = 0x2, |
| 182 | __restrict_mask = 0x4, |
| 183 | __incomplete_mask = 0x8, |
| 184 | __incomplete_class_mask = 0x10 |
| 185 | }; |
| 186 | |
| 187 | virtual ~__pbase_type_info(); |
| 188 | }; |
| 189 | |
| 190 | class __pointer_type_info |
| 191 | : public __pbase_type_info |
| 192 | { |
| 193 | public: |
| 194 | virtual ~__pointer_type_info(); |
| 195 | }; |
| 196 | |
| 197 | class __pointer_to_member_type_info |
| 198 | : public __pbase_type_info |
| 199 | { |
| 200 | public: |
| 201 | const __class_type_info* __context; |
| 202 | |
| 203 | virtual ~__pointer_to_member_type_info(); |
| 204 | }; |
| 205 | |
| 206 | } // __cxxabiv1 |
| 207 | |
| 208 | #endif // __PRIVATE_TYPEINFO_H_ |