libcpp: eliminate COMBINE_LOCATION_DATA
This patch eliminates the function "COMBINE_LOCATION_DATA" (which hasn't been a macro since r6-739-g0501dbd932a7e9) and the function "get_combined_adhoc_loc" in favor of a new line_maps::get_or_create_combined_loc member function. No functional change intended. gcc/cp/ChangeLog: * module.cc (module_state::read_location): Update for renaming of get_combined_adhoc_loc. gcc/ChangeLog: * genmatch.cc (main): Update for "m_" prefix of some fields of line_maps. * input.cc (make_location): Update for removal of COMBINE_LOCATION_DATA. (dump_line_table_statistics): Update for "m_" prefix of some fields of line_maps. (location_with_discriminator): Update for removal of COMBINE_LOCATION_DATA. (line_table_test::line_table_test): Update for "m_" prefix of some fields of line_maps. * toplev.cc (general_init): Likewise. * tree.cc (set_block): Update for removal of COMBINE_LOCATION_DATA. (set_source_range): Likewise. libcpp/ChangeLog: * 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. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
This commit is contained in:
parent
25af7c1a80
commit
1f68a3e872
8 changed files with 118 additions and 119 deletions
|
@ -15969,7 +15969,8 @@ module_state::read_location (bytes_in &sec) const
|
|||
range.m_finish = read_location (sec);
|
||||
unsigned discriminator = sec.u ();
|
||||
if (locus != loc && range.m_start != loc && range.m_finish != loc)
|
||||
locus = get_combined_adhoc_loc (line_table, locus, range, NULL, discriminator);
|
||||
locus = line_table->get_or_create_combined_loc (locus, range,
|
||||
nullptr, discriminator);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -5458,8 +5458,8 @@ main (int argc, char **argv)
|
|||
|
||||
line_table = XCNEW (class line_maps);
|
||||
linemap_init (line_table, 0);
|
||||
line_table->reallocator = xrealloc;
|
||||
line_table->round_alloc_size = round_alloc_size;
|
||||
line_table->m_reallocator = xrealloc;
|
||||
line_table->m_round_alloc_size = round_alloc_size;
|
||||
|
||||
r = cpp_create_reader (CLK_GNUC99, NULL, line_table);
|
||||
cpp_callbacks *cb = cpp_get_callbacks (r);
|
||||
|
|
26
gcc/input.cc
26
gcc/input.cc
|
@ -1231,7 +1231,8 @@ location_t
|
|||
make_location (location_t caret, source_range src_range)
|
||||
{
|
||||
location_t pure_loc = get_pure_location (caret);
|
||||
return COMBINE_LOCATION_DATA (line_table, pure_loc, src_range, NULL, 0);
|
||||
return line_table->get_or_create_combined_loc (pure_loc, src_range,
|
||||
nullptr, 0);
|
||||
}
|
||||
|
||||
/* An expanded_location stores the column in byte units. This function
|
||||
|
@ -1313,9 +1314,9 @@ dump_line_table_statistics (void)
|
|||
fprintf (stderr, "Ad-hoc table entries used: " PRsa (5) "\n",
|
||||
SIZE_AMOUNT (s.adhoc_table_entries_used));
|
||||
fprintf (stderr, "optimized_ranges: " PRsa (5) "\n",
|
||||
SIZE_AMOUNT (line_table->num_optimized_ranges));
|
||||
SIZE_AMOUNT (line_table->m_num_optimized_ranges));
|
||||
fprintf (stderr, "unoptimized_ranges: " PRsa (5) "\n",
|
||||
SIZE_AMOUNT (line_table->num_unoptimized_ranges));
|
||||
SIZE_AMOUNT (line_table->m_num_unoptimized_ranges));
|
||||
|
||||
fprintf (stderr, "\n");
|
||||
}
|
||||
|
@ -1917,7 +1918,8 @@ location_with_discriminator (location_t locus, int discriminator)
|
|||
if (locus == UNKNOWN_LOCATION)
|
||||
return locus;
|
||||
|
||||
return COMBINE_LOCATION_DATA (line_table, locus, src_range, block, discriminator);
|
||||
return line_table->get_or_create_combined_loc (locus, src_range, block,
|
||||
discriminator);
|
||||
}
|
||||
|
||||
/* Return TRUE if LOCUS represents a location with a discriminator. */
|
||||
|
@ -2099,10 +2101,10 @@ line_table_test::line_table_test ()
|
|||
saved_line_table = line_table;
|
||||
line_table = ggc_alloc<line_maps> ();
|
||||
linemap_init (line_table, BUILTINS_LOCATION);
|
||||
gcc_assert (saved_line_table->reallocator);
|
||||
line_table->reallocator = saved_line_table->reallocator;
|
||||
gcc_assert (saved_line_table->round_alloc_size);
|
||||
line_table->round_alloc_size = saved_line_table->round_alloc_size;
|
||||
gcc_assert (saved_line_table->m_reallocator);
|
||||
line_table->m_reallocator = saved_line_table->m_reallocator;
|
||||
gcc_assert (saved_line_table->m_round_alloc_size);
|
||||
line_table->m_round_alloc_size = saved_line_table->m_round_alloc_size;
|
||||
line_table->default_range_bits = 0;
|
||||
}
|
||||
|
||||
|
@ -2115,10 +2117,10 @@ line_table_test::line_table_test (const line_table_case &case_)
|
|||
saved_line_table = line_table;
|
||||
line_table = ggc_alloc<line_maps> ();
|
||||
linemap_init (line_table, BUILTINS_LOCATION);
|
||||
gcc_assert (saved_line_table->reallocator);
|
||||
line_table->reallocator = saved_line_table->reallocator;
|
||||
gcc_assert (saved_line_table->round_alloc_size);
|
||||
line_table->round_alloc_size = saved_line_table->round_alloc_size;
|
||||
gcc_assert (saved_line_table->m_reallocator);
|
||||
line_table->m_reallocator = saved_line_table->m_reallocator;
|
||||
gcc_assert (saved_line_table->m_round_alloc_size);
|
||||
line_table->m_round_alloc_size = saved_line_table->m_round_alloc_size;
|
||||
line_table->default_range_bits = case_.m_default_range_bits;
|
||||
if (case_.m_base_location)
|
||||
{
|
||||
|
|
|
@ -1082,8 +1082,8 @@ general_init (const char *argv0, bool init_signals)
|
|||
input_location = UNKNOWN_LOCATION;
|
||||
line_table = ggc_alloc<line_maps> ();
|
||||
linemap_init (line_table, BUILTINS_LOCATION);
|
||||
line_table->reallocator = realloc_for_line_map;
|
||||
line_table->round_alloc_size = ggc_round_alloc_size;
|
||||
line_table->m_reallocator = realloc_for_line_map;
|
||||
line_table->m_round_alloc_size = ggc_round_alloc_size;
|
||||
line_table->default_range_bits = 5;
|
||||
init_ttree ();
|
||||
|
||||
|
|
12
gcc/tree.cc
12
gcc/tree.cc
|
@ -14505,7 +14505,8 @@ set_block (location_t loc, tree block)
|
|||
location_t pure_loc = get_pure_location (loc);
|
||||
source_range src_range = get_range_from_loc (line_table, loc);
|
||||
unsigned discriminator = get_discriminator_from_loc (line_table, loc);
|
||||
return COMBINE_LOCATION_DATA (line_table, pure_loc, src_range, block, discriminator);
|
||||
return line_table->get_or_create_combined_loc (pure_loc, src_range, block,
|
||||
discriminator);
|
||||
}
|
||||
|
||||
location_t
|
||||
|
@ -14526,11 +14527,10 @@ set_source_range (tree expr, source_range src_range)
|
|||
location_t expr_location = EXPR_LOCATION (expr);
|
||||
location_t pure_loc = get_pure_location (expr_location);
|
||||
unsigned discriminator = get_discriminator_from_loc (expr_location);
|
||||
location_t adhoc = COMBINE_LOCATION_DATA (line_table,
|
||||
pure_loc,
|
||||
src_range,
|
||||
NULL,
|
||||
discriminator);
|
||||
location_t adhoc = line_table->get_or_create_combined_loc (pure_loc,
|
||||
src_range,
|
||||
nullptr,
|
||||
discriminator);
|
||||
SET_EXPR_LOCATION (expr, adhoc);
|
||||
return adhoc;
|
||||
}
|
||||
|
|
|
@ -802,7 +802,21 @@ public:
|
|||
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;
|
||||
|
@ -827,13 +841,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. */
|
||||
|
@ -842,8 +856,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
|
||||
|
@ -1052,8 +1066,6 @@ 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 *,
|
||||
|
@ -1073,18 +1085,6 @@ pure_location_p (const line_maps *set, location_t loc);
|
|||
|
||||
extern location_t get_pure_location (const 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 void rebuild_location_adhoc_htab (class line_maps *);
|
||||
|
||||
/* Initialize a line map set. SET is the line map set to initialize
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 (const 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 (const 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 (const 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,47 +215,47 @@ 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
|
||||
|
@ -283,11 +281,10 @@ line_maps::make_location (location_t caret, location_t start, location_t finish)
|
|||
source_range src_range;
|
||||
src_range.m_start = get_start (start);
|
||||
src_range.m_finish = get_finish (finish);
|
||||
location_t combined_loc = COMBINE_LOCATION_DATA (this,
|
||||
pure_loc,
|
||||
src_range,
|
||||
NULL,
|
||||
0);
|
||||
location_t combined_loc = get_or_create_combined_loc (pure_loc,
|
||||
src_range,
|
||||
nullptr,
|
||||
0);
|
||||
return combined_loc;
|
||||
}
|
||||
|
||||
|
@ -297,14 +294,14 @@ void *
|
|||
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 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. */
|
||||
|
@ -313,16 +310,16 @@ location_t
|
|||
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 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
|
||||
|
@ -332,7 +329,7 @@ source_range
|
|||
line_maps::get_range_from_loc (location_t loc) const
|
||||
{
|
||||
if (IS_ADHOC_LOC (loc))
|
||||
return get_range_from_adhoc_loc (this, loc);
|
||||
return get_range_from_adhoc_loc (loc);
|
||||
|
||||
/* For ordinary maps, extract packed range. */
|
||||
if (loc >= RESERVED_LOCATION_COUNT
|
||||
|
@ -433,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;
|
||||
}
|
||||
|
@ -502,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)
|
||||
|
@ -783,9 +780,8 @@ 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));
|
||||
|
@ -2115,9 +2111,9 @@ linemap_get_statistics (const 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;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue