From e659eca9f3b9c167c37a7862cb45d996fb784a6f Mon Sep 17 00:00:00 2001 From: Owen Avery Date: Sat, 8 Jul 2023 23:20:01 -0400 Subject: [PATCH] gccrs: Merge Linemap::to_string into Linemap::location_to_string gcc/rust/ChangeLog: * lex/rust-lex.cc (Lexer::dump_and_skip): Use location_to_string. * rust-linemap.cc (Linemap::to_string): Move to... (Linemap::location_to_string): ... here. * rust-linemap.h (Linemap::to_string): Remove. (Linemap::location_to_string): Remove definition. Signed-off-by: Owen Avery --- gcc/rust/lex/rust-lex.cc | 2 +- gcc/rust/rust-linemap.cc | 2 +- gcc/rust/rust-linemap.h | 15 ++++----------- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/gcc/rust/lex/rust-lex.cc b/gcc/rust/lex/rust-lex.cc index 628fecc9982c..b5702a0966ef 100644 --- a/gcc/rust/lex/rust-lex.cc +++ b/gcc/rust/lex/rust-lex.cc @@ -246,7 +246,7 @@ Lexer::dump_and_skip (int n) + std::string (tok->get_type_hint_str ())) : "") << " "; - out << get_line_map ()->to_string (loc) << " "; + out << Linemap::location_to_string (loc) << " "; } token_queue.skip (0); diff --git a/gcc/rust/rust-linemap.cc b/gcc/rust/rust-linemap.cc index 87b72f8fbeb6..e7257e87c6d8 100644 --- a/gcc/rust/rust-linemap.cc +++ b/gcc/rust/rust-linemap.cc @@ -36,7 +36,7 @@ Linemap::start_file (const char *file_name, unsigned line_begin) // Stringify a location std::string -Linemap::to_string (Location location) +Linemap::location_to_string (Location location) { const line_map_ordinary *lmo; location_t resolved_location; diff --git a/gcc/rust/rust-linemap.h b/gcc/rust/rust-linemap.h index 5b74464b2624..81c622b50062 100644 --- a/gcc/rust/rust-linemap.h +++ b/gcc/rust/rust-linemap.h @@ -60,11 +60,6 @@ public: // input files have been read, in case any cleanup is required. void stop (); - // Produce a human-readable description of a Location, e.g. - // "foo.rust:10". Returns an empty string for predeclared, builtin or - // unknown locations. - std::string to_string (Location); - protected: // The single existing instance of Linemap. static Linemap *instance_; @@ -77,12 +72,10 @@ public: // Return the special Location used for predeclared identifiers. static Location predeclared_location () { return BUILTINS_LOCATION; } - // Produce a human-readable description of a Location. - static std::string location_to_string (Location loc) - { - rust_assert (Linemap::instance_ != NULL); - return Linemap::instance_->to_string (loc); - } + // Produce a human-readable description of a Location, e.g. + // "foo.rust:10". Returns an empty string for predeclared, builtin or + // unknown locations. + static std::string location_to_string (Location loc); private: // Whether we are currently reading a file. -- 2.47.2