From 6ec8e34c3229250427731cdab5db980b9100942b Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Wed, 18 Oct 2023 11:57:56 +0200 Subject: [PATCH] suppression: Make the "end" data member offset selector be named boundary Now that we have what is called a "named boundary", introduced by commit [1], this patch re-writes the handling of the "end" data member offset selector (used in expressions like: offset_of(end) in suppression specifications) in terms of the new "named boundary" infrastructure. In other words, the "end" keyword is now a named boundary constant, just like the "offset_of_flexible_array_data_member" is a named boundary constant. [1]: The patch that introduced the concept of "named boundary" is this one: commit b12ba51e62de7c61526bd0a0cac6cc9bcf28fdee Author: Dodji Seketeli Date: Thu Oct 5 13:32:21 2023 +0200 Support suppressing data member insertion before a flexible array member * src/abg-suppression.cc (END_STRING): Define new static string constant accessor. (type_suppression::insertion_range::eval_boundary): Eval the "end" named boundary as having a numerical value of std::numeric_limits::max(). (read_type_suppression): Parse the "end" token as a named boundary. Signed-off-by: Dodji Seketeli --- src/abg-suppression.cc | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/abg-suppression.cc b/src/abg-suppression.cc index d84857ba..326d003e 100644 --- a/src/abg-suppression.cc +++ b/src/abg-suppression.cc @@ -51,6 +51,14 @@ OFFSET_OF_FLEXIBLE_ARRAY_DATA_MEMBER_STRING() return s; } +/// @return the string constant "end"; +static const string& +END_STRING() +{ + static string s = "end"; + return s; +} + // // section parsing @@ -1602,6 +1610,14 @@ type_suppression::insertion_range::eval_boundary(const boundary_sptr boundary, return true; } } + else if (b->get_name() == END_STRING()) + { + // The 'end' of a struct is represented by the value + // std::numeric_limits::max(), recognized by + // type_suppression::insertion_range::boundary_value_is_end. + value = std::numeric_limits::max(); + return true; + } } return false; } @@ -2100,8 +2116,8 @@ read_type_suppression(const ini::config::section& section) // has_data_member_inserted_at = string ins_point = prop->get_value()->as_string(); type_suppression::insertion_range::boundary_sptr begin, end; - if (ins_point == "end") - begin = type_suppression::insertion_range::create_integer_boundary(-1); + if (ins_point == END_STRING()) + begin = type_suppression::insertion_range::create_named_boundary(ins_point); else if (ins_point == OFFSET_OF_FLEXIBLE_ARRAY_DATA_MEMBER_STRING()) begin = type_suppression::insertion_range::create_named_boundary(ins_point); else if (isdigit(ins_point[0]))