]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Reduce Linemap/Gcc_linemap abstraction
authorOwen Avery <powerboat9.gamer@gmail.com>
Mon, 3 Jul 2023 16:44:54 +0000 (12:44 -0400)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:49:32 +0000 (18:49 +0100)
This should help work towards the removal of Linemap/Gcc_linemap.

gcc/rust/ChangeLog:

* rust-linemap.cc
(Gcc_linemap::get_unknown_location): Remove.
(Gcc_linemap::get_predeclared_location): Remove.
(Gcc_linemap::is_predeclared): Remove.
(Gcc_linemap::is_unknown): Remove.
* rust-linemap.h
(Linemap::get_predeclared_location): Remove.
(Linemap::get_unknown_location): Remove.
(Linemap::is_predeclared): Remove.
(Linemap::is_unknown): Remove.
(Linemap::predeclared_location): Use BUILTINS_LOCATION.
(Linemap::unknown_location): Use UNKNOWN_LOCATION.
(Linemap::is_predeclared_location): Remove.
(Linemap::is_unknown_location): Remove.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
gcc/rust/rust-linemap.cc
gcc/rust/rust-linemap.h

index 17589bfb0ab393a82169c2fb810548d84d74b061..33d786f985c9bb59aca8e0be34f9199f859b4655 100644 (file)
@@ -44,15 +44,6 @@ public:
 
   int location_column (Location);
 
-protected:
-  Location get_predeclared_location ();
-
-  Location get_unknown_location ();
-
-  bool is_predeclared (Location);
-
-  bool is_unknown (Location);
-
 private:
   // Whether we are currently reading a file.
   bool in_file_;
@@ -144,38 +135,6 @@ Gcc_linemap::get_location (unsigned column)
   return Location (linemap_position_for_column (line_table, column));
 }
 
-// Get the unknown location.
-
-Location
-Gcc_linemap::get_unknown_location ()
-{
-  return Location (UNKNOWN_LOCATION);
-}
-
-// Get the predeclared location.
-
-Location
-Gcc_linemap::get_predeclared_location ()
-{
-  return Location (BUILTINS_LOCATION);
-}
-
-// Return whether a location is the predeclared location.
-
-bool
-Gcc_linemap::is_predeclared (Location loc)
-{
-  return loc == BUILTINS_LOCATION;
-}
-
-// Return whether a location is the unknown location.
-
-bool
-Gcc_linemap::is_unknown (Location loc)
-{
-  return loc == UNKNOWN_LOCATION;
-}
-
 // Return the Linemap to use for the gcc backend.
 
 Linemap *
index 99bd7d3d656b1caf90315ec816c7656fcf24f0aa..aa4fa9026ecdf8149040d2936e0da519a31cb097 100644 (file)
@@ -76,24 +76,6 @@ public:
   virtual int location_column (Location) = 0;
 
 protected:
-  // Return a special Location used for predeclared identifiers.  This
-  // Location should be different from that for any actual source
-  // file.  This location will be used for various different types,
-  // functions, and objects created by the frontend.
-  virtual Location get_predeclared_location () = 0;
-
-  // Return a special Location which indicates that no actual location
-  // is known.  This is used for undefined objects and for errors.
-  virtual Location get_unknown_location () = 0;
-
-  // Return whether the argument is the Location returned by
-  // get_predeclared_location.
-  virtual bool is_predeclared (Location) = 0;
-
-  // Return whether the argument is the Location returned by
-  // get_unknown_location.
-  virtual bool is_unknown (Location) = 0;
-
   // The single existing instance of Linemap.
   static Linemap *instance_;
 
@@ -103,34 +85,10 @@ public:
   // an instance of Linemap.
 
   // Return the special Location used for predeclared identifiers.
-  static Location predeclared_location ()
-  {
-    rust_assert (Linemap::instance_ != NULL);
-    return Linemap::instance_->get_predeclared_location ();
-  }
+  static Location predeclared_location () { return BUILTINS_LOCATION; }
 
   // Return the special Location used when no location is known.
-  static Location unknown_location ()
-  {
-    rust_assert (Linemap::instance_ != NULL);
-    return Linemap::instance_->get_unknown_location ();
-  }
-
-  // Return whether the argument is the special location used for
-  // predeclared identifiers.
-  static bool is_predeclared_location (Location loc)
-  {
-    rust_assert (Linemap::instance_ != NULL);
-    return Linemap::instance_->is_predeclared (loc);
-  }
-
-  // Return whether the argument is the special location used when no
-  // location is known.
-  static bool is_unknown_location (Location loc)
-  {
-    rust_assert (Linemap::instance_ != NULL);
-    return Linemap::instance_->is_unknown (loc);
-  }
+  static Location unknown_location () { return UNKNOWN_LOCATION; }
 
   // Produce a human-readable description of a Location.
   static std::string location_to_string (Location loc)