c++: Macro location fixes [PR 98718]
This fixes some issues with macro maps. We were incorrectly calculating the number of macro expansions in a location span, and I had a workaround that partially covered that up. Further, while macro location spans are monotonic, that is not true of ordinary location spans. Thus we need to insert an indirection array when binary searching the latter. (We load ordinary locations before loading imports, but macro locations afterwards. We make sure an import location is de-macrofied, if needed.) PR c++/98718 gcc/cp/ * module.cc (ool): New indirection vector. (loc_spans::maybe_propagate): Location is not optional. (loc_spans::open): Likewise. Assert monotonically advancing. (module_for_ordinary_loc): Use ool indirection vector. (module_state::write_prepare_maps): Do not count empty macro expansions. Elide empty spans. (module_state::write_macro_maps): Skip empty expansions. (ool_cmp): New qsort comparator. (module_state::write): Create and destroy ool vector. (name_pending_imports): Fix dump push/pop. (preprocess_module): Likewise. Add more dumping. (preprocessed_module): Likewise. libcpp/ * include/line-map.h * line-map.c gcc/testsuite/ * g++.dg/modules/pr98718_a.C: New. * g++.dg/modules/pr98718_b.C: New.
This commit is contained in:
@@ -1136,8 +1136,9 @@ extern location_t linemap_module_loc
|
||||
extern void linemap_module_reparent
|
||||
(line_maps *, location_t loc, location_t new_parent);
|
||||
|
||||
/* Restore the linemap state such that the map at LWM-1 continues. */
|
||||
extern void linemap_module_restore
|
||||
/* Restore the linemap state such that the map at LWM-1 continues.
|
||||
Return start location of the new map. */
|
||||
extern unsigned linemap_module_restore
|
||||
(line_maps *, unsigned lwm);
|
||||
|
||||
/* Given a logical source location, returns the map which the
|
||||
|
||||
Reference in New Issue
Block a user