GCC Middle and Back End API Reference
|
Public Member Functions | |
changed_line (file_cache &fc, const char *filename, int line_num) | |
~changed_line () | |
int | get_line_num () const |
const char * | get_content () const |
int | get_len () const |
int | get_effective_column (int orig_column) const |
bool | apply_fixit (int start_column, int next_column, const char *replacement_str, int replacement_len) |
int | get_effective_line_count () const |
bool | actually_edited_p () const |
void | print_content (pretty_printer *pp) const |
void | print_diff_lines (pretty_printer *pp) const |
Static Public Member Functions | |
static void | delete_cb (changed_line *el) |
Private Member Functions | |
void | ensure_capacity (int len) |
void | ensure_terminated () |
Private Attributes | |
int | m_line_num |
char * | m_content |
int | m_len |
int | m_alloc_sz |
auto_vec< line_event > | m_line_events |
auto_vec< added_line * > | m_predecessors |
The state of one edited line within an changed_file. As well as the current content of the line, it contains a record of the changes, so that further changes can be applied in the correct place. When handling fix-it hints containing newlines, new lines are added as added_line predecessors to an changed_line. Hence it's possible for an "changed_line" to not actually have been changed, but to merely be a placeholder for the lines added before it. This can be tested for with actuall_edited_p, and has a slight effect on how diff hunks are generated.
diagnostics::changes::changed_line::changed_line | ( | file_cache & | fc, |
const char * | filename, | ||
int | line_num ) |
Implementation of class changed_line.
changed_line's ctor.
References ensure_capacity(), ensure_terminated(), diagnostics::char_span::get_buffer(), diagnostics::file_cache::get_source_line(), diagnostics::char_span::length(), m_alloc_sz, m_content, m_len, m_line_events, m_line_num, m_predecessors, and NULL.
Referenced by delete_cb().
diagnostics::changes::changed_line::~changed_line | ( | ) |
changed_line's dtor.
References FOR_EACH_VEC_ELT, free(), i, m_content, and m_predecessors.
|
inline |
References m_line_events.
Referenced by print_diff_lines(), and diagnostics::changes::changed_file::print_run_of_changed_lines().
bool diagnostics::changes::changed_line::apply_fixit | ( | int | start_column, |
int | next_column, | ||
const char * | replacement_str, | ||
int | replacement_len ) |
Attempt to replace columns START_COLUMN up to but not including NEXT_COLUMN of the line with the string REPLACEMENT_STR of length REPLACEMENT_LEN, updating the in-memory copy of the line, and the record of edits to the line. Return true if successful; false if an error occurred.
References ensure_capacity(), ensure_terminated(), gcc_assert, get_effective_column(), m_content, m_len, m_line_events, and m_predecessors.
|
static |
A callback for deleting changed_line *, for use as a delete_value_fn for changed_file::m_changed_lines.
References changed_line().
|
private |
Ensure that the buffer for m_content is at least large enough to hold a string of length LEN and its 0-terminator, doubling on repeated allocations.
References m_alloc_sz, and m_content.
Referenced by apply_fixit(), and changed_line().
|
private |
Ensure that m_content is 0-terminated.
References gcc_assert, m_alloc_sz, m_content, and m_len.
Referenced by apply_fixit(), and changed_line().
|
inline |
References m_content.
int diagnostics::changes::changed_line::get_effective_column | ( | int | orig_column | ) | const |
Map a location before the edits to a column number after the edits, within a specific line.
References FOR_EACH_VEC_ELT, diagnostics::changes::line_event::get_effective_column(), i, and m_line_events.
Referenced by apply_fixit().
int diagnostics::changes::changed_line::get_effective_line_count | ( | ) | const |
Determine the number of lines that will be present after editing for this line. Typically this is just 1, but if newlines have been added before this line, they will also be counted.
References m_predecessors.
|
inline |
References m_len.
|
inline |
References m_line_num.
Referenced by diagnostics::changes::changed_file::print_diff().
void diagnostics::changes::changed_line::print_content | ( | pretty_printer * | pp | ) | const |
Subroutine of changed_file::print_content. Print this line and any new lines added before it, to PP.
References FOR_EACH_VEC_ELT, diagnostics::changes::added_line::get_content(), i, m_content, m_predecessors, pp_newline(), and pp_string().
void diagnostics::changes::changed_line::print_diff_lines | ( | pretty_printer * | pp | ) | const |
Subroutine of changed_file::print_run_of_changed_lines for printing diff hunks to PP. Print the '+' line for this line, and any newlines added before it. Note that if this changed_line was actually edited, the '-' line has already been printed. If it wasn't, then we merely have a placeholder changed_line for adding newlines to, and we need to print a ' ' line for the changed_line as we haven't printed it yet.
References actually_edited_p(), FOR_EACH_VEC_ELT, diagnostics::changes::added_line::get_content(), diagnostics::changes::added_line::get_len(), i, m_content, m_len, m_predecessors, and diagnostics::changes::print_diff_line().
Referenced by diagnostics::changes::changed_file::print_run_of_changed_lines().
|
private |
Referenced by changed_line(), ensure_capacity(), and ensure_terminated().
|
private |
Referenced by apply_fixit(), changed_line(), ensure_capacity(), ensure_terminated(), get_content(), print_content(), print_diff_lines(), and ~changed_line().
|
private |
Referenced by apply_fixit(), changed_line(), ensure_terminated(), get_len(), and print_diff_lines().
|
private |
Referenced by actually_edited_p(), apply_fixit(), changed_line(), and get_effective_column().
|
private |
Referenced by changed_line(), and get_line_num().
|
private |
Referenced by apply_fixit(), changed_line(), get_effective_line_count(), print_content(), print_diff_lines(), and ~changed_line().