Commit 943cc2fb by Ian Lance Taylor Committed by Ian Lance Taylor

compiler: add location_file

    
    Add support for getting the file name from a Location value.  This
    will be used by later work.
    
    Reviewed-on: https://go-review.googlesource.com/c/145318

	* go-linemap.cc (Gcc_linemap::location_file): New method.

From-SVN: r265598
parent 266ef361
2018-10-29 Ian Lance Taylor <iant@golang.org>
* go-linemap.cc (Gcc_linemap::location_file): New method.
2018-10-17 David Malcolm <dmalcolm@redhat.com> 2018-10-17 David Malcolm <dmalcolm@redhat.com>
* Make-lang.in (selftest-go): New. * Make-lang.in (selftest-go): New.
......
...@@ -34,6 +34,9 @@ class Gcc_linemap : public Linemap ...@@ -34,6 +34,9 @@ class Gcc_linemap : public Linemap
std::string std::string
to_string(Location); to_string(Location);
std::string
location_file(Location);
int int
location_line(Location); location_line(Location);
...@@ -93,7 +96,16 @@ Gcc_linemap::to_string(Location location) ...@@ -93,7 +96,16 @@ Gcc_linemap::to_string(Location location)
return ss.str(); return ss.str();
} }
// Return the line number for a given location (for debugging dumps) // Return the file name for a given location.
std::string
Gcc_linemap::location_file(Location loc)
{
return LOCATION_FILE(loc.gcc_location());
}
// Return the line number for a given location.
int int
Gcc_linemap::location_line(Location loc) Gcc_linemap::location_line(Location loc)
{ {
......
8902fb43c569e4d3ec5bd143bfa8cb6bf2836780 e4a421a01ad1fcc4315e530e79272604f3683051
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the gofrontend repository. merge done from the gofrontend repository.
...@@ -63,7 +63,11 @@ class Linemap ...@@ -63,7 +63,11 @@ class Linemap
virtual std::string virtual std::string
to_string(Location) = 0; to_string(Location) = 0;
// Return the line number for a given location (for debugging dumps) // Return the file name for a given location.
virtual std::string
location_file(Location) = 0;
// Return the line number for a given location.
virtual int virtual int
location_line(Location) = 0; location_line(Location) = 0;
...@@ -140,7 +144,15 @@ class Linemap ...@@ -140,7 +144,15 @@ class Linemap
return Linemap::instance_->to_string(loc); return Linemap::instance_->to_string(loc);
} }
// Return line number for location // Return the file name of a location.
static std::string
location_to_file(Location loc)
{
go_assert(Linemap::instance_ != NULL);
return Linemap::instance_->location_file(loc);
}
// Return line number of a location.
static int static int
location_to_line(Location loc) location_to_line(Location loc)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment