1 // Copyright (C) 1994-2021 Free Software Foundation, Inc.
3 // This file is part of GCC.
5 // GCC is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3, or (at your option)
10 // GCC is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // Under Section 7 of GPL version 3, you are granted additional
16 // permissions described in the GCC Runtime Library Exception, version
17 // 3.1, as published by the Free Software Foundation.
19 // You should have received a copy of the GNU General Public License and
20 // a copy of the GCC Runtime Library Exception along with this program;
21 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22 // <http://www.gnu.org/licenses/>.
26 namespace __cxxabiv1
{
32 bool __class_type_info::
33 __do_catch (const type_info
*thr_type
,
37 if (*this == *thr_type
)
40 // Neither `A' nor `A *'.
42 return thr_type
->__do_upcast (this, thr_obj
);
45 bool __class_type_info::
46 __do_upcast (const __class_type_info
*dst_type
,
49 __upcast_result
result (__vmi_class_type_info::__flags_unknown_mask
);
51 __do_upcast (dst_type
, *obj_ptr
, result
);
52 if (!contained_public_p (result
.part2dst
))
54 *obj_ptr
= const_cast <void *> (result
.dst_ptr
);
58 __class_type_info::__sub_kind
__class_type_info::
59 __do_find_public_src (ptrdiff_t,
61 const __class_type_info
*,
62 const void *src_ptr
) const
64 if (src_ptr
== obj_ptr
)
65 // Must be our type, as the pointers match.
66 return __contained_public
;
67 return __not_contained
;
70 bool __class_type_info::
71 __do_dyncast (ptrdiff_t,
72 __sub_kind access_path
,
73 const __class_type_info
*dst_type
,
75 const __class_type_info
*src_type
,
77 __dyncast_result
&__restrict result
) const
79 if (obj_ptr
== src_ptr
&& *this == *src_type
)
81 // The src object we started from. Indicate how we are accessible from
82 // the most derived object.
83 result
.whole2src
= access_path
;
86 if (*this == *dst_type
)
88 result
.dst_ptr
= obj_ptr
;
89 result
.whole2dst
= access_path
;
90 result
.dst2src
= __not_contained
;
96 bool __class_type_info::
97 __do_upcast (const __class_type_info
*dst
, const void *obj
,
98 __upcast_result
&__restrict result
) const
102 result
.dst_ptr
= obj
;
103 result
.base_type
= nonvirtual_base_type
;
104 result
.part2dst
= __contained_public
;