+2016-05-10 David Malcolm <dmalcolm@redhat.com>
+
+ * diagnostic-show-locus.c (layout::layout): Call show_ruler
+ if show_ruler_p was set on the context.
+ (layout::show_ruler): New method.
+ * diagnostic.h (struct diagnostic_context): Add field
+ "show_ruler_p".
+
2016-05-10 Richard Biener <rguenther@suse.de>
PR tree-optimization/71039
void print_annotation_line (int row, const line_bounds lbounds);
void print_any_fixits (int row, const rich_location *richloc);
+ void show_ruler (int max_column) const;
+
private:
void calculate_line_spans ();
m_x_offset = column - right_margin;
gcc_assert (m_x_offset >= 0);
}
+
+ if (context->show_ruler_p)
+ show_ruler (m_x_offset + max_width);
}
/* Return true iff we should print a heading when starting the
}
}
+/* For debugging layout issues, render a ruler giving column numbers
+ (after the 1-column indent). */
+
+void
+layout::show_ruler (int max_column) const
+{
+ /* Hundreds. */
+ if (max_column > 99)
+ {
+ pp_space (m_pp);
+ for (int column = 1 + m_x_offset; column <= max_column; column++)
+ if (0 == column % 10)
+ pp_character (m_pp, '0' + (column / 100) % 10);
+ else
+ pp_space (m_pp);
+ pp_newline (m_pp);
+ }
+
+ /* Tens. */
+ pp_space (m_pp);
+ for (int column = 1 + m_x_offset; column <= max_column; column++)
+ if (0 == column % 10)
+ pp_character (m_pp, '0' + (column / 10) % 10);
+ else
+ pp_space (m_pp);
+ pp_newline (m_pp);
+
+ /* Units. */
+ pp_space (m_pp);
+ for (int column = 1 + m_x_offset; column <= max_column; column++)
+ pp_character (m_pp, '0' + (column % 10));
+ pp_newline (m_pp);
+}
+
} /* End of anonymous namespace. */
/* Print the physical source code corresponding to the location of
source code (to avoid e.g. colorizing just the first character in
a token, which would look strange). */
bool colorize_source_p;
+
+ /* Usable by plugins; if true, print a debugging ruler above the
+ source output. */
+ bool show_ruler_p;
};
static inline void
+2016-05-10 David Malcolm <dmalcolm@redhat.com>
+
+ * gcc.dg/plugin/diagnostic-test-show-locus-bw.c
+ (test_very_wide_line): Add ruler to expected output.
+ * gcc.dg/plugin/diagnostic-test-show-locus-color.c
+ (test_very_wide_line): Likewise.
+ * gcc.dg/plugin/diagnostic_plugin_test_show_locus.c
+ (test_show_locus): Within the handling of "test_very_wide_line",
+ enable show_ruler_p on the diagnostic context.
+
2016-05-10 Richard Biener <rguenther@suse.de>
PR tree-optimization/71039
#if 0
float f = foo * bar; /* { dg-warning "95: test" } */
/* { dg-begin-multiline-output "" }
+ 0 0 0 0 0 0 1
+ 4 5 6 7 8 9 0
+ 6789012345678901234567890123456789012345678901234567890123456789012345
float f = foo * bar;
~~~~^~~~~
{ dg-end-multiline-output "" } */
#if 0
float f = foo * bar; /* { dg-warning "95: test" } */
/* { dg-begin-multiline-output "" }
+ 0 0 0 0 0 0 1
+ 4 5 6 7 8 9 0
+ 6789012345678901234567890123456789012345678901234567890123456789012345
float f = \e[01;35m\e[Kfoo * bar\e[m\e[K;
\e[01;35m\e[K~~~~^~~~~\e[m\e[K
{ dg-end-multiline-output "" } */
if (0 == strcmp (fnname, "test_very_wide_line"))
{
const int line = fnstart_line + 2;
+ global_dc->show_ruler_p = true;
warning_at (make_location (get_loc (line, 94), get_loc (line, 90),
get_loc (line, 98)),
0, "test");
+ global_dc->show_ruler_p = false;
}
/* Example of multiple carets. */