On 10/23/2015 02:41 PM, David Malcolm wrote:
Some diagnostics e.g. -Wmaybe-uninitialized weren't showing
underlines, despite being provided with range-based data.
Debugging showed that it the pertinent location was an
ad-hoc location with a range:
(gdb) p /x loc
$9 = 0x8000002a
(gdb) p line_table->location_adhoc_data_map.data[0x2a]
$10 = {locus = 6919936, src_range = {m_start = 6919936,
m_finish = 6921216}, data = 0x7ffff19a8480}
(gdb) call inform (loc, "foo")
test.c: In function 'test':
test.c:173:10: note: foo
return result;
^~~~~~
but the result from linemap_resolve_location here:
location = linemap_resolve_location (line_table, location,
LRK_SPELLING_LOCATION,
NULL);
was stripping away the ad-hoc location to just the locus:
Value returned is $11 = 6919936
at the front of the token, thus losing the underline.
The fix is to rework linemap_resolve_location to avoid bypassing
ad-hoc locations, so that range data is available later.
gcc/testsuite/ChangeLog:
* gcc.dg/diagnostic-tree-expr-ranges-2.c: New file.
libcpp/ChangeLog:
* line-map.c (linemap_position_for_loc_and_offset): Handle
ad-hoc locations.
(linemap_macro_map_loc_unwind_toward_spelling): Add line_maps
param. Handle ad-hoc locations.
(linemap_location_in_system_header_p): Pass on "set" to call to
linemap_macro_map_loc_unwind_toward_spelling.
(linemap_macro_loc_to_spelling_point): Retain ad-hoc locations.
Pass on "set" to call to
linemap_macro_map_loc_unwind_toward_spelling.
(linemap_resolve_location): Retain ad-hoc locations. Pass on
"set" to call to linemap_macro_map_loc_unwind_toward_spelling.
(linemap_unwind_toward_expansion): Pass on "set" to call to
linemap_macro_map_loc_unwind_toward_spelling.
This is fine. Other than the test it seems like it'd be independent of
the other patches. If so, you can commit the linmap changes
independently of the rest.
Jeff
---