From d8a697a658e4621abfb7a294cedadb8ac5b285cd Mon Sep 17 00:00:00 2001 From: Owen Avery Date: Sun, 2 Jul 2023 19:59:29 -0400 Subject: gccrs: Change class Location into typedef gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::address_expression): Remove gcc_location method call. (HIRCompileBase::indirect_expression): Likewise. (HIRCompileBase::compile_constant_item): Likewise. (HIRCompileBase::named_constant_expression): Likewise. * backend/rust-compile-expr.cc (CompileExpr::visit): Remove gcc_location method call, use UNKNOWN_LOCATION to initialize. (CompileExpr::get_fn_addr_from_dyn): Remove gcc_location method call. (CompileExpr::type_cast_expression): Likewise. * backend/rust-compile-intrinsic.cc (transmute_handler): Replace "Location ().gcc_location ()" with UNKNOWN_LOCATION. (copy_nonoverlapping_handler): Likewise. (prefetch_data_handler): Likewise. (atomic_store_handler_inner): Likewise. (atomic_load_handler_inner): Likewise. * resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Remove gcc_location method call. * rust-diagnostics.cc (rust_be_error_at): Likewise. (rust_be_warning_at): Likewise. (rust_be_fatal_error): Likewise. (rust_be_inform): Likewise. * rust-diagnostics.h (rust_sorry_at): Likewise. * rust-gcc.cc (Bvariable::get_tree): Likewise. (Gcc_backend::fill_in_fields): Likewise. (Gcc_backend::named_type): Likewise. (Gcc_backend::real_part_expression): Likewise. (Gcc_backend::imag_part_expression): Likewise. (Gcc_backend::complex_expression): Likewise. (Gcc_backend::convert_expression): Likewise. (Gcc_backend::struct_field_expression): Likewise. (Gcc_backend::compound_expression): Likewise. (Gcc_backend::conditional_expression): Likewise. (Gcc_backend::negation_expression): Likewise. (Gcc_backend::arithmetic_or_logical_expression): Likewise. (Gcc_backend::arithmetic_or_logical_expression_checked): Likewise. (Gcc_backend::comparison_expression): Likewise. (Gcc_backend::lazy_boolean_expression): Likewise. (Gcc_backend::constructor_expression): Likewise. (Gcc_backend::array_constructor_expression): Likewise. (Gcc_backend::array_initializer): Likewise. (Gcc_backend::array_index_expression): Likewise. (Gcc_backend::call_expression): Likewise. (Gcc_backend::assignment_statement): Likewise. (Gcc_backend::return_statement): Likewise. (Gcc_backend::exception_handler_statement): Likewise. (Gcc_backend::if_statement): Likewise. (Gcc_backend::loop_expression): Likewise. (Gcc_backend::exit_expression): Likewise. (Gcc_backend::block): Likewise. (Gcc_backend::convert_tree): Likewise. (Gcc_backend::global_variable): Likewise. (Gcc_backend::local_variable): Likewise. (Gcc_backend::parameter_variable): Likewise. (Gcc_backend::static_chain_variable): Likewise. (Gcc_backend::temporary_variable): Likewise. (Gcc_backend::label): Likewise. (Gcc_backend::goto_statement): Likewise. (Gcc_backend::label_address): Likewise. (Gcc_backend::function): Likewise. * rust-linemap.cc (Gcc_linemap::to_string): Likewise. (Gcc_linemap::location_file): Likewise. (Gcc_linemap::location_line): Likewise. (Gcc_linemap::location_column): Likewise. (Gcc_linemap::is_predeclared): Likewise. (Gcc_linemap::is_unknown): Likewise. (RichLocation::RichLocation): Likewise. (RichLocation::add_range): Likewise. (RichLocation::add_fixit_insert_before): Likewise. (RichLocation::add_fixit_insert_after): Likewise. * rust-location.h (class Location): Replace with typedef. (operator<): Remove. (operator==): Remove. (operator+): Remove. (operator-): Remove. * typecheck/rust-hir-trait-resolve.cc (AssociatedImplTrait::setup_associated_types): Initialize Location with UNKNOWN_LOCATION. * typecheck/rust-hir-type-check-stmt.cc (TypeCheckStmt::visit): Likewise. * util/rust-token-converter.cc (convert): Remove gcc_location method call. Signed-off-by: Owen Avery --- gcc/rust/rust-location.h | 55 +----------------------------------------------- 1 file changed, 1 insertion(+), 54 deletions(-) (limited to 'gcc/rust/rust-location.h') diff --git a/gcc/rust/rust-location.h b/gcc/rust/rust-location.h index b2f53d8..b0b14c6 100644 --- a/gcc/rust/rust-location.h +++ b/gcc/rust/rust-location.h @@ -26,60 +26,7 @@ // A location in an input source file. -class Location -{ -public: - Location () : gcc_loc_ (UNKNOWN_LOCATION) {} - - explicit Location (location_t loc) : gcc_loc_ (loc) {} - - location_t gcc_location () const { return gcc_loc_; } - - Location operator+= (location_t rhs) - { - gcc_loc_ += rhs; - return *this; - } - - Location operator-= (location_t rhs) - { - gcc_loc_ -= rhs; - return *this; - } - - bool operator== (location_t rhs) { return rhs == gcc_loc_; } - -private: - location_t gcc_loc_; -}; - -// The Rust frontend requires the ability to compare Locations. - -inline bool -operator< (Location loca, Location locb) -{ - return loca.gcc_location () < locb.gcc_location (); -} - -inline bool -operator== (Location loca, Location locb) -{ - return loca.gcc_location () == locb.gcc_location (); -} - -inline Location -operator+ (Location lhs, location_t rhs) -{ - lhs += rhs; - return lhs; -} - -inline Location -operator- (Location lhs, location_t rhs) -{ - lhs -= rhs; - return lhs; -} +typedef location_t Location; class RichLocation { -- cgit v1.1