aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-ast-fragment.cc
diff options
context:
space:
mode:
authorMarc Poulhiès <dkm@kataplop.net>2023-07-19 10:54:52 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 18:56:04 +0100
commit58b49a65a3f91f0f6643dc973f46911363148c16 (patch)
treeac0de3c24d0e9479aaee3969f232c84ff4d8c7d2 /gcc/rust/ast/rust-ast-fragment.cc
parent432cdee6a6e28c52dae6b69079db301b9681485b (diff)
downloadgcc-58b49a65a3f91f0f6643dc973f46911363148c16.zip
gcc-58b49a65a3f91f0f6643dc973f46911363148c16.tar.gz
gcc-58b49a65a3f91f0f6643dc973f46911363148c16.tar.bz2
gccrs: use tl::optional for macro transcribers
refs #2421. gcc/rust/ChangeLog: * ast/rust-ast-fragment.cc (Fragment::create_empty): New. * ast/rust-ast-fragment.h (MacroTranscriberFunc): New. * ast/rust-macro.h (MacroRulesDefinition): Use MacroTranscriberFunc. * expand/rust-macro-builtins.cc (MacroBuiltin::builtin_transcribers): likewise. (MacroBuiltin::assert_handler): Return optional. (MacroBuiltin::file_handler): Likewise. (MacroBuiltin::column_handler): Likewise. (MacroBuiltin::include_bytes_handler): Likewise. (MacroBuiltin::include_str_handler): Likewise. (MacroBuiltin::compile_error_handler): Likewise. (MacroBuiltin::concat_handler): Likewise. (MacroBuiltin::env_handler): Likewise. (MacroBuiltin::cfg_handler): Likewise. (MacroBuiltin::include_handler): Likewise. (MacroBuiltin::line_handler): Likewise. (MacroBuiltin::stringify_handler): Likewise. (MacroBuiltin::sorry): Likewise. * expand/rust-macro-builtins.h (builtin_transcribers): Use MacroTranscriberFunc. (assert_handler): Return optional. (file_handler): Likewise. (column_handler): Likewise. (include_bytes_handler): Likewise. (include_str_handler): Likewise. (compile_error_handler): Likewise. (concat_handler): Likewise. (env_handler): Likewise. (cfg_handler): Likewise. (include_handler): Likewise. (line_handler): Likewise. (stringify_handler): Likewise. (sorry): Likewise. * expand/rust-macro-expand.cc (MacroExpander::expand_invoc): Adjust to transcribers returning optional. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Diffstat (limited to 'gcc/rust/ast/rust-ast-fragment.cc')
-rw-r--r--gcc/rust/ast/rust-ast-fragment.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/rust/ast/rust-ast-fragment.cc b/gcc/rust/ast/rust-ast-fragment.cc
index 0814ef4..e757451 100644
--- a/gcc/rust/ast/rust-ast-fragment.cc
+++ b/gcc/rust/ast/rust-ast-fragment.cc
@@ -55,6 +55,12 @@ Fragment::create_error ()
return Fragment (FragmentKind::Error, {}, {});
}
+Fragment
+Fragment::create_empty ()
+{
+ return Fragment (FragmentKind::Complete, {}, {});
+}
+
Fragment::Fragment (std::vector<AST::SingleASTNode> nodes,
std::vector<std::unique_ptr<AST::Token>> tokens)
: kind (FragmentKind::Complete), nodes (std::move (nodes)),