aboutsummaryrefslogtreecommitdiff
path: root/gcc/go/gofrontend/go-linemap.h
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 /gcc/go/gofrontend/go-linemap.h
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
Diffstat (limited to 'gcc/go/gofrontend/go-linemap.h')
-rw-r--r--gcc/go/gofrontend/go-linemap.h12
1 files changed, 12 insertions, 0 deletions
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