public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: Bernd Schmidt <bschmidt@redhat.com>
Cc: gcc-patches@gcc.gnu.org, David Malcolm <dmalcolm@redhat.com>
Subject: [PATCH 2/3] Fix range/location terminology
Date: Fri, 11 Dec 2015 18:25:00 -0000	[thread overview]
Message-ID: <1449859503-7614-3-git-send-email-dmalcolm@redhat.com> (raw)
In-Reply-To: <1449859503-7614-1-git-send-email-dmalcolm@redhat.com>

The terminology within rich_location has become muddled, and
with the simplifications of the previous patch, I'd like to
rename things to better reflect what's going on.

A rich_location can contain one more more nested locations, each
of which can have a start, a finish, and optionally a caret.
These nested locations are essentially a location_t plus a flag,
but for historical reasons the current code confusingly refers to
them as "ranges".

This patch consolidates the terminology throughout rich_location
and diagnostic_show_locus; I believe it's a significant
clarification.

"struct location_range" becomes "struct nested_location"
Various "range" within rich_location become "location" e.g.
"add_range" becomes "add_location".

I didn't rename class layout_range within diagnostic-show-locus.c
as this is relatively localized, and I can't think of a better name
for it.

gcc/c-family/ChangeLog:
	* c-common.c (c_cpp_error): Update for renaming of
	rich_location::set_range to set_location.

gcc/ChangeLog:
	* diagnostic-show-locus.c (class layout_range): Update
	for "range" to "location" renamings.
	(layout::layout): Likewise, updating wording of comments.
	* diagnostic.c (diagnostic_initialize): Likewise.
	* diagnostic.h (struct diagnostic_context): Likewise.
	* gcc-rich-location.c (gcc_rich_location::add_expr): Likewise.
	(gcc_rich_location::maybe_add_expr): Likewise.
	* pretty-print.c (text_info::set_location): Likewise.

gcc/testsuite/ChangeLog:
	* gcc.dg/plugin/diagnostic_plugin_show_trees.c
	(gcc_rich_location::add_expr): Update for "range" to "location"
	renamings.
	(show_tree): Drop redundant local "range".
	* gcc.dg/plugin/diagnostic_plugin_test_show_locus.c (add_range):
	Rename to...
	(add_location): ...this.  Update for corresponding renaming of
	rich_location method.
	(test_show_locus): Update for renamings.

libcpp/ChangeLog:
	* include/line-map.h (struct location_range): Rename to...
	(struct nested_location): ...this, and update wording of comment.
	(class rich_location): Update comment.
	(rich_location::add_range): Rename to...
	(rich_location::add_location): ...this.
	(rich_location::set_range): Rename to...
	(rich_location::set_location): ...this.
	(rich_location::get_num_locations): Update for renamings.
	(rich_location::get_range): Rename to...
	(rich_location::get_location): ...this.
	(rich_location::MAX_RANGES): Rename to...
	(rich_location::MAX_LOCATIONS): ...this.
	(rich_location::m_num_ranges): Rename to...
	(rich_location::m_num_locations): ...this.
	(rich_location::m_locations): Update for renaming of
	location_range to nested_location.
	* line-map.c (rich_location::rich_location): Update for renamings.
	(rich_location::get_loc): Update for renamings.
	(rich_location::get_expanded_location): Update comment.
	(rich_location::override_column): Likewise.
	(rich_location::add_range): Rename to...
	(rich_location::add_location): ...this, updating for renamings,
	and renaming local "range" to "nested_loc".
	(rich_location::set_range): Rename to...
	(rich_location::set_location): ...this, updating for renamings,
	renaming local "locrange" to "nested_loc".
---
 gcc/c-family/c-common.c                            |  2 +-
 gcc/diagnostic-show-locus.c                        | 24 ++++-----
 gcc/diagnostic.c                                   |  2 +-
 gcc/diagnostic.h                                   |  2 +-
 gcc/gcc-rich-location.c                            |  6 +--
 gcc/pretty-print.c                                 |  4 +-
 .../gcc.dg/plugin/diagnostic_plugin_show_trees.c   |  3 +-
 .../plugin/diagnostic_plugin_test_show_locus.c     | 24 ++++-----
 libcpp/include/line-map.h                          | 61 +++++++++++-----------
 libcpp/line-map.c                                  | 47 +++++++++--------
 10 files changed, 88 insertions(+), 87 deletions(-)

diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 509a0ca..ab61031 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -10161,7 +10161,7 @@ c_cpp_error (cpp_reader *pfile ATTRIBUTE_UNUSED, int level, int reason,
       gcc_unreachable ();
     }
   if (done_lexing)
-    richloc->set_range (0, input_location, true);
+    richloc->set_location (0, input_location, true);
   diagnostic_set_info_translated (&diagnostic, msg, ap,
 				  richloc, dlevel);
   diagnostic_override_option_index (&diagnostic,
diff --git a/gcc/diagnostic-show-locus.c b/gcc/diagnostic-show-locus.c
index 16004d8..f279019 100644
--- a/gcc/diagnostic-show-locus.c
+++ b/gcc/diagnostic-show-locus.c
@@ -112,7 +112,7 @@ class layout_point
   int m_column;
 };
 
-/* A class for use by "class layout" below: a filtered location_range.  */
+/* A class for use by "class layout" below: a filtered nested_location.  */
 
 class layout_range
 {
@@ -440,7 +440,7 @@ layout::layout (diagnostic_context * context,
   m_exploc (diagnostic->richloc->get_expanded_location (0)),
   m_colorizer (context, diagnostic),
   m_colorize_source_p (context->colorize_source_p),
-  m_layout_ranges (rich_location::MAX_RANGES),
+  m_layout_ranges (rich_location::MAX_LOCATIONS),
   m_first_line (m_exploc.line),
   m_last_line  (m_exploc.line),
   m_x_offset (0)
@@ -448,12 +448,12 @@ layout::layout (diagnostic_context * context,
   rich_location *richloc = diagnostic->richloc;
   for (unsigned int idx = 0; idx < richloc->get_num_locations (); idx++)
     {
-      /* 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);
+      /* This diagnostic printer can only cope with "sufficiently sane"
+	 locations. Ignore any that are awkward to handle.  */
+      const nested_location *nested_loc = richloc->get_location (idx);
 
-      /* Split the "range" into caret and range information.  */
-      source_range src_range = get_range_from_loc (line_table, loc_range->m_loc);
+      /* Split the location into caret and range information.  */
+      source_range src_range = get_range_from_loc (line_table, nested_loc->m_loc);
 
       /* Expand the various locations.  */
       expanded_location start
@@ -461,21 +461,21 @@ layout::layout (diagnostic_context * context,
       expanded_location finish
 	= linemap_client_expand_location_to_spelling_point (src_range.m_finish);
       expanded_location caret
-	= linemap_client_expand_location_to_spelling_point (loc_range->m_loc);
+	= linemap_client_expand_location_to_spelling_point (nested_loc->m_loc);
 
-      /* If any part of the range isn't in the same file as the primary
+      /* If any part of the location isn't in the same file as the primary
 	 location of this diagnostic, ignore the range.  */
       if (start.file != m_exploc.file)
 	continue;
       if (finish.file != m_exploc.file)
 	continue;
-      if (loc_range->m_show_caret_p)
+      if (nested_loc->m_show_caret_p)
 	if (caret.file != m_exploc.file)
 	  continue;
 
-      /* Passed all the tests; add the range to m_layout_ranges so that
+      /* Passed all the tests; add the location to m_layout_ranges so that
 	 it will be printed.  */
-      layout_range ri (&start, &finish, loc_range->m_show_caret_p, &caret);
+      layout_range ri (&start, &finish, nested_loc->m_show_caret_p, &caret);
       m_layout_ranges.safe_push (ri);
 
       /* Update m_first_line/m_last_line if necessary.  */
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
index b6dbc6a..d14afce 100644
--- a/gcc/diagnostic.c
+++ b/gcc/diagnostic.c
@@ -144,7 +144,7 @@ diagnostic_initialize (diagnostic_context *context, int n_opts)
     context->classify_diagnostic[i] = DK_UNSPECIFIED;
   context->show_caret = false;
   diagnostic_set_caret_max_width (context, pp_line_cutoff (context->printer));
-  for (i = 0; i < rich_location::MAX_RANGES; i++)
+  for (i = 0; i < rich_location::MAX_LOCATIONS; i++)
     context->caret_chars[i] = '^';
   context->show_option_requested = false;
   context->abort_on_error = false;
diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h
index 6794262..0e2297e 100644
--- a/gcc/diagnostic.h
+++ b/gcc/diagnostic.h
@@ -105,7 +105,7 @@ struct diagnostic_context
   int caret_max_width;
 
   /* Character used for caret diagnostics.  */
-  char caret_chars[rich_location::MAX_RANGES];
+  char caret_chars[rich_location::MAX_LOCATIONS];
 
   /* True if we should print the command line option which controls
      each diagnostic, if known.  */
diff --git a/gcc/gcc-rich-location.c b/gcc/gcc-rich-location.c
index 88bd82d..15c6376 100644
--- a/gcc/gcc-rich-location.c
+++ b/gcc/gcc-rich-location.c
@@ -41,7 +41,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "cpplib.h"
 #include "diagnostic.h"
 
-/* Add a range to the rich_location, covering expression EXPR. */
+/* Add a location to the rich_location, covering expression EXPR. */
 
 void
 gcc_rich_location::add_expr (tree expr)
@@ -49,10 +49,10 @@ gcc_rich_location::add_expr (tree expr)
   gcc_assert (expr);
 
   if (CAN_HAVE_RANGE_P (expr))
-    add_range (EXPR_LOCATION (expr), false);
+    add_location (EXPR_LOCATION (expr), false);
 }
 
-/* If T is an expression, add a range for it to the rich_location.  */
+/* If T is an expression, add a location for it to the rich_location.  */
 
 void
 gcc_rich_location::maybe_add_expr (tree t)
diff --git a/gcc/pretty-print.c b/gcc/pretty-print.c
index cd35792..d972d9b 100644
--- a/gcc/pretty-print.c
+++ b/gcc/pretty-print.c
@@ -31,14 +31,14 @@ along with GCC; see the file COPYING3.  If not see
 #include <iconv.h>
 #endif
 
-/* Overwrite the given location/range within this text_info's rich_location.
+/* Overwrite the given location within this text_info's rich_location.
    For use e.g. when implementing "+" in client format decoders.  */
 
 void
 text_info::set_location (unsigned int idx, location_t loc, bool show_caret_p)
 {
   gcc_checking_assert (m_richloc);
-  m_richloc->set_range (idx, loc, show_caret_p);
+  m_richloc->set_location (idx, loc, show_caret_p);
 }
 
 location_t
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c
index 8b1d1b7..5457d01 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c
@@ -50,7 +50,7 @@ gcc_rich_location::add_expr (tree expr)
   gcc_assert (expr);
 
   if (CAN_HAVE_RANGE_P (expr))
-    add_range (EXPR_LOCATION (expr), false);
+    add_location (EXPR_LOCATION (expr), false);
 }
 
 /* FIXME: end of material taken from gcc-rich-location.c */
@@ -74,7 +74,6 @@ show_tree (tree node)
 
   enum tree_code code = TREE_CODE (node);
 
-  location_range *range = richloc.get_range (1);
   inform_at_rich_loc (&richloc, "%s", get_tree_code_name (code));
 
   /* Recurse.  */
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c
index 3f9d139..cb8b4f6 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c
@@ -143,10 +143,10 @@ custom_diagnostic_finalizer (diagnostic_context *context,
 /* Add a location to RICHLOC with caret==start at START, ranging to FINISH.  */
 
 static void
-add_range (rich_location *richloc, location_t start, location_t finish,
+add_location (rich_location *richloc, location_t start, location_t finish,
 	   bool show_caret_p)
 {
-  richloc->add_range (make_location (start, start, finish), show_caret_p);
+  richloc->add_location (make_location (start, start, finish), show_caret_p);
 }
 
 /* Exercise the diagnostic machinery to emit various warnings,
@@ -174,8 +174,8 @@ test_show_locus (function *fun)
     {
       const int line = fnstart_line + 2;
       rich_location richloc (get_loc (line, 15));
-      add_range (&richloc, get_loc (line, 10), get_loc (line, 14), false);
-      add_range (&richloc, get_loc (line, 16), get_loc (line, 16), false);
+      add_location (&richloc, get_loc (line, 10), get_loc (line, 14), false);
+      add_location (&richloc, get_loc (line, 16), get_loc (line, 16), false);
       warning_at_rich_loc (&richloc, 0, "test");
     }
 
@@ -183,8 +183,8 @@ test_show_locus (function *fun)
     {
       const int line = fnstart_line + 2;
       rich_location richloc (get_loc (line, 24));
-      add_range (&richloc, get_loc (line, 6), get_loc (line, 22), false);
-      add_range (&richloc, get_loc (line, 26), get_loc (line, 43), false);
+      add_location (&richloc, get_loc (line, 6), get_loc (line, 22), false);
+      add_location (&richloc, get_loc (line, 26), get_loc (line, 43), false);
       warning_at_rich_loc (&richloc, 0, "test");
     }
 
@@ -192,8 +192,8 @@ test_show_locus (function *fun)
     {
       const int line = fnstart_line + 2;
       rich_location richloc (get_loc (line + 1, 7));
-      add_range (&richloc, get_loc (line, 7), get_loc (line, 23), false);
-      add_range (&richloc, get_loc (line + 1, 9), get_loc (line + 1, 26),
+      add_location (&richloc, get_loc (line, 7), get_loc (line, 23), false);
+      add_location (&richloc, get_loc (line + 1, 9), get_loc (line + 1, 26),
 		 false);
       warning_at_rich_loc (&richloc, 0, "test");
     }
@@ -202,8 +202,8 @@ test_show_locus (function *fun)
     {
       const int line = fnstart_line + 2;
       rich_location richloc (get_loc (line + 5, 7));
-      add_range (&richloc, get_loc (line, 7), get_loc (line + 4, 65), false);
-      add_range (&richloc, get_loc (line + 5, 9), get_loc (line + 10, 61),
+      add_location (&richloc, get_loc (line, 7), get_loc (line + 4, 65), false);
+      add_location (&richloc, get_loc (line + 5, 9), get_loc (line + 10, 61),
 		 false);
       warning_at_rich_loc (&richloc, 0, "test");
     }
@@ -246,7 +246,7 @@ test_show_locus (function *fun)
       location_t caret_a = get_loc (line, 7);
       location_t caret_b = get_loc (line, 11);
       rich_location richloc (caret_a);
-      add_range (&richloc, caret_b, caret_b, true);
+      add_location (&richloc, caret_b, caret_b, true);
       global_dc->caret_chars[0] = 'A';
       global_dc->caret_chars[1] = 'B';
       warning_at_rich_loc (&richloc, 0, "test");
@@ -305,7 +305,7 @@ test_show_locus (function *fun)
       location_t caret_a = get_loc (line, 5);
       location_t caret_b = get_loc (line - 1, 19);
       rich_location richloc (caret_a);
-      richloc.add_range (caret_b, true);
+      richloc.add_location (caret_b, true);
       global_dc->caret_chars[0] = '1';
       global_dc->caret_chars[1] = '2';
       warning_at_rich_loc (&richloc, 0, "test");
diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h
index 0cd3c1d..498e43c 100644
--- a/libcpp/include/line-map.h
+++ b/libcpp/include/line-map.h
@@ -1238,12 +1238,12 @@ typedef struct
 /* A location within a rich_location: a caret&range, with
    the caret potentially flagged for display.  */
 
-struct location_range
+struct nested_location
 {
   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,
+  /* Should a caret be drawn for this location?  Typically this is
+     true for the 0th location, and false for subsequent locations,
      but the Fortran frontend overrides this for rendering things like:
 
        x = x + y
@@ -1260,18 +1260,19 @@ class fixit_hint;
   class fixit_replace;
 
 /* A "rich" source code location, for use when printing diagnostics.
-   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.
+   A rich_location has one or more nested_location instances within it.
+   Each nested_location has a caret and a ranges, where the carets are
+   optional.  These nested locations are referred to as "locations" from
+   here.  Typically the zeroth location has a caret; other locations
+   sometimes have carets.
 
-   The "primary" location of a rich_location is the caret of range 0,
+   The "primary" location of a rich_location is the caret of location 0,
    used for determining the line/column when printing diagnostic
    text, such as:
 
       some-file.c:3:1: error: ...etc...
 
-   Additional ranges may be added to help the user identify other
+   Additional locations may be added to help the user identify other
    pertinent clauses in a diagnostic.
 
    rich_location instances are intended to be allocated on the stack
@@ -1284,14 +1285,14 @@ class fixit_hint;
    *********
       int i = "foo";
               ^
-   This "rich" location is simply a single range (range 0), with
+   This "rich" location is simply a single location (location 0), with
    caret = start = finish at the given point.
 
    Example B
    *********
       a = (foo && bar)
           ~~~~~^~~~~~~
-   This rich location has a single range (range 0), with the caret
+   This rich location has a single location (location 0), with the caret
    at the first "&", and the start/finish at the parentheses.
    Compare with example C below.
 
@@ -1299,13 +1300,13 @@ class fixit_hint;
    *********
       a = (foo && bar)
            ~~~ ^~ ~~~
-   This rich location has three ranges:
-   - Range 0 has its caret and start location at the first "&" and
+   This rich location has three locations:
+   - Location 0 has its caret and start location at the first "&" and
      end at the second "&.
-   - Range 1 has its start and finish at the "f" and "o" of "foo";
+   - Location 1 has its start and finish at the "f" and "o" of "foo";
      the caret is not flagged for display, but is perhaps at the "f"
      of "foo".
-   - Similarly, range 2 has its start and finish at the "b" and "r" of
+   - Similarly, location 2 has its start and finish at the "b" and "r" of
      "bar"; the caret is not flagged for display, but is perhaps at the
      "b" of "bar".
    Compare with example B above.
@@ -1314,10 +1315,10 @@ class fixit_hint;
    ****************************
        x = x + y
            1   2
-   This rich location has range 0 at "1", and range 1 at "2".
-   Both are flagged for caret display.  Both ranges have start/finish
+   This rich location has location 0 at "1", and location 1 at "2".
+   Both are flagged for caret display.  Both locations have start/finish
    equal to their caret point.  The frontend overrides the diagnostic
-   context's default caret character for these ranges.
+   context's default caret character for these locations.
 
    Example E
    *********
@@ -1325,10 +1326,10 @@ class fixit_hint;
                                ^~
               100, 101, 102);
                    ~~~
-   This rich location has two ranges:
-   - range 0 is at the "%s" with start = caret = "%" and finish at
+   This rich location has two locations:
+   - location 0 is at the "%s" with start = caret = "%" and finish at
      the "s".
-   - range 1 has start/finish covering the "101" and is not flagged for
+   - location 1 has start/finish covering the "101" and is not flagged for
      caret printing; it is perhaps at the start of "101".  */
 
 class rich_location
@@ -1345,17 +1346,17 @@ class rich_location
   source_location get_loc (unsigned int idx) const;
 
   void
-  add_range (source_location loc,  bool show_caret_p);
+  add_location (source_location loc,  bool show_caret_p);
 
   void
-  set_range (unsigned int idx, source_location loc, bool show_caret_p);
+  set_location (unsigned int idx, source_location loc, bool show_caret_p);
 
-  unsigned int get_num_locations () const { return m_num_ranges; }
+  unsigned int get_num_locations () const { return m_num_locations; }
 
-  location_range *get_range (unsigned int idx)
+  const nested_location *get_location (unsigned int idx)
   {
-    linemap_assert (idx < m_num_ranges);
-    return &m_ranges[idx];
+    linemap_assert (idx < m_num_locations);
+    return &m_locations[idx];
   }
 
   expanded_location get_expanded_location (unsigned int idx);
@@ -1379,12 +1380,12 @@ class rich_location
   fixit_hint *get_fixit_hint (int idx) const { return m_fixit_hints[idx]; }
 
 public:
-  static const int MAX_RANGES = 3;
+  static const int MAX_LOCATIONS = 3;
   static const int MAX_FIXIT_HINTS = 2;
 
 protected:
-  unsigned int m_num_ranges;
-  location_range m_ranges[MAX_RANGES];
+  unsigned int m_num_locations;
+  nested_location m_locations[MAX_LOCATIONS];
 
   int m_column_override;
 
diff --git a/libcpp/line-map.c b/libcpp/line-map.c
index 6bdf841..5ca4440 100644
--- a/libcpp/line-map.c
+++ b/libcpp/line-map.c
@@ -1974,12 +1974,12 @@ source_range::intersects_line_p (const char *file, int line) const
 /* Construct a rich_location with location LOC as its initial range.  */
 
 rich_location::rich_location (source_location loc) :
-  m_num_ranges (0),
+  m_num_locations (0),
   m_column_override (0),
   m_have_expanded_location (false),
   m_num_fixit_hints (0)
 {
-  add_range (loc, true);
+  add_location (loc, true);
 }
 
 /* The destructor for class rich_location.  */
@@ -1995,11 +1995,12 @@ rich_location::~rich_location ()
 source_location
 rich_location::get_loc (unsigned int idx) const
 {
-  linemap_assert (idx < m_num_ranges);
-  return m_ranges[idx].m_loc;
+  linemap_assert (idx < m_num_locations);
+  return m_locations[idx].m_loc;
 }
 
-/* Expand location IDX within this rich_location.  */
+/* Expand location IDX within this rich_location,
+   potentially overriding the column.   */
 
 expanded_location
 rich_location::get_expanded_location (unsigned int idx)
@@ -2022,8 +2023,8 @@ rich_location::get_expanded_location (unsigned int idx)
     return linemap_client_expand_location_to_spelling_point (get_loc (idx));
 }
 
-/* Potentially set the column of the primary location, with 0 meaning
-   "don't override it".  */
+/*  Set the column of the primary location (as reported by
+    get_expanded_location) with 0 meaning "don't override it".  */
 
 void
 rich_location::override_column (int column)
@@ -2032,16 +2033,16 @@ rich_location::override_column (int column)
   m_have_expanded_location = false;
 }
 
-/* Add the given range.  */
+/* Add the given location.  */
 
 void
-rich_location::add_range (source_location loc, bool show_caret_p)
+rich_location::add_location (source_location loc, bool show_caret_p)
 {
-  linemap_assert (m_num_ranges < MAX_RANGES);
+  linemap_assert (m_num_locations < MAX_LOCATIONS);
 
-  location_range *range = &m_ranges[m_num_ranges++];
-  range->m_loc = loc;
-  range->m_show_caret_p = show_caret_p;
+  nested_location *nested_loc = &m_locations[m_num_locations++];
+  nested_loc->m_loc = loc;
+  nested_loc->m_show_caret_p = show_caret_p;
 }
 
 /* Add or overwrite the location given by IDX, setting its location to LOC,
@@ -2058,22 +2059,22 @@ rich_location::add_range (source_location loc, bool show_caret_p)
    - the "%C" and "%L" format codes in the Fortran frontend.  */
 
 void
-rich_location::set_range (unsigned int idx, source_location loc,
-			  bool show_caret_p)
+rich_location::set_location (unsigned int idx, source_location loc,
+			     bool show_caret_p)
 {
-  linemap_assert (idx < MAX_RANGES);
+  linemap_assert (idx < MAX_LOCATIONS);
 
   /* We can either overwrite an existing range, or add one exactly
      on the end of the array.  */
-  linemap_assert (idx <= m_num_ranges);
+  linemap_assert (idx <= m_num_locations);
 
-  location_range *locrange = &m_ranges[idx];
-  locrange->m_loc = loc;
-  locrange->m_show_caret_p = show_caret_p;
+  nested_location *nested_loc = &m_locations[idx];
+  nested_loc->m_loc = loc;
+  nested_loc->m_show_caret_p = show_caret_p;
 
-  /* Are we adding a range onto the end?  */
-  if (idx == m_num_ranges)
-    m_num_ranges = idx + 1;
+  /* Are we adding a location onto the end?  */
+  if (idx == m_num_locations)
+    m_num_locations = idx + 1;
 
   if (idx == 0)
     /* Mark any cached value here as dirty.  */
-- 
1.8.5.3

  parent reply	other threads:[~2015-12-11 18:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-23 17:59 [PATCH] PR c/68473: sanitize source range-printing within certain macro expansions David Malcolm
2015-11-23 18:13 ` Bernd Schmidt
2015-11-23 18:37   ` David Malcolm
2015-11-24 12:44     ` Bernd Schmidt
2015-12-11 18:25       ` [PATCH 0/3] " David Malcolm
2015-12-11 18:25         ` [PATCH 1/3] Delay location expansion within rich_location until printing David Malcolm
2015-12-11 18:25         ` [PATCH 3/3] PR c/68473: sanitize source range-printing within certain macro expansions (v2) David Malcolm
2015-12-11 18:25         ` David Malcolm [this message]
2015-12-14 12:39         ` [PATCH 0/3] Re: [PATCH] PR c/68473: sanitize source range-printing within certain macro expansions Bernd Schmidt
2015-12-10 16:24 ` Martin Sebor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1449859503-7614-3-git-send-email-dmalcolm@redhat.com \
    --to=dmalcolm@redhat.com \
    --cc=bschmidt@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).