aboutsummaryrefslogtreecommitdiff
path: root/gcc/go/gofrontend/go-linemap.h
diff options
context:
space:
mode:
authorThan McIntosh <thanm@google.com>2016-09-27 20:49:05 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2016-09-27 20:49:05 +0000
commit437018ea2b6dc966ce40cd5dd684054126ddda6b (patch)
tree10cc817706743a8a7bea457f727d3ab9ee181ab8 /gcc/go/gofrontend/go-linemap.h
parent6e39060a7f6f58dacf4e74762fd5dd85a5afb0d8 (diff)
downloadgcc-437018ea2b6dc966ce40cd5dd684054126ddda6b.zip
gcc-437018ea2b6dc966ce40cd5dd684054126ddda6b.tar.gz
gcc-437018ea2b6dc966ce40cd5dd684054126ddda6b.tar.bz2
compiler: add src information to AST dumps (part 1 of 2).
When emitting AST dumps, tag the end of selected statements with with source file and line number information where available. Example: tmp.76832448 = 0 // p.go:6 Requires a corresponding change in gcc/go as well as this change to gofrontend. Reviewed-on: https://go-review.googlesource.com/29856 * go-linemap.cc (Gcc_linemap::to_string): New method. From-SVN: r240558
Diffstat (limited to 'gcc/go/gofrontend/go-linemap.h')
-rw-r--r--gcc/go/gofrontend/go-linemap.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/go-linemap.h b/gcc/go/gofrontend/go-linemap.h
index ffbcbe7..d60cff6 100644
--- a/gcc/go/gofrontend/go-linemap.h
+++ b/gcc/go/gofrontend/go-linemap.h
@@ -17,7 +17,6 @@
// The type is normally passed by value rather than by reference, and
// it should support that efficiently. The type should be defined in
// "go-location.h".
-
#include "go-location.h"
// The Linemap class is a pure abstract interface, plus some static
@@ -58,6 +57,12 @@ class Linemap
virtual void
stop() = 0;
+ // Produce a human-readable description of a Location, e.g.
+ // "foo.go:10". Returns an empty string for predeclared, builtin or
+ // unknown locations.
+ virtual std::string
+ to_string(Location) = 0;
+
protected:
// Return a special Location used for predeclared identifiers. This
// Location should be different from that for any actual source
@@ -122,6 +127,14 @@ class Linemap
go_assert(Linemap::instance_ != NULL);
return Linemap::instance_->is_unknown(loc);
}
+
+ // Produce a human-readable description of a Location.
+ static std::string
+ location_to_string(Location loc)
+ {
+ go_assert(Linemap::instance_ != NULL);
+ return Linemap::instance_->to_string(loc);
+ }
};
// The backend interface must define this function. It should return