Fix thinko in libcpp preparation patch for modules
The problem is that the new IS_MACRO_LOC macro: inline bool IS_MACRO_LOC (location_t loc) { return !IS_ORDINARY_LOC (loc) && !IS_ADHOC_LOC (loc); } is not fully correct since the position of the macro lines is not fixed: /* Returns the lowest location [of a token resulting from macro expansion] encoded in this line table. */ inline location_t LINEMAPS_MACRO_LOWEST_LOCATION (const line_maps *set) { return LINEMAPS_MACRO_USED (set) ? MAP_START_LOCATION (LINEMAPS_LAST_MACRO_MAP (set)) : MAX_LOCATION_T + 1; } In Ada, LINEMAPS_MACRO_USED is false so LINEMAPS_MACRO_LOWEST_LOCATION is MAX_LOCATION_T + 1, but IS_MACRO_LOC nevertheless returns true for anything in the range [LINE_MAP_MAX_LOCATION; MAX_LOCATION_T], thus yielding an ICE in linemap_macro_map_lookup for very large files. libcpp/ * include/line-map.h (IS_MACRO_LOC): Delete. * line-map.c (linemap_location_from_macro_expansion_p): Test LINEMAPS_MACRO_LOWEST_LOCATION of the linemap.
This commit is contained in:
parent
beec602b78
commit
e268afb4a8
|
@ -561,7 +561,7 @@ struct GTY((tag ("2"))) line_map_macro : public line_map {
|
|||
#define linemap_assert_fails(EXPR) (! (EXPR))
|
||||
#endif
|
||||
|
||||
/* Get whether location LOC is an ad-hoc, ordinary or macro location. */
|
||||
/* Get whether location LOC is an ordinary location. */
|
||||
|
||||
inline bool
|
||||
IS_ORDINARY_LOC (location_t loc)
|
||||
|
@ -569,18 +569,14 @@ IS_ORDINARY_LOC (location_t loc)
|
|||
return loc < LINE_MAP_MAX_LOCATION;
|
||||
}
|
||||
|
||||
/* Get whether location LOC is an ad-hoc location. */
|
||||
|
||||
inline bool
|
||||
IS_ADHOC_LOC (location_t loc)
|
||||
{
|
||||
return loc > MAX_LOCATION_T;
|
||||
}
|
||||
|
||||
inline bool
|
||||
IS_MACRO_LOC (location_t loc)
|
||||
{
|
||||
return !IS_ORDINARY_LOC (loc) && !IS_ADHOC_LOC (loc);
|
||||
}
|
||||
|
||||
/* Categorize line map kinds. */
|
||||
|
||||
inline bool
|
||||
|
|
|
@ -1243,7 +1243,7 @@ linemap_location_from_macro_expansion_p (const struct line_maps *set,
|
|||
location = set->location_adhoc_data_map.data[location
|
||||
& MAX_LOCATION_T].locus;
|
||||
|
||||
return IS_MACRO_LOC (location);
|
||||
return location >= LINEMAPS_MACRO_LOWEST_LOCATION (set);
|
||||
}
|
||||
|
||||
/* Given two virtual locations *LOC0 and *LOC1, return the first
|
||||
|
|
Loading…
Reference in New Issue