Skip to content

Commit

Permalink
Remove unneeded vrange_traits.
Browse files Browse the repository at this point in the history
The traits struct is no longer needed.

Tested on x86-64 Linux.

gcc/ChangeLog:

	* value-range.h (struct vrange_traits): Remove.
	(is_a): Rewrite without vrange_traits.
	(as_a): Same.
  • Loading branch information
aldyh committed Jun 3, 2022
1 parent 89b0276 commit f4fa81b
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions gcc/value-range.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,24 +245,12 @@ class unsupported_range : public vrange
virtual void dump (FILE *) const override;
};

// Traits to implement vrange is_a<> and as_a<>.

template<typename T>
struct vrange_traits
{
// Default to something unusable.
typedef void range_type;
};

template<>
struct vrange_traits<irange>
{
typedef irange range_type;
};
// is_a<> and as_a<> implementation for vrange.

// Anything we haven't specialized is a hard fail.
template <typename T>
inline bool
is_a (vrange &v)
is_a (vrange &)
{
gcc_unreachable ();
return false;
Expand All @@ -281,18 +269,16 @@ template <typename T>
inline T &
as_a (vrange &v)
{
typedef typename vrange_traits<T>::range_type range_type;
gcc_checking_assert (is_a <range_type> (v));
return static_cast <range_type &> (v);
gcc_checking_assert (is_a <T> (v));
return static_cast <T &> (v);
}

template <typename T>
inline const T &
as_a (const vrange &v)
{
typedef typename vrange_traits<T>::range_type range_type;
gcc_checking_assert (is_a <range_type> (v));
return static_cast <const range_type &> (v);
gcc_checking_assert (is_a <T> (v));
return static_cast <const T &> (v);
}

// Specializations for the different range types.
Expand Down

0 comments on commit f4fa81b

Please sign in to comment.