From: Owen Avery Date: Mon, 3 Jul 2023 16:44:54 +0000 (-0400) Subject: gccrs: Reduce Linemap/Gcc_linemap abstraction X-Git-Tag: basepoints/gcc-15~2399 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc0aa04839ebb8ca014b3ca3ca20b248c18f1073;p=thirdparty%2Fgcc.git gccrs: Reduce Linemap/Gcc_linemap abstraction 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 --- diff --git a/gcc/rust/rust-linemap.cc b/gcc/rust/rust-linemap.cc index 17589bfb0ab3..33d786f985c9 100644 --- a/gcc/rust/rust-linemap.cc +++ b/gcc/rust/rust-linemap.cc @@ -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 * diff --git a/gcc/rust/rust-linemap.h b/gcc/rust/rust-linemap.h index 99bd7d3d656b..aa4fa9026ecd 100644 --- a/gcc/rust/rust-linemap.h +++ b/gcc/rust/rust-linemap.h @@ -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)