aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/util
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2024-05-04 02:42:10 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-17 16:35:26 +0100
commite4778eceb42e914e4d202f851cd71f426f19ef7e (patch)
tree905dcfaf6f2733097f93840a104216b09f952c55 /gcc/rust/util
parent80c44d211c0d57f6e34f6dc57599ec6754e19f27 (diff)
downloadgcc-e4778eceb42e914e4d202f851cd71f426f19ef7e.zip
gcc-e4778eceb42e914e4d202f851cd71f426f19ef7e.tar.gz
gcc-e4778eceb42e914e4d202f851cd71f426f19ef7e.tar.bz2
gccrs: Change lookup_macro_def return type
Wrap the function's return type within an optional. gcc/rust/ChangeLog: * resolve/rust-early-name-resolver-2.0.cc (Early::insert_once): Change call site to accomodate the new return type. (Early::visit): Likewise. * resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Likewise. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Likewise. * util/rust-hir-map.cc (Mappings::lookup_macro_def): Change the function's return type. * util/rust-hir-map.h: Update the function's prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust/util')
-rw-r--r--gcc/rust/util/rust-hir-map.cc9
-rw-r--r--gcc/rust/util/rust-hir-map.h2
2 files changed, 5 insertions, 6 deletions
diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc
index 2ac6141..f6df55f 100644
--- a/gcc/rust/util/rust-hir-map.cc
+++ b/gcc/rust/util/rust-hir-map.cc
@@ -877,15 +877,14 @@ Mappings::insert_macro_def (AST::MacroRulesDefinition *macro)
macroMappings[macro->get_node_id ()] = macro;
}
-bool
-Mappings::lookup_macro_def (NodeId id, AST::MacroRulesDefinition **def)
+tl::optional<AST::MacroRulesDefinition *>
+Mappings::lookup_macro_def (NodeId id)
{
auto it = macroMappings.find (id);
if (it == macroMappings.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 eafa2ae..3747804 100644
--- a/gcc/rust/util/rust-hir-map.h
+++ b/gcc/rust/util/rust-hir-map.h
@@ -278,7 +278,7 @@ public:
void insert_macro_def (AST::MacroRulesDefinition *macro);
- bool lookup_macro_def (NodeId id, AST::MacroRulesDefinition **def);
+ tl::optional<AST::MacroRulesDefinition *> lookup_macro_def (NodeId id);
void insert_macro_invocation (AST::MacroInvocation &invoc,
AST::MacroRulesDefinition *def);