111
|
1 // Methods for type_info for -*- C++ -*- Run Time Type Identification.
|
145
|
2 // Copyright (C) 1994-2020 Free Software Foundation, Inc.
|
111
|
3 //
|
|
4 // This file is part of GCC.
|
|
5 //
|
|
6 // GCC is free software; you can redistribute it and/or modify
|
|
7 // it under the terms of the GNU General Public License as published by
|
|
8 // the Free Software Foundation; either version 3, or (at your option)
|
|
9 // any later version.
|
|
10
|
|
11 // GCC is distributed in the hope that it will be useful,
|
|
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 // GNU General Public License for more details.
|
|
15
|
|
16 // Under Section 7 of GPL version 3, you are granted additional
|
|
17 // permissions described in the GCC Runtime Library Exception, version
|
|
18 // 3.1, as published by the Free Software Foundation.
|
|
19
|
|
20 // You should have received a copy of the GNU General Public License and
|
|
21 // a copy of the GCC Runtime Library Exception along with this program;
|
|
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
23 // <http://www.gnu.org/licenses/>.
|
|
24
|
|
25 #include <bits/c++config.h>
|
|
26 #include <cstddef>
|
|
27 #include "tinfo.h"
|
|
28
|
|
29 std::type_info::
|
|
30 ~type_info ()
|
|
31 { }
|
|
32
|
|
33 #if !__GXX_TYPEINFO_EQUALITY_INLINE
|
|
34
|
|
35 // We can't rely on common symbols being shared between shared objects.
|
|
36 bool std::type_info::
|
|
37 operator== (const std::type_info& arg) const _GLIBCXX_NOEXCEPT
|
|
38 {
|
|
39 #if __GXX_MERGED_TYPEINFO_NAMES
|
|
40 return name () == arg.name ();
|
|
41 #else
|
|
42 /* The name() method will strip any leading '*' prefix. Therefore
|
|
43 take care to look at __name rather than name() when looking for
|
|
44 the "pointer" prefix. */
|
|
45 return (&arg == this)
|
|
46 || (__name[0] != '*' && (__builtin_strcmp (name (), arg.name ()) == 0));
|
|
47 #endif
|
|
48 }
|
|
49
|
|
50 #endif
|
|
51
|
|
52 namespace std {
|
|
53
|
|
54 // return true if this is a type_info for a pointer type
|
|
55 bool type_info::
|
|
56 __is_pointer_p () const
|
|
57 {
|
|
58 return false;
|
|
59 }
|
|
60
|
|
61 // return true if this is a type_info for a function type
|
|
62 bool type_info::
|
|
63 __is_function_p () const
|
|
64 {
|
|
65 return false;
|
|
66 }
|
|
67
|
|
68 // try and catch a thrown object.
|
|
69 bool type_info::
|
|
70 __do_catch (const type_info *thr_type, void **, unsigned) const
|
|
71 {
|
|
72 return *this == *thr_type;
|
|
73 }
|
|
74
|
|
75 // upcast from this type to the target. __class_type_info will override
|
|
76 bool type_info::
|
|
77 __do_upcast (const abi::__class_type_info *, void **) const
|
|
78 {
|
|
79 return false;
|
|
80 }
|
|
81
|
|
82 }
|