GCC Middle and Back End API Reference
|
Data Structures | |
class | line_info |
Public Member Functions | |
file_cache_slot () | |
~file_cache_slot () | |
void | dump (FILE *out, int indent) const |
void DEBUG_FUNCTION | dump () const |
bool | read_line_num (size_t line_num, char **line, ssize_t *line_len) |
const char * | get_file_path () const |
unsigned | get_use_count () const |
bool | missing_trailing_newline_p () const |
char_span | get_full_file_content () |
void | inc_use_count () |
bool | create (const file_cache::input_context &in_context, const char *file_path, FILE *fp, unsigned highest_use_count) |
void | evict () |
void | set_content (const char *buf, size_t sz) |
Static Public Member Functions | |
static void | tune (size_t line_record_size_) |
Private Member Functions | |
bool | needs_read_p () const |
bool | needs_grow_p () const |
void | maybe_grow () |
bool | read_data () |
bool | maybe_read_data () |
bool | get_next_line (char **line, ssize_t *line_len) |
bool | read_next_line (char **line, ssize_t *line_len) |
bool | goto_next_line () |
void | offset_buffer (int offset) |
Private Attributes | |
unsigned | m_use_count |
const char * | m_file_path |
FILE * | m_fp |
bool | m_error |
char * | m_data |
int | m_alloc_offset |
size_t | m_size |
size_t | m_nb_read |
size_t | m_line_start_idx |
size_t | m_line_num |
bool | m_missing_trailing_newline |
vec< line_info, va_heap > | m_line_record |
vec< line_info, va_heap > | m_line_recent |
size_t | m_line_recent_last |
size_t | m_line_recent_first |
Static Private Attributes | |
static const size_t | buffer_size = 4 * 1024 |
static size_t | line_record_size = 0 |
static size_t | recent_cached_lines_shift = 8 |
This is a cache used by get_next_line to store the content of a file to be searched for file lines.
file_cache_slot::file_cache_slot | ( | ) |
Default constructor for a cache of file used by caret diagnostic.
References false, i, m_alloc_offset, m_data, m_error, m_file_path, m_fp, m_line_num, m_line_recent, m_line_recent_first, m_line_recent_last, m_line_record, m_line_start_idx, m_missing_trailing_newline, m_nb_read, m_size, m_use_count, NULL, recent_cached_lines_shift, and true.
file_cache_slot::~file_cache_slot | ( | ) |
Destructor for a cache of file used by caret diagnostic.
References m_alloc_offset, m_data, m_fp, m_line_recent, m_line_record, NULL, and offset_buffer().
bool file_cache_slot::create | ( | const file_cache::input_context & | in_context, |
const char * | file_path, | ||
FILE * | fp, | ||
unsigned | highest_use_count ) |
Populate this slot for use on FILE_PATH and FP, dropping any existing cached content within it.
References file_cache::input_context::ccb, m_alloc_offset, m_data, m_error, m_file_path, m_fp, m_line_num, m_line_recent_first, m_line_recent_last, m_line_record, m_line_start_idx, m_missing_trailing_newline, m_nb_read, m_size, m_use_count, NULL, offset_buffer(), read_data(), and file_cache::input_context::should_skip_bom.
|
inline |
References DEBUG_FUNCTION, and dump().
Referenced by dump().
void file_cache_slot::dump | ( | FILE * | out, |
int | indent ) const |
References m_file_path, m_fp, m_line_num, m_line_record, m_line_start_idx, m_missing_trailing_newline, m_nb_read, m_size, m_use_count, needs_grow_p(), and needs_read_p().
void file_cache_slot::evict | ( | ) |
References m_error, m_file_path, m_fp, m_line_num, m_line_recent_first, m_line_recent_last, m_line_record, m_line_start_idx, m_missing_trailing_newline, m_nb_read, m_use_count, and NULL.
|
inline |
References m_file_path.
Referenced by file_cache::evicted_cache_tab_entry(), and file_cache::lookup_file().
char_span file_cache_slot::get_full_file_content | ( | ) |
Get a borrowed char_span to the full content of this file as decoded according to the input charset, encoded as UTF-8.
References get_next_line(), m_data, and m_nb_read.
Referenced by file_cache::get_source_file_content().
|
private |
Read a new line from file FP, using C as a cache for the data coming from the file. Upon successful completion, *LINE is set to the beginning of the line found. *LINE points directly in the line cache and is only valid until the next call of get_next_line. *LINE_LEN is set to the length of the line. Note that the line does not contain any terminal delimiter. This function returns true if some data was read or process from the cache, false otherwise. Note that subsequent calls to get_next_line might make the content of *LINE invalid.
References find_end_of_line(), gcc_assert, i, line_record_size, line_start(), m_data, m_error, m_line_num, m_line_recent, m_line_recent_first, m_line_recent_last, m_line_record, m_line_start_idx, m_missing_trailing_newline, m_nb_read, maybe_read_data(), NULL, and recent_cached_lines_shift.
Referenced by get_full_file_content(), goto_next_line(), and read_line_num().
|
inline |
References m_use_count.
Referenced by file_cache::evicted_cache_tab_entry().
|
private |
Consume the next bytes coming from the cache (or from its underlying file if there are remaining unread bytes in the file) until we reach the next end-of-line (or end-of-file). There is no copying from the cache involved. Return TRUE upon successful completion.
References get_next_line().
Referenced by read_line_num().
|
inline |
References m_use_count.
Referenced by file_cache::lookup_file().
|
private |
Grow the cache if it needs to be extended.
References buffer_size, gcc_assert, m_alloc_offset, m_data, m_size, needs_grow_p(), and offset_buffer().
Referenced by read_data().
|
private |
Read new data iff the cache needs to be filled with more data coming from the file FP. Return TRUE iff the cache was filled with mode data.
References needs_read_p(), and read_data().
Referenced by get_next_line().
|
inline |
References m_missing_trailing_newline.
|
private |
Return TRUE iff the cache is full and thus needs to be extended.
References m_nb_read, and m_size.
Referenced by dump(), and maybe_grow().
|
private |
Returns TRUE iff the cache would need to be filled with data coming from the file. That is, either the cache is empty or full or the current line is empty. Note that if the cache is full, it would need to be extended and filled again.
References m_fp, m_line_start_idx, m_nb_read, and m_size.
Referenced by dump(), and maybe_read_data().
|
inlineprivate |
References gcc_assert, m_alloc_offset, m_data, and m_size.
Referenced by create(), maybe_grow(), and ~file_cache_slot().
|
private |
Read more data into the cache. Extends the cache if need be. Returns TRUE iff new data could be read.
References m_data, m_error, m_fp, m_nb_read, m_size, and maybe_grow().
Referenced by create(), and maybe_read_data().
bool file_cache_slot::read_line_num | ( | size_t | line_num, |
char ** | line, | ||
ssize_t * | line_len ) |
Read an arbitrary line number LINE_NUM from the file cached in C. If the line was read successfully, *LINE points to the beginning of the line in the file cache and *LINE_LEN is the length of the line. *LINE is not nul-terminated, but may contain zero bytes. *LINE is only valid until the next call of read_line_num. This function returns bool if a line was read.
References file_cache_slot::line_info::end_pos, gcc_assert, get_next_line(), goto_next_line(), i, last, file_cache_slot::line_info::less_than(), file_cache_slot::line_info::line_num, m_data, m_line_num, m_line_recent, m_line_recent_first, m_line_recent_last, m_line_record, m_line_start_idx, recent_cached_lines_shift, and file_cache_slot::line_info::start_pos.
Referenced by file_cache::get_source_line().
|
private |
void file_cache_slot::set_content | ( | const char * | buf, |
size_t | sz ) |
References m_alloc_offset, m_data, m_fp, m_nb_read, and m_size.
|
inlinestatic |
References line_record_size.
Referenced by file_cache::tune().
|
staticprivate |
Referenced by maybe_grow().
|
staticprivate |
Referenced by get_next_line(), and tune().
|
private |
Referenced by create(), file_cache_slot(), maybe_grow(), offset_buffer(), set_content(), and ~file_cache_slot().
|
private |
Referenced by create(), file_cache_slot(), get_full_file_content(), get_next_line(), maybe_grow(), offset_buffer(), read_data(), read_line_num(), set_content(), and ~file_cache_slot().
|
private |
Referenced by create(), evict(), file_cache_slot(), get_next_line(), and read_data().
|
private |
Referenced by create(), dump(), evict(), file_cache_slot(), and get_file_path().
|
private |
Referenced by create(), dump(), evict(), file_cache_slot(), needs_read_p(), read_data(), set_content(), and ~file_cache_slot().
|
private |
Referenced by create(), dump(), evict(), file_cache_slot(), get_next_line(), and read_line_num().
Referenced by file_cache_slot(), get_next_line(), read_line_num(), and ~file_cache_slot().
|
private |
Referenced by create(), evict(), file_cache_slot(), get_next_line(), and read_line_num().
|
private |
Referenced by create(), evict(), file_cache_slot(), get_next_line(), and read_line_num().
Referenced by create(), dump(), evict(), file_cache_slot(), get_next_line(), read_line_num(), and ~file_cache_slot().
|
private |
Referenced by create(), dump(), evict(), file_cache_slot(), get_next_line(), needs_read_p(), and read_line_num().
|
private |
Referenced by create(), dump(), evict(), file_cache_slot(), get_next_line(), and missing_trailing_newline_p().
|
private |
Referenced by create(), dump(), evict(), file_cache_slot(), get_full_file_content(), get_next_line(), needs_grow_p(), needs_read_p(), read_data(), and set_content().
|
private |
Referenced by create(), dump(), file_cache_slot(), maybe_grow(), needs_grow_p(), needs_read_p(), offset_buffer(), read_data(), and set_content().
|
private |
Referenced by create(), dump(), evict(), file_cache_slot(), get_use_count(), and inc_use_count().
|
staticprivate |
Referenced by file_cache_slot(), get_next_line(), and read_line_num().