From b0f19336f247c63abbc08935f0c1efe16f22ac3a Mon Sep 17 00:00:00 2001 From: David Malcolm <dmalcolm@redhat.com> Date: Tue, 31 Oct 2023 17:05:41 -0400 Subject: [PATCH] libcpp: eliminate MACRO_MAP_EXPANSION_POINT_LOCATION This patch eliminates the function "MACRO_MAP_EXPANSION_POINT_LOCATION" (which hasn't been a macro since r6-739-g0501dbd932a7e9) in favor of a new line_map_macro::get_expansion_point_location accessor. No functional change intended. gcc/c-family/ChangeLog: * c-warn.cc (warn_for_multistatement_macros): Update for removal of MACRO_MAP_EXPANSION_POINT_LOCATION. gcc/cp/ChangeLog: * module.cc (ordinary_loc_of): Update for removal of MACRO_MAP_EXPANSION_POINT_LOCATION. (module_state::note_location): Update for renaming of field. (module_state::write_macro_maps): Likewise. gcc/ChangeLog: * input.cc (dump_location_info): Update for removal of MACRO_MAP_EXPANSION_POINT_LOCATION. * tree-diagnostic.cc (maybe_unwind_expanded_macro_loc): Likewise. libcpp/ChangeLog: * include/line-map.h (line_map_macro::get_expansion_point_location): New accessor. (line_map_macro::expansion): Rename field to... (line_map_macro::mexpansion): Rename field to... (MACRO_MAP_EXPANSION_POINT_LOCATION): Delete this function. * line-map.cc (linemap_enter_macro): Update for renaming of field. (linemap_macro_map_loc_to_exp_point): Update for removal of MACRO_MAP_EXPANSION_POINT_LOCATION. Signed-off-by: David Malcolm <dmalcolm@redhat.com> --- gcc/c-family/c-warn.cc | 2 +- gcc/cp/module.cc | 6 +++--- gcc/input.cc | 4 ++-- gcc/tree-diagnostic.cc | 2 +- libcpp/include/line-map.h | 19 ++++++++++--------- libcpp/line-map.cc | 4 ++-- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/gcc/c-family/c-warn.cc b/gcc/c-family/c-warn.cc index 9ab83a9a84aa..bc889cee6b91 100644 --- a/gcc/c-family/c-warn.cc +++ b/gcc/c-family/c-warn.cc @@ -2951,7 +2951,7 @@ warn_for_multistatement_macros (location_t body_loc, location_t next_loc, while (linemap_macro_expansion_map_p (guard_map)) { const line_map_macro *mm = linemap_check_macro (guard_map); - guard_loc_exp = MACRO_MAP_EXPANSION_POINT_LOCATION (mm); + guard_loc_exp = mm->get_expansion_point_location (); guard_map = linemap_lookup (line_table, guard_loc_exp); if (guard_map == body_map) return; diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 539518d79234..c1c8c226bc1e 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -13937,7 +13937,7 @@ ordinary_loc_of (line_maps *lmaps, location_t from) /* Find the ordinary location nearest FROM. */ const line_map *map = linemap_lookup (lmaps, from); const line_map_macro *mac_map = linemap_check_macro (map); - from = MACRO_MAP_EXPANSION_POINT_LOCATION (mac_map); + from = mac_map->get_expansion_point_location (); } } return from; @@ -15779,7 +15779,7 @@ module_state::note_location (location_t loc) slot->remap = 0; // Expansion locations could themselves be from a // macro, we need to note them all. - note_location (mac_map->expansion); + note_location (mac_map->m_expansion); gcc_checking_assert (mac_map->n_tokens); location_t tloc = UNKNOWN_LOCATION; for (unsigned ix = mac_map->n_tokens * 2; ix--;) @@ -16375,7 +16375,7 @@ module_state::write_macro_maps (elf_out *to, range_t &info, unsigned *crc_p) sec.u (iter->remap); sec.u (mac->n_tokens); sec.cpp_node (mac->macro); - write_location (sec, mac->expansion); + write_location (sec, mac->m_expansion); const location_t *locs = mac->macro_locations; /* There are lots of identical runs. */ location_t prev = UNKNOWN_LOCATION; diff --git a/gcc/input.cc b/gcc/input.cc index fd09fccb0e3c..6256d81f5319 100644 --- a/gcc/input.cc +++ b/gcc/input.cc @@ -1530,9 +1530,9 @@ dump_location_info (FILE *stream) map->start_location, (map->start_location + MACRO_MAP_NUM_MACRO_TOKENS (map))); - inform (MACRO_MAP_EXPANSION_POINT_LOCATION (map), + inform (map->get_expansion_point_location (), "expansion point is location %i", - MACRO_MAP_EXPANSION_POINT_LOCATION (map)); + map->get_expansion_point_location ()); fprintf (stream, " map->start_location: %u\n", map->start_location); diff --git a/gcc/tree-diagnostic.cc b/gcc/tree-diagnostic.cc index a600f0e9f64e..cae400cf3727 100644 --- a/gcc/tree-diagnostic.cc +++ b/gcc/tree-diagnostic.cc @@ -217,7 +217,7 @@ maybe_unwind_expanded_macro_loc (diagnostic_context *context, This is the locus 2/ of the earlier comment. */ location_t resolved_exp_loc = linemap_resolve_location (line_table, - MACRO_MAP_EXPANSION_POINT_LOCATION (iter->map), + iter->map->get_expansion_point_location (), LRK_MACRO_DEFINITION_LOCATION, NULL); diagnostic_append_note (context, resolved_exp_loc, diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h index cb934e6b9b33..635d6d3077c5 100644 --- a/libcpp/include/line-map.h +++ b/libcpp/include/line-map.h @@ -461,6 +461,15 @@ struct cpp_hashnode; The offset from START_LOCATION is used to index into MACRO_LOCATIONS; this holds the original location of the token. */ struct GTY((tag ("2"))) line_map_macro : public line_map { + + /* Get the location of the expansion point of this macro map. */ + + location_t + get_expansion_point_location () const + { + return m_expansion; + } + /* Base is 4 bytes. */ /* The number of tokens inside the replacement-list of MACRO. */ @@ -535,7 +544,7 @@ struct GTY((tag ("2"))) line_map_macro : public line_map { by the map that was current right before the current one. It could have been either a macro or an ordinary map, depending on if we are in a nested expansion context not. */ - location_t expansion; + location_t m_expansion; /* Size is 20 or 32 (4 bytes padding on 64-bit). */ }; @@ -705,14 +714,6 @@ MACRO_MAP_LOCATIONS (const line_map_macro *macro_map) return macro_map->macro_locations; } -/* Get the location of the expansion point of the macro map MAP. */ - -inline location_t -MACRO_MAP_EXPANSION_POINT_LOCATION (const line_map_macro *macro_map) -{ - return macro_map->expansion; -} - /* The abstraction of a set of location maps. There can be several types of location maps. This abstraction contains the attributes that are independent from the type of the map. diff --git a/libcpp/line-map.cc b/libcpp/line-map.cc index cd1735301493..cc9e14aa61e3 100644 --- a/libcpp/line-map.cc +++ b/libcpp/line-map.cc @@ -782,7 +782,7 @@ linemap_enter_macro (class line_maps *set, struct cpp_hashnode *macro_node, map->macro_locations = (location_t*) set->m_reallocator (nullptr, 2 * num_tokens * sizeof (location_t)); - map->expansion = expansion; + map->m_expansion = expansion; memset (MACRO_MAP_LOCATIONS (map), 0, 2 * num_tokens * sizeof (location_t)); @@ -1225,7 +1225,7 @@ linemap_macro_map_loc_to_exp_point (const line_map_macro *map, linemap_assert ((location - MAP_START_LOCATION (map)) < MACRO_MAP_NUM_MACRO_TOKENS (map)); - return MACRO_MAP_EXPANSION_POINT_LOCATION (map); + return map->get_expansion_point_location (); } /* LOCATION is the source location of a token that belongs to a macro -- GitLab