From: Pierre-Emmanuel Patry <pierre-emmanuel.pa...@embecosm.com> Change the return type to an optional.
gcc/rust/ChangeLog: * util/rust-hir-map.cc (Mappings::resolve_nodeid_to_stmt): Change the return type and remove pointer out argument. * util/rust-hir-map.h: Update function prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.pa...@embecosm.com> --- gcc/rust/util/rust-hir-map.cc | 10 ++++------ gcc/rust/util/rust-hir-map.h | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc index b8d393759d6..57a766758d9 100644 --- a/gcc/rust/util/rust-hir-map.cc +++ b/gcc/rust/util/rust-hir-map.cc @@ -805,17 +805,15 @@ Mappings::lookup_location (HirId id) return it->second; } -bool -Mappings::resolve_nodeid_to_stmt (NodeId id, HIR::Stmt **stmt) +tl::optional<HIR::Stmt *> +Mappings::resolve_nodeid_to_stmt (NodeId id) { auto it = nodeIdToHirMappings.find (id); if (it == nodeIdToHirMappings.end ()) - return false; + return tl::nullopt; HirId resolved = it->second; - auto resolved_stmt = lookup_hir_stmt (resolved); - *stmt = resolved_stmt; - return resolved_stmt != nullptr; + return {lookup_hir_stmt (resolved)}; } void diff --git a/gcc/rust/util/rust-hir-map.h b/gcc/rust/util/rust-hir-map.h index 6fd0e7a52f4..6ed3beee8fc 100644 --- a/gcc/rust/util/rust-hir-map.h +++ b/gcc/rust/util/rust-hir-map.h @@ -176,7 +176,7 @@ public: void insert_location (HirId id, location_t locus); location_t lookup_location (HirId id); - bool resolve_nodeid_to_stmt (NodeId id, HIR::Stmt **stmt); + tl::optional<HIR::Stmt *> resolve_nodeid_to_stmt (NodeId id); std::set<HirId> &get_hirids_within_crate (CrateNum crate) { -- 2.45.2