c++: make strip_typedefs generalize strip_typedefs_expr
commitd180a5524ccdab8ef839ee55efecf60ce5b0240b
authorPatrick Palka <ppalka@redhat.com>
Thu, 20 Apr 2023 19:00:04 +0000 (20 15:00 -0400)
committerPatrick Palka <ppalka@redhat.com>
Thu, 20 Apr 2023 19:00:04 +0000 (20 15:00 -0400)
treeb6b293a224d39606c5665af2a66e8974a353f333
parentd4e8523bf3bfb5f7c23822c23bd2b230030c3d2a
c++: make strip_typedefs generalize strip_typedefs_expr

Currently if we have a TREE_VEC of types that we want to strip of typedefs,
we unintuitively need to call strip_typedefs_expr instead of strip_typedefs
since only strip_typedefs_expr handles TREE_VEC, and it also dispatches
to strip_typedefs when given a type.  But this seems backwards: arguably
strip_typedefs_expr should be the more specialized function, which
strip_typedefs dispatches to (and thus generalizes).

So this patch makes strip_typedefs subsume strip_typedefs_expr rather
than vice versa, which allows for some simplifications.

gcc/cp/ChangeLog:

* tree.cc (strip_typedefs): Move TREE_LIST handling to
strip_typedefs_expr.  Dispatch to strip_typedefs_expr for
non-type 't'.
<case TYPENAME_TYPE>: Remove manual dispatching to
strip_typedefs_expr.
<case TRAIT_TYPE>: Likewise.
(strip_typedefs_expr): Replaces calls to strip_typedefs_expr
with strip_typedefs throughout.  Don't dispatch to strip_typedefs
for type 't'.
<case TREE_LIST>: Replace this with the better version from
strip_typedefs.
gcc/cp/tree.cc