summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authordodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>2014-07-16 10:33:27 +0000
committerdodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>2014-07-16 10:33:27 +0000
commita4cfdfed6839584bcde0c2c884e3dd55476adaa3 (patch)
tree2b9dadc35640ecec96428e5e73e233c98df2477d /gcc
parentc4884451cad7af65335e5a3dfbd99a75a50110e7 (diff)
downloadgcc-a4cfdfed6839584bcde0c2c884e3dd55476adaa3.tar.gz
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 <dodji@redhat.com> git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@212637 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/input.c16
-rw-r--r--gcc/input.h1
-rw-r--r--gcc/toplev.c2
4 files changed, 28 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 11d7551cf42..6680787ba41 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2014-07-16 Dodji Seketeli <dodji@redhat.com>
+
+ Support location tracking for built-in macro tokens
+ * 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.
+
2014-07-16 Jakub Jelinek <jakub@redhat.com>
* omp-low.c (create_omp_child_function): Don't set DECL_NAMELESS
diff --git a/gcc/input.c b/gcc/input.c
index 63cd062ec5b..f3fd0e9d755 100644
--- a/gcc/input.c
+++ b/gcc/input.c
@@ -713,6 +713,22 @@ location_get_source_line (expanded_location xloc,
return read ? buffer : NULL;
}
+/* Test if the location originates from the spelling location of a
+ builtin-tokens. That is, return TRUE if LOC is a (possibly
+ virtual) location of a built-in token that appears in the expansion
+ list of a macro. Please note that this function also works on
+ tokens that result from built-in tokens. For instance, the
+ function would return true if passed a token "4" that is the result
+ of the expansion of the built-in __LINE__ macro. */
+bool
+is_location_from_builtin_token (source_location loc)
+{
+ const line_map *map = NULL;
+ loc = linemap_resolve_location (line_table, loc,
+ LRK_SPELLING_LOCATION, &map);
+ return loc == BUILTINS_LOCATION;
+}
+
/* Expand the source location LOC into a human readable location. If
LOC is virtual, it resolves to the expansion point of the involved
macro. If LOC resolves to a builtin location, the file name of the
diff --git a/gcc/input.h b/gcc/input.h
index d910bb88f97..1def793ae30 100644
--- a/gcc/input.h
+++ b/gcc/input.h
@@ -36,6 +36,7 @@ extern GTY(()) struct line_maps *line_table;
extern char builtins_location_check[(BUILTINS_LOCATION
< RESERVED_LOCATION_COUNT) ? 1 : -1];
+extern bool is_location_from_builtin_token (source_location);
extern expanded_location expand_location (source_location);
extern const char *location_get_source_line (expanded_location xloc,
int *line_size);
diff --git a/gcc/toplev.c b/gcc/toplev.c
index e35b826e89d..9e747e50b7e 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1157,7 +1157,7 @@ general_init (const char *argv0)
init_ggc ();
init_stringpool ();
line_table = ggc_alloc<line_maps> ();
- linemap_init (line_table);
+ linemap_init (line_table, BUILTINS_LOCATION);
line_table->reallocator = realloc_for_line_map;
line_table->round_alloc_size = ggc_round_alloc_size;
init_ttree ();