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)
{
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);
}
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);
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,
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);
"<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.
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);
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,
/* 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);
/* 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)
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);
/* 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
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) )
{
/* "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 ())
/* 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);
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. */
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",
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. */
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);
- 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.