llvm-mos-sdk
private-typeinfo.h
Go to the documentation of this file.
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-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef __PRIVATE_TYPEINFO_H_
10 #define __PRIVATE_TYPEINFO_H_
11 
12 #include "cxxabi-config.h"
13 
14 #include <stddef.h>
15 #include <typeinfo>
16 
17 namespace __cxxabiv1 {
18 
19 class _LIBCXXABI_TYPE_VIS __shim_type_info : public std::type_info {
20 public:
21  _LIBCXXABI_HIDDEN virtual ~__shim_type_info();
22 
23  _LIBCXXABI_HIDDEN virtual void noop1() const;
24  _LIBCXXABI_HIDDEN virtual void noop2() const;
25 };
26 
27 class _LIBCXXABI_TYPE_VIS __fundamental_type_info : public __shim_type_info {
28 public:
29  _LIBCXXABI_HIDDEN virtual ~__fundamental_type_info();
30 };
31 
32 class _LIBCXXABI_TYPE_VIS __array_type_info : public __shim_type_info {
33 public:
34  _LIBCXXABI_HIDDEN virtual ~__array_type_info();
35 };
36 
37 class _LIBCXXABI_TYPE_VIS __function_type_info : public __shim_type_info {
38 public:
39  _LIBCXXABI_HIDDEN virtual ~__function_type_info();
40 };
41 
42 class _LIBCXXABI_TYPE_VIS __enum_type_info : public __shim_type_info {
43 public:
44  _LIBCXXABI_HIDDEN virtual ~__enum_type_info();
45 };
46 
47 enum path_accessibility : unsigned char {
48  unknown_path = 0,
49  public_path,
50  not_public_path,
51 };
52 
53 enum tribool : unsigned char {
54  unknown = 0,
55  // public_path,
56  // not_public_path,
57  yes,
58  no
59 };
60 
61 class _LIBCXXABI_TYPE_VIS __class_type_info;
62 
63 struct _LIBCXXABI_HIDDEN __dynamic_cast_info {
64  // const data supplied to the search:
65 
66  const __class_type_info *dst_type;
67  const void *static_ptr;
68  const __class_type_info *static_type;
69  ptrdiff_t src2dst_offset;
70 
71  // Data that represents the answer:
72 
73  // pointer to a dst_type which has (static_ptr, static_type) above it
74  const void *dst_ptr_leading_to_static_ptr;
75  // pointer to a dst_type which does not have (static_ptr, static_type) above
76  // it
77  const void *dst_ptr_not_leading_to_static_ptr;
78 
79  // The following three paths are either unknown, public_path or
80  // not_public_path. access of path from dst_ptr_leading_to_static_ptr to
81  // (static_ptr, static_type)
82  path_accessibility path_dst_ptr_to_static_ptr;
83  // access of path from (dynamic_ptr, dynamic_type) to (static_ptr,
84  // static_type)
85  // when there is no dst_type along the path
86  path_accessibility path_dynamic_ptr_to_static_ptr;
87  // access of path from (dynamic_ptr, dynamic_type) to dst_type
88  // (not used if there is a (static_ptr, static_type) above a dst_type).
89  path_accessibility path_dynamic_ptr_to_dst_ptr;
90 
91  // Number of dst_types below (static_ptr, static_type)
92  unsigned char number_to_static_ptr;
93  // Number of dst_types not below (static_ptr, static_type)
94  unsigned char number_to_dst_ptr;
95 
96  // Data that helps stop the search before the entire tree is searched:
97 
98  // is_dst_type_derived_from_static_type is either unknown, yes or no.
99  tribool is_dst_type_derived_from_static_type;
100  // Number of dst_type in tree. If 0, then that means unknown.
101  unsigned char number_of_dst_type;
102  // communicates to a dst_type node that (static_ptr, static_type) was found
103  // above it.
104  bool found_our_static_ptr;
105  // communicates to a dst_type node that a static_type was found
106  // above it, but it wasn't (static_ptr, static_type)
107  bool found_any_static_type;
108  // Set whenever a search can be stopped
109  bool search_done;
110 };
111 
112 // Has no base class
113 class _LIBCXXABI_TYPE_VIS __class_type_info : public __shim_type_info {
114 public:
115  _LIBCXXABI_HIDDEN virtual ~__class_type_info();
116 
117  _LIBCXXABI_HIDDEN void
118  process_static_type_above_dst(__dynamic_cast_info *, const void *,
119  const void *, path_accessibility) const;
120  _LIBCXXABI_HIDDEN void
121  process_static_type_below_dst(__dynamic_cast_info *, const void *,
122  path_accessibility) const;
123  _LIBCXXABI_HIDDEN void process_found_base_class(__dynamic_cast_info *, void *,
124  path_accessibility) const;
125  _LIBCXXABI_HIDDEN void devirt_search_above_dst(__dynamic_cast_info *,
126  const void *, const void *,
127  path_accessibility,
128  bool) const;
129  _LIBCXXABI_HIDDEN void devirt_search_below_dst(__dynamic_cast_info *,
130  const void *,
131  path_accessibility,
132  bool) const;
133  template <class type_info_most_derived>
134  _LIBCXXABI_HIDDEN static void
135  invoke_search_above_dst(const __class_type_info *, __dynamic_cast_info *,
136  const void *, const void *, path_accessibility, bool);
137  template <class type_info_most_derived>
138  _LIBCXXABI_HIDDEN static void
139  invoke_search_below_dst(const __class_type_info *, __dynamic_cast_info *,
140  const void *, path_accessibility, bool);
141 
142 private:
144  void search_above_dst(__dynamic_cast_info *, const void *, const void *,
145  path_accessibility, bool) const;
146 
147  _LIBCXXABI_HIDDEN void search_below_dst(__dynamic_cast_info *, const void *,
148  path_accessibility, bool) const;
149 };
150 
151 // Has one non-virtual public base class at offset zero
152 class _LIBCXXABI_TYPE_VIS __si_class_type_info : public __class_type_info {
153 public:
154  const __class_type_info *__base_type;
155 
156  _LIBCXXABI_HIDDEN virtual ~__si_class_type_info();
157 
158  _LIBCXXABI_HIDDEN void search_above_dst(__dynamic_cast_info *, const void *,
159  const void *, path_accessibility,
160  bool) const;
161  _LIBCXXABI_HIDDEN void search_below_dst(__dynamic_cast_info *, const void *,
162  path_accessibility, bool) const;
163 };
164 
165 struct _LIBCXXABI_HIDDEN __base_class_type_info {
166 public:
167  const __class_type_info *__base_type;
168  long __offset_flags;
169 
170  enum __offset_flags_masks {
171  __virtual_mask = 0x1,
172  __public_mask = 0x2, // base is public
173  __offset_shift = 8
174  };
175 
176  void search_above_dst(__dynamic_cast_info *, const void *, const void *,
177  path_accessibility, bool) const;
178  void search_below_dst(__dynamic_cast_info *, const void *, path_accessibility,
179  bool) const;
180 };
181 
182 // Has one or more base classes
183 class _LIBCXXABI_TYPE_VIS __vmi_class_type_info : public __class_type_info {
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  __non_diamond_repeat_mask = 0x1, // has two or more distinct base class
191  // objects of the same type
192  __diamond_shaped_mask = 0x2 // has base class object with two or
193  // more derived objects
194  };
195 
196  _LIBCXXABI_HIDDEN virtual ~__vmi_class_type_info();
197 
198  _LIBCXXABI_HIDDEN void search_above_dst(__dynamic_cast_info *, const void *,
199  const void *, path_accessibility,
200  bool) const;
201  _LIBCXXABI_HIDDEN void search_below_dst(__dynamic_cast_info *, const void *,
202  path_accessibility, bool) const;
203 };
204 
205 class _LIBCXXABI_TYPE_VIS __pbase_type_info : public __shim_type_info {
206 public:
207  unsigned int __flags;
208  const __shim_type_info *__pointee;
209 
210  enum __masks {
211  __const_mask = 0x1,
212  __volatile_mask = 0x2,
213  __restrict_mask = 0x4,
214  __incomplete_mask = 0x8,
215  __incomplete_class_mask = 0x10,
216  __transaction_safe_mask = 0x20,
217  // This implements the following proposal from cxx-abi-dev (not yet part of
218  // the ABI document):
219  //
220  // http://sourcerytools.com/pipermail/cxx-abi-dev/2016-October/002986.html
221  //
222  // This is necessary for support of http://wg21.link/p0012, which permits
223  // throwing noexcept function and member function pointers and catching
224  // them as non-noexcept pointers.
225  __noexcept_mask = 0x40,
226 
227  // Flags that cannot be removed by a standard conversion.
228  __no_remove_flags_mask = __const_mask | __volatile_mask | __restrict_mask,
229  // Flags that cannot be added by a standard conversion.
230  __no_add_flags_mask = __transaction_safe_mask | __noexcept_mask
231  };
232 
233  _LIBCXXABI_HIDDEN virtual ~__pbase_type_info();
234 };
235 
236 class _LIBCXXABI_TYPE_VIS __pointer_type_info : public __pbase_type_info {
237 public:
238  _LIBCXXABI_HIDDEN virtual ~__pointer_type_info();
239 };
240 
241 class _LIBCXXABI_TYPE_VIS __pointer_to_member_type_info
242  : public __pbase_type_info {
243 public:
244  const __class_type_info *__context;
245 
246  _LIBCXXABI_HIDDEN virtual ~__pointer_to_member_type_info();
247 };
248 
249 } // namespace __cxxabiv1
250 
251 #endif // __PRIVATE_TYPEINFO_H_
_LIBCXXABI_TYPE_VIS
#define _LIBCXXABI_TYPE_VIS
Definition: cxxabi-config.h:30
cxxabi-config.h
std::ptrdiff_t
::ptrdiff_t ptrdiff_t
Definition: cstddef:8
typeinfo
std::type_info
Definition: typeinfo:5
_LIBCXXABI_HIDDEN
#define _LIBCXXABI_HIDDEN
Definition: cxxabi-config.h:24