aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThan McIntosh <thanm@google.com>2016-10-10 17:33:32 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2016-10-10 17:33:32 +0000
commit71543388eec6aad6fb096b1de16264051cf06d3e (patch)
treef8073361e3fb096f990d2672a5480cd3528b458b
parent5d8c099edebfe908256c2bd77a0e2b67182b0f57 (diff)
downloadgcc-71543388eec6aad6fb096b1de16264051cf06d3e.zip
gcc-71543388eec6aad6fb096b1de16264051cf06d3e.tar.gz
gcc-71543388eec6aad6fb096b1de16264051cf06d3e.tar.bz2
compiler: prune away gcc-specific linemap usage
Add an interface to the go Linemap class to allow clients to ask for the line number for a Location (for debugging dumps), so as to move some gcc-specific location code into the back end. Reviewed-on: https://go-review.googlesource.com/30699 * go-linemap.cc (Gcc_linemap::location_line): New method. From-SVN: r240942
-rw-r--r--gcc/go/ChangeLog4
-rw-r--r--gcc/go/go-linemap.cc10
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/escape.cc2
-rw-r--r--gcc/go/gofrontend/go-linemap.h12
5 files changed, 28 insertions, 2 deletions
diff --git a/gcc/go/ChangeLog b/gcc/go/ChangeLog
index 070acc5..6ea6138 100644
--- a/gcc/go/ChangeLog
+++ b/gcc/go/ChangeLog
@@ -1,3 +1,7 @@
+2016-10-10 Than McIntosh <thanm@google.com>
+
+ * go-linemap.cc (Gcc_linemap::location_line): New method.
+
2016-10-10 Eric Botcazou <ebotcazou@adacore.com>
* config-lang.in (lang_requires_boot_languages): Delete.
diff --git a/gcc/go/go-linemap.cc b/gcc/go/go-linemap.cc
index b58a54b..22498d9 100644
--- a/gcc/go/go-linemap.cc
+++ b/gcc/go/go-linemap.cc
@@ -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
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 05752dac..e22f79e 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -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.
diff --git a/gcc/go/gofrontend/escape.cc b/gcc/go/gofrontend/escape.cc
index e0df77d..732af77 100644
--- a/gcc/go/gofrontend/escape.cc
+++ b/gcc/go/gofrontend/escape.cc
@@ -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;
diff --git a/gcc/go/gofrontend/go-linemap.h b/gcc/go/gofrontend/go-linemap.h
index d60cff6..f0ca99d 100644
--- a/gcc/go/gofrontend/go-linemap.h
+++ b/gcc/go/gofrontend/go-linemap.h
@@ -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