aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/util/rust-hir-map.cc
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2024-05-03 19:40:18 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-17 16:35:25 +0100
commit4dd34b1fd1241afeeb4fa7e6f5848a6c1af5430b (patch)
tree66ed41ea3e36d657be795ff1234b36a1800963dc /gcc/rust/util/rust-hir-map.cc
parent01e2a53cb84f959f400af79172843e4bc906ff9a (diff)
downloadgcc-4dd34b1fd1241afeeb4fa7e6f5848a6c1af5430b.zip
gcc-4dd34b1fd1241afeeb4fa7e6f5848a6c1af5430b.tar.gz
gcc-4dd34b1fd1241afeeb4fa7e6f5848a6c1af5430b.tar.bz2
gccrs: Change lookup_hir_expr return type to optional
Wrap the function's return type with an optional in order to differentiate missing values from null pointers. gcc/rust/ChangeLog: * backend/rust-mangle-v0.cc (v0_path): Adapt call site to new returned type. * util/rust-hir-map.cc (Mappings::lookup_hir_expr): 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/rust/util/rust-hir-map.cc')
-rw-r--r--gcc/rust/util/rust-hir-map.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc
index 89c990d..8078649 100644
--- a/gcc/rust/util/rust-hir-map.cc
+++ b/gcc/rust/util/rust-hir-map.cc
@@ -536,12 +536,12 @@ Mappings::insert_hir_expr (HIR::Expr *expr)
insert_location (id, expr->get_locus ());
}
-HIR::Expr *
+tl::optional<HIR::Expr *>
Mappings::lookup_hir_expr (HirId id)
{
auto it = hirExprMappings.find (id);
if (it == hirExprMappings.end ())
- return nullptr;
+ return tl::nullopt;
return it->second;
}