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