diff options
Diffstat (limited to 'libcpp')
-rw-r--r-- | libcpp/ChangeLog | 142 | ||||
-rw-r--r-- | libcpp/include/line-map.h | 186 | ||||
-rw-r--r-- | libcpp/init.cc | 2 | ||||
-rw-r--r-- | libcpp/internal.h | 4 | ||||
-rw-r--r-- | libcpp/lex.cc | 20 | ||||
-rw-r--r-- | libcpp/line-map.cc | 263 |
6 files changed, 380 insertions, 237 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index 1a5ff99..9d2e4f5 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,145 @@ +2023-10-08 David Malcolm <dmalcolm@redhat.com> + + * include/line-map.h (LINEMAPS_ORDINARY_MAPS): Delete. + (LINEMAPS_MACRO_MAPS): Delete. + * line-map.cc (linemap_tracks_macro_expansion_locs_p): Update for + deletion of LINEMAPS_MACRO_MAPS. + (linemap_get_statistics): Likewise. + +2023-10-08 David Malcolm <dmalcolm@redhat.com> + + * include/line-map.h (maps_info_ordinary::cache): Rename to... + (maps_info_ordinary::m_cache): ...this. + (maps_info_macro::cache): Rename to... + (maps_info_macro::m_cache): ...this. + (LINEMAPS_CACHE): Delete. + (LINEMAPS_ORDINARY_CACHE): Delete. + (LINEMAPS_MACRO_CACHE): Delete. + * init.cc (read_original_filename): Update for adding "m_" prefix. + * line-map.cc (linemap_add): Eliminate LINEMAPS_ORDINARY_CACHE in + favor of a simple field access. + (linemap_enter_macro): Likewise for LINEMAPS_MACRO_CACHE. + (linemap_ordinary_map_lookup): Likewise for + LINEMAPS_ORDINARY_CACHE, twice. + (linemap_lookup_macro_index): Likewise for LINEMAPS_MACRO_CACHE. + +2023-10-08 David Malcolm <dmalcolm@redhat.com> + + * include/line-map.h (LINEMAPS_LAST_ALLOCATED_MAP): Delete. + (LINEMAPS_LAST_ALLOCATED_ORDINARY_MAP): Delete. + (LINEMAPS_LAST_ALLOCATED_MACRO_MAP): Delete. + +2023-10-08 David Malcolm <dmalcolm@redhat.com> + + * include/line-map.h (line_maps::reallocator): Rename to... + (line_maps::m_reallocator): ...this. + (line_maps::round_alloc_size): Rename to... + (line_maps::m_round_alloc_size): ...this. + (line_maps::location_adhoc_data_map): Rename to... + (line_maps::m_location_adhoc_data_map): ...this. + (line_maps::num_optimized_ranges): Rename to... + (line_maps::m_num_optimized_ranges): ..this. + (line_maps::num_unoptimized_ranges): Rename to... + (line_maps::m_num_unoptimized_ranges): ...this. + (get_combined_adhoc_loc): Delete decl. + (COMBINE_LOCATION_DATA): Delete. + * lex.cc (get_location_for_byte_range_in_cur_line): Update for + removal of COMBINE_LOCATION_DATA. + (warn_about_normalization): Likewise. + (_cpp_lex_direct): Likewise. + * line-map.cc (line_maps::~line_maps): Update for "m_" prefix of + some fields of line_maps. + (rebuild_location_adhoc_htab): Likewise. + (can_be_stored_compactly_p): Convert to... + (line_maps::can_be_stored_compactly_p): ...this private member + function. + (get_combined_adhoc_loc): Convert to... + (line_maps::get_or_create_combined_loc): ...this public member + function. + (line_maps::make_location): Update for removal of + COMBINE_LOCATION_DATA. + (get_data_from_adhoc_loc): Update for "m_" prefix of some fields + of line_maps. + (get_discriminator_from_adhoc_loc): Likewise. + (get_location_from_adhoc_loc): Likewise. + (get_range_from_adhoc_loc): Convert to... + (line_maps::get_range_from_adhoc_loc): ...this private member + function. + (line_maps::get_range_from_loc): Update for conversion of + get_range_from_adhoc_loc to a member function. + (linemap_init): Update for "m_" prefix of some fields of + line_maps. + (line_map_new_raw): Likewise. + (linemap_enter_macro): Likewise. + (linemap_get_statistics): Likewise. + +2023-10-08 David Malcolm <dmalcolm@redhat.com> + + * include/line-map.h (line_maps::pure_location_p): New decl. + (line_maps::get_pure_location): New decl. + (line_maps::get_range_from_loc): New decl. + (line_maps::get_start): New. + (line_maps::get_finish): New. + (line_maps::make_location): New decl. + (get_range_from_loc): Make line_maps param const. + (get_discriminator_from_loc): Likewise. + (pure_location_p): Likewise. + (get_pure_location): Likewise. + (linemap_check_files_exited): Likewise. + (linemap_tracks_macro_expansion_locs_p): Likewise. + (linemap_location_in_system_header_p): Likewise. + (linemap_location_from_macro_definition_p): Likewise. + (linemap_macro_map_loc_unwind_toward_spelling): Likewise. + (linemap_included_from_linemap): Likewise. + (first_map_in_common): Likewise. + (linemap_compare_locations): Likewise. + (linemap_location_before_p): Likewise. + (linemap_resolve_location): Likewise. + (linemap_unwind_toward_expansion): Likewise. + (linemap_unwind_to_first_non_reserved_loc): Likewise. + (linemap_expand_location): Likewise. + (linemap_get_file_highest_location): Likewise. + (linemap_get_statistics): Likewise. + (linemap_dump_location): Likewise. + (linemap_dump): Likewise. + (line_table_dump): Likewise. + * internal.h (linemap_get_expansion_line): Likewise. + (linemap_get_expansion_filename): Likewise. + * line-map.cc (can_be_stored_compactly_p): Likewise. + (get_data_from_adhoc_loc): Drop redundant "class". + (get_discriminator_from_adhoc_loc): Likewise. + (get_location_from_adhoc_loc): Likewise. + (get_range_from_adhoc_loc): Likewise. + (get_range_from_loc): Make const and move implementation to... + (line_maps::get_range_from_loc): ...this new function. + (get_discriminator_from_loc): Make line_maps param const. + (pure_location_p): Make const and move implementation to... + (line_maps::pure_location_p): ...this new function. + (get_pure_location): Make const and move implementation to... + (line_maps::get_pure_location): ...this new function. + (linemap_included_from_linemap): Make line_maps param const. + (linemap_check_files_exited): Likewise. + (linemap_tracks_macro_expansion_locs_p): Likewise. + (linemap_macro_map_loc_unwind_toward_spelling): Likewise. + (linemap_get_expansion_line): Likewise. + (linemap_get_expansion_filename): Likewise. + (linemap_location_in_system_header_p): Likewise. + (first_map_in_common_1): Likewise. + (linemap_compare_locations): Likewise. + (linemap_macro_loc_to_spelling_point): Likewise. + (linemap_macro_loc_to_def_point): Likewise. + (linemap_macro_loc_to_exp_point): Likewise. + (linemap_resolve_location): Likewise. + (linemap_location_from_macro_definition_p): Likewise. + (linemap_unwind_toward_expansion): Likewise. + (linemap_unwind_to_first_non_reserved_loc): Likewise. + (linemap_expand_location): Likewise. + (linemap_dump): Likewise. + (linemap_dump_location): Likewise. + (linemap_get_file_highest_location): Likewise. + (linemap_get_statistics): Likewise. + (line_table_dump): Likewise. + 2023-09-20 Lewis Hyatt <lhyatt@gmail.com> PR preprocessor/61474 diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h index 44fea0e..cb934e6 100644 --- a/libcpp/include/line-map.h +++ b/libcpp/include/line-map.h @@ -733,7 +733,9 @@ struct GTY(()) maps_info_ordinary { or equal to ALLOCATED. */ unsigned int used; - mutable unsigned int cache; + /* The index of the last ordinary map that was looked up with + linemap_lookup. */ + mutable unsigned int m_cache; }; struct GTY(()) maps_info_macro { @@ -748,7 +750,9 @@ struct GTY(()) maps_info_macro { or equal to ALLOCATED. */ unsigned int used; - mutable unsigned int cache; + /* The index of the last macro map that was looked up with + linemap_lookup. */ + mutable unsigned int m_cache; }; /* Data structure to associate a source_range together with an arbitrary @@ -784,7 +788,39 @@ class GTY(()) line_maps { public: ~line_maps (); - + + bool pure_location_p (location_t loc) const; + location_t get_pure_location (location_t loc) const; + + source_range get_range_from_loc (location_t loc) const; + location_t get_start (location_t loc) const + { + return get_range_from_loc (loc).m_start; + } + location_t + get_finish (location_t loc) const + { + return get_range_from_loc (loc).m_finish; + } + + location_t make_location (location_t caret, + location_t start, + location_t finish); + + location_t + get_or_create_combined_loc (location_t locus, + source_range src_range, + void *data, + unsigned discriminator); + + private: + bool can_be_stored_compactly_p (location_t locus, + source_range src_range, + void *data, + unsigned discriminator) const; + source_range get_range_from_adhoc_loc (location_t loc) const; + + public: maps_info_ordinary info_ordinary; maps_info_macro info_macro; @@ -809,13 +845,13 @@ public: unsigned int max_column_hint; /* The allocator to use when resizing 'maps', defaults to xrealloc. */ - line_map_realloc GTY((callback)) reallocator; + line_map_realloc GTY((callback)) m_reallocator; /* The allocators' function used to know the actual size it allocated, for a certain allocation size requested. */ - line_map_round_alloc_size_func GTY((callback)) round_alloc_size; + line_map_round_alloc_size_func GTY((callback)) m_round_alloc_size; - struct location_adhoc_data_map location_adhoc_data_map; + struct location_adhoc_data_map m_location_adhoc_data_map; /* The special location value that is used as spelling location for built-in tokens. */ @@ -824,8 +860,8 @@ public: /* The default value of range_bits in ordinary line maps. */ unsigned int default_range_bits; - unsigned int num_optimized_ranges; - unsigned int num_unoptimized_ranges; + unsigned int m_num_optimized_ranges; + unsigned int m_num_unoptimized_ranges; }; /* Returns the number of allocated maps so far. MAP_KIND shall be TRUE @@ -872,18 +908,6 @@ LINEMAPS_USED (line_maps *set, bool map_kind) return set->info_ordinary.used; } -/* Returns the index of the last map that was looked up with - linemap_lookup. MAP_KIND shall be TRUE if we are interested in - macro maps, FALSE otherwise. */ -inline unsigned int & -LINEMAPS_CACHE (const line_maps *set, bool map_kind) -{ - if (map_kind) - return set->info_macro.cache; - else - return set->info_ordinary.cache; -} - /* Return the map at a given index. */ inline line_map * LINEMAPS_MAP_AT (const line_maps *set, bool map_kind, int index) @@ -904,24 +928,6 @@ LINEMAPS_LAST_MAP (const line_maps *set, bool map_kind) LINEMAPS_USED (set, map_kind) - 1); } -/* Returns the last map that was allocated in the line table SET. - MAP_KIND shall be TRUE if we are interested in macro maps, FALSE - otherwise.*/ -inline line_map * -LINEMAPS_LAST_ALLOCATED_MAP (const line_maps *set, bool map_kind) -{ - return LINEMAPS_MAP_AT (set, map_kind, - LINEMAPS_ALLOCATED (set, map_kind) - 1); -} - -/* Returns a pointer to the memory region where ordinary maps are - allocated in the line table SET. */ -inline line_map_ordinary * -LINEMAPS_ORDINARY_MAPS (const line_maps *set) -{ - return set->info_ordinary.maps; -} - /* Returns the INDEXth ordinary map. */ inline line_map_ordinary * LINEMAPS_ORDINARY_MAP_AT (const line_maps *set, int index) @@ -946,14 +952,6 @@ LINEMAPS_ORDINARY_USED (const line_maps *set) return LINEMAPS_USED (set, false); } -/* Return the index of the last ordinary map that was looked up with - linemap_lookup. */ -inline unsigned int & -LINEMAPS_ORDINARY_CACHE (const line_maps *set) -{ - return LINEMAPS_CACHE (set, false); -} - /* Returns a pointer to the last ordinary map used in the line table SET. */ inline line_map_ordinary * @@ -962,22 +960,6 @@ LINEMAPS_LAST_ORDINARY_MAP (const line_maps *set) return (line_map_ordinary *)LINEMAPS_LAST_MAP (set, false); } -/* Returns a pointer to the last ordinary map allocated the line table - SET. */ -inline line_map_ordinary * -LINEMAPS_LAST_ALLOCATED_ORDINARY_MAP (const line_maps *set) -{ - return (line_map_ordinary *)LINEMAPS_LAST_ALLOCATED_MAP (set, false); -} - -/* Returns a pointer to the beginning of the region where macro maps - are allocated. */ -inline line_map_macro * -LINEMAPS_MACRO_MAPS (const line_maps *set) -{ - return set->info_macro.maps; -} - /* Returns the INDEXth macro map. */ inline line_map_macro * LINEMAPS_MACRO_MAP_AT (const line_maps *set, int index) @@ -1002,14 +984,6 @@ LINEMAPS_MACRO_USED (const line_maps *set) return LINEMAPS_USED (set, true); } -/* Return the index of the last macro map that was looked up with - linemap_lookup. */ -inline unsigned int & -LINEMAPS_MACRO_CACHE (const line_maps *set) -{ - return LINEMAPS_CACHE (set, true); -} - /* Returns the last macro map used in the line table SET. */ inline line_map_macro * LINEMAPS_LAST_MACRO_MAP (const line_maps *set) @@ -1027,45 +1001,24 @@ LINEMAPS_MACRO_LOWEST_LOCATION (const line_maps *set) : MAX_LOCATION_T + 1; } -/* Returns the last macro map allocated in the line table SET. */ -inline line_map_macro * -LINEMAPS_LAST_ALLOCATED_MACRO_MAP (const line_maps *set) -{ - return (line_map_macro *)LINEMAPS_LAST_ALLOCATED_MAP (set, true); -} - -extern location_t get_combined_adhoc_loc (line_maps *, location_t, - source_range, void *, unsigned); extern void *get_data_from_adhoc_loc (const line_maps *, location_t); extern unsigned get_discriminator_from_adhoc_loc (const line_maps *, location_t); extern location_t get_location_from_adhoc_loc (const line_maps *, location_t); -extern source_range get_range_from_loc (line_maps *set, location_t loc); -extern unsigned get_discriminator_from_loc (line_maps *set, location_t loc); +extern source_range get_range_from_loc (const line_maps *set, location_t loc); +extern unsigned get_discriminator_from_loc (const line_maps *set, location_t loc); /* Get whether location LOC is a "pure" location, or whether it is an ad-hoc location, or embeds range information. */ bool -pure_location_p (line_maps *set, location_t loc); +pure_location_p (const line_maps *set, location_t loc); /* Given location LOC within SET, strip away any packed range information or ad-hoc information. */ -extern location_t get_pure_location (line_maps *set, location_t loc); - -/* Combine LOC and BLOCK, giving a combined adhoc location. */ - -inline location_t -COMBINE_LOCATION_DATA (class line_maps *set, - location_t loc, - source_range src_range, - void *block, - unsigned discriminator) -{ - return get_combined_adhoc_loc (set, loc, src_range, block, discriminator); -} +extern location_t get_pure_location (const line_maps *set, location_t loc); extern void rebuild_location_adhoc_htab (class line_maps *); @@ -1078,7 +1031,7 @@ extern void linemap_init (class line_maps *set, /* Check for and warn about line_maps entered but not exited. */ -extern void linemap_check_files_exited (class line_maps *); +extern void linemap_check_files_exited (const line_maps *); /* Return a location_t for the start (i.e. column==0) of (physical) line TO_LINE in the current source file (as in the @@ -1156,7 +1109,7 @@ unsigned linemap_lookup_macro_index (const line_maps *, location_t); /* Returns TRUE if the line table set tracks token locations across macro expansion, FALSE otherwise. */ -bool linemap_tracks_macro_expansion_locs_p (class line_maps *); +bool linemap_tracks_macro_expansion_locs_p (const line_maps *); /* Return the name of the macro associated to MACRO_MAP. */ const char* linemap_map_get_macro_name (const line_map_macro *); @@ -1170,7 +1123,7 @@ const char* linemap_map_get_macro_name (const line_map_macro *); Note that this function returns 1 if LOCATION belongs to a token that is part of a macro replacement-list defined in a system header, but expanded in a non-system file. */ -int linemap_location_in_system_header_p (class line_maps *, +int linemap_location_in_system_header_p (const line_maps *, location_t); /* Return TRUE if LOCATION is a source code location of a token that is part of @@ -1180,7 +1133,7 @@ bool linemap_location_from_macro_expansion_p (const line_maps *, /* TRUE if LOCATION is a source code location of a token that is part of the definition of a macro, FALSE otherwise. */ -bool linemap_location_from_macro_definition_p (class line_maps *, +bool linemap_location_from_macro_definition_p (const line_maps *, location_t); /* With the precondition that LOCATION is the locus of a token that is @@ -1188,8 +1141,10 @@ bool linemap_location_from_macro_definition_p (class line_maps *, expansion of MACRO_MAP, return the locus of that argument in the context of the caller of MACRO_MAP. */ -extern location_t linemap_macro_map_loc_unwind_toward_spelling - (line_maps *set, const line_map_macro *macro_map, location_t location); +extern location_t +linemap_macro_map_loc_unwind_toward_spelling (const line_maps *set, + const line_map_macro *macro_map, + location_t location); /* location_t values from 0 to RESERVED_LOCATION_COUNT-1 will be reserved for libcpp user as special values, no token from libcpp @@ -1220,8 +1175,9 @@ linemap_included_from (const line_map_ordinary *ord_map) } /* The linemap containing the included-from location of MAP. */ -const line_map_ordinary *linemap_included_from_linemap - (line_maps *set, const line_map_ordinary *map); +const line_map_ordinary * +linemap_included_from_linemap (const line_maps *set, + const line_map_ordinary *map); /* True if the map is at the bottom of the include stack. */ @@ -1277,7 +1233,7 @@ LINEMAP_SYSP (const line_map_ordinary *ord_map) return ord_map->sysp; } -const struct line_map *first_map_in_common (line_maps *set, +const struct line_map *first_map_in_common (const line_maps *set, location_t loc0, location_t loc1, location_t *res_loc0, @@ -1287,7 +1243,7 @@ const struct line_map *first_map_in_common (line_maps *set, comes before the token of POST, 0 if PRE denotes the location of the same token as the token for POST, and a negative value otherwise. */ -int linemap_compare_locations (class line_maps *set, +int linemap_compare_locations (const line_maps *set, location_t pre, location_t post); @@ -1295,7 +1251,7 @@ int linemap_compare_locations (class line_maps *set, topogically before the token denoted by location LOC_B, or if they are equal. */ inline bool -linemap_location_before_p (class line_maps *set, +linemap_location_before_p (const line_maps *set, location_t loc_a, location_t loc_b) { @@ -2043,7 +1999,7 @@ enum location_resolution_kind resolves to a location reserved for the client code, like UNKNOWN_LOCATION or BUILTINS_LOCATION in GCC. */ -location_t linemap_resolve_location (class line_maps *, +location_t linemap_resolve_location (const line_maps *, location_t loc, enum location_resolution_kind lrk, const line_map_ordinary **loc_map); @@ -2055,7 +2011,7 @@ location_t linemap_resolve_location (class line_maps *, the point where M' was expanded. LOC_MAP is an output parameter. When non-NULL, *LOC_MAP is set to the map of the returned location. */ -location_t linemap_unwind_toward_expansion (class line_maps *, +location_t linemap_unwind_toward_expansion (const line_maps *, location_t loc, const line_map **loc_map); @@ -2073,7 +2029,7 @@ location_t linemap_unwind_toward_expansion (class line_maps *, *MAP is set to the map of the returned location if the later is different from LOC. */ -location_t linemap_unwind_to_first_non_reserved_loc (class line_maps *, +location_t linemap_unwind_to_first_non_reserved_loc (const line_maps *, location_t loc, const line_map **map); @@ -2081,7 +2037,7 @@ location_t linemap_unwind_to_first_non_reserved_loc (class line_maps *, code location. LOC must be a spelling (non-virtual) location. If it's a location < RESERVED_LOCATION_COUNT a zeroed expanded source location is returned. */ -expanded_location linemap_expand_location (class line_maps *, +expanded_location linemap_expand_location (const line_maps *, const line_map *, location_t loc); @@ -2108,27 +2064,27 @@ struct linemap_stats there is a line map in SET. FILE_NAME is the file name to consider. If the function returns TRUE, *LOC is set to the highest location emitted for that file. */ -bool linemap_get_file_highest_location (class line_maps * set, +bool linemap_get_file_highest_location (const line_maps * set, const char *file_name, location_t *loc); /* Compute and return statistics about the memory consumption of some parts of the line table SET. */ -void linemap_get_statistics (line_maps *, struct linemap_stats *); +void linemap_get_statistics (const line_maps *, struct linemap_stats *); /* Dump debugging information about source location LOC into the file stream STREAM. SET is the line map set LOC comes from. */ -void linemap_dump_location (line_maps *, location_t, FILE *); +void linemap_dump_location (const line_maps *, location_t, FILE *); /* Dump line map at index IX in line table SET to STREAM. If STREAM is NULL, use stderr. IS_MACRO is true if the caller wants to dump a macro map, false otherwise. */ -void linemap_dump (FILE *, line_maps *, unsigned, bool); +void linemap_dump (FILE *, const line_maps *, unsigned, bool); /* Dump line table SET to STREAM. If STREAM is NULL, stderr is used. NUM_ORDINARY specifies how many ordinary maps to dump. NUM_MACRO specifies how many macro maps to dump. */ -void line_table_dump (FILE *, line_maps *, unsigned int, unsigned int); +void line_table_dump (FILE *, const line_maps *, unsigned int, unsigned int); /* An enum for distinguishing the various parts within a location_t. */ diff --git a/libcpp/init.cc b/libcpp/init.cc index 9a20f8d..b97d7a7 100644 --- a/libcpp/init.cc +++ b/libcpp/init.cc @@ -788,7 +788,7 @@ read_original_filename (cpp_reader *pfile) penult[1].reason = penult[0].reason; penult[0] = penult[1]; pfile->line_table->info_ordinary.used--; - pfile->line_table->info_ordinary.cache = 0; + pfile->line_table->info_ordinary.m_cache = 0; } return true; diff --git a/libcpp/internal.h b/libcpp/internal.h index 8b74d10..33ed0a2 100644 --- a/libcpp/internal.h +++ b/libcpp/internal.h @@ -935,7 +935,7 @@ location_t linemap_add_macro_token (const line_map_macro *, LOCATION is the location of token that is part of the expansion-list of a macro expansion return the line number of the macro expansion point. */ -int linemap_get_expansion_line (class line_maps *, +int linemap_get_expansion_line (const line_maps *, location_t); /* Return the path of the file corresponding to source code location @@ -946,7 +946,7 @@ int linemap_get_expansion_line (class line_maps *, macro expansion point. SET is the line map set LOCATION comes from. */ -const char* linemap_get_expansion_filename (class line_maps *, +const char* linemap_get_expansion_filename (const line_maps *, location_t); /* A subclass of rich_location for emitting a diagnostic diff --git a/libcpp/lex.cc b/libcpp/lex.cc index 8dea4d3..ce8ff61 100644 --- a/libcpp/lex.cc +++ b/libcpp/lex.cc @@ -1362,11 +1362,11 @@ get_location_for_byte_range_in_cur_line (cpp_reader *pfile, source_range src_range; src_range.m_start = start_loc; src_range.m_finish = end_loc; - location_t combined_loc = COMBINE_LOCATION_DATA (pfile->line_table, - start_loc, - src_range, - NULL, - 0); + location_t combined_loc + = pfile->line_table->get_or_create_combined_loc (start_loc, + src_range, + nullptr, + 0); return combined_loc; } @@ -2032,8 +2032,8 @@ warn_about_normalization (cpp_reader *pfile, = linemap_position_for_column (pfile->line_table, CPP_BUF_COLUMN (pfile->buffer, pfile->buffer->cur)); - loc = COMBINE_LOCATION_DATA (pfile->line_table, - loc, tok_range, NULL, 0); + loc = pfile->line_table->get_or_create_combined_loc (loc, tok_range, + nullptr, 0); } encoding_rich_location rich_loc (pfile, loc); @@ -4333,9 +4333,9 @@ _cpp_lex_direct (cpp_reader *pfile) = linemap_position_for_column (pfile->line_table, CPP_BUF_COLUMN (buffer, buffer->cur)); - result->src_loc = COMBINE_LOCATION_DATA (pfile->line_table, - result->src_loc, - tok_range, NULL, 0); + result->src_loc + = pfile->line_table->get_or_create_combined_loc (result->src_loc, + tok_range, nullptr, 0); } return result; diff --git a/libcpp/line-map.cc b/libcpp/line-map.cc index e0f82e20..cd17353 100644 --- a/libcpp/line-map.cc +++ b/libcpp/line-map.cc @@ -36,11 +36,11 @@ static location_t linemap_macro_map_loc_to_def_point static location_t linemap_macro_map_loc_to_exp_point (const line_map_macro *, location_t); static location_t linemap_macro_loc_to_spelling_point -(line_maps *, location_t, const line_map_ordinary **); -static location_t linemap_macro_loc_to_def_point (line_maps *, +(const line_maps *, location_t, const line_map_ordinary **); +static location_t linemap_macro_loc_to_def_point (const line_maps *, location_t, const line_map_ordinary **); -static location_t linemap_macro_loc_to_exp_point (line_maps *, +static location_t linemap_macro_loc_to_exp_point (const line_maps *, location_t, const line_map_ordinary **); @@ -53,8 +53,8 @@ extern unsigned num_macro_tokens_counter; line_maps::~line_maps () { - if (location_adhoc_data_map.htab) - htab_delete (location_adhoc_data_map.htab); + if (m_location_adhoc_data_map.htab) + htab_delete (m_location_adhoc_data_map.htab); } /* Hash function for location_adhoc_data hashtable. */ @@ -109,14 +109,14 @@ location_adhoc_data_update (void **slot_v, void *param_v) void rebuild_location_adhoc_htab (line_maps *set) { - set->location_adhoc_data_map.htab = + set->m_location_adhoc_data_map.htab = htab_create (100, location_adhoc_data_hash, location_adhoc_data_eq, NULL); - for (auto p = set->location_adhoc_data_map.data, - end = p + set->location_adhoc_data_map.curr_loc; + for (auto p = set->m_location_adhoc_data_map.data, + end = p + set->m_location_adhoc_data_map.curr_loc; p != end; ++p) { const auto slot = reinterpret_cast<location_adhoc_data **> - (htab_find_slot (set->location_adhoc_data_map.htab, p, INSERT)); + (htab_find_slot (set->m_location_adhoc_data_map.htab, p, INSERT)); *slot = p; } } @@ -125,12 +125,11 @@ rebuild_location_adhoc_htab (line_maps *set) Can the given LOCUS + SRC_RANGE and DATA pointer be stored compactly within a location_t, without needing to use an ad-hoc location. */ -static bool -can_be_stored_compactly_p (line_maps *set, - location_t locus, - source_range src_range, - void *data, - unsigned discriminator) +bool +line_maps::can_be_stored_compactly_p (location_t locus, + source_range src_range, + void *data, + unsigned discriminator) const { /* If there's an ad-hoc pointer, we can't store it directly in the location_t, we need the lookaside. */ @@ -156,7 +155,7 @@ can_be_stored_compactly_p (line_maps *set, /* All 3 locations must be within ordinary maps, typically, the same ordinary map. */ - location_t lowest_macro_loc = LINEMAPS_MACRO_LOWEST_LOCATION (set); + location_t lowest_macro_loc = LINEMAPS_MACRO_LOWEST_LOCATION (this); if (locus >= lowest_macro_loc) return false; if (src_range.m_start >= lowest_macro_loc) @@ -171,17 +170,16 @@ can_be_stored_compactly_p (line_maps *set, /* Combine LOCUS and DATA to a combined adhoc loc. */ location_t -get_combined_adhoc_loc (line_maps *set, - location_t locus, - source_range src_range, - void *data, - unsigned discriminator) +line_maps::get_or_create_combined_loc (location_t locus, + source_range src_range, + void *data, + unsigned discriminator) { struct location_adhoc_data lb; struct location_adhoc_data **slot; if (IS_ADHOC_LOC (locus)) - locus = get_location_from_adhoc_loc (set, locus); + locus = get_location_from_adhoc_loc (this, locus); if (locus == 0 && data == NULL) return 0; @@ -189,22 +187,22 @@ get_combined_adhoc_loc (line_maps *set, compressed ranges. */ linemap_assert (locus < RESERVED_LOCATION_COUNT || locus >= LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES - || locus >= LINEMAPS_MACRO_LOWEST_LOCATION (set) - || pure_location_p (set, locus)); + || locus >= LINEMAPS_MACRO_LOWEST_LOCATION (this) + || pure_location_p (locus)); /* Consider short-range optimization. */ - if (can_be_stored_compactly_p (set, locus, src_range, data, discriminator)) + if (can_be_stored_compactly_p (locus, src_range, data, discriminator)) { /* The low bits ought to be clear. */ - linemap_assert (pure_location_p (set, locus)); - const line_map *map = linemap_lookup (set, locus); + linemap_assert (pure_location_p (locus)); + const line_map *map = linemap_lookup (this, locus); const line_map_ordinary *ordmap = linemap_check_ordinary (map); unsigned int int_diff = src_range.m_finish - src_range.m_start; unsigned int col_diff = (int_diff >> ordmap->m_range_bits); if (col_diff < (1U << ordmap->m_range_bits)) { location_t packed = locus | col_diff; - set->num_optimized_ranges++; + m_num_optimized_ranges++; return packed; } } @@ -217,99 +215,128 @@ get_combined_adhoc_loc (line_maps *set, return locus; if (!data && discriminator == 0) - set->num_unoptimized_ranges++; + m_num_unoptimized_ranges++; lb.locus = locus; lb.src_range = src_range; lb.data = data; lb.discriminator = discriminator; slot = (struct location_adhoc_data **) - htab_find_slot (set->location_adhoc_data_map.htab, &lb, INSERT); + htab_find_slot (m_location_adhoc_data_map.htab, &lb, INSERT); if (*slot == NULL) { - if (set->location_adhoc_data_map.curr_loc >= - set->location_adhoc_data_map.allocated) + if (m_location_adhoc_data_map.curr_loc >= + m_location_adhoc_data_map.allocated) { - const auto orig_data = set->location_adhoc_data_map.data; + const auto orig_data = m_location_adhoc_data_map.data; /* Cast away extern "C" from the type of xrealloc. */ - line_map_realloc reallocator = (set->reallocator - ? set->reallocator + line_map_realloc reallocator = (m_reallocator + ? m_reallocator : (line_map_realloc) xrealloc); - if (set->location_adhoc_data_map.allocated == 0) - set->location_adhoc_data_map.allocated = 128; + if (m_location_adhoc_data_map.allocated == 0) + m_location_adhoc_data_map.allocated = 128; else - set->location_adhoc_data_map.allocated *= 2; - set->location_adhoc_data_map.data = (struct location_adhoc_data *) - reallocator (set->location_adhoc_data_map.data, - set->location_adhoc_data_map.allocated + m_location_adhoc_data_map.allocated *= 2; + m_location_adhoc_data_map.data = (struct location_adhoc_data *) + reallocator (m_location_adhoc_data_map.data, + m_location_adhoc_data_map.allocated * sizeof (struct location_adhoc_data)); - if (set->location_adhoc_data_map.allocated > 128) + if (m_location_adhoc_data_map.allocated > 128) { location_adhoc_data *param[2] - = {orig_data, set->location_adhoc_data_map.data}; - htab_traverse (set->location_adhoc_data_map.htab, + = {orig_data, m_location_adhoc_data_map.data}; + htab_traverse (m_location_adhoc_data_map.htab, location_adhoc_data_update, param); } } - *slot = set->location_adhoc_data_map.data - + set->location_adhoc_data_map.curr_loc; - set->location_adhoc_data_map.data[set->location_adhoc_data_map.curr_loc++] + *slot = m_location_adhoc_data_map.data + + m_location_adhoc_data_map.curr_loc; + m_location_adhoc_data_map.data[m_location_adhoc_data_map.curr_loc++] = lb; } - return ((*slot) - set->location_adhoc_data_map.data) | 0x80000000; + return ((*slot) - m_location_adhoc_data_map.data) | 0x80000000; +} + +/* Construct a location with caret at CARET, ranging from START to + FINISH. + + For example, consider: + + 11111111112 + 12345678901234567890 + 522 + 523 return foo + bar; + ~~~~^~~~~ + 524 + + The location's caret is at the "+", line 523 column 15, but starts + earlier, at the "f" of "foo" at column 11. The finish is at the "r" + of "bar" at column 19. */ + +location_t +line_maps::make_location (location_t caret, location_t start, location_t finish) +{ + location_t pure_loc = get_pure_location (caret); + source_range src_range; + src_range.m_start = get_start (start); + src_range.m_finish = get_finish (finish); + location_t combined_loc = get_or_create_combined_loc (pure_loc, + src_range, + nullptr, + 0); + return combined_loc; } /* Return the data for the adhoc loc. */ void * -get_data_from_adhoc_loc (const class line_maps *set, location_t loc) +get_data_from_adhoc_loc (const line_maps *set, location_t loc) { linemap_assert (IS_ADHOC_LOC (loc)); - return set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].data; + return set->m_location_adhoc_data_map.data[loc & MAX_LOCATION_T].data; } unsigned -get_discriminator_from_adhoc_loc (const class line_maps *set, location_t loc) +get_discriminator_from_adhoc_loc (const line_maps *set, location_t loc) { linemap_assert (IS_ADHOC_LOC (loc)); - return set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].discriminator; + return set->m_location_adhoc_data_map.data[loc & MAX_LOCATION_T].discriminator; } /* Return the location for the adhoc loc. */ location_t -get_location_from_adhoc_loc (const class line_maps *set, location_t loc) +get_location_from_adhoc_loc (const line_maps *set, location_t loc) { linemap_assert (IS_ADHOC_LOC (loc)); - return set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus; + return set->m_location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus; } /* Return the source_range for adhoc location LOC. */ -static source_range -get_range_from_adhoc_loc (const class line_maps *set, location_t loc) +source_range +line_maps::get_range_from_adhoc_loc (location_t loc) const { linemap_assert (IS_ADHOC_LOC (loc)); - return set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].src_range; + return m_location_adhoc_data_map.data[loc & MAX_LOCATION_T].src_range; } /* Get the source_range of location LOC, either from the ad-hoc lookaside table, or embedded inside LOC itself. */ source_range -get_range_from_loc (line_maps *set, - location_t loc) +line_maps::get_range_from_loc (location_t loc) const { if (IS_ADHOC_LOC (loc)) - return get_range_from_adhoc_loc (set, loc); + return get_range_from_adhoc_loc (loc); /* For ordinary maps, extract packed range. */ if (loc >= RESERVED_LOCATION_COUNT - && loc < LINEMAPS_MACRO_LOWEST_LOCATION (set) + && loc < LINEMAPS_MACRO_LOWEST_LOCATION (this) && loc <= LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES) { - const line_map *map = linemap_lookup (set, loc); + const line_map *map = linemap_lookup (this, loc); const line_map_ordinary *ordmap = linemap_check_ordinary (map); source_range result; int offset = loc & ((1 << ordmap->m_range_bits) - 1); @@ -321,8 +348,15 @@ get_range_from_loc (line_maps *set, return source_range::from_location (loc); } +source_range +get_range_from_loc (const line_maps *set, + location_t loc) +{ + return set->get_range_from_loc (loc); +} + unsigned -get_discriminator_from_loc (line_maps *set, +get_discriminator_from_loc (const line_maps *set, location_t loc) { if (IS_ADHOC_LOC (loc)) @@ -334,12 +368,12 @@ get_discriminator_from_loc (line_maps *set, whether it is an ad-hoc location, or embeds range information. */ bool -pure_location_p (line_maps *set, location_t loc) +line_maps::pure_location_p (location_t loc) const { if (IS_ADHOC_LOC (loc)) return false; - const line_map *map = linemap_lookup (set, loc); + const line_map *map = linemap_lookup (this, loc); if (map == NULL) return true; const line_map_ordinary *ordmap = linemap_check_ordinary (map); @@ -350,27 +384,39 @@ pure_location_p (line_maps *set, location_t loc) return true; } +bool +pure_location_p (const line_maps *set, location_t loc) +{ + return set->pure_location_p (loc); +} + /* Given location LOC within SET, strip away any packed range information or ad-hoc information. */ location_t -get_pure_location (line_maps *set, location_t loc) +line_maps::get_pure_location (location_t loc) const { if (IS_ADHOC_LOC (loc)) - loc = get_location_from_adhoc_loc (set, loc); + loc = get_location_from_adhoc_loc (this, loc); - if (loc >= LINEMAPS_MACRO_LOWEST_LOCATION (set)) + if (loc >= LINEMAPS_MACRO_LOWEST_LOCATION (this)) return loc; if (loc < RESERVED_LOCATION_COUNT) return loc; - const line_map *map = linemap_lookup (set, loc); + const line_map *map = linemap_lookup (this, loc); const line_map_ordinary *ordmap = linemap_check_ordinary (map); return loc & ~((1 << ordmap->m_range_bits) - 1); } +location_t +get_pure_location (const line_maps *set, location_t loc) +{ + return set->get_pure_location (loc); +} + /* Initialize a line map set. */ void @@ -384,10 +430,10 @@ linemap_init (line_maps *set, new (set) line_maps(); #endif /* Set default reallocator (used for initial alloc too). */ - set->reallocator = xrealloc; + set->m_reallocator = xrealloc; set->highest_location = RESERVED_LOCATION_COUNT - 1; set->highest_line = RESERVED_LOCATION_COUNT - 1; - set->location_adhoc_data_map.htab = + set->m_location_adhoc_data_map.htab = htab_create (100, location_adhoc_data_hash, location_adhoc_data_eq, NULL); set->builtin_location = builtin_location; } @@ -396,7 +442,7 @@ linemap_init (line_maps *set, NULL if MAP was not an include. */ const line_map_ordinary * -linemap_included_from_linemap (line_maps *set, const line_map_ordinary *map) +linemap_included_from_linemap (const line_maps *set, const line_map_ordinary *map) { return linemap_ordinary_map_lookup (set, linemap_included_from (map)); } @@ -404,7 +450,7 @@ linemap_included_from_linemap (line_maps *set, const line_map_ordinary *map) /* Check for and warn about line_maps entered but not exited. */ void -linemap_check_files_exited (line_maps *set) +linemap_check_files_exited (const line_maps *set) { /* Depending upon whether we are handling preprocessed input or not, this can be a user error or an ICE. */ @@ -453,13 +499,13 @@ line_map_new_raw (line_maps *set, bool macro_p, unsigned num) allocator may well be larger than what we ask for. Use this hook to find what that size is. */ size_t alloc_size - = set->round_alloc_size (num_maps_allocated * size_of_a_map); + = set->m_round_alloc_size (num_maps_allocated * size_of_a_map); /* Now alloc_size contains the exact memory size we would get if we have asked for the initial alloc_size amount of memory. Let's get back to the number of map that amounts to. */ unsigned num_maps = alloc_size / size_of_a_map; - buffer = set->reallocator (buffer, num_maps * size_of_a_map); + buffer = set->m_reallocator (buffer, num_maps * size_of_a_map); memset ((char *)buffer + num_maps_used * size_of_a_map, 0, (num_maps - num_maps_used) * size_of_a_map); if (macro_p) @@ -592,7 +638,7 @@ linemap_add (line_maps *set, enum lc_reason reason, map->sysp = sysp; map->to_file = to_file; map->to_line = to_line; - LINEMAPS_ORDINARY_CACHE (set) = LINEMAPS_ORDINARY_USED (set) - 1; + set->info_ordinary.m_cache = LINEMAPS_ORDINARY_USED (set) - 1; /* Do not store range_bits here. That's readjusted in linemap_line_start. */ map->m_range_bits = map->m_column_and_range_bits = 0; @@ -690,9 +736,9 @@ linemap_module_restore (line_maps *set, unsigned lwm) macro expansion, FALSE otherwise. */ bool -linemap_tracks_macro_expansion_locs_p (line_maps *set) +linemap_tracks_macro_expansion_locs_p (const line_maps *set) { - return LINEMAPS_MACRO_MAPS (set) != NULL; + return set->info_macro.maps != nullptr; } /* Create a macro map. A macro map encodes source locations of tokens @@ -734,14 +780,13 @@ linemap_enter_macro (class line_maps *set, struct cpp_hashnode *macro_node, map->macro = macro_node; map->n_tokens = num_tokens; map->macro_locations - = (location_t*) set->reallocator (NULL, - 2 * num_tokens - * sizeof (location_t)); + = (location_t*) set->m_reallocator (nullptr, + 2 * num_tokens * sizeof (location_t)); map->expansion = expansion; memset (MACRO_MAP_LOCATIONS (map), 0, 2 * num_tokens * sizeof (location_t)); - LINEMAPS_MACRO_CACHE (set) = LINEMAPS_MACRO_USED (set) - 1; + set->info_macro.m_cache = LINEMAPS_MACRO_USED (set) - 1; return map; } @@ -1071,7 +1116,7 @@ linemap_ordinary_map_lookup (const line_maps *set, location_t line) if (set == NULL || line < RESERVED_LOCATION_COUNT) return NULL; - unsigned mn = LINEMAPS_ORDINARY_CACHE (set); + unsigned mn = set->info_ordinary.m_cache; unsigned mx = LINEMAPS_ORDINARY_USED (set); const line_map_ordinary *cached = LINEMAPS_ORDINARY_MAP_AT (set, mn); @@ -1096,7 +1141,7 @@ linemap_ordinary_map_lookup (const line_maps *set, location_t line) mn = md; } - LINEMAPS_ORDINARY_CACHE (set) = mn; + set->info_ordinary.m_cache = mn; const line_map_ordinary *result = LINEMAPS_ORDINARY_MAP_AT (set, mn); linemap_assert (line >= MAP_START_LOCATION (result)); return result; @@ -1128,7 +1173,7 @@ linemap_macro_map_lookup (const line_maps *set, location_t line) unsigned linemap_lookup_macro_index (const line_maps *set, location_t line) { - unsigned mn = LINEMAPS_MACRO_CACHE (set); + unsigned mn = set->info_macro.m_cache; unsigned mx = LINEMAPS_MACRO_USED (set); const struct line_map_macro *cached = LINEMAPS_MACRO_MAP_AT (set, mn); @@ -1150,7 +1195,7 @@ linemap_lookup_macro_index (const line_maps *set, location_t line) mx = md; } - LINEMAPS_MACRO_CACHE (set) = mx; + set->info_macro.m_cache = mx; return mx; } @@ -1214,7 +1259,7 @@ linemap_macro_map_loc_to_def_point (const line_map_macro *map, In other words, this returns the xI location presented in the comments of line_map_macro above. */ location_t -linemap_macro_map_loc_unwind_toward_spelling (line_maps *set, +linemap_macro_map_loc_unwind_toward_spelling (const line_maps *set, const line_map_macro* map, location_t location) { @@ -1243,7 +1288,7 @@ linemap_macro_map_loc_unwind_toward_spelling (line_maps *set, macro expansion point. */ int -linemap_get_expansion_line (line_maps *set, +linemap_get_expansion_line (const line_maps *set, location_t location) { const line_map_ordinary *map = NULL; @@ -1270,7 +1315,7 @@ linemap_get_expansion_line (line_maps *set, SET is the line map set LOCATION comes from. */ const char* -linemap_get_expansion_filename (line_maps *set, +linemap_get_expansion_filename (const line_maps *set, location_t location) { const struct line_map_ordinary *map = NULL; @@ -1306,7 +1351,7 @@ linemap_map_get_macro_name (const line_map_macro *macro_map) header, but expanded in a non-system file. */ int -linemap_location_in_system_header_p (line_maps *set, +linemap_location_in_system_header_p (const line_maps *set, location_t location) { const struct line_map *map = NULL; @@ -1366,7 +1411,7 @@ linemap_location_from_macro_expansion_p (const class line_maps *set, virtual location of the token inside the resulting macro. */ static const struct line_map* -first_map_in_common_1 (line_maps *set, +first_map_in_common_1 (const line_maps *set, location_t *loc0, location_t *loc1) { @@ -1413,7 +1458,7 @@ first_map_in_common_1 (line_maps *set, return of a non-NULL result. */ const struct line_map* -first_map_in_common (line_maps *set, +first_map_in_common (const line_maps *set, location_t loc0, location_t loc1, location_t *res_loc0, @@ -1431,7 +1476,7 @@ first_map_in_common (line_maps *set, otherwise. */ int -linemap_compare_locations (line_maps *set, +linemap_compare_locations (const line_maps *set, location_t pre, location_t post) { @@ -1506,7 +1551,7 @@ trace_include (const class line_maps *set, const line_map_ordinary *map) This is a subroutine for linemap_resolve_location. */ static location_t -linemap_macro_loc_to_spelling_point (line_maps *set, +linemap_macro_loc_to_spelling_point (const line_maps *set, location_t location, const line_map_ordinary **original_map) { @@ -1540,7 +1585,7 @@ linemap_macro_loc_to_spelling_point (line_maps *set, This is a subroutine of linemap_resolve_location. */ static location_t -linemap_macro_loc_to_def_point (line_maps *set, +linemap_macro_loc_to_def_point (const line_maps *set, location_t location, const line_map_ordinary **original_map) { @@ -1582,7 +1627,7 @@ linemap_macro_loc_to_def_point (line_maps *set, This is a subroutine of linemap_resolve_location. */ static location_t -linemap_macro_loc_to_exp_point (line_maps *set, +linemap_macro_loc_to_exp_point (const line_maps *set, location_t location, const line_map_ordinary **original_map) { @@ -1656,7 +1701,7 @@ linemap_macro_loc_to_exp_point (line_maps *set, UNKNOWN_LOCATION or BUILTINS_LOCATION in GCC. */ location_t -linemap_resolve_location (line_maps *set, +linemap_resolve_location (const line_maps *set, location_t loc, enum location_resolution_kind lrk, const line_map_ordinary **map) @@ -1696,7 +1741,7 @@ linemap_resolve_location (line_maps *set, definition of a macro, FALSE otherwise. */ bool -linemap_location_from_macro_definition_p (line_maps *set, +linemap_location_from_macro_definition_p (const line_maps *set, location_t loc) { if (IS_ADHOC_LOC (loc)) @@ -1736,7 +1781,7 @@ linemap_location_from_macro_definition_p (line_maps *set, to the map of the returned location. */ location_t -linemap_unwind_toward_expansion (line_maps *set, +linemap_unwind_toward_expansion (const line_maps *set, location_t loc, const struct line_map **map) { @@ -1776,7 +1821,7 @@ linemap_unwind_toward_expansion (line_maps *set, *MAP is set to the map of the returned location if the later is different from LOC. */ location_t -linemap_unwind_to_first_non_reserved_loc (line_maps *set, +linemap_unwind_to_first_non_reserved_loc (const line_maps *set, location_t loc, const struct line_map **map) { @@ -1820,7 +1865,7 @@ linemap_unwind_to_first_non_reserved_loc (line_maps *set, location is returned. */ expanded_location -linemap_expand_location (line_maps *set, +linemap_expand_location (const line_maps *set, const struct line_map *map, location_t loc) @@ -1869,7 +1914,7 @@ linemap_expand_location (line_maps *set, dump a macro map, false otherwise. */ void -linemap_dump (FILE *stream, class line_maps *set, unsigned ix, bool is_macro) +linemap_dump (FILE *stream, const line_maps *set, unsigned ix, bool is_macro) { const char *const lc_reasons_v[LC_HWM] = { "LC_ENTER", "LC_LEAVE", "LC_RENAME", "LC_RENAME_VERBATIM", @@ -1925,7 +1970,7 @@ linemap_dump (FILE *stream, class line_maps *set, unsigned ix, bool is_macro) stream STREAM. SET is the line map set LOC comes from. */ void -linemap_dump_location (line_maps *set, +linemap_dump_location (const line_maps *set, location_t loc, FILE *stream) { @@ -1975,7 +2020,7 @@ linemap_dump_location (line_maps *set, location emitted for that file. */ bool -linemap_get_file_highest_location (line_maps *set, +linemap_get_file_highest_location (const line_maps *set, const char *file_name, location_t *loc) { @@ -2013,7 +2058,7 @@ linemap_get_file_highest_location (line_maps *set, parts of the line table SET. */ void -linemap_get_statistics (line_maps *set, +linemap_get_statistics (const line_maps *set, struct linemap_stats *s) { long ordinary_maps_allocated_size, ordinary_maps_used_size, @@ -2031,7 +2076,7 @@ linemap_get_statistics (line_maps *set, macro_maps_allocated_size = LINEMAPS_MACRO_ALLOCATED (set) * sizeof (struct line_map_macro); - for (cur_map = LINEMAPS_MACRO_MAPS (set); + for (cur_map = set->info_macro.maps; cur_map && cur_map <= LINEMAPS_LAST_MACRO_MAP (set); ++cur_map) { @@ -2066,9 +2111,9 @@ linemap_get_statistics (line_maps *set, s->macro_maps_used_size = macro_maps_used_size; s->duplicated_macro_maps_locations_size = duplicated_macro_maps_locations_size; - s->adhoc_table_size = (set->location_adhoc_data_map.allocated + s->adhoc_table_size = (set->m_location_adhoc_data_map.allocated * sizeof (struct location_adhoc_data)); - s->adhoc_table_entries_used = set->location_adhoc_data_map.curr_loc; + s->adhoc_table_entries_used = set->m_location_adhoc_data_map.curr_loc; } @@ -2077,7 +2122,7 @@ linemap_get_statistics (line_maps *set, specifies how many macro maps to dump. */ void -line_table_dump (FILE *stream, class line_maps *set, unsigned int num_ordinary, +line_table_dump (FILE *stream, const line_maps *set, unsigned int num_ordinary, unsigned int num_macro) { unsigned int i; |