diff options
author | Nathan Sidwell <nathan@acm.org> | 2019-10-15 12:03:04 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2019-10-15 12:03:04 +0000 |
commit | 9158f0ba97ff987948cd5ce8391a546751c6dff3 (patch) | |
tree | 23993f28ac6545c0a27d83cecfcfe29a6cd27608 /libcpp/line-map.c | |
parent | d8955dc0f4583317c4d6a65d17c92c538f46a60c (diff) | |
download | gcc-9158f0ba97ff987948cd5ce8391a546751c6dff3.zip gcc-9158f0ba97ff987948cd5ce8391a546751c6dff3.tar.gz gcc-9158f0ba97ff987948cd5ce8391a546751c6dff3.tar.bz2 |
[linemap PATCH] Constify lookup
https://gcc.gnu.org/ml/gcc-patches/2019-10/msg01080.html
looking up a line map takes a non-constant line_maps object, which is confusing.
This makes the caching fields mutable, so permits a constant object, as one might expect for a lookup.
* include/line-map.h (struct maps_info_ordinary): Make cache
mutable.
(struct maps_info_macro): Likewise.
(LINEMAPS_CACHE): Remove non-ref accessor. Constify ref accessor.
(LINEMAPS_ORDINARY_CACHE, LINEMAPS_MACRO_CACHE): Likewise.
(LINEMAPS_ORDINARY_MAP_AT, LINEMAPS_MACRO_MAP_AT): Use
LINEMAPS_USED and LINEMAPS_MAP_AT.
(linemap_lookup): Constify line_map arg.
linemap.c (linemap_ordinary_map_lookup, linemap_macro_map_lookup):
Constify line_map arg.
From-SVN: r276994
Diffstat (limited to 'libcpp/line-map.c')
-rw-r--r-- | libcpp/line-map.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/libcpp/line-map.c b/libcpp/line-map.c index feeb748..b86a116 100644 --- a/libcpp/line-map.c +++ b/libcpp/line-map.c @@ -27,9 +27,9 @@ along with this program; see the file COPYING3. If not see #include "hashtab.h" static void trace_include (const line_maps *, const line_map_ordinary *); -static const line_map_ordinary * linemap_ordinary_map_lookup (line_maps *, +static const line_map_ordinary * linemap_ordinary_map_lookup (const line_maps *, location_t); -static const line_map_macro* linemap_macro_map_lookup (line_maps *, +static const line_map_macro* linemap_macro_map_lookup (const line_maps *, location_t); static location_t linemap_macro_map_loc_to_def_point (const line_map_macro *, location_t); @@ -937,7 +937,7 @@ linemap_position_for_loc_and_offset (line_maps *set, ordinary or a macro map), returns that map. */ const struct line_map* -linemap_lookup (line_maps *set, location_t line) +linemap_lookup (const line_maps *set, location_t line) { if (IS_ADHOC_LOC (line)) line = get_location_from_adhoc_loc (set, line); @@ -952,7 +952,7 @@ linemap_lookup (line_maps *set, location_t line) binary search. */ static const line_map_ordinary * -linemap_ordinary_map_lookup (line_maps *set, location_t line) +linemap_ordinary_map_lookup (const line_maps *set, location_t line) { unsigned int md, mn, mx; const line_map_ordinary *cached, *result; @@ -965,7 +965,7 @@ linemap_ordinary_map_lookup (line_maps *set, location_t line) mn = LINEMAPS_ORDINARY_CACHE (set); mx = LINEMAPS_ORDINARY_USED (set); - + cached = LINEMAPS_ORDINARY_MAP_AT (set, mn); /* We should get a segfault if no line_maps have been added yet. */ if (line >= MAP_START_LOCATION (cached)) @@ -1000,7 +1000,7 @@ linemap_ordinary_map_lookup (line_maps *set, location_t line) binary search. */ static const line_map_macro * -linemap_macro_map_lookup (line_maps *set, location_t line) +linemap_macro_map_lookup (const line_maps *set, location_t line) { unsigned int md, mn, mx; const struct line_map_macro *cached, *result; |