diff options
Diffstat (limited to 'libcpp/line-map.c')
-rw-r--r-- | libcpp/line-map.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/libcpp/line-map.c b/libcpp/line-map.c index 694137a..7ba003a 100644 --- a/libcpp/line-map.c +++ b/libcpp/line-map.c @@ -2327,6 +2327,25 @@ rich_location::maybe_add_fixit (source_location start, if (reject_impossible_fixit (next_loc)) return; + /* Only allow fix-it hints that affect a single line in one file. + Compare the end-points. */ + expanded_location exploc_start + = linemap_client_expand_location_to_spelling_point (start); + expanded_location exploc_next_loc + = linemap_client_expand_location_to_spelling_point (next_loc); + /* They must be within the same file... */ + if (exploc_start.file != exploc_next_loc.file) + { + stop_supporting_fixits (); + return; + } + /* ...and on the same line. */ + if (exploc_start.line != exploc_next_loc.line) + { + stop_supporting_fixits (); + return; + } + const char *newline = strchr (new_content, '\n'); if (newline) { @@ -2342,8 +2361,6 @@ rich_location::maybe_add_fixit (source_location start, } /* The insertion must be at the start of a line. */ - expanded_location exploc_start - = linemap_client_expand_location_to_spelling_point (start); if (exploc_start.column != 1) { stop_supporting_fixits (); |