private:
vec<span> *spans;
+ bool locs_exhausted_p;
public:
loc_spans ()
/* Do not preallocate spans, as that causes
--enable-detailed-mem-stats problems. */
- : spans (nullptr)
+ : spans (nullptr), locs_exhausted_p (false)
{
}
~loc_spans ()
/* Propagate imported linemaps to us, if needed. */
bool maybe_propagate (module_state *import, location_t loc);
+public:
+ /* Whether we can no longer represent new imported locations. */
+ bool locations_exhausted_p () const
+ {
+ return locs_exhausted_p;
+ }
+ void report_location_exhaustion (location_t loc)
+ {
+ if (!locs_exhausted_p)
+ {
+ /* Just give the notice once. */
+ locs_exhausted_p = true;
+ inform (loc, "unable to represent further imported source locations");
+ }
+ }
+
public:
const span *ordinary (location_t);
const span *macro (location_t);
}
else if (IS_ORDINARY_LOC (loc))
{
+ /* If we ran out of locations for imported decls, this location could
+ be a module unit's location. In that case, remap the location
+ to be where we imported the module from. */
+ if (spans.locations_exhausted_p () || CHECKING_P)
+ {
+ const line_map_ordinary *map
+ = linemap_check_ordinary (linemap_lookup (line_table, loc));
+ if (MAP_MODULE_P (map) && loc == MAP_START_LOCATION (map))
+ {
+ gcc_checking_assert (spans.locations_exhausted_p ());
+ write_location (sec, linemap_included_from (map));
+ return;
+ }
+ }
+
const ord_loc_info *info = nullptr;
unsigned offset = 0;
if (unsigned hwm = ord_loc_remap->length ())
ordinary_locs.first = ordinary_locs.second = 0;
macro_locs.first = macro_locs.second = 0;
- static bool informed = false;
- if (!informed)
- {
- /* Just give the notice once. */
- informed = true;
- inform (loc, "unable to represent further imported source locations");
- }
+ spans.report_location_exhaustion (loc);
return false;
}