From 71543388eec6aad6fb096b1de16264051cf06d3e Mon Sep 17 00:00:00 2001 From: Than McIntosh Date: Mon, 10 Oct 2016 17:33:32 +0000 Subject: 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 --- gcc/go/gofrontend/go-linemap.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'gcc/go/gofrontend/go-linemap.h') 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 -- cgit v1.1