aboutsummaryrefslogtreecommitdiff
path: root/gcc/input.c
diff options
context:
space:
mode:
authorMike Gulick <mgulick@mathworks.com>2018-11-27 16:04:31 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2018-11-27 16:04:31 +0000
commitbc65bad27f066e2b91380071d65a8f6c6745c2a2 (patch)
tree8fd44fa810e725cd4e7434022b0220e3c931a500 /gcc/input.c
parentfb51a3a867e20f574bde3b929ec9ccfba6cc374b (diff)
downloadgcc-bc65bad27f066e2b91380071d65a8f6c6745c2a2.zip
gcc-bc65bad27f066e2b91380071d65a8f6c6745c2a2.tar.gz
gcc-bc65bad27f066e2b91380071d65a8f6c6745c2a2.tar.bz2
PR preprocessor/83173: Enhance -fdump-internal-locations output
gcc/ChangeLog: 2018-11-27 Mike Gulick <mgulick@mathworks.com> PR preprocessor/83173 * input.c (dump_location_info): Dump reason and included_from fields from line_map_ordinary struct. Fix indentation when location > 5 digits. * diagnostic-show-locus.c (num_digits, num_digits): Move to diagnostic.c to allow it to be utilized by input.c. * diagnostic.c (num_digits, selftest::test_num_digits): Moved here. (selftest::diagnostic_c_tests): Run selftest::test_num_digits. * diagnostic.h (num_digits): Add extern definition. libcpp/ChangeLog: 2018-11-27 Mike Gulick <mgulick@mathworks.com> PR preprocessor/83173 * location-example.txt: Update example -fdump-internal-locations output. From-SVN: r266520
Diffstat (limited to 'gcc/input.c')
-rw-r--r--gcc/input.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/gcc/input.c b/gcc/input.c
index 237c0d5..6ce9782 100644
--- a/gcc/input.c
+++ b/gcc/input.c
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3. If not see
#include "system.h"
#include "coretypes.h"
#include "intl.h"
+#include "diagnostic.h"
#include "diagnostic-core.h"
#include "selftest.h"
#include "cpplib.h"
@@ -1067,6 +1068,37 @@ dump_location_info (FILE *stream)
map->m_column_and_range_bits - map->m_range_bits);
fprintf (stream, " range bits: %i\n",
map->m_range_bits);
+ const char * reason;
+ switch (map->reason) {
+ case LC_ENTER:
+ reason = "LC_ENTER";
+ break;
+ case LC_LEAVE:
+ reason = "LC_LEAVE";
+ break;
+ case LC_RENAME:
+ reason = "LC_RENAME";
+ break;
+ case LC_RENAME_VERBATIM:
+ reason = "LC_RENAME_VERBATIM";
+ break;
+ case LC_ENTER_MACRO:
+ reason = "LC_RENAME_MACRO";
+ break;
+ default:
+ reason = "Unknown";
+ }
+ fprintf (stream, " reason: %d (%s)\n", map->reason, reason);
+
+ const line_map_ordinary *includer_map
+ = linemap_included_from_linemap (line_table, map);
+ fprintf (stream, " included from location: %d",
+ linemap_included_from (map));
+ if (includer_map) {
+ fprintf (stream, " (in ordinary map %d)",
+ int (includer_map - line_table->info_ordinary.maps));
+ }
+ fprintf (stream, "\n");
/* Render the span of source lines that this "map" covers. */
for (location_t loc = MAP_START_LOCATION (map);
@@ -1100,7 +1132,14 @@ dump_location_info (FILE *stream)
if (max_col > line_text.length ())
max_col = line_text.length () + 1;
- int indent = 14 + strlen (exploc.file);
+ int len_lnum = num_digits (exploc.line);
+ if (len_lnum < 3)
+ len_lnum = 3;
+ int len_loc = num_digits (loc);
+ if (len_loc < 5)
+ len_loc = 5;
+
+ int indent = 6 + strlen (exploc.file) + len_lnum + len_loc;
/* Thousands. */
if (end_location > 999)