aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2024-05-03 20:42:06 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-17 16:35:25 +0100
commit2c08ad6c41cedc09401718060911198b025cd1ec (patch)
tree8fa8daac77dae92e7f2b54ee0cd9bae0482ba5e3 /gcc
parentbcc66efaf14af971c080b6128ea30d51c2b41516 (diff)
downloadgcc-2c08ad6c41cedc09401718060911198b025cd1ec.zip
gcc-2c08ad6c41cedc09401718060911198b025cd1ec.tar.gz
gcc-2c08ad6c41cedc09401718060911198b025cd1ec.tar.bz2
gccrs: Change lookup_hir_self_param return type
Wrap the function's return type within an optional in order to differentiate null pointers from missing value. gcc/rust/ChangeLog: * util/rust-hir-map.cc (Mappings::insert_hir_self_param): Adapt call site to new return type. (Mappings::lookup_hir_self_param): 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')
-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 e2c3b98..f124be8 100644
--- a/gcc/rust/util/rust-hir-map.cc
+++ b/gcc/rust/util/rust-hir-map.cc
@@ -652,18 +652,18 @@ void
Mappings::insert_hir_self_param (HIR::SelfParam *param)
{
auto id = param->get_mappings ().get_hirid ();
- rust_assert (lookup_hir_self_param (id) == nullptr);
+ rust_assert (!lookup_hir_self_param (id));
hirSelfParamMappings[id] = param;
insert_node_to_hir (param->get_mappings ().get_nodeid (), id);
}
-HIR::SelfParam *
+tl::optional<HIR::SelfParam *>
Mappings::lookup_hir_self_param (HirId id)
{
auto it = hirSelfParamMappings.find (id);
if (it == hirSelfParamMappings.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 6f97dcb..720dd97 100644
--- a/gcc/rust/util/rust-hir-map.h
+++ b/gcc/rust/util/rust-hir-map.h
@@ -164,7 +164,7 @@ public:
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);
+ tl::optional<HIR::SelfParam *> lookup_hir_self_param (HirId id);
void insert_hir_struct_field (HIR::StructExprField *type);
HIR::StructExprField *lookup_hir_struct_field (HirId id);