blob: 967a6140abee990ae0b749b94c7d932448cd30ea [file] [log] [blame]
Howard Hinnant152beb72012-01-09 17:10:00 +00001//===------------------------ 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 Hinnantf877d212012-01-11 23:49:18 +000014#include <cstddef>
Howard Hinnant152beb72012-01-09 17:10:00 +000015
16namespace __cxxabiv1
17{
18
19class __fundamental_type_info
20 : public std::type_info
21{
22public:
23 virtual ~__fundamental_type_info();
24};
25
26class __array_type_info
27 : public std::type_info
28{
29public:
30 virtual ~__array_type_info();
31};
32
33class __function_type_info
34 : public std::type_info
35{
36public:
37 virtual ~__function_type_info();
38};
39
40class __enum_type_info
41 : public std::type_info
42{
43public:
44 virtual ~__enum_type_info();
45};
46
Howard Hinnantf877d212012-01-11 23:49:18 +000047enum
48{
49 unknown = 0,
50 public_path,
Howard Hinnant13093662012-01-16 00:13:46 +000051 not_public_path,
52 yes,
53 no
Howard Hinnantf877d212012-01-11 23:49:18 +000054};
55
56class __class_type_info;
57
58struct __dynamic_cast_info
59{
Howard Hinnantcc614df2012-01-16 17:06:51 +000060// const data supplied to the search:
Howard Hinnantf877d212012-01-11 23:49:18 +000061
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 Hinnantcc614df2012-01-16 17:06:51 +000067// Data that represents the answer:
Howard Hinnantf877d212012-01-11 23:49:18 +000068
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 Hinnantcc614df2012-01-16 17:06:51 +000073
74 // The following three paths are either unknown, public_path or not_public_path.
Howard Hinnantf877d212012-01-11 23:49:18 +000075 // 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 Hinnantcc614df2012-01-16 17:06:51 +000083
Howard Hinnantf877d212012-01-11 23:49:18 +000084 // 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 Hinnantcc614df2012-01-16 17:06:51 +000088
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 Hinnant13093662012-01-16 00:13:46 +000092 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 Hinnantf877d212012-01-11 23:49:18 +000095 // communicates to a dst_type node that (static_ptr, static_type) was found
96 // above it.
Howard Hinnant13093662012-01-16 00:13:46 +000097 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 Hinnantf877d212012-01-11 23:49:18 +0000103};
104
Howard Hinnant16650b52012-01-11 00:11:17 +0000105// Has no base class
Howard Hinnant152beb72012-01-09 17:10:00 +0000106class __class_type_info
107 : public std::type_info
108{
109public:
110 virtual ~__class_type_info();
Howard Hinnant16650b52012-01-11 00:11:17 +0000111
Howard Hinnant13093662012-01-16 00:13:46 +0000112 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 Hinnant152beb72012-01-09 17:10:00 +0000116};
117
Howard Hinnant16650b52012-01-11 00:11:17 +0000118// Has one non-virtual public base class at offset zero
Howard Hinnant152beb72012-01-09 17:10:00 +0000119class __si_class_type_info
120 : public __class_type_info
121{
122public:
123 const __class_type_info* __base_type;
124
125 virtual ~__si_class_type_info();
Howard Hinnant16650b52012-01-11 00:11:17 +0000126
Howard Hinnant13093662012-01-16 00:13:46 +0000127 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 Hinnant152beb72012-01-09 17:10:00 +0000129};
130
131struct __base_class_type_info
132{
133public:
134 const __class_type_info* __base_type;
135 long __offset_flags;
136
137 enum __offset_flags_masks
138 {
139 __virtual_mask = 0x1,
Howard Hinnant16650b52012-01-11 00:11:17 +0000140 __public_mask = 0x2, // base is public
Howard Hinnant152beb72012-01-09 17:10:00 +0000141 __offset_shift = 8
142 };
Howard Hinnant16650b52012-01-11 00:11:17 +0000143
Howard Hinnant13093662012-01-16 00:13:46 +0000144 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 Hinnant152beb72012-01-09 17:10:00 +0000146};
147
Howard Hinnant16650b52012-01-11 00:11:17 +0000148// Has one or more base classes
Howard Hinnant152beb72012-01-09 17:10:00 +0000149class __vmi_class_type_info
150 : public __class_type_info
151{
152public:
153 unsigned int __flags;
154 unsigned int __base_count;
155 __base_class_type_info __base_info[1];
156
157 enum __flags_masks
158 {
Howard Hinnant16650b52012-01-11 00:11:17 +0000159 __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 Hinnant152beb72012-01-09 17:10:00 +0000163 };
164
165 virtual ~__vmi_class_type_info();
Howard Hinnant16650b52012-01-11 00:11:17 +0000166
Howard Hinnant13093662012-01-16 00:13:46 +0000167 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 Hinnant152beb72012-01-09 17:10:00 +0000169};
170
171class __pbase_type_info
172 : public std::type_info
173{
174public:
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
190class __pointer_type_info
191 : public __pbase_type_info
192{
193public:
194 virtual ~__pointer_type_info();
195};
196
197class __pointer_to_member_type_info
198 : public __pbase_type_info
199{
200public:
201 const __class_type_info* __context;
202
203 virtual ~__pointer_to_member_type_info();
204};
205
206} // __cxxabiv1
207
208#endif // __PRIVATE_TYPEINFO_H_