aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2024-04-24 23:21:57 +0200
committerP-E-P <32375388+P-E-P@users.noreply.github.com>2024-05-17 15:28:30 +0000
commit73f87d81c0ee1af1f9e9cc838e16653729173851 (patch)
tree7772813586d8f6156867b9d605196f25d1a99e9c /gcc
parent402d329819bebd43918aaa68adb698fb4989f987 (diff)
downloadgcc-73f87d81c0ee1af1f9e9cc838e16653729173851.zip
gcc-73f87d81c0ee1af1f9e9cc838e16653729173851.tar.gz
gcc-73f87d81c0ee1af1f9e9cc838e16653729173851.tar.bz2
Change return type of resolve_nodeid_to_stmt
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>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/util/rust-hir-map.cc10
-rw-r--r--gcc/rust/util/rust-hir-map.h2
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 06f3e7a..6d97771 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 753b2e0..039ace5 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)
{