summaryrefslogtreecommitdiff
path: root/gcc/gcc-rich-location.c
diff options
context:
space:
mode:
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2016-03-09 18:14:43 +0000
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2016-03-09 18:14:43 +0000
commit83108969e7ecc8af296a569efd678de116b1519f (patch)
treeba81cb8d930007773d9d7556e938bf62e095d82e /gcc/gcc-rich-location.c
parent6733c0e8ca30d4b4fee867f3209617927f9d8c58 (diff)
downloadgcc-83108969e7ecc8af296a569efd678de116b1519f.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@234087 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gcc-rich-location.c')
-rw-r--r--gcc/gcc-rich-location.c28
1 files changed, 2 insertions, 26 deletions
diff --git a/gcc/gcc-rich-location.c b/gcc/gcc-rich-location.c
index 9ab4314a875..a03ce0ee5fa 100644
--- a/gcc/gcc-rich-location.c
+++ b/gcc/gcc-rich-location.c
@@ -41,28 +41,6 @@ along with GCC; see the file COPYING3. If not see
#include "cpplib.h"
#include "diagnostic.h"
-/* Extract any source range information from EXPR and write it
- to *R. */
-
-static bool
-get_range_for_expr (tree expr, location_range *r)
-{
- if (EXPR_HAS_RANGE (expr))
- {
- source_range sr = EXPR_LOCATION_RANGE (expr);
-
- /* Do we have meaningful data? */
- if (sr.m_start && sr.m_finish)
- {
- r->m_start = expand_location (sr.m_start);
- r->m_finish = expand_location (sr.m_finish);
- return true;
- }
- }
-
- return false;
-}
-
/* Add a range to the rich_location, covering expression EXPR. */
void
@@ -70,10 +48,8 @@ gcc_rich_location::add_expr (tree expr)
{
gcc_assert (expr);
- location_range r;
- r.m_show_caret_p = false;
- if (get_range_for_expr (expr, &r))
- add_range (&r);
+ if (CAN_HAVE_RANGE_P (expr))
+ add_range (EXPR_LOCATION (expr), false);
}
/* If T is an expression, add a range for it to the rich_location. */