diff options
author | Nathan Sidwell <nathan@acm.org> | 2018-08-08 18:13:00 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2018-08-08 18:13:00 +0000 |
commit | f10a91352f83232394646df5a67bdb8f4366a067 (patch) | |
tree | a4ec7ecbde7bfc84329e5a2bb1dc8dea689d7d31 /gcc/c-family | |
parent | a801991954f70fb9470502d305065719849c5660 (diff) | |
download | gcc-f10a91352f83232394646df5a67bdb8f4366a067.zip gcc-f10a91352f83232394646df5a67bdb8f4366a067.tar.gz gcc-f10a91352f83232394646df5a67bdb8f4366a067.tar.bz2 |
[PATCH] line-map include-from representation
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg00554.html
Make linemap::included_from a location
libcpp/
* include/line-map.h (struct line_map_ordinary): Replace
included_from map index with included_at source_location.
(ORDINARY_MAP_INCLUDER_FILE_INDEX): Delete.
(LAST_SOURCE_LINE_LOCATION): Delete.
(LAST_SOURCE_LINE, LAST_SOURCE_COLUMN): Delete.
(linemap_included_from): New.
(linemap_included_from_linemap): Declare.
(MAIN_FILE_P): Adjust.
* line-map.c (linemap_included_from_linemap): New.
(lonemap_check_files_exited): Use linemap_included_at.
(linemap_add): Adjust inclusion setting.
(linemap_dump, linemap_dump_location): Adjust.
* directives.c (do_linemarker): Use linemap_included_at.
gcc/
* diagnostic.c (diagnostic_report_current_module): Use
linemap_included_from & linemap_included_from_linemap.
gcc/c-family/
* c-common.c (try_to_locate_new_include_inertion_point): Use
linemap_included_from_linemap.
* c-lex.c (fe_file_change): Use linemap_included_from.
* c-ppoutput.c (pp_file_change): Likewise.
gcc/fortran/
* cpp.c (cb_file_change): Use linemap_included_from.
gcc/testsuite/
* c-c++-common/inc-from-1a.h, c-c++-common/inc-from-1b.h,
c-c++-common/inc-from-1.c: New
From-SVN: r263429
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/c-family/c-common.c | 4 | ||||
-rw-r--r-- | gcc/c-family/c-lex.c | 2 | ||||
-rw-r--r-- | gcc/c-family/c-ppoutput.c | 6 |
4 files changed, 12 insertions, 7 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index d5e5fff..aa7aada 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,10 @@ +2018-08-08 Nathan Sidwell <nathan@acm.org> + + * c-common.c (try_to_locate_new_include_inertion_point): Use + linemap_included_from_linemap. + * c-lex.c (fe_file_change): Use linemap_included_from. + * c-ppoutput.c (pp_file_change): Likewise. + 2018-08-01 Martin Sebor <msebor@redhat.com> PR tree-optimization/86650 diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index d919605..91e60f3 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -8413,8 +8413,8 @@ try_to_locate_new_include_insertion_point (const char *file, location_t loc) const line_map_ordinary *ord_map = LINEMAPS_ORDINARY_MAP_AT (line_table, i); - const line_map_ordinary *from = INCLUDED_FROM (line_table, ord_map); - if (from) + if (const line_map_ordinary *from + = linemap_included_from_linemap (line_table, ord_map)) if (from->to_file == file) { last_include_ord_map = from; diff --git a/gcc/c-family/c-lex.c b/gcc/c-family/c-lex.c index 074c2d2..ac58335c 100644 --- a/gcc/c-family/c-lex.c +++ b/gcc/c-family/c-lex.c @@ -199,7 +199,7 @@ fe_file_change (const line_map_ordinary *new_map) we already did in compile_file. */ if (!MAIN_FILE_P (new_map)) { - unsigned int included_at = LAST_SOURCE_LINE_LOCATION (new_map - 1); + location_t included_at = linemap_included_from (new_map); int line = 0; if (included_at > BUILTINS_LOCATION) line = SOURCE_LINE (new_map - 1, included_at); diff --git a/gcc/c-family/c-ppoutput.c b/gcc/c-family/c-ppoutput.c index 8c525caf..b8fc1c6 100644 --- a/gcc/c-family/c-ppoutput.c +++ b/gcc/c-family/c-ppoutput.c @@ -663,11 +663,9 @@ pp_file_change (const line_map_ordinary *map) /* Bring current file to correct line when entering a new file. */ if (map->reason == LC_ENTER) { - const line_map_ordinary *from = INCLUDED_FROM (line_table, map); - maybe_print_line (LAST_SOURCE_LINE_LOCATION (from)); + maybe_print_line (linemap_included_from (map)); + flags = " 1"; } - if (map->reason == LC_ENTER) - flags = " 1"; else if (map->reason == LC_LEAVE) flags = " 2"; print_line (map->start_location, flags); |