+2018-09-17 David Malcolm <dmalcolm@redhat.com>
+
+ * diagnostic-show-locus.c (class layout_range): Add field
+ "m_original_idx".
+ (layout_range::layout_range): Add "original_idx" param and use it
+ to initialize new field.
+ (make_range): Use 0 for original_idx.
+ (layout::layout): Pass in index to calls to
+ maybe_add_location_range.
+ (layout::maybe_add_location_range): Add param "original_idx" and
+ pass it on to layout_range.
+ (layout::print_any_labels): Pass on range->m_original_idx to
+ get_text call.
+ (gcc_rich_location::add_location_if_nearby): Use 0 for
+ original_idx.
+ * gcc-rich-location.h (text_range_label::get_text): Update for new
+ param.
+ (range_label_for_type_mismatch::get_text): Likewise.
+
2018-09-17 Uros Bizjak <ubizjak@gmail.com>
* config/i386/i386.c (ix86_emit_i387_log1p): Emit fldln2 earlier.
const expanded_location *finish_exploc,
enum range_display_kind range_display_kind,
const expanded_location *caret_exploc,
+ unsigned original_idx,
const range_label *label);
bool contains_point (linenum_type row, int column) const;
layout_point m_finish;
enum range_display_kind m_range_display_kind;
layout_point m_caret;
+ unsigned m_original_idx;
const range_label *m_label;
};
diagnostic_t diagnostic_kind);
bool maybe_add_location_range (const location_range *loc_range,
+ unsigned original_idx,
bool restrict_to_current_line_spans);
int get_num_line_spans () const { return m_line_spans.length (); }
const expanded_location *finish_exploc,
enum range_display_kind range_display_kind,
const expanded_location *caret_exploc,
+ unsigned original_idx,
const range_label *label)
: m_start (*start_exploc),
m_finish (*finish_exploc),
m_range_display_kind (range_display_kind),
m_caret (*caret_exploc),
+ m_original_idx (original_idx),
m_label (label)
{
}
const expanded_location finish_exploc
= {"test.c", end_line, end_col, NULL, false};
return layout_range (&start_exploc, &finish_exploc, SHOW_RANGE_WITHOUT_CARET,
- &start_exploc, NULL);
+ &start_exploc, 0, NULL);
}
/* Selftests for layout_range::contains_point and
/* This diagnostic printer can only cope with "sufficiently sane" ranges.
Ignore any ranges that are awkward to handle. */
const location_range *loc_range = richloc->get_range (idx);
- maybe_add_location_range (loc_range, false);
+ maybe_add_location_range (loc_range, idx, false);
}
/* Populate m_fixit_hints, filtering to only those that are in the
/* Attempt to add LOC_RANGE to m_layout_ranges, filtering them to
those that we can sanely print.
+ ORIGINAL_IDX is the index of LOC_RANGE within its rich_location,
+ (for use as extrinsic state by label ranges FIXME).
+
If RESTRICT_TO_CURRENT_LINE_SPANS is true, then LOC_RANGE is also
filtered against this layout instance's current line spans: it
will only be added if the location is fully within the lines
bool
layout::maybe_add_location_range (const location_range *loc_range,
+ unsigned original_idx,
bool restrict_to_current_line_spans)
{
gcc_assert (loc_range);
/* Everything is now known to be in the correct source file,
but it may require further sanitization. */
layout_range ri (&start, &finish, loc_range->m_range_display_kind, &caret,
- loc_range->m_label);
+ original_idx, loc_range->m_label);
/* If we have a range that finishes before it starts (perhaps
from something built via macro expansion), printing the
continue;
label_text text;
- text = range->m_label->get_text ();
+ text = range->m_label->get_text (range->m_original_idx);
/* Allow for labels that return NULL from their get_text
implementation (so e.g. such labels can control their own
location_range loc_range;
loc_range.m_loc = loc;
loc_range.m_range_display_kind = SHOW_RANGE_WITHOUT_CARET;
- if (!layout.maybe_add_location_range (&loc_range, true))
+ if (!layout.maybe_add_location_range (&loc_range, 0, true))
return false;
add_range (loc);