aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorOwen Avery <powerboat9.gamer@gmail.com>2023-07-03 13:33:16 -0400
committerCohenArthur <arthur.cohen@embecosm.com>2023-07-07 12:10:52 +0000
commit5ca1ed0397314d47e7ecd937000ec096f8274a60 (patch)
tree183273ee5f5464ec101641671138494e3ca63f20 /gcc
parent65553ce9a9821591d0296f2b20286a91e25be8da (diff)
downloadgcc-5ca1ed0397314d47e7ecd937000ec096f8274a60.zip
gcc-5ca1ed0397314d47e7ecd937000ec096f8274a60.tar.gz
gcc-5ca1ed0397314d47e7ecd937000ec096f8274a60.tar.bz2
Reduce Linemap/Gcc_linemap abstraction further
gcc/rust/ChangeLog: * expand/rust-macro-builtins.cc (source_relative_path): Use LOCATION_FILE. (MacroBuiltin::file_handler): Likewise. (MacroBuiltin::column_handler): Use LOCATION_COLUMN. (MacroBuiltin::line_handler): Use LOCATION_LINE. * rust-linemap.cc (Gcc_linemap::location_file): Remove. (Gcc_linemap::location_line): Remove. (Gcc_linemap::location_column): Remove. * rust-linemap.h (Linemap::location_file): Remove. (Linemap::location_line): Remove. (Linemap::location_column): Remove. (Linemap::location_to_file): Remove. (Linemap::location_to_line): Remove. (Linemap::location_to_column): Remove. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/expand/rust-macro-builtins.cc12
-rw-r--r--gcc/rust/rust-linemap.cc29
-rw-r--r--gcc/rust/rust-linemap.h29
3 files changed, 4 insertions, 66 deletions
diff --git a/gcc/rust/expand/rust-macro-builtins.cc b/gcc/rust/expand/rust-macro-builtins.cc
index 59a1f19..6b3f3c7 100644
--- a/gcc/rust/expand/rust-macro-builtins.cc
+++ b/gcc/rust/expand/rust-macro-builtins.cc
@@ -354,8 +354,7 @@ parse_single_string_literal (BuiltinMacro kind,
std::string
source_relative_path (std::string path, Location locus)
{
- std::string compile_fname
- = Session::get_instance ().linemap->location_file (locus);
+ std::string compile_fname = LOCATION_FILE (locus);
auto dir_separator_pos = compile_fname.rfind (file_separator);
@@ -410,8 +409,7 @@ MacroBuiltin::assert_handler (Location invoc_locus, AST::MacroInvocData &invoc)
AST::Fragment
MacroBuiltin::file_handler (Location invoc_locus, AST::MacroInvocData &)
{
- auto current_file
- = Session::get_instance ().linemap->location_file (invoc_locus);
+ auto current_file = LOCATION_FILE (invoc_locus);
auto file_str = AST::SingleASTNode (make_string (invoc_locus, current_file));
auto str_token
= make_token (Token::make_string (invoc_locus, std::move (current_file)));
@@ -422,8 +420,7 @@ MacroBuiltin::file_handler (Location invoc_locus, AST::MacroInvocData &)
AST::Fragment
MacroBuiltin::column_handler (Location invoc_locus, AST::MacroInvocData &)
{
- auto current_column
- = Session::get_instance ().linemap->location_to_column (invoc_locus);
+ auto current_column = LOCATION_COLUMN (invoc_locus);
auto column_tok = make_token (
Token::make_int (invoc_locus, std::to_string (current_column)));
@@ -896,8 +893,7 @@ MacroBuiltin::include_handler (Location invoc_locus, AST::MacroInvocData &invoc)
AST::Fragment
MacroBuiltin::line_handler (Location invoc_locus, AST::MacroInvocData &)
{
- auto current_line
- = Session::get_instance ().linemap->location_to_line (invoc_locus);
+ auto current_line = LOCATION_LINE (invoc_locus);
auto line_no = AST::SingleASTNode (std::unique_ptr<AST::Expr> (
new AST::LiteralExpr (std::to_string (current_line), AST::Literal::INT,
diff --git a/gcc/rust/rust-linemap.cc b/gcc/rust/rust-linemap.cc
index 1dc50dc..2d8c14c 100644
--- a/gcc/rust/rust-linemap.cc
+++ b/gcc/rust/rust-linemap.cc
@@ -38,12 +38,6 @@ public:
std::string to_string (Location);
- std::string location_file (Location);
-
- int location_line (Location);
-
- int location_column (Location);
-
private:
// Whether we are currently reading a file.
bool in_file_;
@@ -87,29 +81,6 @@ Gcc_linemap::to_string (Location location)
return ss.str ();
}
-// Return the file name for a given location.
-
-std::string
-Gcc_linemap::location_file (Location loc)
-{
- return LOCATION_FILE (loc);
-}
-
-// Return the line number for a given location.
-
-int
-Gcc_linemap::location_line (Location loc)
-{
- return LOCATION_LINE (loc);
-}
-
-// Return the column number for a given location.
-int
-Gcc_linemap::location_column (Location loc)
-{
- return LOCATION_COLUMN (loc);
-}
-
// Stop getting locations.
void
diff --git a/gcc/rust/rust-linemap.h b/gcc/rust/rust-linemap.h
index ae8f6f6..12fdb9f 100644
--- a/gcc/rust/rust-linemap.h
+++ b/gcc/rust/rust-linemap.h
@@ -66,15 +66,6 @@ public:
// unknown locations.
virtual std::string to_string (Location) = 0;
- // Return the file name for a given location.
- virtual std::string location_file (Location) = 0;
-
- // Return the line number for a given location.
- virtual int location_line (Location) = 0;
-
- // Return the column number for a given location.
- virtual int location_column (Location) = 0;
-
protected:
// The single existing instance of Linemap.
static Linemap *instance_;
@@ -96,26 +87,6 @@ public:
rust_assert (Linemap::instance_ != NULL);
return Linemap::instance_->to_string (loc);
}
-
- // Return the file name of a location.
- static std::string location_to_file (Location loc)
- {
- rust_assert (Linemap::instance_ != NULL);
- return Linemap::instance_->location_file (loc);
- }
-
- // Return line number of a location.
- static int location_to_line (Location loc)
- {
- rust_assert (Linemap::instance_ != NULL);
- return Linemap::instance_->location_line (loc);
- }
-
- static int location_to_column (Location loc)
- {
- rust_assert (Linemap::instance_ != NULL);
- return Linemap::instance_->location_column (loc);
- }
};
#endif // !defined(RUST_LINEMAP_H)