]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Change return type of resolve_nodeid_to_stmt
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Wed, 24 Apr 2024 21:21:57 +0000 (23:21 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Mon, 17 Mar 2025 15:35:23 +0000 (16:35 +0100)
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.patry@embecosm.com>
gcc/rust/util/rust-hir-map.cc
gcc/rust/util/rust-hir-map.h

index b8d393759d6a46333fe667008ca19e2985de6690..57a766758d9a53f04f5d7b9edd558c7c6ba43d0c 100644 (file)
@@ -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
index 6fd0e7a52f4cd6681dd266768a5c143facf47ab7..6ed3beee8fc45984cf6d5ccdb2e9fe7c0bbe6124 100644 (file)
@@ -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)
   {