Allow the use of ad-hoc locations for fix-it hints

Currently the fix-it validator rejects ad-hoc locations.
Fix this by calling get_pure_location on the input locations to
add_fixit_insert/replace.  Doing so requires moving get_pure_location
from gcc to libcpp.

gcc/ChangeLog:
	* diagnostic-show-locus.c
	(selftest::test_one_liner_fixit_validation_adhoc_locations): New
	function.
	(selftest::test_diagnostic_show_locus_one_liner): Call it.
	* input.c (get_pure_location): Move to libcpp/line-map.c.
	* input.h (get_pure_location): Convert decl to an inline function
	calling implementation in libcpp.

libcpp/ChangeLog:
	* include/line-map.h (get_pure_location): New decl.
	* line-map.c (get_pure_location): Move here, from gcc/input.c, adding
	a line_maps * param.
	(rich_location::add_fixit_insert): Call get_pure_location on "where".
	(rich_location::add_fixit_replace): Call get_pure_location on the
	end-points.

From-SVN: r239843
This commit is contained in:
David Malcolm
2016-08-29 20:42:57 +00:00
committed by David Malcolm
parent adfa1e6b37
commit 2aa514130a
7 changed files with 127 additions and 23 deletions

View File

@@ -1002,6 +1002,12 @@ IS_ADHOC_LOC (source_location loc)
bool
pure_location_p (line_maps *set, source_location loc);
/* Given location LOC within SET, strip away any packed range information
or ad-hoc information. */
extern source_location get_pure_location (line_maps *set,
source_location loc);
/* Combine LOC and BLOCK, giving a combined adhoc location. */
inline source_location