From c468587ac23c889abfa67ce8979e8baedcb349e9 Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Wed, 16 Jul 2014 10:33:27 +0000 Subject: Support location tracking for built-in macro tokens When a built-in macro is expanded, the location of the token in the epansion list is the location of the expansion point of the built-in macro. This patch creates a virtual location for that token instead, effectively tracking locations of tokens resulting from built-in macro tokens. libcpp/ * include/line-map.h (line_maps::builtin_location): New data member. (line_map_init): Add a new parameter to initialize the new line_maps::builtin_location data member. * line-map.c (linemap_init): Initialize the line_maps::builtin_location data member. * macro.c (builtin_macro): Create a macro map and track the token resulting from the expansion of a built-in macro. gcc/ * input.h (is_location_from_builtin_token): New function declaration. * input.c (is_location_from_builtin_token): New function definition. * toplev.c (general_init): Tell libcpp what the pre-defined spelling location for built-in tokens is. Signed-off-by: Dodji Seketeli From-SVN: r212637 --- libcpp/include/line-map.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'libcpp/include/line-map.h') diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h index 9886314..0c8f588 100644 --- a/libcpp/include/line-map.h +++ b/libcpp/include/line-map.h @@ -315,6 +315,10 @@ struct GTY(()) line_maps { line_map_round_alloc_size_func round_alloc_size; struct location_adhoc_data_map location_adhoc_data_map; + + /* The special location value that is used as spelling location for + built-in tokens. */ + source_location builtin_location; }; /* Returns the pointer to the memory region where information about @@ -447,8 +451,12 @@ extern source_location get_location_from_adhoc_loc (struct line_maps *, extern void rebuild_location_adhoc_htab (struct line_maps *); -/* Initialize a line map set. */ -extern void linemap_init (struct line_maps *); +/* Initialize a line map set. SET is the line map set to initialize + and BUILTIN_LOCATION is the special location value to be used as + spelling location for built-in tokens. This BUILTIN_LOCATION has + to be strictly less than RESERVED_LOCATION_COUNT. */ +extern void linemap_init (struct line_maps *set, + source_location builtin_location); /* Check for and warn about line_maps entered but not exited. */ -- cgit v1.1