]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/input.c
Eliminate source_location in favor of location_t
[thirdparty/gcc.git] / gcc / input.c
index 9fb6e72421fc992b1a854157d086199153616099..347122e98a852b4f324be28b6576c04c333b0f57 100644 (file)
@@ -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.