diff mbox

Go patch committed: remove GCC-specific linemap usage

Message ID CAOyqgcWjOpY0ZpOvotUtVy4RFCqVECKQ18RZ0mfh5+yhFcw2sw@mail.gmail.com
State New
Headers show

Commit Message

Ian Lance Taylor Oct. 10, 2016, 5:33 p.m. UTC
This patch by Than McIntosh removes a GCC-specific use of the linemap
code to retrieve the line number.  Bootstrapped and ran Go testsuite
on x86_64-pc-linux-gnu.  Committed to mainline.

Ian

2016-10-10  Than McIntosh  <thanm@google.com>

* go-linemap.cc (Gcc_linemap::location_line): New method.
diff mbox

Patch

Index: gcc/go/go-linemap.cc
===================================================================
--- gcc/go/go-linemap.cc	(revision 240755)
+++ gcc/go/go-linemap.cc	(working copy)
@@ -32,6 +32,9 @@  class Gcc_linemap : public Linemap
   std::string
   to_string(Location);
 
+  int
+  location_line(Location);
+
  protected:
   Location
   get_predeclared_location();
@@ -88,6 +91,13 @@  Gcc_linemap::to_string(Location location
   return ss.str();
 }
 
+// Return the line number for a given location (for debugging dumps)
+int
+Gcc_linemap::location_line(Location loc)
+{
+  return LOCATION_LINE(loc.gcc_location());
+}
+
 // Stop getting locations.
 
 void
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 240941)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@ 
-9401e714d690e3907a64ac5c8cd5aed9e28f511b
+f3658aea2493c7f1c4a72502f9e7da562c7764c4
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/escape.cc
===================================================================
--- gcc/go/gofrontend/escape.cc	(revision 240941)
+++ gcc/go/gofrontend/escape.cc	(working copy)
@@ -145,7 +145,7 @@  Node::details() const
   std::stringstream details;
 
   if (!this->is_sink())
-    details << " l(" << LOCATION_LINE(this->location().gcc_location()) << ")";
+    details << " l(" << Linemap::location_to_line(this->location()) << ")";
 
   bool is_varargs = false;
   bool is_address_taken = false;
Index: gcc/go/gofrontend/go-linemap.h
===================================================================
--- gcc/go/gofrontend/go-linemap.h	(revision 240755)
+++ gcc/go/gofrontend/go-linemap.h	(working copy)
@@ -63,6 +63,10 @@  class Linemap
   virtual std::string
   to_string(Location) = 0;
 
+  // Return the line number for a given location (for debugging dumps)
+  virtual int
+  location_line(Location) = 0;
+
  protected:
   // Return a special Location used for predeclared identifiers.  This
   // Location should be different from that for any actual source
@@ -135,6 +139,14 @@  class Linemap
     go_assert(Linemap::instance_ != NULL);
     return Linemap::instance_->to_string(loc);
   }
+
+  // Return line number for location
+  static int
+  location_to_line(Location loc)
+  {
+    go_assert(Linemap::instance_ != NULL);
+    return Linemap::instance_->location_line(loc);
+  }
 };
 
 // The backend interface must define this function.  It should return