Skip to content
  • Lewis Hyatt's avatar
    927625d0
    Support for 64-bit location_t: libcpp preliminaries · 927625d0
    Lewis Hyatt authored
    Prepare libcpp to support 64-bit location_t, without yet making
    any functional changes, by adding new typedefs that enable code to be
    written such that it works with any size location_t. Update the usage of
    line maps within libcpp accordingly.
    
    Subsequent patches will prepare the rest of the codebase similarly, and then
    afterwards, location_t will be changed to uint64_t.
    
    libcpp/ChangeLog:
    
    	* include/line-map.h (line_map_uint_t): New typedef, the same type
    	as location_t.
    	(location_diff_t): New typedef.
    	(line_map_suggested_range_bits): New constant.
    	(struct maps_info_ordinary): Change member types from "unsigned int"
    	to "line_map_uint_t".
    	(struct maps_info_macro): Likewise.
    	(struct location_adhoc_data_map): Likewise.
    	(LINEMAPS_ALLOCATED): Change return type from "unsigned int" to
    	"line_map_uint_t".
    	(LINEMAPS_ORDINARY_ALLOCATED): Likewise.
    	(LINEMAPS_MACRO_ALLOCATED): Likewise.
    	(LINEMAPS_USED): Likewise.
    	(LINEMAPS_ORDINARY_USED): Likewise.
    	(LINEMAPS_MACRO_USED): Likewise.
    	(linemap_lookup_macro_index): Likewise.
    	(LINEMAPS_MAP_AT): Change argument type from "unsigned int" to
    	"line_map_uint_t".
    	(LINEMAPS_ORDINARY_MAP_AT): Likewise.
    	(LINEMAPS_MACRO_MAP_AT): Likewise.
    	(line_map_new_raw): Likewise.
    	(linemap_module_restore): Likewise.
    	(linemap_dump): Likewise.
    	(line_table_dump): Likewise.
    	(LINEMAPS_LAST_MAP): Add a linemap_assert() for safety.
    	(SOURCE_COLUMN): Use a cast to ensure correctness if location_t
    	becomes a 64-bit type.
    	* line-map.cc (location_adhoc_data_hash): Don't truncate to 32-bit
    	prematurely when hashing.
    	(line_maps::get_or_create_combined_loc): Adapt types to support
    	potentially 64-bit location_t. Use MAX_LOCATION_T rather than a
    	hard-coded constant.
    	(line_maps::get_range_from_loc): Adapt types and constants to
    	support potentially 64-bit location_t.
    	(line_maps::pure_location_p): Likewise.
    	(line_maps::get_pure_location): Likewise.
    	(line_map_new_raw): Likewise.
    	(LAST_SOURCE_LINE_LOCATION): Likewise.
    	(linemap_add): Likewise.
    	(linemap_module_restore): Likewise.
    	(linemap_line_start): Likewise.
    	(linemap_position_for_column): Likewise.
    	(linemap_position_for_line_and_column): Likewise.
    	(linemap_position_for_loc_and_offset): Likewise.
    	(linemap_ordinary_map_lookup): Likewise.
    	(linemap_lookup_macro_index): Likewise.
    	(linemap_dump): Likewise.
    	(linemap_dump_location): Likewise.
    	(linemap_get_file_highest_location): Likewise.
    	(line_table_dump): Likewise.
    	(linemap_compare_locations): Avoid signed int overflow in the result.
    	* macro.cc (num_expanded_macros_counter): Change type of global
    	variable from "unsigned int" to "line_map_uint_t".
    	(num_macro_tokens_counter): Likewise.
    927625d0
    Support for 64-bit location_t: libcpp preliminaries
    Lewis Hyatt authored
    Prepare libcpp to support 64-bit location_t, without yet making
    any functional changes, by adding new typedefs that enable code to be
    written such that it works with any size location_t. Update the usage of
    line maps within libcpp accordingly.
    
    Subsequent patches will prepare the rest of the codebase similarly, and then
    afterwards, location_t will be changed to uint64_t.
    
    libcpp/ChangeLog:
    
    	* include/line-map.h (line_map_uint_t): New typedef, the same type
    	as location_t.
    	(location_diff_t): New typedef.
    	(line_map_suggested_range_bits): New constant.
    	(struct maps_info_ordinary): Change member types from "unsigned int"
    	to "line_map_uint_t".
    	(struct maps_info_macro): Likewise.
    	(struct location_adhoc_data_map): Likewise.
    	(LINEMAPS_ALLOCATED): Change return type from "unsigned int" to
    	"line_map_uint_t".
    	(LINEMAPS_ORDINARY_ALLOCATED): Likewise.
    	(LINEMAPS_MACRO_ALLOCATED): Likewise.
    	(LINEMAPS_USED): Likewise.
    	(LINEMAPS_ORDINARY_USED): Likewise.
    	(LINEMAPS_MACRO_USED): Likewise.
    	(linemap_lookup_macro_index): Likewise.
    	(LINEMAPS_MAP_AT): Change argument type from "unsigned int" to
    	"line_map_uint_t".
    	(LINEMAPS_ORDINARY_MAP_AT): Likewise.
    	(LINEMAPS_MACRO_MAP_AT): Likewise.
    	(line_map_new_raw): Likewise.
    	(linemap_module_restore): Likewise.
    	(linemap_dump): Likewise.
    	(line_table_dump): Likewise.
    	(LINEMAPS_LAST_MAP): Add a linemap_assert() for safety.
    	(SOURCE_COLUMN): Use a cast to ensure correctness if location_t
    	becomes a 64-bit type.
    	* line-map.cc (location_adhoc_data_hash): Don't truncate to 32-bit
    	prematurely when hashing.
    	(line_maps::get_or_create_combined_loc): Adapt types to support
    	potentially 64-bit location_t. Use MAX_LOCATION_T rather than a
    	hard-coded constant.
    	(line_maps::get_range_from_loc): Adapt types and constants to
    	support potentially 64-bit location_t.
    	(line_maps::pure_location_p): Likewise.
    	(line_maps::get_pure_location): Likewise.
    	(line_map_new_raw): Likewise.
    	(LAST_SOURCE_LINE_LOCATION): Likewise.
    	(linemap_add): Likewise.
    	(linemap_module_restore): Likewise.
    	(linemap_line_start): Likewise.
    	(linemap_position_for_column): Likewise.
    	(linemap_position_for_line_and_column): Likewise.
    	(linemap_position_for_loc_and_offset): Likewise.
    	(linemap_ordinary_map_lookup): Likewise.
    	(linemap_lookup_macro_index): Likewise.
    	(linemap_dump): Likewise.
    	(linemap_dump_location): Likewise.
    	(linemap_get_file_highest_location): Likewise.
    	(line_table_dump): Likewise.
    	(linemap_compare_locations): Avoid signed int overflow in the result.
    	* macro.cc (num_expanded_macros_counter): Change type of global
    	variable from "unsigned int" to "line_map_uint_t".
    	(num_macro_tokens_counter): Likewise.
Loading