From 66c5c997624cac979f038f7492c2697a0de2176b Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Wed, 8 Jun 2016 15:12:01 -0400
Subject: [PATCH 14/22] FIXME: reimplement removal fixits in terms of replace,
 to ease consolidation

---
 gcc/diagnostic-show-locus.c | 17 -----------------
 gcc/diagnostic.c            |  4 ----
 libcpp/include/line-map.h   | 26 +-------------------------
 libcpp/line-map.c           | 26 +-------------------------
 4 files changed, 2 insertions(+), 71 deletions(-)

diff --git a/gcc/diagnostic-show-locus.c b/gcc/diagnostic-show-locus.c
index e9d6a3f..e4198e9 100644
--- a/gcc/diagnostic-show-locus.c
+++ b/gcc/diagnostic-show-locus.c
@@ -1082,23 +1082,6 @@ layout::print_any_fixits (int row, const rich_location *richloc)
 	      }
 	      break;
 
-	    case fixit_hint::REMOVE:
-	      {
-		fixit_remove *remove = static_cast <fixit_remove *> (hint);
-		/* This assumes the removal just affects one line.  */
-		source_range src_range = remove->get_range ();
-		int start_column = LOCATION_COLUMN (src_range.m_start);
-		int finish_column = LOCATION_COLUMN (src_range.m_finish);
-		move_to_column (&column, start_column);
-		for (int column = start_column; column <= finish_column; column++)
-		  {
-		    m_colorizer.set_fixit_hint ();
-		    pp_character (m_pp, '-');
-		    m_colorizer.set_normal_text ();
-		  }
-	      }
-	      break;
-
 	    case fixit_hint::REPLACE:
 	      {
 		fixit_replace *replace = static_cast <fixit_replace *> (hint);
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
index 856e7fb..4f999e6 100644
--- a/gcc/diagnostic.c
+++ b/gcc/diagnostic.c
@@ -737,10 +737,6 @@ print_parseable_fixits (FILE* out, diagnostic_info *diagnostic)
 	    }
 	    break;
 
-	  case fixit_hint::REMOVE:
-	    print_escaped_string (out, "");
-	    break;
-
 	  case fixit_hint::REPLACE:
 	    {
 	      const fixit_replace *replace
diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h
index 67b33de..34c1a05 100644
--- a/libcpp/include/line-map.h
+++ b/libcpp/include/line-map.h
@@ -1411,7 +1411,7 @@ protected:
 class fixit_hint
 {
 public:
-  enum kind {INSERT, REMOVE, REPLACE};
+  enum kind {INSERT, REPLACE};
 
   virtual ~fixit_hint () {}
 
@@ -1450,30 +1450,6 @@ class fixit_insert : public fixit_hint
   size_t m_len;
 };
 
-class fixit_remove : public fixit_hint
-{
- public:
-  fixit_remove (source_range src_range);
-  ~fixit_remove () {}
-
-  enum kind get_kind () const { return REMOVE; }
-  bool affects_line_p (const char *file, int line);
-  source_location get_start_loc () const { return m_src_range.m_start; }
-  bool maybe_get_end_loc (source_location *out) const
-  {
-    *out = m_src_range.m_finish;
-    return true;
-  }
-  bool maybe_append_replace (line_maps *set,
-			     source_range src_range,
-			     const char *new_content);
-
-  source_range get_range () const { return m_src_range; }
-
- private:
-  source_range m_src_range;
-};
-
 class fixit_replace : public fixit_hint
 {
  public:
diff --git a/libcpp/line-map.c b/libcpp/line-map.c
index 668505f..f7240ee 100644
--- a/libcpp/line-map.c
+++ b/libcpp/line-map.c
@@ -2099,8 +2099,7 @@ rich_location::add_fixit_insert (source_location where,
 void
 rich_location::add_fixit_remove (source_range src_range)
 {
-  linemap_assert (m_num_fixit_hints < MAX_FIXIT_HINTS);
-  m_fixit_hints[m_num_fixit_hints++] = new fixit_remove (src_range);
+  add_fixit_replace (src_range, "");
 }
 
 /* FIXME.  */
@@ -2201,29 +2200,6 @@ fixit_insert::maybe_append_replace (line_maps *, source_range, const char *)
   return false;
 }
 
-/* class fixit_remove.  */
-
-fixit_remove::fixit_remove (source_range src_range)
-: m_src_range (src_range)
-{
-}
-
-/* Implementation of fixit_hint::affects_line_p for fixit_remove.  */
-
-bool
-fixit_remove::affects_line_p (const char *file, int line)
-{
-  return m_src_range.intersects_line_p (file, line);
-}
-
-/* FIXME.  */
-
-bool
-fixit_remove::maybe_append_replace (line_maps *, source_range, const char *)
-{
-  return false;
-}
-
 /* class fixit_replace.  */
 
 fixit_replace::fixit_replace (source_range src_range,
-- 
1.8.5.3

