Jakub had some concern about the use of sorry, so here's a revised
version of the patch, with the following changes:
- fixed the comment issues noted above.
- changed from a "sorry" to an "inform" (as per Jakub), passing
in the pertinent location_t to avoid adding a use of
input_location.
- I filed PR preprocessor/69177 to cover the increased chance of
hitting LINE_MAP_MAX_LOCATION_WITH_COLS, so I've updated the
ChangeLog to reflect which parts affect that, and which just affect
-Wmisleading-indentation (PR c++/68819).
This patch resolves both; the test cases are written from the POV
of specific ranges of location_t values and hence mingle the two PRs
somewhat.
I did some crude performance testing on this on gimple-match.o;
the compile time taken was < 1% difference with/without this patch
(and that with the patch it had compiled lines 35769-52607 of that
file using the "don't use bit-packing for ranges" fallback).
Successfully bootstrapped®rtested on x86_64-pc-linux-gnu; adds
11 PASS results to gcc.sum.
OK for trunk?
gcc/c-family/ChangeLog:
PR c++/68819
* c-indentation.c (get_visual_column): Add location_t param.
Handle the columnnumber being zero by effectively disabling the
warning, with an "inform".
(should_warn_for_misleading_indentation): Add location_t argument
for all uses of get_visual_column.
gcc/testsuite/ChangeLog:
PR c++/68819
PR preprocessor/69177
* gcc.dg/plugin/location-overflow-test-1.c: New test case.
* gcc.dg/plugin/location-overflow-test-2.c: New test case.
* gcc.dg/plugin/location_overflow_plugin.c: New test plugin.
* gcc.dg/plugin/plugin.exp (plugin_test_list): Add the above.
libcpp/ChangeLog:
PR preprocessor/69177
* line-map.c (LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES): New
constant.
(LINE_MAP_MAX_LOCATION_WITH_COLS): Add note about unit tests
to comment.
(can_be_stored_compactly_p): Reduce threshold from
LINE_MAP_MAX_LOCATION_WITH_COLS to
LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES.
(get_combined_adhoc_loc): Likewise.
(get_range_from_loc): Likewise.
(linemap_line_start): Ensure that a new ordinary map is created
when transitioning from range-packing being enabled to disabled,
at the LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES threshold. Set
range_bits to 0 for new ordinary maps when beyond this limit.
Prevent the "increase the column bits of a freshly created map"
optimization if the range bits has reduced.