aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2024-05-03 20:55:01 +0200
committerP-E-P <32375388+P-E-P@users.noreply.github.com>2024-05-17 15:28:30 +0000
commit36518ef25d5f3d625ff9501f66d8c300f076e748 (patch)
tree41a635c7e880f124f0390586ed3b496dd3739b5b /gcc
parente956f3a7bbf0d1e31d15bc46bd3451172a9b8869 (diff)
downloadgcc-36518ef25d5f3d625ff9501f66d8c300f076e748.zip
gcc-36518ef25d5f3d625ff9501f66d8c300f076e748.tar.gz
gcc-36518ef25d5f3d625ff9501f66d8c300f076e748.tar.bz2
Change lookup_hir_pattern return type
Wrap the function's return type within an optional in order to differentiate between a null pointer and a missing value. gcc/rust/ChangeLog: * util/rust-hir-map.cc (Mappings::insert_hir_pattern): Change call site in order to accomodate new return type. (Mappings::lookup_hir_pattern): 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 1e5d322..c0d9a65 100644
--- a/gcc/rust/util/rust-hir-map.cc
+++ b/gcc/rust/util/rust-hir-map.cc
@@ -692,18 +692,18 @@ void
Mappings::insert_hir_pattern (HIR::Pattern *pattern)
{
auto id = pattern->get_mappings ().get_hirid ();
- rust_assert (lookup_hir_pattern (id) == nullptr);
+ rust_assert (!lookup_hir_pattern (id));
hirPatternMappings[id] = pattern;
insert_node_to_hir (pattern->get_mappings ().get_nodeid (), id);
}
-HIR::Pattern *
+tl::optional<HIR::Pattern *>
Mappings::lookup_hir_pattern (HirId id)
{
auto it = hirPatternMappings.find (id);
if (it == hirPatternMappings.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 d613d7f..8676964 100644
--- a/gcc/rust/util/rust-hir-map.h
+++ b/gcc/rust/util/rust-hir-map.h
@@ -170,7 +170,7 @@ public:
tl::optional<HIR::StructExprField *> lookup_hir_struct_field (HirId id);
void insert_hir_pattern (HIR::Pattern *pattern);
- HIR::Pattern *lookup_hir_pattern (HirId id);
+ tl::optional<HIR::Pattern *> lookup_hir_pattern (HirId id);
void walk_local_defids_for_crate (CrateNum crateNum,
std::function<bool (HIR::Item *)> cb);