]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/input.c
input.c: move file caching globals to a new file_cache class
authorDavid Malcolm <dmalcolm@redhat.com>
Thu, 1 Jul 2021 21:44:51 +0000 (17:44 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Thu, 1 Jul 2021 21:44:51 +0000 (17:44 -0400)
commitb544c348e13ad33d55f0d954370ab1fb0f2bf683
tree3a30b3a50f0c137816db64cb1f07a171a63278d2
parent58b735b70b03884052c80ac032df90eed7059f8d
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: David Malcolm <dmalcolm@redhat.com>
gcc/diagnostic.h
gcc/input.c
gcc/input.h