aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2024-05-03 20:34:58 +0200
committerP-E-P <32375388+P-E-P@users.noreply.github.com>2024-05-17 15:28:30 +0000
commitb4927ee8b13e2f7501bc258c14f67b2b6bb42a0e (patch)
tree5950908411acd24c8ea19f6386d672825b1779a0
parent0e7cff81b25b43a7a94de591ea03484e60334879 (diff)
downloadgcc-b4927ee8b13e2f7501bc258c14f67b2b6bb42a0e.zip
gcc-b4927ee8b13e2f7501bc258c14f67b2b6bb42a0e.tar.gz
gcc-b4927ee8b13e2f7501bc258c14f67b2b6bb42a0e.tar.bz2
Change lookup_hir_param return type with optional
Wrap the function's return type within an optional to differentiate between a null ppointer and a missing value. gcc/rust/ChangeLog: * util/rust-hir-map.cc (Mappings::insert_hir_param): Change call site to accomodate new return type. (Mappings::lookup_hir_param): Change the function's return type. * util/rust-hir-map.h: Updat ethe function's prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
-rw-r--r--gcc/rust/util/rust-hir-map.cc6
-rw-r--r--gcc/rust/util/rust-hir-map.h2
2 files changed, 4 insertions, 4 deletions
diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc
index 3083f2c..3fb6496 100644
--- a/gcc/rust/util/rust-hir-map.cc
+++ b/gcc/rust/util/rust-hir-map.cc
@@ -632,18 +632,18 @@ void
Mappings::insert_hir_param (HIR::FunctionParam *param)
{
auto id = param->get_mappings ().get_hirid ();
- rust_assert (lookup_hir_param (id) == nullptr);
+ rust_assert (!lookup_hir_param (id));
hirParamMappings[id] = param;
insert_node_to_hir (param->get_mappings ().get_nodeid (), id);
}
-HIR::FunctionParam *
+tl::optional<HIR::FunctionParam *>
Mappings::lookup_hir_param (HirId id)
{
auto it = hirParamMappings.find (id);
if (it == hirParamMappings.end ())
- return nullptr;
+ return tl::nullopt;
return it->second;
}
diff --git a/gcc/rust/util/rust-hir-map.h b/gcc/rust/util/rust-hir-map.h
index 15b1142..f8c3cb1 100644
--- a/gcc/rust/util/rust-hir-map.h
+++ b/gcc/rust/util/rust-hir-map.h
@@ -161,7 +161,7 @@ public:
tl::optional<HIR::Stmt *> lookup_hir_stmt (HirId id);
void insert_hir_param (HIR::FunctionParam *type);
- HIR::FunctionParam *lookup_hir_param (HirId id);
+ tl::optional<HIR::FunctionParam *> lookup_hir_param (HirId id);
void insert_hir_self_param (HIR::SelfParam *type);
HIR::SelfParam *lookup_hir_self_param (HirId id);