From 1d7d56aab77fa53e3cba8a885208a07772d91a76 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Sat, 4 May 2024 03:21:27 +0200 Subject: gccrs: Change lookup_macro_invocation's return type Wrap the function's return type within an optional and remove the out reference argument. gcc/rust/ChangeLog: * expand/rust-macro-expand.cc (MacroExpander::expand_invoc): Adapt the function call to match its new prototype. * resolve/rust-early-name-resolver-2.0.cc (Early::insert_once): Likewise. (Early::visit): Likewise. * resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Likewise. * util/rust-hir-map.cc (Mappings::lookup_macro_invocation): Change the function's return type. * util/rust-hir-map.h: Update the function's prototype. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/util/rust-hir-map.cc | 10 ++++------ gcc/rust/util/rust-hir-map.h | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'gcc/rust/util') diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc index f6df55f..3b72119 100644 --- a/gcc/rust/util/rust-hir-map.cc +++ b/gcc/rust/util/rust-hir-map.cc @@ -897,16 +897,14 @@ Mappings::insert_macro_invocation (AST::MacroInvocation &invoc, macroInvocations[invoc.get_macro_node_id ()] = def; } -bool -Mappings::lookup_macro_invocation (AST::MacroInvocation &invoc, - AST::MacroRulesDefinition **def) +tl::optional +Mappings::lookup_macro_invocation (AST::MacroInvocation &invoc) { auto it = macroInvocations.find (invoc.get_macro_node_id ()); if (it == macroInvocations.end ()) - return false; + return tl::nullopt; - *def = it->second; - return true; + return it->second; } void diff --git a/gcc/rust/util/rust-hir-map.h b/gcc/rust/util/rust-hir-map.h index 3747804..d80a15e 100644 --- a/gcc/rust/util/rust-hir-map.h +++ b/gcc/rust/util/rust-hir-map.h @@ -282,8 +282,8 @@ public: void insert_macro_invocation (AST::MacroInvocation &invoc, AST::MacroRulesDefinition *def); - bool lookup_macro_invocation (AST::MacroInvocation &invoc, - AST::MacroRulesDefinition **def); + tl::optional + lookup_macro_invocation (AST::MacroInvocation &invoc); void insert_exported_macro (AST::MacroRulesDefinition &def); std::vector &get_exported_macros (); -- cgit v1.1