GCC Middle and Back End API Reference
|
Public Member Functions | |
edited_line (file_cache &fc, const char *filename, int line_num) | |
~edited_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 (edited_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 edited_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 edited_line. Hence it's possible for an "edited_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.
edited_line::edited_line | ( | file_cache & | fc, |
const char * | filename, | ||
int | line_num ) |
Implementation of class edited_line.
edited_line's ctor.
References ensure_capacity(), ensure_terminated(), char_span::get_buffer(), file_cache::get_source_line(), char_span::length(), m_content, and m_len.
edited_line::~edited_line | ( | ) |
edited_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 edited_file::print_run_of_changed_lines().
bool edited_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 edited_line *, for use as a delete_value_fn for edited_file::m_edited_lines.
|
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 edited_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 edited_line().
|
inline |
References m_content.
int edited_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, line_event::get_effective_column(), i, and m_line_events.
Referenced by apply_fixit().
int edited_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 edited_file::print_diff().
void edited_line::print_content | ( | pretty_printer * | pp | ) | const |
Subroutine of edited_file::print_content. Print this line and any new lines added before it, to PP.
References FOR_EACH_VEC_ELT, added_line::get_content(), i, m_content, m_predecessors, pp_newline(), and pp_string().
void edited_line::print_diff_lines | ( | pretty_printer * | pp | ) | const |
Subroutine of edited_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 edited_line was actually edited, the '-' line has already been printed. If it wasn't, then we merely have a placeholder edited_line for adding newlines to, and we need to print a ' ' line for the edited_line as we haven't printed it yet.
References actually_edited_p(), FOR_EACH_VEC_ELT, added_line::get_content(), added_line::get_len(), i, m_content, m_len, m_predecessors, and print_diff_line().
Referenced by edited_file::print_run_of_changed_lines().
|
private |
Referenced by ensure_capacity(), and ensure_terminated().
|
private |
Referenced by apply_fixit(), edited_line(), ensure_capacity(), ensure_terminated(), get_content(), print_content(), print_diff_lines(), and ~edited_line().
|
private |
Referenced by apply_fixit(), edited_line(), ensure_terminated(), get_len(), and print_diff_lines().
|
private |
Referenced by actually_edited_p(), apply_fixit(), and get_effective_column().
|
private |
Referenced by get_line_num().
|
private |
Referenced by apply_fixit(), get_effective_line_count(), print_content(), print_diff_lines(), and ~edited_line().