Skip to content

Commit

Permalink
Remove Linemap::get_location
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
powerboat9 authored and philberty committed Jul 12, 2023
1 parent 1531c69 commit 486c8b8
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 21 deletions.
9 changes: 1 addition & 8 deletions gcc/rust/lex/rust-lex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 0 additions & 8 deletions gcc/rust/rust-linemap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down
4 changes: 0 additions & 4 deletions gcc/rust/rust-linemap.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ class Linemap
// 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 ();
Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/rust-session-manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
Expand Down

0 comments on commit 486c8b8

Please sign in to comment.