diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2000-04-09 15:59:16 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2000-04-09 15:59:16 +0000 |
commit | 7e2d247261b874a7cf47f0b91b548a46107b6b44 (patch) | |
tree | 5bc6e63c7f5748ffa81c8b2fdfef88f166f80269 /gcc | |
parent | c42f056abe054deb0044688a6b9e82627c2253e2 (diff) | |
download | gcc-7e2d247261b874a7cf47f0b91b548a46107b6b44.zip gcc-7e2d247261b874a7cf47f0b91b548a46107b6b44.tar.gz gcc-7e2d247261b874a7cf47f0b91b548a46107b6b44.tar.bz2 |
Prepend __ to implementation defined names.
* inc/typeinfo (type_info): Rename _name to __name.
(type_info::type_info): Rename parameter.
(type_info::operator==, type_info::operator!=,
type_info::before): Likewise.
(type_info::is_pointer_p, type_info::is_function_p,
type_info::do_catch, type_info::do_upcast): Prepend __. Rename
parameters.
* inc/cxxabi.h
(__fundamental_type_info::__fundamental_type_info) Rename parameters.
(__pointer_type_info::__pointer_type_info): Likewise.
(__pointer_type_info::is_pointer_p,
__pointer_type_info::do_catch): Prepend __. Rename parameters.
(__array_type_info::__array_type_info): Rename parameters.
(__function_type_info::__function_type_info): Likewise.
(__function_type_info::is_function_p): Prepend __.
(__enum_type_info::__enum_type_info): Rename parameters.
(__pointer_to_member_type_info::__pointer_to_member_type_info):
Likewise.
(__pointer_to_member_type_info::do_catch): Prepend __. Rename
parameters.
(__base_class_info::is_virtual_p, is_public_p, offset): Prepend __.
(__class_type_info::__class_type_info): Rename parameters.
(__class_type_info::sub_kind): Prepend __. Adjust member names.
(__class_type_info::upcast_result,
__class_type_info::dyncast_result): Prepend __. Move definition
into tinfo.cc.
(__class_type_info::do_upcast, __class_type_info::do_catch,
__class_type_info::find_public_src,
__class_type_info::do_dyncast,
__class_type_info::do_find_public_src): Prepend __. Rename
parameters.
(__si_class_type_info::__si_class_type_info): Rename parameters.
(__si_class_type_info::do_upcast, __si_class_type_info::do_dyncast,
__si_class_type_info::do_find_public_src): Prepent __. Rename
parameters.
(__vmi_class_type_info::__vmi_class_type_info): Rename parameters.
(__vmi_class_type_info::do_upcast, __vmi_class_type_info::do_dyncast,
__vmi_class_type_info::do_find_public_src): Prepent __. Rename
parameters.
(__dynamic_cast): Rename parameters.
* tinfo.cc (type_info::is_pointer_p, type_info::is_function_p,
type_info::do_catch, type_info::do_upcast): Prepend __.
(contained_p, public_p, virtual_p, contained_public_p,
contained_nonpublic_p, contained_nonvirtual_p): Adjust.
(__class_type_info::do_catch,
__class_type_info::do_upcast): Prepend __. Adjust.
(__class_type_info::__upcast_result,
__class_type_info::__dyncast_result): Move from inc/cxxabi.h.
Adjust.
(__class_type_info::find_public_src): Prepend __. Adjust.
(__class_type_info::do_find_public_src,
__si_class_type_info::do_find_public_src,
__vmi_class_type_info::do_find_public_src): Likewise.
(__class_type_info::do_dyncast,
__si_class_type_info::do_dyncast,
__vmi_class_type_info::do_dyncast): Likewise.
(__class_type_info::do_upcast,
__si_class_type_info::do_upcast,
__vmi_class_type_info::do_upcast): Likewise.
(__dynamic_cast): Adjust.
* tinfo2.cc (__pointer_type_info::is_pointer_p): Prepend __.
(__function_type_info::is_function_p): Likewise.
(__pointer_type_info::do_catch): Likewise. Adjust.
(__pointer_to_member_type_info::do_catch): Likewise. Adjust.
(__throw_type_match_rtti_2): Adjust.
(__is_pointer): Adjust.
From-SVN: r33041
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 70 | ||||
-rw-r--r-- | gcc/cp/inc/cxxabi.h | 221 | ||||
-rw-r--r-- | gcc/cp/inc/typeinfo | 37 | ||||
-rw-r--r-- | gcc/cp/tinfo.cc | 330 | ||||
-rw-r--r-- | gcc/cp/tinfo2.cc | 26 |
5 files changed, 390 insertions, 294 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8fbd554..f76ef39 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,73 @@ +2000-04-09 Nathan Sidwell <nathan@codesourcery.com> + + Prepend __ to implementation defined names. + * inc/typeinfo (type_info): Rename _name to __name. + (type_info::type_info): Rename parameter. + (type_info::operator==, type_info::operator!=, + type_info::before): Likewise. + (type_info::is_pointer_p, type_info::is_function_p, + type_info::do_catch, type_info::do_upcast): Prepend __. Rename + parameters. + * inc/cxxabi.h + (__fundamental_type_info::__fundamental_type_info) Rename parameters. + (__pointer_type_info::__pointer_type_info): Likewise. + (__pointer_type_info::is_pointer_p, + __pointer_type_info::do_catch): Prepend __. Rename parameters. + (__array_type_info::__array_type_info): Rename parameters. + (__function_type_info::__function_type_info): Likewise. + (__function_type_info::is_function_p): Prepend __. + (__enum_type_info::__enum_type_info): Rename parameters. + (__pointer_to_member_type_info::__pointer_to_member_type_info): + Likewise. + (__pointer_to_member_type_info::do_catch): Prepend __. Rename + parameters. + (__base_class_info::is_virtual_p, is_public_p, offset): Prepend __. + (__class_type_info::__class_type_info): Rename parameters. + (__class_type_info::sub_kind): Prepend __. Adjust member names. + (__class_type_info::upcast_result, + __class_type_info::dyncast_result): Prepend __. Move definition + into tinfo.cc. + (__class_type_info::do_upcast, __class_type_info::do_catch, + __class_type_info::find_public_src, + __class_type_info::do_dyncast, + __class_type_info::do_find_public_src): Prepend __. Rename + parameters. + (__si_class_type_info::__si_class_type_info): Rename parameters. + (__si_class_type_info::do_upcast, __si_class_type_info::do_dyncast, + __si_class_type_info::do_find_public_src): Prepent __. Rename + parameters. + (__vmi_class_type_info::__vmi_class_type_info): Rename parameters. + (__vmi_class_type_info::do_upcast, __vmi_class_type_info::do_dyncast, + __vmi_class_type_info::do_find_public_src): Prepent __. Rename + parameters. + (__dynamic_cast): Rename parameters. + * tinfo.cc (type_info::is_pointer_p, type_info::is_function_p, + type_info::do_catch, type_info::do_upcast): Prepend __. + (contained_p, public_p, virtual_p, contained_public_p, + contained_nonpublic_p, contained_nonvirtual_p): Adjust. + (__class_type_info::do_catch, + __class_type_info::do_upcast): Prepend __. Adjust. + (__class_type_info::__upcast_result, + __class_type_info::__dyncast_result): Move from inc/cxxabi.h. + Adjust. + (__class_type_info::find_public_src): Prepend __. Adjust. + (__class_type_info::do_find_public_src, + __si_class_type_info::do_find_public_src, + __vmi_class_type_info::do_find_public_src): Likewise. + (__class_type_info::do_dyncast, + __si_class_type_info::do_dyncast, + __vmi_class_type_info::do_dyncast): Likewise. + (__class_type_info::do_upcast, + __si_class_type_info::do_upcast, + __vmi_class_type_info::do_upcast): Likewise. + (__dynamic_cast): Adjust. + * tinfo2.cc (__pointer_type_info::is_pointer_p): Prepend __. + (__function_type_info::is_function_p): Likewise. + (__pointer_type_info::do_catch): Likewise. Adjust. + (__pointer_to_member_type_info::do_catch): Likewise. Adjust. + (__throw_type_match_rtti_2): Adjust. + (__is_pointer): Adjust. + 2000-04-08 Mark Mitchell <mark@codesourcery.com> * cp-tree.h (cp_tree_index): Add CPTI_COMPLETE_CTOR_IDENTIFIER. diff --git a/gcc/cp/inc/cxxabi.h b/gcc/cp/inc/cxxabi.h index e0c1531..66a6607 100644 --- a/gcc/cp/inc/cxxabi.h +++ b/gcc/cp/inc/cxxabi.h @@ -36,8 +36,8 @@ class __fundamental_type_info public: virtual ~__fundamental_type_info (); public: - explicit __fundamental_type_info (const char *n_) - : std::type_info (n_) + explicit __fundamental_type_info (const char *__n) + : std::type_info (__n) { } }; @@ -54,10 +54,10 @@ public: public: virtual ~__pointer_type_info (); public: - explicit __pointer_type_info (const char *n_, - int quals_, - const std::type_info *type_) - : std::type_info (n_), quals (quals_), type (type_) + explicit __pointer_type_info (const char *__n, + int __quals, + const std::type_info *__type) + : std::type_info (__n), quals (__quals), type (__type) { } /* implementation defined types */ @@ -69,10 +69,10 @@ public: /* implementation defined member functions */ protected: - virtual bool is_pointer_p () const; + virtual bool __is_pointer_p () const; protected: - virtual bool do_catch (const std::type_info *thr_type, void **thr_obj, - unsigned outer) const; + virtual bool __do_catch (const std::type_info *__thr_type, void **__thr_obj, + unsigned __outer) const; }; /* type information for array objects */ @@ -83,8 +83,8 @@ class __array_type_info protected: virtual ~__array_type_info (); public: - explicit __array_type_info (const char *n_) - : std::type_info (n_) + explicit __array_type_info (const char *__n) + : std::type_info (__n) { } }; @@ -96,13 +96,13 @@ class __function_type_info public: virtual ~__function_type_info (); public: - explicit __function_type_info (const char *n_) - : std::type_info (n_) + explicit __function_type_info (const char *__n) + : std::type_info (__n) { } /* implementation defined member functions */ protected: - virtual bool is_function_p () const; + virtual bool __is_function_p () const; }; /* type information for enumerations */ @@ -113,8 +113,8 @@ class __enum_type_info public: virtual ~__enum_type_info (); public: - explicit __enum_type_info (const char *n_) - : std::type_info (n_) + explicit __enum_type_info (const char *__n) + : std::type_info (__n) { } }; @@ -132,11 +132,11 @@ public: public: virtual ~__pointer_to_member_type_info (); public: - explicit __pointer_to_member_type_info (const char *n_, - const __class_type_info *klass_, - const std::type_info *type_, - int quals_) - : std::type_info (n_), klass (klass_), type (type_), quals (quals_) + explicit __pointer_to_member_type_info (const char *__n, + const __class_type_info *__klass, + const std::type_info *__type, + int __quals) + : std::type_info (__n), klass (__klass), type (__type), quals (__quals) { } /* implementation defined types */ @@ -148,8 +148,8 @@ public: /* implementation defined member functions */ protected: - virtual bool do_catch (const std::type_info *thr_type, void **thr_obj, - unsigned outer) const; + virtual bool __do_catch (const std::type_info *__thr_type, void **__thr_obj, + unsigned __outer) const; }; class __class_type_info; @@ -173,11 +173,11 @@ public: /* implementation defined member functions */ public: - bool is_virtual_p () const + bool __is_virtual_p () const { return vmi_offset_flags & virtual_mask; } - bool is_public_p () const + bool __is_public_p () const { return vmi_offset_flags & public_mask; } - std::ptrdiff_t offset () const + std::ptrdiff_t __offset () const { return std::ptrdiff_t (vmi_offset_flags) >> offset_shift; } }; @@ -189,8 +189,8 @@ class __class_type_info public: virtual ~__class_type_info (); public: - explicit __class_type_info (const char *n_) - : type_info (n_) + explicit __class_type_info (const char *__n) + : type_info (__n) { } /* implementation defined types */ @@ -198,71 +198,43 @@ public: /* sub_kind tells us about how a base object is contained within a derived object. We often do this lazily, hence the UNKNOWN value. At other times we may use NOT_CONTAINED to mean not publicly contained. */ - enum sub_kind + enum __sub_kind { - unknown = 0, /* we have no idea */ - not_contained, /* not contained within us (in some */ - /* circumstances this might mean not contained */ - /* publicly) */ - contained_ambig, /* contained ambiguously */ + __unknown = 0, /* we have no idea */ + __not_contained, /* not contained within us (in some */ + /* circumstances this might mean not contained */ + /* publicly) */ + __contained_ambig, /* contained ambiguously */ - contained_virtual_mask = __base_class_info::virtual_mask, /* via a virtual path */ - contained_public_mask = __base_class_info::public_mask, /* via a public path */ - contained_mask = 1 << __base_class_info::hwm_bit, /* contained within us */ + __contained_virtual_mask = __base_class_info::virtual_mask, /* via a virtual path */ + __contained_public_mask = __base_class_info::public_mask, /* via a public path */ + __contained_mask = 1 << __base_class_info::hwm_bit, /* contained within us */ - contained_private = contained_mask, - contained_public = contained_mask | contained_public_mask + __contained_private = __contained_mask, + __contained_public = __contained_mask | __contained_public_mask }; public: - struct upcast_result - { - const void *dst_ptr; /* pointer to caught object */ - sub_kind whole2dst; /* path from most derived object to target */ - int src_details; /* hints about the source type heirarchy */ - const __class_type_info *base_type; /* where we found the target, */ - /* if in vbase the __class_type_info of vbase */ - /* if a non-virtual base then 1 */ - /* else NULL */ - public: - upcast_result (int d) - :dst_ptr (NULL), whole2dst (unknown), src_details (d), base_type (NULL) - {} - }; - -public: - /* dyncast_result is used to hold information during traversal of a class - heirarchy when dynamic casting. */ - struct dyncast_result - { - const void *dst_ptr; /* pointer to target object or NULL */ - sub_kind whole2dst; /* path from most derived object to target */ - sub_kind whole2src; /* path from most derived object to sub object */ - sub_kind dst2src; /* path from target to sub object */ - - public: - dyncast_result () - :dst_ptr (NULL), whole2dst (unknown), - whole2src (unknown), dst2src (unknown) - {} - }; + struct __upcast_result; + struct __dyncast_result; /* implementation defined member functions */ protected: - virtual bool do_upcast (const __class_type_info *dst_type, void **obj_ptr) const; + virtual bool __do_upcast (const __class_type_info *__dst_type, void **__obj_ptr) const; protected: - virtual bool do_catch (const type_info *thr_type, void **thr_obj, - unsigned outer) const; + virtual bool __do_catch (const type_info *__thr_type, void **__thr_obj, + unsigned __outer) const; public: /* Helper for upcast. See if DST is us, or one of our bases. ACCESS_PATH */ /* gives the access from the start object. Return TRUE if we know the upcast */ /* fails. */ - virtual bool do_upcast (sub_kind access_path, - const __class_type_info *dst, const void *obj, - upcast_result &__restrict result) const; + virtual bool __do_upcast (__sub_kind __access_path, + const __class_type_info *__dst, + const void *__obj, + __upcast_result &__restrict __result) const; public: /* Indicate whether SRC_PTR of type SRC_TYPE is contained publicly within @@ -271,9 +243,10 @@ public: within this type. If SRC_PTR is one of our SRC_TYPE bases, indicate the virtuality. Returns not_contained for non containment or private containment. */ - inline sub_kind find_public_src (std::ptrdiff_t src2dst, const void *obj_ptr, - const __class_type_info *src_type, - const void *src_ptr) const; + inline __sub_kind __find_public_src (std::ptrdiff_t __src2dst, + const void *__obj_ptr, + const __class_type_info *__src_type, + const void *__src_ptr) const; public: /* dynamic cast helper. ACCESS_PATH gives the access from the most derived @@ -282,18 +255,22 @@ public: indicates the static type started from and SRC_PTR points to that base within the most derived object. Fill in RESULT with what we find. Return true if we have located an ambiguous match. */ - virtual bool do_dyncast (std::ptrdiff_t src2dst, sub_kind access_path, - const __class_type_info *dst_type, const void *obj_ptr, - const __class_type_info *src_type, const void *src_ptr, - dyncast_result &result) const; + virtual bool __do_dyncast (std::ptrdiff_t __src2dst, + __sub_kind __access_path, + const __class_type_info *__dst_type, + const void *__obj_ptr, + const __class_type_info *__src_type, + const void *__src_ptr, + __dyncast_result &__result) const; public: /* Helper for find_public_subobj. SRC2DST indicates how SRC_TYPE bases are inherited by the type started from -- which is not necessarily the current type. The current type will be a base of the destination type. OBJ_PTR points to the current base. */ - virtual sub_kind do_find_public_src (std::ptrdiff_t src2dst, const void *obj_ptr, - const __class_type_info *src_type, - const void *src_ptr) const; + virtual __sub_kind __do_find_public_src (std::ptrdiff_t __src2dst, + const void *__obj_ptr, + const __class_type_info *__src_type, + const void *__src_ptr) const; }; /* type information for a class with a single non-virtual base */ @@ -308,23 +285,28 @@ protected: public: virtual ~__si_class_type_info (); public: - explicit __si_class_type_info (const char *n_, - const __class_type_info *base_) - : __class_type_info (n_), base (base_) + explicit __si_class_type_info (const char *__n, + const __class_type_info *__base) + : __class_type_info (__n), base (__base) { } /* implementation defined member functions */ protected: - virtual bool do_dyncast (std::ptrdiff_t src2dst, sub_kind access_path, - const __class_type_info *dst_type, const void *obj_ptr, - const __class_type_info *src_type, const void *src_ptr, - dyncast_result &result) const; - virtual sub_kind do_find_public_src (std::ptrdiff_t src2dst, const void *obj_ptr, - const __class_type_info *src_type, - const void *sub_ptr) const; - virtual bool do_upcast (sub_kind access_path, - const __class_type_info *dst, const void *obj, - upcast_result &__restrict result) const; + virtual bool __do_dyncast (std::ptrdiff_t __src2dst, + __sub_kind __access_path, + const __class_type_info *__dst_type, + const void *__obj_ptr, + const __class_type_info *__src_type, + const void *__src_ptr, + __dyncast_result &__result) const; + virtual __sub_kind __do_find_public_src (std::ptrdiff_t __src2dst, + const void *__obj_ptr, + const __class_type_info *__src_type, + const void *__sub_ptr) const; + virtual bool __do_upcast (__sub_kind __access_path, + const __class_type_info *__dst, + const void *__obj, + __upcast_result &__restrict __result) const; }; /* type information for a class with multiple and/or virtual bases */ @@ -342,9 +324,9 @@ public: public: virtual ~__vmi_class_type_info (); public: - explicit __vmi_class_type_info (const char *n_, - int flags_) - : __class_type_info (n_), vmi_flags (flags_), vmi_base_count (0) + explicit __vmi_class_type_info (const char *__n, + int __flags) + : __class_type_info (__n), vmi_flags (__flags), vmi_base_count (0) { } /* implementation defined types */ @@ -355,28 +337,33 @@ public: non_public_base_mask = 0x4, /* has non-public direct or indirect base */ public_base_mask = 0x8, /* has public base (direct) */ - flags_unknown_mask = 0x10 + __flags_unknown_mask = 0x10 }; /* implementation defined member functions */ protected: - virtual bool do_dyncast (std::ptrdiff_t src2dst, sub_kind access_path, - const __class_type_info *dst_type, const void *obj_ptr, - const __class_type_info *src_type, const void *src_ptr, - dyncast_result &result) const; - virtual sub_kind do_find_public_src (std::ptrdiff_t src2dst, const void *obj_ptr, - const __class_type_info *src_type, - const void *src_ptr) const; - virtual bool do_upcast (sub_kind access_path, - const __class_type_info *dst, const void *obj, - upcast_result &__restrict result) const; + virtual bool __do_dyncast (std::ptrdiff_t __src2dst, + __sub_kind __access_path, + const __class_type_info *__dst_type, + const void *__obj_ptr, + const __class_type_info *__src_type, + const void *__src_ptr, + __dyncast_result &__result) const; + virtual __sub_kind __do_find_public_src (std::ptrdiff_t __src2dst, + const void *__obj_ptr, + const __class_type_info *__src_type, + const void *__src_ptr) const; + virtual bool __do_upcast (__sub_kind __access_path, + const __class_type_info *__dst, + const void *__obj, + __upcast_result &__restrict __result) const; }; /* dynamic cast runtime */ -void *__dynamic_cast (const void *src_ptr, /* object started from */ - const __class_type_info *src_type, /* static type of object */ - const __class_type_info *dst_type, /* desired target type */ - std::ptrdiff_t src2dst); /* how src and dst are related */ +void *__dynamic_cast (const void *__src_ptr, /* object started from */ + const __class_type_info *__src_type, /* static type of object */ + const __class_type_info *__dst_type, /* desired target type */ + std::ptrdiff_t __src2dst); /* how src and dst are related */ /* src2dst has the following possible values >= 0: src_type is a unique public non-virtual base of dst_type diff --git a/gcc/cp/inc/typeinfo b/gcc/cp/inc/typeinfo index 02fa73d..632e453 100644 --- a/gcc/cp/inc/typeinfo +++ b/gcc/cp/inc/typeinfo @@ -38,10 +38,10 @@ private: type_info (const type_info&); protected: - const char *_name; + const char *__name; protected: - explicit type_info (const char *n): _name (n) { } + explicit type_info (const char *__n): __name (__n) { } public: // the public interface @@ -50,42 +50,43 @@ public: // type. Uniqueness must use the _name value, not object address. bool before (const type_info& arg) const; const char* name () const - { return _name; } - bool operator== (const type_info& arg) const; - bool operator!= (const type_info& arg) const - { return !operator== (arg); } + { return __name; } + bool operator== (const type_info& __arg) const; + bool operator!= (const type_info& __arg) const + { return !operator== (__arg); } #else // In new abi we can rely on type_info's being unique, // and therefore address comparisons are sufficient. - bool before (const type_info& arg) const - { return this < &arg; } + bool before (const type_info& __arg) const + { return this < &__arg; } const char* name () const - { return _name; } - bool operator== (const type_info& arg) const - { return &arg == this; } - bool operator!= (const type_info& arg) const - { return !operator== (arg); } + { return __name; } + bool operator== (const type_info& __arg) const + { return &__arg == this; } + bool operator!= (const type_info& __arg) const + { return !operator== (__arg); } #endif // the internal interface #if defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 public: // return true if this is a pointer type of some kind - virtual bool is_pointer_p () const; + virtual bool __is_pointer_p () const; // return true if this is a function type - virtual bool is_function_p () const; + virtual bool __is_function_p () const; // Try and catch a thrown type. Store an adjusted pointer to the caught type // in THR_OBJ. If THR_TYPE is not a pointer type, then THR_OBJ points to the // thrown object. If THR_TYPE is a pointer type, then THR_OBJ is the pointer // itself. OUTER indicates the number of outer pointers, and whether they // were const qualified. - virtual bool do_catch (const type_info *thr_type, void **thr_obj, - unsigned outer) const; + virtual bool __do_catch (const type_info *__thr_type, void **__thr_obj, + unsigned __outer) const; // internally used during catch matching - virtual bool do_upcast (const __cxxabiv1::__class_type_info *target, void **obj_ptr) const; + virtual bool __do_upcast (const __cxxabiv1::__class_type_info *__target, + void **__obj_ptr) const; #endif }; diff --git a/gcc/cp/tinfo.cc b/gcc/cp/tinfo.cc index 0bf9cfe..d84d83e 100644 --- a/gcc/cp/tinfo.cc +++ b/gcc/cp/tinfo.cc @@ -541,28 +541,28 @@ namespace std { // return true if this is a type_info for a pointer type bool type_info:: -is_pointer_p () const +__is_pointer_p () const { return false; } // return true if this is a type_info for a function type bool type_info:: -is_function_p () const +__is_function_p () const { return false; } // try and catch a thrown object. bool type_info:: -do_catch (const type_info *thr_type, void **, unsigned) const +__do_catch (const type_info *thr_type, void **, unsigned) const { return *this == *thr_type; } // upcast from this type to the target. __class_type_info will override bool type_info:: -do_upcast (const abi::__class_type_info *, void **) const +__do_upcast (const abi::__class_type_info *, void **) const { return false; } @@ -605,31 +605,34 @@ convert_to_base (void const *addr, bool is_virtual, ptrdiff_t offset) return adjust_pointer<void> (addr, offset); } -// some predicate functions for __class_type_info::sub_kind -inline bool contained_p (__class_type_info::sub_kind access_path) +// some predicate functions for __class_type_info::__sub_kind +inline bool contained_p (__class_type_info::__sub_kind access_path) { - return access_path >= __class_type_info::contained_mask; + return access_path >= __class_type_info::__contained_mask; } -inline bool public_p (__class_type_info::sub_kind access_path) +inline bool public_p (__class_type_info::__sub_kind access_path) { - return access_path & __class_type_info::contained_public_mask; + return access_path & __class_type_info::__contained_public_mask; } -inline bool virtual_p (__class_type_info::sub_kind access_path) +inline bool virtual_p (__class_type_info::__sub_kind access_path) { - return (access_path & __class_type_info::contained_virtual_mask); + return (access_path & __class_type_info::__contained_virtual_mask); } -inline bool contained_public_p (__class_type_info::sub_kind access_path) +inline bool contained_public_p (__class_type_info::__sub_kind access_path) { - return (access_path & __class_type_info::contained_public) == __class_type_info::contained_public; + return ((access_path & __class_type_info::__contained_public) + == __class_type_info::__contained_public); } -inline bool contained_nonpublic_p (__class_type_info::sub_kind access_path) +inline bool contained_nonpublic_p (__class_type_info::__sub_kind access_path) { - return (access_path & __class_type_info::contained_public) == __class_type_info::contained_mask; + return ((access_path & __class_type_info::__contained_public) + == __class_type_info::__contained_mask); } -inline bool contained_nonvirtual_p (__class_type_info::sub_kind access_path) +inline bool contained_nonvirtual_p (__class_type_info::__sub_kind access_path) { - return (access_path & (__class_type_info::contained_mask | __class_type_info::contained_virtual_mask)) - == __class_type_info::contained_mask; + return ((access_path & (__class_type_info::__contained_mask + | __class_type_info::__contained_virtual_mask)) + == __class_type_info::__contained_mask); } static const __class_type_info *const nonvirtual_base_type = @@ -652,83 +655,118 @@ __vmi_class_type_info:: ~__vmi_class_type_info () {} +// __upcast_result is used to hold information during traversal of a class +// heirarchy when catch matching. +struct __class_type_info::__upcast_result +{ + const void *dst_ptr; // pointer to caught object + __sub_kind whole2dst; // path from most derived object to target + int src_details; // hints about the source type heirarchy + const __class_type_info *base_type; // where we found the target, + // if in vbase the __class_type_info of vbase + // if a non-virtual base then 1 + // else NULL + public: + __upcast_result (int d) + :dst_ptr (NULL), whole2dst (__unknown), src_details (d), base_type (NULL) + {} +}; + +// __dyncast_result is used to hold information during traversal of a class +// heirarchy when dynamic casting. +struct __class_type_info::__dyncast_result +{ + const void *dst_ptr; // pointer to target object or NULL + __sub_kind whole2dst; // path from most derived object to target + __sub_kind whole2src; // path from most derived object to sub object + __sub_kind dst2src; // path from target to sub object + + public: + __dyncast_result () + :dst_ptr (NULL), whole2dst (__unknown), + whole2src (__unknown), dst2src (__unknown) + {} +}; + bool __class_type_info:: -do_catch (const type_info *thr_type, void **thr_obj, - unsigned outer) const +__do_catch (const type_info *thr_type, + void **thr_obj, + unsigned outer) const { if (*this == *thr_type) return true; if (outer >= 4) // Neither `A' nor `A *'. return false; - return thr_type->do_upcast (this, thr_obj); + return thr_type->__do_upcast (this, thr_obj); } bool __class_type_info:: -do_upcast (const __class_type_info *dst_type, void **obj_ptr) const +__do_upcast (const __class_type_info *dst_type, + void **obj_ptr) const { - upcast_result result (__vmi_class_type_info::flags_unknown_mask); + __upcast_result result (__vmi_class_type_info::__flags_unknown_mask); - if (do_upcast (contained_public, dst_type, *obj_ptr, result)) + if (__do_upcast (__contained_public, dst_type, *obj_ptr, result)) return false; *obj_ptr = const_cast <void *> (result.dst_ptr); return contained_public_p (result.whole2dst); } -inline __class_type_info::sub_kind __class_type_info:: -find_public_src (ptrdiff_t src2dst, - const void *obj_ptr, - const __class_type_info *src_type, - const void *src_ptr) const +inline __class_type_info::__sub_kind __class_type_info:: +__find_public_src (ptrdiff_t src2dst, + const void *obj_ptr, + const __class_type_info *src_type, + const void *src_ptr) const { if (src2dst >= 0) return adjust_pointer <void> (obj_ptr, src2dst) == src_ptr - ? contained_public : not_contained; + ? __contained_public : __not_contained; if (src2dst == -2) - return not_contained; - return do_find_public_src (src2dst, obj_ptr, src_type, src_ptr); + return __not_contained; + return __do_find_public_src (src2dst, obj_ptr, src_type, src_ptr); } -__class_type_info::sub_kind __class_type_info:: -do_find_public_src (ptrdiff_t, - const void *obj_ptr, - const __class_type_info *, - const void *src_ptr) const +__class_type_info::__sub_kind __class_type_info:: +__do_find_public_src (ptrdiff_t, + const void *obj_ptr, + const __class_type_info *, + const void *src_ptr) const { if (src_ptr == obj_ptr) // Must be our type, as the pointers match. - return contained_public; - return not_contained; + return __contained_public; + return __not_contained; } -__class_type_info::sub_kind __si_class_type_info:: -do_find_public_src (ptrdiff_t src2dst, - const void *obj_ptr, - const __class_type_info *src_type, - const void *src_ptr) const +__class_type_info::__sub_kind __si_class_type_info:: +__do_find_public_src (ptrdiff_t src2dst, + const void *obj_ptr, + const __class_type_info *src_type, + const void *src_ptr) const { if (src_ptr == obj_ptr && *this == *src_type) - return contained_public; - return base->do_find_public_src (src2dst, obj_ptr, src_type, src_ptr); + return __contained_public; + return base->__do_find_public_src (src2dst, obj_ptr, src_type, src_ptr); } -__class_type_info::sub_kind __vmi_class_type_info:: -do_find_public_src (ptrdiff_t src2dst, - const void *obj_ptr, - const __class_type_info *src_type, - const void *src_ptr) const +__class_type_info::__sub_kind __vmi_class_type_info:: +__do_find_public_src (ptrdiff_t src2dst, + const void *obj_ptr, + const __class_type_info *src_type, + const void *src_ptr) const { if (obj_ptr == src_ptr && *this == *src_type) - return contained_public; + return __contained_public; for (size_t i = vmi_base_count; i--;) { - if (!vmi_bases[i].is_public_p ()) + if (!vmi_bases[i].__is_public_p ()) continue; // Not public, can't be here. const void *base = obj_ptr; - ptrdiff_t offset = vmi_bases[i].offset (); - bool is_virtual = vmi_bases[i].is_virtual_p (); + ptrdiff_t offset = vmi_bases[i].__offset (); + bool is_virtual = vmi_bases[i].__is_virtual_p (); if (is_virtual) { @@ -737,27 +775,27 @@ do_find_public_src (ptrdiff_t src2dst, } base = convert_to_base (base, is_virtual, offset); - sub_kind base_kind = vmi_bases[i].base->do_find_public_src + __sub_kind base_kind = vmi_bases[i].base->__do_find_public_src (src2dst, base, src_type, src_ptr); if (contained_p (base_kind)) { if (is_virtual) - base_kind = sub_kind (base_kind | contained_virtual_mask); + base_kind = __sub_kind (base_kind | __contained_virtual_mask); return base_kind; } } - return not_contained; + return __not_contained; } bool __class_type_info:: -do_dyncast (ptrdiff_t, - sub_kind access_path, - const __class_type_info *dst_type, - const void *obj_ptr, - const __class_type_info *src_type, - const void *src_ptr, - dyncast_result &__restrict result) const +__do_dyncast (ptrdiff_t, + __sub_kind access_path, + const __class_type_info *dst_type, + const void *obj_ptr, + const __class_type_info *src_type, + const void *src_ptr, + __dyncast_result &__restrict result) const { if (obj_ptr == src_ptr && *this == *src_type) { @@ -770,20 +808,20 @@ do_dyncast (ptrdiff_t, { result.dst_ptr = obj_ptr; result.whole2dst = access_path; - result.dst2src = not_contained; + result.dst2src = __not_contained; return false; } return false; } bool __si_class_type_info:: -do_dyncast (ptrdiff_t src2dst, - sub_kind access_path, - const __class_type_info *dst_type, - const void *obj_ptr, - const __class_type_info *src_type, - const void *src_ptr, - dyncast_result &__restrict result) const +__do_dyncast (ptrdiff_t src2dst, + __sub_kind access_path, + const __class_type_info *dst_type, + const void *obj_ptr, + const __class_type_info *src_type, + const void *src_ptr, + __dyncast_result &__restrict result) const { if (*this == *dst_type) { @@ -791,9 +829,9 @@ do_dyncast (ptrdiff_t src2dst, result.whole2dst = access_path; if (src2dst >= 0) result.dst2src = adjust_pointer <void> (obj_ptr, src2dst) == src_ptr - ? contained_public : not_contained; + ? __contained_public : __not_contained; else if (src2dst == -2) - result.dst2src = not_contained; + result.dst2src = __not_contained; return false; } if (obj_ptr == src_ptr && *this == *src_type) @@ -803,8 +841,8 @@ do_dyncast (ptrdiff_t src2dst, result.whole2src = access_path; return false; } - return base->do_dyncast (src2dst, access_path, dst_type, obj_ptr, - src_type, src_ptr, result); + return base->__do_dyncast (src2dst, access_path, dst_type, obj_ptr, + src_type, src_ptr, result); } // This is a big hairy function. Although the run-time behaviour of @@ -817,13 +855,13 @@ do_dyncast (ptrdiff_t src2dst, // work by filling in things lazily (when we know we need the information), // and opportunisticly take early success or failure results. bool __vmi_class_type_info:: -do_dyncast (ptrdiff_t src2dst, - sub_kind access_path, - const __class_type_info *dst_type, - const void *obj_ptr, - const __class_type_info *src_type, - const void *src_ptr, - dyncast_result &__restrict result) const +__do_dyncast (ptrdiff_t src2dst, + __sub_kind access_path, + const __class_type_info *dst_type, + const void *obj_ptr, + const __class_type_info *src_type, + const void *src_ptr, + __dyncast_result &__restrict result) const { if (obj_ptr == src_ptr && *this == *src_type) { @@ -838,34 +876,34 @@ do_dyncast (ptrdiff_t src2dst, result.whole2dst = access_path; if (src2dst >= 0) result.dst2src = adjust_pointer <void> (obj_ptr, src2dst) == src_ptr - ? contained_public : not_contained; + ? __contained_public : __not_contained; else if (src2dst == -2) - result.dst2src = not_contained; + result.dst2src = __not_contained; return false; } bool result_ambig = false; for (size_t i = vmi_base_count; i--;) { - dyncast_result result2; + __dyncast_result result2; void const *base = obj_ptr; - sub_kind base_access = access_path; - ptrdiff_t offset = vmi_bases[i].offset (); - bool is_virtual = vmi_bases[i].is_virtual_p (); + __sub_kind base_access = access_path; + ptrdiff_t offset = vmi_bases[i].__offset (); + bool is_virtual = vmi_bases[i].__is_virtual_p (); if (is_virtual) - base_access = sub_kind (base_access | contained_virtual_mask); + base_access = __sub_kind (base_access | __contained_virtual_mask); base = convert_to_base (base, is_virtual, offset); - if (!vmi_bases[i].is_public_p ()) - base_access = sub_kind (base_access & ~contained_public_mask); + if (!vmi_bases[i].__is_public_p ()) + base_access = __sub_kind (base_access & ~__contained_public_mask); bool result2_ambig - = vmi_bases[i].base->do_dyncast (src2dst, base_access, - dst_type, base, - src_type, src_ptr, result2); - result.whole2src = sub_kind (result.whole2src | result2.whole2src); - if (result2.dst2src == contained_public - || result2.dst2src == contained_ambig) + = vmi_bases[i].base->__do_dyncast (src2dst, base_access, + dst_type, base, + src_type, src_ptr, result2); + result.whole2src = __sub_kind (result.whole2src | result2.whole2src); + if (result2.dst2src == __contained_public + || result2.dst2src == __contained_ambig) { result.dst_ptr = result2.dst_ptr; result.whole2dst = result2.whole2dst; @@ -887,7 +925,7 @@ do_dyncast (ptrdiff_t src2dst, // Found at same address, must be via virtual. Pick the most // accessible path. result.whole2dst = - sub_kind (result.whole2dst | result2.whole2dst); + __sub_kind (result.whole2dst | result2.whole2dst); } else if ((result.dst_ptr && result2.dst_ptr) || (result_ambig && result2.dst_ptr) @@ -901,45 +939,45 @@ do_dyncast (ptrdiff_t src2dst, // but don't yet fail as we might later find a third base which does // contain SRC_PTR. - sub_kind new_sub_kind = result2.dst2src; - sub_kind old_sub_kind = result.dst2src; + __sub_kind new_sub_kind = result2.dst2src; + __sub_kind old_sub_kind = result.dst2src; if (contained_nonvirtual_p (result.whole2src)) { // We already found SRC_PTR as a non-virtual base of most // derived. Therefore if it is in either choice, it can only be // in one of them, and we will already know. - if (old_sub_kind == unknown) - old_sub_kind = not_contained; - if (new_sub_kind == unknown) - new_sub_kind = not_contained; + if (old_sub_kind == __unknown) + old_sub_kind = __not_contained; + if (new_sub_kind == __unknown) + new_sub_kind = __not_contained; } else { - if (old_sub_kind >= not_contained) + if (old_sub_kind >= __not_contained) ;// already calculated else if (contained_nonvirtual_p (new_sub_kind)) // Already found non-virtually inside the other choice, // cannot be in this. - old_sub_kind = not_contained; + old_sub_kind = __not_contained; else - old_sub_kind = dst_type->find_public_src + old_sub_kind = dst_type->__find_public_src (src2dst, result.dst_ptr, src_type, src_ptr); - if (new_sub_kind >= not_contained) + if (new_sub_kind >= __not_contained) ;// already calculated else if (contained_nonvirtual_p (old_sub_kind)) // Already found non-virtually inside the other choice, // cannot be in this. - new_sub_kind = not_contained; + new_sub_kind = __not_contained; else - new_sub_kind = dst_type->find_public_src + new_sub_kind = dst_type->__find_public_src (src2dst, result2.dst_ptr, src_type, src_ptr); } // Neither sub_kind can be contained_ambig -- we bail out early // when we find those. - if (contained_p (sub_kind (new_sub_kind ^ old_sub_kind))) + if (contained_p (__sub_kind (new_sub_kind ^ old_sub_kind))) { // Only on one choice, not ambiguous. if (contained_p (new_sub_kind)) @@ -956,11 +994,11 @@ do_dyncast (ptrdiff_t src2dst, if (!virtual_p (result.dst2src)) return false; // Found non-virtually can't be bettered } - else if (contained_p (sub_kind (new_sub_kind & old_sub_kind))) + else if (contained_p (__sub_kind (new_sub_kind & old_sub_kind))) { // In both. result.dst_ptr = NULL; - result.dst2src = contained_ambig; + result.dst2src = __contained_ambig; return true; // Fail. } else @@ -969,12 +1007,12 @@ do_dyncast (ptrdiff_t src2dst, // looking. It is possible that it was private in one or // both and therefore we should fail, but that's just tough. result.dst_ptr = NULL; - result.dst2src = not_contained; + result.dst2src = __not_contained; result_ambig = true; } } - if (result.whole2src == contained_private) + if (result.whole2src == __contained_private) // We found SRC_PTR as a private non-virtual base, therefore all // cross casts will fail. We have already found a down cast, if // there is one. @@ -985,9 +1023,9 @@ do_dyncast (ptrdiff_t src2dst, } bool __class_type_info:: -do_upcast (sub_kind access_path, - const __class_type_info *dst, const void *obj, - upcast_result &__restrict result) const +__do_upcast (__sub_kind access_path, + const __class_type_info *dst, const void *obj, + __upcast_result &__restrict result) const { if (*this == *dst) { @@ -1000,9 +1038,9 @@ do_upcast (sub_kind access_path, } bool __si_class_type_info:: -do_upcast (sub_kind access_path, - const __class_type_info *dst, const void *obj_ptr, - upcast_result &__restrict result) const +__do_upcast (__sub_kind access_path, + const __class_type_info *dst, const void *obj_ptr, + __upcast_result &__restrict result) const { if (*this == *dst) { @@ -1011,13 +1049,13 @@ do_upcast (sub_kind access_path, result.whole2dst = access_path; return contained_nonpublic_p (access_path); } - return base->do_upcast (access_path, dst, obj_ptr, result); + return base->__do_upcast (access_path, dst, obj_ptr, result); } bool __vmi_class_type_info:: -do_upcast (sub_kind access_path, - const __class_type_info *dst, const void *obj_ptr, - upcast_result &__restrict result) const +__do_upcast (__sub_kind access_path, + const __class_type_info *dst, const void *obj_ptr, + __upcast_result &__restrict result) const { if (*this == *dst) { @@ -1028,30 +1066,30 @@ do_upcast (sub_kind access_path, } int src_details = result.src_details; - if (src_details & flags_unknown_mask) + if (src_details & __flags_unknown_mask) src_details = vmi_flags; for (size_t i = vmi_base_count; i--;) { - upcast_result result2 (src_details); + __upcast_result result2 (src_details); const void *base = obj_ptr; - sub_kind sub_access = access_path; - ptrdiff_t offset = vmi_bases[i].offset (); - bool is_virtual = vmi_bases[i].is_virtual_p (); + __sub_kind sub_access = access_path; + ptrdiff_t offset = vmi_bases[i].__offset (); + bool is_virtual = vmi_bases[i].__is_virtual_p (); - if (!vmi_bases[i].is_public_p ()) + if (!vmi_bases[i].__is_public_p ()) { if (!(src_details & non_diamond_repeat_mask)) // original cannot have an ambiguous base continue; - sub_access = sub_kind (sub_access & ~contained_public_mask); + sub_access = __sub_kind (sub_access & ~__contained_public_mask); } if (is_virtual) - sub_access = sub_kind (sub_access | contained_virtual_mask); + sub_access = __sub_kind (sub_access | __contained_virtual_mask); if (base) base = convert_to_base (base, is_virtual, offset); - if (vmi_bases[i].base->do_upcast (sub_access, dst, base, result2)) + if (vmi_bases[i].base->__do_upcast (sub_access, dst, base, result2)) return true; // must fail if (result2.base_type) { @@ -1068,14 +1106,14 @@ do_upcast (sub_kind access_path, { // Found an ambiguity. result.dst_ptr = NULL; - result.whole2dst = contained_ambig; + result.whole2dst = __contained_ambig; return true; } else if (result.dst_ptr) { // Ok, found real object via a virtual path. result.whole2dst - = sub_kind (result.whole2dst | result2.whole2dst); + = __sub_kind (result.whole2dst | result2.whole2dst); } else { @@ -1087,7 +1125,7 @@ do_upcast (sub_kind access_path, { // Already ambiguous, not virtual or via different virtuals. // Cannot match. - result.whole2dst = contained_ambig; + result.whole2dst = __contained_ambig; return true; } } @@ -1110,15 +1148,15 @@ __dynamic_cast (const void *src_ptr, // object started from const void *whole_ptr = adjust_pointer <void> (src_ptr, prefix->whole_object); const __class_type_info *whole_type = prefix->whole_type; - __class_type_info::dyncast_result result; + __class_type_info::__dyncast_result result; - whole_type->do_dyncast (src2dst, __class_type_info::contained_public, - dst_type, whole_ptr, src_type, src_ptr, result); + whole_type->__do_dyncast (src2dst, __class_type_info::__contained_public, + dst_type, whole_ptr, src_type, src_ptr, result); if (!result.dst_ptr) return NULL; if (contained_public_p (result.dst2src)) return const_cast <void *> (result.dst_ptr); - if (contained_public_p (__class_type_info::sub_kind (result.whole2src & result.whole2dst))) + if (contained_public_p (__class_type_info::__sub_kind (result.whole2src & result.whole2dst))) // Found a valid cross cast return const_cast <void *> (result.dst_ptr); if (contained_nonvirtual_p (result.whole2src)) @@ -1129,9 +1167,9 @@ __dynamic_cast (const void *src_ptr, // object started from // whole type has no private bases return const_cast <void *> (result.dst_ptr); #endif - if (result.dst2src == __class_type_info::unknown) - result.dst2src = dst_type->find_public_src (src2dst, result.dst_ptr, - src_type, src_ptr); + if (result.dst2src == __class_type_info::__unknown) + result.dst2src = dst_type->__find_public_src (src2dst, result.dst_ptr, + src_type, src_ptr); if (contained_public_p (result.dst2src)) // Found a valid down cast return const_cast <void *> (result.dst_ptr); diff --git a/gcc/cp/tinfo2.cc b/gcc/cp/tinfo2.cc index d137408..b41b071 100644 --- a/gcc/cp/tinfo2.cc +++ b/gcc/cp/tinfo2.cc @@ -127,21 +127,21 @@ __pointer_to_member_type_info:: {} bool __pointer_type_info:: -is_pointer_p () const +__is_pointer_p () const { return true; } bool __function_type_info:: -is_function_p () const +__is_function_p () const { return true; } bool __pointer_type_info:: -do_catch (const type_info *thr_type, - void **thr_obj, - unsigned outer) const +__do_catch (const type_info *thr_type, + void **thr_obj, + unsigned outer) const { if (*this == *thr_type) return true; // same type @@ -167,16 +167,16 @@ do_catch (const type_info *thr_type, if (outer < 2 && *type == typeid (void)) { // conversion to void - return !thrown_type->is_function_p (); + return !thrown_type->__is_function_p (); } - return type->do_catch (thrown_type->type, thr_obj, outer + 2); + return type->__do_catch (thrown_type->type, thr_obj, outer + 2); } bool __pointer_to_member_type_info:: -do_catch (const type_info *thr_type, - void **thr_obj, - unsigned outer) const +__do_catch (const type_info *thr_type, + void **thr_obj, + unsigned outer) const { if (*this == *thr_type) return true; // same type @@ -202,7 +202,7 @@ do_catch (const type_info *thr_type, if (*klass != *thrown_type->klass) return false; // not pointers to member of same class - return type->do_catch (thrown_type->type, thr_obj, outer + 2); + return type->__do_catch (thrown_type->type, thr_obj, outer + 2); } } // namespace std @@ -338,7 +338,7 @@ __throw_type_match_rtti_2 (const void *catch_type_r, const void *throw_type_r, #else // new abi - return catch_type.do_catch (&throw_type, valp, 1); + return catch_type.__do_catch (&throw_type, valp, 1); #endif return 0; } @@ -371,7 +371,7 @@ __is_pointer (void *p) return pt != 0; #else // new abi - return t->is_pointer_p (); + return t->__is_pointer_p (); #endif } |