diff options
author | Owen Avery <powerboat9.gamer@gmail.com> | 2023-07-10 16:21:36 -0400 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-01-16 18:55:59 +0100 |
commit | 80c68893f446bf883c67dd78c317b5c0f0f55f4f (patch) | |
tree | d651782c2a914046c3033bf01ed3e68334232385 /gcc/rust/expand | |
parent | d686ffaf26b3da16d1ea6e61f88f0a546bb33cf0 (diff) | |
download | gcc-80c68893f446bf883c67dd78c317b5c0f0f55f4f.zip gcc-80c68893f446bf883c67dd78c317b5c0f0f55f4f.tar.gz gcc-80c68893f446bf883c67dd78c317b5c0f0f55f4f.tar.bz2 |
gccrs: Replace Location with location_t in parsing and macro expansion
gcc/rust/ChangeLog:
* expand/rust-derive-clone.cc: Replace Location with location_t.
* expand/rust-derive-clone.h: Likewise.
* expand/rust-derive-copy.cc: Likewise.
* expand/rust-derive-copy.h: Likewise.
* expand/rust-derive.cc: Likewise.
* expand/rust-derive.h: Likewise.
* expand/rust-macro-builtins.cc: Likewise.
* expand/rust-macro-builtins.h: Likewise.
* expand/rust-macro-expand.cc: Likewise.
* parse/rust-parse-impl.h: Likewise.
* parse/rust-parse.cc: Likewise.
* parse/rust-parse.h: Likewise.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc/rust/expand')
-rw-r--r-- | gcc/rust/expand/rust-derive-clone.cc | 2 | ||||
-rw-r--r-- | gcc/rust/expand/rust-derive-clone.h | 2 | ||||
-rw-r--r-- | gcc/rust/expand/rust-derive-copy.cc | 3 | ||||
-rw-r--r-- | gcc/rust/expand/rust-derive-copy.h | 2 | ||||
-rw-r--r-- | gcc/rust/expand/rust-derive.cc | 2 | ||||
-rw-r--r-- | gcc/rust/expand/rust-derive.h | 4 | ||||
-rw-r--r-- | gcc/rust/expand/rust-macro-builtins.cc | 39 | ||||
-rw-r--r-- | gcc/rust/expand/rust-macro-builtins.h | 33 | ||||
-rw-r--r-- | gcc/rust/expand/rust-macro-expand.cc | 2 |
9 files changed, 47 insertions, 42 deletions
diff --git a/gcc/rust/expand/rust-derive-clone.cc b/gcc/rust/expand/rust-derive-clone.cc index 34886b2..964602b 100644 --- a/gcc/rust/expand/rust-derive-clone.cc +++ b/gcc/rust/expand/rust-derive-clone.cc @@ -87,7 +87,7 @@ DeriveClone::clone_impl (std::unique_ptr<TraitImplItem> &&clone_fn, // TODO: Create new `make_qualified_call` helper function -DeriveClone::DeriveClone (Location loc) +DeriveClone::DeriveClone (location_t loc) : DeriveVisitor (loc), expanded (nullptr) {} diff --git a/gcc/rust/expand/rust-derive-clone.h b/gcc/rust/expand/rust-derive-clone.h index e1fadc7..dcb88f9 100644 --- a/gcc/rust/expand/rust-derive-clone.h +++ b/gcc/rust/expand/rust-derive-clone.h @@ -27,7 +27,7 @@ namespace AST { class DeriveClone : DeriveVisitor { public: - DeriveClone (Location loc); + DeriveClone (location_t loc); std::unique_ptr<AST::Item> go (Item &item); diff --git a/gcc/rust/expand/rust-derive-copy.cc b/gcc/rust/expand/rust-derive-copy.cc index 51a6599..ffac7fd 100644 --- a/gcc/rust/expand/rust-derive-copy.cc +++ b/gcc/rust/expand/rust-derive-copy.cc @@ -22,7 +22,8 @@ namespace Rust { namespace AST { -DeriveCopy::DeriveCopy (Location loc) : DeriveVisitor (loc), expanded (nullptr) +DeriveCopy::DeriveCopy (location_t loc) + : DeriveVisitor (loc), expanded (nullptr) {} std::unique_ptr<AST::Item> diff --git a/gcc/rust/expand/rust-derive-copy.h b/gcc/rust/expand/rust-derive-copy.h index 0e1e207..f02b671 100644 --- a/gcc/rust/expand/rust-derive-copy.h +++ b/gcc/rust/expand/rust-derive-copy.h @@ -27,7 +27,7 @@ namespace AST { class DeriveCopy : DeriveVisitor { public: - DeriveCopy (Location loc); + DeriveCopy (location_t loc); std::unique_ptr<Item> go (Item &); diff --git a/gcc/rust/expand/rust-derive.cc b/gcc/rust/expand/rust-derive.cc index 1a7413b..7b8f404 100644 --- a/gcc/rust/expand/rust-derive.cc +++ b/gcc/rust/expand/rust-derive.cc @@ -23,7 +23,7 @@ namespace Rust { namespace AST { -DeriveVisitor::DeriveVisitor (Location loc) +DeriveVisitor::DeriveVisitor (location_t loc) : loc (loc), builder (AstBuilder (loc)) {} diff --git a/gcc/rust/expand/rust-derive.h b/gcc/rust/expand/rust-derive.h index 01f3f02..f315f06 100644 --- a/gcc/rust/expand/rust-derive.h +++ b/gcc/rust/expand/rust-derive.h @@ -38,9 +38,9 @@ public: BuiltinMacro to_derive); protected: - DeriveVisitor (Location loc); + DeriveVisitor (location_t loc); - Location loc; + location_t loc; AstBuilder builder; private: diff --git a/gcc/rust/expand/rust-macro-builtins.cc b/gcc/rust/expand/rust-macro-builtins.cc index 82bb8d8..57949ad 100644 --- a/gcc/rust/expand/rust-macro-builtins.cc +++ b/gcc/rust/expand/rust-macro-builtins.cc @@ -75,7 +75,7 @@ const BiMap<std::string, BuiltinMacro> MacroBuiltin::builtins = {{ }}; std::unordered_map< - std::string, std::function<AST::Fragment (Location, AST::MacroInvocData &)>> + std::string, std::function<AST::Fragment (location_t, AST::MacroInvocData &)>> MacroBuiltin::builtin_transcribers = { {"assert", MacroBuiltin::assert_handler}, {"file", MacroBuiltin::file_handler}, @@ -221,7 +221,7 @@ macro_end_token (AST::DelimTokenTree &invoc_token_tree, /* Expand and then extract a string literal from the macro */ static std::unique_ptr<AST::LiteralExpr> -try_extract_string_literal_from_fragment (const Location &parent_locus, +try_extract_string_literal_from_fragment (const location_t &parent_locus, std::unique_ptr<AST::Expr> &node) { auto maybe_lit = static_cast<AST::LiteralExpr *> (node.get ()); @@ -287,7 +287,7 @@ try_expand_many_expr (Parser<MacroInvocLexer> &parser, std::unique_ptr<AST::Expr> parse_single_string_literal (BuiltinMacro kind, AST::DelimTokenTree &invoc_token_tree, - Location invoc_locus, MacroExpander *expander) + location_t invoc_locus, MacroExpander *expander) { MacroInvocLexer lex (invoc_token_tree.to_token_stream ()); Parser<MacroInvocLexer> parser (lex); @@ -372,7 +372,7 @@ source_relative_path (std::string path, location_t locus) FIXME: platform specific. */ std::vector<uint8_t> -load_file_bytes (Location invoc_locus, const char *filename) +load_file_bytes (location_t invoc_locus, const char *filename) { RAIIFile file_wrap (filename); if (file_wrap.get_raw () == nullptr) @@ -399,7 +399,8 @@ load_file_bytes (Location invoc_locus, const char *filename) } // namespace AST::Fragment -MacroBuiltin::assert_handler (Location invoc_locus, AST::MacroInvocData &invoc) +MacroBuiltin::assert_handler (location_t invoc_locus, + AST::MacroInvocData &invoc) { rust_debug ("assert!() called"); @@ -407,7 +408,7 @@ MacroBuiltin::assert_handler (Location invoc_locus, AST::MacroInvocData &invoc) } AST::Fragment -MacroBuiltin::file_handler (Location invoc_locus, AST::MacroInvocData &) +MacroBuiltin::file_handler (location_t invoc_locus, AST::MacroInvocData &) { auto current_file = LOCATION_FILE (invoc_locus); auto file_str = AST::SingleASTNode (make_string (invoc_locus, current_file)); @@ -418,7 +419,7 @@ MacroBuiltin::file_handler (Location invoc_locus, AST::MacroInvocData &) } AST::Fragment -MacroBuiltin::column_handler (Location invoc_locus, AST::MacroInvocData &) +MacroBuiltin::column_handler (location_t invoc_locus, AST::MacroInvocData &) { auto current_column = LOCATION_COLUMN (invoc_locus); @@ -436,7 +437,7 @@ MacroBuiltin::column_handler (Location invoc_locus, AST::MacroInvocData &) &'static [u8; N]. */ AST::Fragment -MacroBuiltin::include_bytes_handler (Location invoc_locus, +MacroBuiltin::include_bytes_handler (location_t invoc_locus, AST::MacroInvocData &invoc) { /* Get target filename from the macro invocation, which is treated as a path @@ -496,7 +497,7 @@ MacroBuiltin::include_bytes_handler (Location invoc_locus, expression of type &'static str. */ AST::Fragment -MacroBuiltin::include_str_handler (Location invoc_locus, +MacroBuiltin::include_str_handler (location_t invoc_locus, AST::MacroInvocData &invoc) { /* Get target filename from the macro invocation, which is treated as a path @@ -581,7 +582,7 @@ MacroBuiltin::include_str_handler (Location invoc_locus, /* Expand builtin macro compile_error!("error"), which forces a compile error during the compile time. */ AST::Fragment -MacroBuiltin::compile_error_handler (Location invoc_locus, +MacroBuiltin::compile_error_handler (location_t invoc_locus, AST::MacroInvocData &invoc) { auto lit_expr @@ -642,7 +643,8 @@ MacroBuiltin::compile_error_handler (Location invoc_locus, // Do we split the two passes of parsing the token tree and then expanding it? // Can we do that easily? AST::Fragment -MacroBuiltin::concat_handler (Location invoc_locus, AST::MacroInvocData &invoc) +MacroBuiltin::concat_handler (location_t invoc_locus, + AST::MacroInvocData &invoc) { auto invoc_token_tree = invoc.get_delim_tok_tree (); MacroInvocLexer lex (invoc_token_tree.to_token_stream ()); @@ -706,7 +708,7 @@ MacroBuiltin::concat_handler (Location invoc_locus, AST::MacroInvocData &invoc) /* Expand builtin macro env!(), which inspects an environment variable at compile time. */ AST::Fragment -MacroBuiltin::env_handler (Location invoc_locus, AST::MacroInvocData &invoc) +MacroBuiltin::env_handler (location_t invoc_locus, AST::MacroInvocData &invoc) { auto invoc_token_tree = invoc.get_delim_tok_tree (); MacroInvocLexer lex (invoc_token_tree.to_token_stream ()); @@ -780,7 +782,7 @@ MacroBuiltin::env_handler (Location invoc_locus, AST::MacroInvocData &invoc) } AST::Fragment -MacroBuiltin::cfg_handler (Location invoc_locus, AST::MacroInvocData &invoc) +MacroBuiltin::cfg_handler (location_t invoc_locus, AST::MacroInvocData &invoc) { // only parse if not already parsed if (!invoc.is_parsed ()) @@ -822,7 +824,8 @@ MacroBuiltin::cfg_handler (Location invoc_locus, AST::MacroInvocData &invoc) scope compile time. */ AST::Fragment -MacroBuiltin::include_handler (Location invoc_locus, AST::MacroInvocData &invoc) +MacroBuiltin::include_handler (location_t invoc_locus, + AST::MacroInvocData &invoc) { /* Get target filename from the macro invocation, which is treated as a path relative to the include!-ing file (currently being compiled). */ @@ -891,7 +894,7 @@ MacroBuiltin::include_handler (Location invoc_locus, AST::MacroInvocData &invoc) } AST::Fragment -MacroBuiltin::line_handler (Location invoc_locus, AST::MacroInvocData &) +MacroBuiltin::line_handler (location_t invoc_locus, AST::MacroInvocData &) { auto current_line = LOCATION_LINE (invoc_locus); @@ -906,7 +909,7 @@ MacroBuiltin::line_handler (Location invoc_locus, AST::MacroInvocData &) } AST::Fragment -MacroBuiltin::stringify_handler (Location invoc_locus, +MacroBuiltin::stringify_handler (location_t invoc_locus, AST::MacroInvocData &invoc) { std::string content; @@ -936,7 +939,7 @@ MacroBuiltin::stringify_handler (Location invoc_locus, } AST::Fragment -MacroBuiltin::sorry (Location invoc_locus, AST::MacroInvocData &invoc) +MacroBuiltin::sorry (location_t invoc_locus, AST::MacroInvocData &invoc) { rust_sorry_at (invoc_locus, "unimplemented builtin macro: %qs", invoc.get_path ().as_string ().c_str ()); @@ -945,7 +948,7 @@ MacroBuiltin::sorry (Location invoc_locus, AST::MacroInvocData &invoc) } AST::Fragment -MacroBuiltin::proc_macro_builtin (Location invoc_locus, +MacroBuiltin::proc_macro_builtin (location_t invoc_locus, AST::MacroInvocData &invoc) { rust_error_at (invoc_locus, "cannot invoke derive macro: %qs", diff --git a/gcc/rust/expand/rust-macro-builtins.h b/gcc/rust/expand/rust-macro-builtins.h index 87b6a1e..3bde262 100644 --- a/gcc/rust/expand/rust-macro-builtins.h +++ b/gcc/rust/expand/rust-macro-builtins.h @@ -118,51 +118,52 @@ class MacroBuiltin { public: static const BiMap<std::string, BuiltinMacro> builtins; - static std::unordered_map< - std::string, std::function<AST::Fragment (Location, AST::MacroInvocData &)>> + static std::unordered_map<std::string, std::function<AST::Fragment ( + location_t, AST::MacroInvocData &)>> builtin_transcribers; - static AST::Fragment assert_handler (Location invoc_locus, + static AST::Fragment assert_handler (location_t invoc_locus, AST::MacroInvocData &invoc); - static AST::Fragment file_handler (Location invoc_locus, + static AST::Fragment file_handler (location_t invoc_locus, AST::MacroInvocData &invoc); - static AST::Fragment column_handler (Location invoc_locus, + static AST::Fragment column_handler (location_t invoc_locus, AST::MacroInvocData &invoc); - static AST::Fragment include_bytes_handler (Location invoc_locus, + static AST::Fragment include_bytes_handler (location_t invoc_locus, AST::MacroInvocData &invoc); - static AST::Fragment include_str_handler (Location invoc_locus, + static AST::Fragment include_str_handler (location_t invoc_locus, AST::MacroInvocData &invoc); - static AST::Fragment stringify_handler (Location invoc_locus, + static AST::Fragment stringify_handler (location_t invoc_locus, AST::MacroInvocData &invoc); - static AST::Fragment compile_error_handler (Location invoc_locus, + static AST::Fragment compile_error_handler (location_t invoc_locus, AST::MacroInvocData &invoc); - static AST::Fragment concat_handler (Location invoc_locus, + static AST::Fragment concat_handler (location_t invoc_locus, AST::MacroInvocData &invoc); - static AST::Fragment env_handler (Location invoc_locus, + static AST::Fragment env_handler (location_t invoc_locus, AST::MacroInvocData &invoc); - static AST::Fragment cfg_handler (Location invoc_locus, + static AST::Fragment cfg_handler (location_t invoc_locus, AST::MacroInvocData &invoc); - static AST::Fragment include_handler (Location invoc_locus, + static AST::Fragment include_handler (location_t invoc_locus, AST::MacroInvocData &invoc); - static AST::Fragment line_handler (Location invoc_locus, + static AST::Fragment line_handler (location_t invoc_locus, AST::MacroInvocData &invoc); - static AST::Fragment sorry (Location invoc_locus, AST::MacroInvocData &invoc); + static AST::Fragment sorry (location_t invoc_locus, + AST::MacroInvocData &invoc); /* Builtin procedural macros do not work directly on tokens, but still need a * builtin transcriber to be considered proper builtin macros */ - static AST::Fragment proc_macro_builtin (Location, AST::MacroInvocData &); + static AST::Fragment proc_macro_builtin (location_t, AST::MacroInvocData &); }; } // namespace Rust diff --git a/gcc/rust/expand/rust-macro-expand.cc b/gcc/rust/expand/rust-macro-expand.cc index 28868af..09c8fc5 100644 --- a/gcc/rust/expand/rust-macro-expand.cc +++ b/gcc/rust/expand/rust-macro-expand.cc @@ -30,7 +30,7 @@ namespace Rust { AST::Fragment -MacroExpander::expand_decl_macro (Location invoc_locus, +MacroExpander::expand_decl_macro (location_t invoc_locus, AST::MacroInvocData &invoc, AST::MacroRulesDefinition &rules_def, bool semicolon) |