diff options
author | Dodji Seketeli <dodji@redhat.com> | 2014-07-16 10:33:27 +0000 |
---|---|---|
committer | Dodji Seketeli <dodji@gcc.gnu.org> | 2014-07-16 12:33:27 +0200 |
commit | c468587ac23c889abfa67ce8979e8baedcb349e9 (patch) | |
tree | 2b9dadc35640ecec96428e5e73e233c98df2477d /gcc/input.c | |
parent | 185b22783adf5355e8ba4701a1c090b27a17e313 (diff) | |
download | gcc-c468587ac23c889abfa67ce8979e8baedcb349e9.zip gcc-c468587ac23c889abfa67ce8979e8baedcb349e9.tar.gz gcc-c468587ac23c889abfa67ce8979e8baedcb349e9.tar.bz2 |
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>
From-SVN: r212637
Diffstat (limited to 'gcc/input.c')
-rw-r--r-- | gcc/input.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/input.c b/gcc/input.c index 63cd062..f3fd0e9 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 |