Skip to content
Snippets Groups Projects
Commit b544c348 authored by David Malcolm's avatar David Malcolm
Browse files

input.c: move file caching globals to a new file_cache class


This moves some global state from input.c to a new file_cache class,
of which an instance is owned by global_dc.  Various state is also
made private.

No functional change intended.

gcc/ChangeLog:
	* diagnostic.h (diagnostic_context::m_file_cache): New field.
	* input.c (class fcache): Rename to...
	(class file_cache_slot): ...this, making most members private and
	prefixing fields with "m_".
	(file_cache_slot::get_file_path): New accessor.
	(file_cache_slot::get_use_count): New accessor.
	(file_cache_slot::missing_trailing_newline_p): New accessor.
	(file_cache_slot::inc_use_count): New.
	(fcache_buffer_size): Move to...
	(file_cache_slot::buffer_size): ...here.
	(fcache_line_record_size): Move to...
	(file_cache_slot::line_record_size): ...here.
	(fcache_tab): Delete, in favor of global_dc->m_file_cache.
	(fcache_tab_size): Move to file_cache::num_file_slots.
	(diagnostic_file_cache_init): Update for move of fcache_tab
	to global_dc->m_file_cache.
	(diagnostic_file_cache_fini): Likewise.
	(lookup_file_in_cache_tab): Convert to...
	(file_cache::lookup_file): ...this.
	(diagnostics_file_cache_forcibly_evict_file): Update for move of
	fcache_tab to global_dc->m_file_cache, moving most of
	implementation to...
	(file_cache::forcibly_evict_file): ...this new function and...
	(file_cache_slot::evict): ...this new function.
	(evicted_cache_tab_entry): Convert to...
	(file_cache::evicted_cache_tab_entry): ...this.
	(add_file_to_cache_tab): Convert to...
	(file_cache::add_file): ...this, moving bulk of implementation
	to...
	(file_cache_slot::create): ..this new function.
	(file_cache::file_cache): New.
	(file_cache::~file_cache): New.
	(lookup_or_add_file_to_cache_tab): Convert to...
	(file_cache::lookup_or_add_file): ..this new function.
	(fcache::fcache): Rename to...
	(file_cache_slot::file_cache_slot): ...this, adding "m_" prefixes
	to fields.
	(fcache::~fcache): Rename to...
	(file_cache_slot::~file_cache_slot): ...this, adding "m_" prefixes
	to fields.
	(needs_read): Convert to...
	(file_cache_slot::needs_read_p): ...this.
	(needs_grow): Convert to...
	(file_cache_slot::needs_grow_p): ...this.
	(maybe_grow): Convert to...
	(file_cache_slot::maybe_grow): ...this.
	(read_data): Convert to...
	(file_cache_slot::read_data): ...this.
	(maybe_read_data): Convert to...
	(file_cache_slot::maybe_read_data): ...this.
	(get_next_line): Convert to...
	(file_cache_slot::get_next_line): ...this.
	(goto_next_line): Convert to...
	(file_cache_slot::goto_next_line): ...this.
	(read_line_num): Convert to...
	(file_cache_slot::read_line_num): ...this.
	(location_get_source_line): Update for moving of globals to
	global_dc->m_file_cache.
	(location_missing_trailing_newline): Likewise.
	* input.h (class file_cache_slot): New forward decl.
	(class file_cache): New.

Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
parent 58b735b7
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment