aboutsummaryrefslogtreecommitdiff
path: root/gcc/input.c
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2018-11-13 20:05:03 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2018-11-13 20:05:03 +0000
commit620e594be58d2f933902a6619fd20aa618070b4b (patch)
tree18b833ac960291d05524d5994ae4292048632226 /gcc/input.c
parentf9731de3db4c59ff0a241ce2c3d6f80aca5b5c28 (diff)
downloadgcc-620e594be58d2f933902a6619fd20aa618070b4b.zip
gcc-620e594be58d2f933902a6619fd20aa618070b4b.tar.gz
gcc-620e594be58d2f933902a6619fd20aa618070b4b.tar.bz2
Eliminate source_location in favor of location_t
Historically GCC used location_t, while libcpp used source_location. This inconsistency has been annoying me for a while, so this patch removes source_location in favor of location_t throughout (as the latter is shorter). gcc/ChangeLog: * builtins.c: Replace "source_location" with "location_t". * diagnostic-show-locus.c: Likewise. * diagnostic.c: Likewise. * dumpfile.c: Likewise. * gcc-rich-location.h: Likewise. * genmatch.c: Likewise. * gimple.h: Likewise. * gimplify.c: Likewise. * input.c: Likewise. * input.h: Likewise. Eliminate the typedef. * omp-expand.c: Likewise. * selftest.h: Likewise. * substring-locations.h (get_source_location_for_substring): Rename to.. (get_location_within_string): ...this. * tree-cfg.c: Replace "source_location" with "location_t". * tree-cfgcleanup.c: Likewise. * tree-diagnostic.c: Likewise. * tree-into-ssa.c: Likewise. * tree-outof-ssa.c: Likewise. * tree-parloops.c: Likewise. * tree-phinodes.c: Likewise. * tree-phinodes.h: Likewise. * tree-ssa-loop-ivopts.c: Likewise. * tree-ssa-loop-manip.c: Likewise. * tree-ssa-phiopt.c: Likewise. * tree-ssa-phiprop.c: Likewise. * tree-ssa-threadupdate.c: Likewise. * tree-ssa.c: Likewise. * tree-ssa.h: Likewise. * tree-vect-loop-manip.c: Likewise. gcc/c-family/ChangeLog: * c-common.c (c_get_substring_location): Update for renaming of get_source_location_for_substring to get_location_within_string. * c-lex.c: Replace "source_location" with "location_t". * c-opts.c: Likewise. * c-ppoutput.c: Likewise. gcc/c/ChangeLog: * c-decl.c: Replace "source_location" with "location_t". * c-tree.h: Likewise. * c-typeck.c: Likewise. * gimple-parser.c: Likewise. gcc/cp/ChangeLog: * call.c: Replace "source_location" with "location_t". * cp-tree.h: Likewise. * cvt.c: Likewise. * name-lookup.c: Likewise. * parser.c: Likewise. * typeck.c: Likewise. gcc/fortran/ChangeLog: * cpp.c: Replace "source_location" with "location_t". * gfortran.h: Likewise. gcc/go/ChangeLog: * go-gcc-diagnostics.cc: Replace "source_location" with "location_t". * go-gcc.cc: Likewise. * go-linemap.cc: Likewise. * go-location.h: Likewise. * gofrontend/README: Likewise. gcc/jit/ChangeLog: * jit-playback.c: Replace "source_location" with "location_t". gcc/testsuite/ChangeLog: * g++.dg/plugin/comment_plugin.c: Replace "source_location" with "location_t". * gcc.dg/plugin/diagnostic_plugin_test_show_locus.c: Likewise. libcc1/ChangeLog: * libcc1plugin.cc: Replace "source_location" with "location_t". (plugin_context::get_source_location): Rename to... (plugin_context::get_location_t): ...this. * libcp1plugin.cc: Likewise. libcpp/ChangeLog: * charset.c: Replace "source_location" with "location_t". * directives-only.c: Likewise. * directives.c: Likewise. * errors.c: Likewise. * expr.c: Likewise. * files.c: Likewise. * include/cpplib.h: Likewise. Rename MAX_SOURCE_LOCATION to MAX_LOCATION_T. * include/line-map.h: Likewise. * init.c: Likewise. * internal.h: Likewise. * lex.c: Likewise. * line-map.c: Likewise. * location-example.txt: Likewise. * macro.c: Likewise. * pch.c: Likewise. * traditional.c: Likewise. From-SVN: r266085
Diffstat (limited to 'gcc/input.c')
-rw-r--r--gcc/input.c84
1 files changed, 42 insertions, 42 deletions
diff --git a/gcc/input.c b/gcc/input.c
index 9fb6e72..347122e 100644
--- a/gcc/input.c
+++ b/gcc/input.c
@@ -152,7 +152,7 @@ static const size_t fcache_line_record_size = 100;
ASPECT controls which part of the location to use. */
static expanded_location
-expand_location_1 (source_location loc,
+expand_location_1 (location_t loc,
bool expansion_point_p,
enum location_aspect aspect)
{
@@ -201,14 +201,14 @@ expand_location_1 (source_location loc,
break;
case LOCATION_ASPECT_START:
{
- source_location start = get_start (loc);
+ location_t start = get_start (loc);
if (start != loc)
return expand_location_1 (start, expansion_point_p, aspect);
}
break;
case LOCATION_ASPECT_FINISH:
{
- source_location finish = get_finish (loc);
+ location_t finish = get_finish (loc);
if (finish != loc)
return expand_location_1 (finish, expansion_point_p, aspect);
}
@@ -256,7 +256,7 @@ static size_t
total_lines_num (const char *file_path)
{
size_t r = 0;
- source_location l = 0;
+ location_t l = 0;
if (linemap_get_file_highest_location (line_table, file_path, &l))
{
gcc_assert (l >= RESERVED_LOCATION_COUNT);
@@ -786,7 +786,7 @@ location_missing_trailing_newline (const char *file_path)
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)
+is_location_from_builtin_token (location_t loc)
{
const line_map_ordinary *map = NULL;
loc = linemap_resolve_location (line_table, loc,
@@ -800,7 +800,7 @@ is_location_from_builtin_token (source_location loc)
readable location is set to the string "<built-in>". */
expanded_location
-expand_location (source_location loc)
+expand_location (location_t loc)
{
return expand_location_1 (loc, /*expansion_point_p=*/true,
LOCATION_ASPECT_CARET);
@@ -813,14 +813,14 @@ expand_location (source_location loc)
"<built-in>". */
expanded_location
-expand_location_to_spelling_point (source_location loc,
+expand_location_to_spelling_point (location_t loc,
enum location_aspect aspect)
{
return expand_location_1 (loc, /*expansion_point_p=*/false, aspect);
}
/* The rich_location class within libcpp requires a way to expand
- source_location instances, and relies on the client code
+ location_t instances, and relies on the client code
providing a symbol named
linemap_client_expand_location_to_spelling_point
to do this.
@@ -829,7 +829,7 @@ expand_location_to_spelling_point (source_location loc,
which simply calls into expand_location_1. */
expanded_location
-linemap_client_expand_location_to_spelling_point (source_location loc,
+linemap_client_expand_location_to_spelling_point (location_t loc,
enum location_aspect aspect)
{
return expand_location_1 (loc, /*expansion_point_p=*/false, aspect);
@@ -848,8 +848,8 @@ linemap_client_expand_location_to_spelling_point (source_location loc,
warning_at, the diagnostic would be suppressed (unless
-Wsystem-headers). */
-source_location
-expansion_point_location_if_in_system_header (source_location location)
+location_t
+expansion_point_location_if_in_system_header (location_t location)
{
if (in_system_header_at (location))
location = linemap_resolve_location (line_table, location,
@@ -861,8 +861,8 @@ expansion_point_location_if_in_system_header (source_location location)
/* If LOCATION is a virtual location for a token coming from the expansion
of a macro, unwind to the location of the expansion point of the macro. */
-source_location
-expansion_point_location (source_location location)
+location_t
+expansion_point_location (location_t location)
{
return linemap_resolve_location (line_table, location,
LRK_MACRO_EXPANSION_POINT, NULL);
@@ -976,7 +976,7 @@ dump_line_table_statistics (void)
/* Get location one beyond the final location in ordinary map IDX. */
-static source_location
+static location_t
get_end_location (struct line_maps *set, unsigned int idx)
{
if (idx == LINEMAPS_ORDINARY_USED (set) - 1)
@@ -1001,37 +1001,37 @@ write_digit (FILE *stream, int digit)
static void
write_digit_row (FILE *stream, int indent,
const line_map_ordinary *map,
- source_location loc, int max_col, int divisor)
+ location_t loc, int max_col, int divisor)
{
fprintf (stream, "%*c", indent, ' ');
fprintf (stream, "|");
for (int column = 1; column < max_col; column++)
{
- source_location column_loc = loc + (column << map->m_range_bits);
+ location_t column_loc = loc + (column << map->m_range_bits);
write_digit (stream, column_loc / divisor);
}
fprintf (stream, "\n");
}
/* Write a half-closed (START) / half-open (END) interval of
- source_location to STREAM. */
+ location_t to STREAM. */
static void
dump_location_range (FILE *stream,
- source_location start, source_location end)
+ location_t start, location_t end)
{
fprintf (stream,
- " source_location interval: %u <= loc < %u\n",
+ " location_t interval: %u <= loc < %u\n",
start, end);
}
/* Write a labelled description of a half-closed (START) / half-open (END)
- interval of source_location to STREAM. */
+ interval of location_t to STREAM. */
static void
dump_labelled_location_range (FILE *stream,
const char *name,
- source_location start, source_location end)
+ location_t start, location_t end)
{
fprintf (stream, "%s\n", name);
dump_location_range (stream, start, end);
@@ -1050,7 +1050,7 @@ dump_location_info (FILE *stream)
/* Visualize the ordinary line_map instances, rendering the sources. */
for (unsigned int idx = 0; idx < LINEMAPS_ORDINARY_USED (line_table); idx++)
{
- source_location end_location = get_end_location (line_table, idx);
+ location_t end_location = get_end_location (line_table, idx);
/* half-closed: doesn't include this one. */
const line_map_ordinary *map
@@ -1069,7 +1069,7 @@ dump_location_info (FILE *stream)
map->m_range_bits);
/* Render the span of source lines that this "map" covers. */
- for (source_location loc = MAP_START_LOCATION (map);
+ for (location_t loc = MAP_START_LOCATION (map);
loc < end_location;
loc += (1 << map->m_range_bits) )
{
@@ -1094,7 +1094,7 @@ dump_location_info (FILE *stream)
/* "loc" is at column 0, which means "the whole line".
Render the locations *within* the line, by underlining
- it, showing the source_location numeric values
+ it, showing the location_t numeric values
at each column. */
size_t max_col = (1 << map->m_column_and_range_bits) - 1;
if (max_col > line_text.length ())
@@ -1128,12 +1128,12 @@ dump_location_info (FILE *stream)
/* Visualize the macro line_map instances, rendering the sources. */
for (unsigned int i = 0; i < LINEMAPS_MACRO_USED (line_table); i++)
{
- /* Each macro map that is allocated owns source_location values
+ /* Each macro map that is allocated owns location_t values
that are *lower* that the one before them.
Hence it's meaningful to view them either in order of ascending
source locations, or in order of ascending macro map index. */
- const bool ascending_source_locations = true;
- unsigned int idx = (ascending_source_locations
+ const bool ascending_location_ts = true;
+ unsigned int idx = (ascending_location_ts
? (LINEMAPS_MACRO_USED (line_table) - (i + 1))
: i);
const line_map_macro *map = LINEMAPS_MACRO_MAP_AT (line_table, idx);
@@ -1154,8 +1154,8 @@ dump_location_info (FILE *stream)
fprintf (stream, " macro_locations:\n");
for (unsigned int i = 0; i < MACRO_MAP_NUM_MACRO_TOKENS (map); i++)
{
- source_location x = MACRO_MAP_LOCATIONS (map)[2 * i];
- source_location y = MACRO_MAP_LOCATIONS (map)[(2 * i) + 1];
+ location_t x = MACRO_MAP_LOCATIONS (map)[2 * i];
+ location_t y = MACRO_MAP_LOCATIONS (map)[(2 * i) + 1];
/* linemap_add_macro_token encodes token numbers in an expansion
by putting them after MAP_START_LOCATION. */
@@ -1166,7 +1166,7 @@ dump_location_info (FILE *stream)
adding 2 extra args for padding tokens; presumably there may
be a leading and/or trailing padding token injected,
each for 2 more location slots.
- This would explain there being up to 4 source_locations slots
+ This would explain there being up to 4 location_ts slots
that may be uninitialized. */
fprintf (stream, " %u: %u, %u\n",
@@ -1191,17 +1191,17 @@ dump_location_info (FILE *stream)
fprintf (stream, "\n");
}
- /* It appears that MAX_SOURCE_LOCATION itself is never assigned to a
+ /* It appears that MAX_LOCATION_T itself is never assigned to a
macro map, presumably due to an off-by-one error somewhere
between the logic in linemap_enter_macro and
LINEMAPS_MACRO_LOWEST_LOCATION. */
- dump_labelled_location_range (stream, "MAX_SOURCE_LOCATION",
- MAX_SOURCE_LOCATION,
- MAX_SOURCE_LOCATION + 1);
+ dump_labelled_location_range (stream, "MAX_LOCATION_T",
+ MAX_LOCATION_T,
+ MAX_LOCATION_T + 1);
/* Visualize ad-hoc values. */
dump_labelled_location_range (stream, "AD-HOC LOCATIONS",
- MAX_SOURCE_LOCATION + 1, UINT_MAX);
+ MAX_LOCATION_T + 1, UINT_MAX);
}
/* string_concat's constructor. */
@@ -1473,12 +1473,12 @@ get_substring_ranges_for_loc (cpp_reader *pfile,
than for end-users. */
const char *
-get_source_location_for_substring (cpp_reader *pfile,
- string_concat_db *concats,
- location_t strloc,
- enum cpp_ttype type,
- int caret_idx, int start_idx, int end_idx,
- source_location *out_loc)
+get_location_within_string (cpp_reader *pfile,
+ string_concat_db *concats,
+ location_t strloc,
+ enum cpp_ttype type,
+ int caret_idx, int start_idx, int end_idx,
+ location_t *out_loc)
{
gcc_checking_assert (caret_idx >= 0);
gcc_checking_assert (start_idx >= 0);
@@ -1638,7 +1638,7 @@ assert_loceq (const char *exp_filename, int exp_linenum, int exp_colnum,
- line_table->default_range_bits: some frontends use a non-zero value
and others use zero
- the fallback modes within line-map.c: there are various threshold
- values for source_location/location_t beyond line-map.c changes
+ values for location_t beyond line-map.c changes
behavior (disabling of the range-packing optimization, disabling
of column-tracking). We can exercise these by starting the line_table
at interesting values at or near these thresholds.