suppression: Factorize out is_data_member_offset_in_range
authorDodji Seketeli <dodji@redhat.com>
Fri, 27 Jan 2023 14:58:37 +0000 (15:58 +0100)
committerDodji Seketeli <dodji@redhat.com>
Wed, 1 Mar 2023 12:49:51 +0000 (13:49 +0100)
commitb1b69abd791d49e1ecb1a8532b3a14af8cfe7e9e
tree93273afaed5e5504dcb668d9f10392ec547caafa
parent153b37a164a0cd9e0136e8393a7a2ac5e34f8fed
suppression: Factorize out is_data_member_offset_in_range

In preparation of subsequent changes, this patch factorizes a function
is_data_member_offset_in_range() out of
type_suppression::suppression().  This is useful to determine if a
data member offset is within an "offset range" expressed by the
type_suppression::insertion_range type.

This function is useful to implement the
offset_of_first_data_member_regexp and
offset_of_last_data_member_regexp properties to come in subsequent
patches.

Please note that is_data_member_offset_in_range works on data members
of unions and classes, not just on classes like what the original code
of inside type_suppression::suppresses_diff was doing.

This patch should not have any functional impact on the code.

* include/abg-fwd.h (get_last_data_member)
(get_next_data_member_offset): Declare functions.
* src/abg-ir.cc (get_next_data_member): Add an overload for
class_or_union and write the overload for class_or_union_sptr in
term of the former.
(get_last_data_member): Add overloads form class_or_union& and
class_or_union*.  Write the overload for class_or_union_sptr in
terms of the one for class_or_union*.
(get_next_data_member_offset): Add an overload for
class_or_union* and write the overload for class_or_union_sptr in
terms of the former.
* include/abg-suppression.h
(type_suppression::insertion_range::eval_boundary): Take a
class_or_union* for the context, as opposed to a class_decl_sptr.
This makes this static function work for unions as well.
(is_data_member_offset_in_range): Declare new function.
* src/abg-suppression.cc (type_suppression::suppression_diff):
Factorize ...
(is_data_member_offset_in_range): ... this function out.
(type_suppression::insertion_range::eval_boundary): Adjust this to
make it take a class_or_union* rather than a class_decl_sptr.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
include/abg-fwd.h
include/abg-suppression.h
src/abg-ir.cc
src/abg-suppression.cc