aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust
diff options
context:
space:
mode:
authorOwen Avery <powerboat9.gamer@gmail.com>2023-07-08 23:51:51 -0400
committerPhilip Herron <philip.herron@embecosm.com>2023-07-12 14:40:54 +0000
commit486c8b87e4d76bccde5746146d99d99ce69dbc7d (patch)
tree3cca0ed025651d8884e6194bcc577b1bd9f8d2fe /gcc/rust
parent1531c699220160e21655fac29b693a436f564188 (diff)
downloadgcc-486c8b87e4d76bccde5746146d99d99ce69dbc7d.zip
gcc-486c8b87e4d76bccde5746146d99d99ce69dbc7d.tar.gz
gcc-486c8b87e4d76bccde5746146d99d99ce69dbc7d.tar.bz2
Remove Linemap::get_location
gcc/rust/ChangeLog: * lex/rust-lex.cc (Lexer::get_current_location): Use linemap_position_for_column. * rust-session-manager.cc (Session::handle_crate_name): Likewise. * rust-linemap.cc (Linemap::get_location): Remove. * rust-linemap.h (Linemap::get_location): Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc/rust')
-rw-r--r--gcc/rust/lex/rust-lex.cc9
-rw-r--r--gcc/rust/rust-linemap.cc8
-rw-r--r--gcc/rust/rust-linemap.h4
-rw-r--r--gcc/rust/rust-session-manager.cc2
4 files changed, 2 insertions, 21 deletions
diff --git a/gcc/rust/lex/rust-lex.cc b/gcc/rust/lex/rust-lex.cc
index 8edefb4..ec9b833 100644
--- a/gcc/rust/lex/rust-lex.cc
+++ b/gcc/rust/lex/rust-lex.cc
@@ -173,18 +173,11 @@ Lexer::input_source_is_valid_utf8 ()
return raw_input_source->is_valid ();
}
-/* TODO: need to optimise somehow to avoid the virtual function call in the
- * tight loop. Best idea at the moment is CRTP, but that might make lexer
- * implementation annoying when storing the "base class" (i.e. would need
- * template parameter everywhere), although in practice it would mostly just
- * look ugly and make enclosing classes like Parser also require a type
- * parameter. At this point a macro might be better. OK I guess macros can be
- * replaced by constexpr if or something if possible. */
Location
Lexer::get_current_location ()
{
if (line_map)
- return line_map->get_location (current_column);
+ return linemap_position_for_column (line_table, current_column);
else
// If we have no linemap, we're lexing something without proper locations
return UNDEF_LOCATION;
diff --git a/gcc/rust/rust-linemap.cc b/gcc/rust/rust-linemap.cc
index 05c9f3d..75862b3 100644
--- a/gcc/rust/rust-linemap.cc
+++ b/gcc/rust/rust-linemap.cc
@@ -75,14 +75,6 @@ Linemap::start_line (unsigned lineno, unsigned linesize)
linemap_line_start (line_table, lineno, linesize);
}
-// Get a location.
-
-Location
-Linemap::get_location (unsigned column)
-{
- return Location (linemap_position_for_column (line_table, column));
-}
-
// 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 1aca05a..68afbc1 100644
--- a/gcc/rust/rust-linemap.h
+++ b/gcc/rust/rust-linemap.h
@@ -52,10 +52,6 @@ public:
// This will normally be called for every line in a source file.
void start_line (unsigned int line_number, unsigned int line_size);
- // Get a Location representing column position COLUMN on the current
- // line in the current file.
- Location get_location (unsigned int column);
-
// Stop generating Location values. This will be called after all
// input files have been read, in case any cleanup is required.
void stop ();
diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc
index 8344bca..c71cd59 100644
--- a/gcc/rust/rust-session-manager.cc
+++ b/gcc/rust/rust-session-manager.cc
@@ -438,7 +438,7 @@ Session::handle_crate_name (const AST::Crate &parsed_crate)
&& !validate_crate_name (options.crate_name, error))
{
error.emit ();
- rust_inform (linemap->get_location (0),
+ rust_inform (linemap_position_for_column (line_table, 0),
"crate name inferred from this file");
}
}