aboutsummaryrefslogtreecommitdiff
path: root/libcpp/include/line-map.h
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2016-03-09 18:14:43 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2016-03-09 18:14:43 +0000
commit40499f81a6a65d903a8b6469797c58c52eaf8008 (patch)
treeba81cb8d930007773d9d7556e938bf62e095d82e /libcpp/include/line-map.h
parentc9e336624a5f3d3845b9b4a070f29d074418bd73 (diff)
downloadgcc-40499f81a6a65d903a8b6469797c58c52eaf8008.zip
gcc-40499f81a6a65d903a8b6469797c58c52eaf8008.tar.gz
gcc-40499f81a6a65d903a8b6469797c58c52eaf8008.tar.bz2
PR c++/70105: Defer location expansion until diagnostic_show_locus
gcc/ChangeLog: PR c/68473 PR c++/70105 * diagnostic-show-locus.c (layout_range::layout_range): Replace location_range param with three const expanded_locations * and a bool. (layout::layout): Replace call to rich_location::lazily_expand_location with get_expanded_location. Extract the range and perform location expansion here, passing the results to the layout_range ctor. * diagnostic.c (source_range::debug): Delete. * diagnostic.h (diagnostic_expand_location): Reimplement in terms of rich_location::get_expanded_location. * gcc-rich-location.c (get_range_for_expr): Delete. (gcc_rich_location::add_expr): Reimplement to avoid the rich_location::add_range overload that took a location_range, passing a location_t instead. gcc/testsuite/ChangeLog: PR c/68473 PR c++/70105 * gcc.dg/plugin/diagnostic_plugin_show_trees.c (show_tree): Drop range information from call to inform_at_rich_loc. * gcc.dg/plugin/diagnostic_plugin_test_show_locus.c (add_range): New. (test_show_locus): Replace calls to rich_location::add_range with calls to add_range. Rewrite the tests that used the now-defunct rich_location ctor taking a source_range. Simplify other tests by replacing calls to COMBINE_LOCATION_DATA with calls to make_location. libcpp/ChangeLog: PR c/68473 PR c++/70105 * include/line-map.h (source_range::debug): Delete. (struct location_range): Update comment. Replace expanded_location fields "m_start", "m_finish", and "m_caret" with a source_location field: "m_loc". (class rich_location): Reword comment. (rich_location::get_loc): Reimplement in terms of a new overloaded variant which takes an unsigned int. (rich_location::get_loc_addr): Delete. (rich_location::add_range): Drop params "start" and "finish" in favor of param "loc". Drop overloaded variants taking a source_range or location_range *. (rich_location::lazily_expand_location): Delete in favor of... (rich_location::get_expanded_location): New decl. (rich_location::m_loc): Delete field. (rich_location::m_column_override): New field. * line-map.c (rich_location::rich_location): Drop name of line_maps * param. Update initializations for deletion of field "m_loc" and addition of field "m_column_override". Reimplement body as a call to add_range. Delete overloaded variant taking a source_range. (rich_location::get_loc): New function. (rich_location::lazily_expand_location): Delete in favor of... (rich_location::get_expanded_location): New function. (rich_location::override_column): Reimplement. (rich_location::add_range): Drop params "start" and "finish" in favor of param "loc". Eliminate location expansion in favor of simply storing loc. Drop overloaded variants taking a source_range or location_range *. (rich_location::set_range): Eliminate location expansion. From-SVN: r234087
Diffstat (limited to 'libcpp/include/line-map.h')
-rw-r--r--libcpp/include/line-map.h51
1 files changed, 14 insertions, 37 deletions
diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h
index 6e858a6..13cc6f8 100644
--- a/libcpp/include/line-map.h
+++ b/libcpp/include/line-map.h
@@ -273,20 +273,6 @@ struct GTY(()) source_range
source_location m_start;
source_location m_finish;
- /* Display this source_range instance, with MSG as a descriptive
- comment. This issues a "note" diagnostic at the range, using
- gcc's diagnostic machinery.
-
- This is declared here, but is implemented within gcc/diagnostic.c,
- since it makes use of gcc's diagnostic-printing machinery. This
- is a slight layering violation, but this is sufficiently useful
- for debugging that it's worth it.
-
- This declaration would have a DEBUG_FUNCTION annotation, but that
- is implemented in gcc/system.h and thus is not available here in
- libcpp. */
- void debug (const char *msg) const;
-
/* We avoid using constructors, since various structs that
don't yet have constructors will embed instances of
source_range. */
@@ -1249,13 +1235,12 @@ typedef struct
i.e. "3:1:" in GCC corresponds to "(3, 0)" in Emacs. */
-/* Ranges are closed
- m_start is the first location within the range, and
- m_finish is the last location within the range. */
+/* A location within a rich_location: a caret&range, with
+ the caret potentially flagged for display. */
+
struct location_range
{
- expanded_location m_start;
- expanded_location m_finish;
+ source_location m_loc;
/* Should a caret be drawn for this range? Typically this is
true for the 0th range, and false for subsequent ranges,
@@ -1267,7 +1252,6 @@ struct location_range
where "1" and "2" are notionally carets. */
bool m_show_caret_p;
- expanded_location m_caret;
};
class fixit_hint;
@@ -1276,9 +1260,10 @@ class fixit_hint;
class fixit_replace;
/* A "rich" source code location, for use when printing diagnostics.
- A rich_location has one or more ranges, each optionally with
- a caret. Typically the zeroth range has a caret; other ranges
- sometimes have carets.
+ A rich_location has one or more carets&ranges, where the carets
+ are optional. These are referred to as "ranges" from here.
+ Typically the zeroth range has a caret; other ranges sometimes
+ have carets.
The "primary" location of a rich_location is the caret of range 0,
used for determining the line/column when printing diagnostic
@@ -1361,19 +1346,11 @@ class rich_location
~rich_location ();
/* Accessors. */
- source_location get_loc () const { return m_loc; }
-
- source_location *get_loc_addr () { return &m_loc; }
-
- void
- add_range (source_location start, source_location finish,
- bool show_caret_p);
-
- void
- add_range (source_range src_range, bool show_caret_p);
+ source_location get_loc () const { return get_loc (0); }
+ source_location get_loc (unsigned int idx) const;
void
- add_range (location_range *src_range);
+ add_range (source_location loc, bool show_caret_p);
void
set_range (line_maps *set, unsigned int idx, source_location loc,
@@ -1387,7 +1364,7 @@ class rich_location
return &m_ranges[idx];
}
- expanded_location lazily_expand_location ();
+ expanded_location get_expanded_location (unsigned int idx);
void
override_column (int column);
@@ -1412,11 +1389,11 @@ public:
static const int MAX_FIXIT_HINTS = 2;
protected:
- source_location m_loc;
-
unsigned int m_num_ranges;
location_range m_ranges[MAX_RANGES];
+ int m_column_override;
+
bool m_have_expanded_location;
expanded_location m_expanded_location;