]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Merge Linemap::to_string into Linemap::location_to_string
authorOwen Avery <powerboat9.gamer@gmail.com>
Sun, 9 Jul 2023 03:20:01 +0000 (23:20 -0400)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:49:35 +0000 (18:49 +0100)
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 <powerboat9.gamer@gmail.com>
gcc/rust/lex/rust-lex.cc
gcc/rust/rust-linemap.cc
gcc/rust/rust-linemap.h

index 628fecc9982c3b1127296e97dabae0711a7a8103..b5702a0966efe9ca2890fa9a63a6ce87d31e0957 100644 (file)
@@ -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);
index 87b72f8fbeb6ea93639ae5ed4e72fa233951294f..e7257e87c6d88887e3bfd3a8f44b5a75f0540d07 100644 (file)
@@ -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;
index 5b74464b26245a7ebd0a0e3f04fe4d6e899bfb0f..81c622b5006216e15f264bd2b3174f6d699df628 100644 (file)
@@ -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.