aboutsummaryrefslogtreecommitdiff
path: root/libcpp/line-map.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libcpp/line-map.cc')
-rw-r--r--libcpp/line-map.cc29
1 files changed, 22 insertions, 7 deletions
diff --git a/libcpp/line-map.cc b/libcpp/line-map.cc
index d5200b3..41aee98 100644
--- a/libcpp/line-map.cc
+++ b/libcpp/line-map.cc
@@ -2160,8 +2160,9 @@ line_table_dump (FILE *stream, const line_maps *set, unsigned int num_ordinary,
/* Construct a rich_location with location LOC as its initial range. */
rich_location::rich_location (line_maps *set, location_t loc,
- const range_label *label) :
- m_line_table (set),
+ const range_label *label,
+ const char *label_highlight_color)
+: m_line_table (set),
m_ranges (),
m_column_override (0),
m_have_expanded_location (false),
@@ -2171,7 +2172,7 @@ rich_location::rich_location (line_maps *set, location_t loc,
m_fixit_hints (),
m_path (NULL)
{
- add_range (loc, SHOW_RANGE_WITH_CARET, label);
+ add_range (loc, SHOW_RANGE_WITH_CARET, label, label_highlight_color);
}
/* The destructor for class rich_location. */
@@ -2244,22 +2245,34 @@ rich_location::override_column (int column)
m_have_expanded_location = false;
}
+/* Set (or clear) the highlight color of the primary location. */
+
+void
+rich_location::set_highlight_color (const char *highlight_color)
+{
+ location_range *locrange = get_range (0);
+ locrange->m_highlight_color = highlight_color;
+}
+
/* Add the given range. */
void
rich_location::add_range (location_t loc,
enum range_display_kind range_display_kind,
- const range_label *label)
+ const range_label *label,
+ const char *label_highlight_color)
{
location_range range;
range.m_loc = loc;
range.m_range_display_kind = range_display_kind;
range.m_label = label;
+ range.m_highlight_color = label_highlight_color;
m_ranges.push (range);
}
/* Add or overwrite the location given by IDX, setting its location to LOC,
- and setting its m_range_display_kind to RANGE_DISPLAY_KIND.
+ setting its m_range_display_kind to RANGE_DISPLAY_KIND, and setting
+ its m_highlight_color to HIGHLIGHT_COLOR (which may be nullptr).
It must either overwrite an existing location, or add one *exactly* on
the end of the array.
@@ -2273,19 +2286,21 @@ rich_location::add_range (location_t loc,
void
rich_location::set_range (unsigned int idx, location_t loc,
- enum range_display_kind range_display_kind)
+ enum range_display_kind range_display_kind,
+ const char *highlight_color)
{
/* We can either overwrite an existing range, or add one exactly
on the end of the array. */
linemap_assert (idx <= m_ranges.count ());
if (idx == m_ranges.count ())
- add_range (loc, range_display_kind);
+ add_range (loc, range_display_kind, nullptr, highlight_color);
else
{
location_range *locrange = get_range (idx);
locrange->m_loc = loc;
locrange->m_range_display_kind = range_display_kind;
+ locrange->m_highlight_color = highlight_color;
}
if (idx == 0)