]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Change lookup_hir_param return type with optional
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Fri, 3 May 2024 18:34:58 +0000 (20:34 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Mon, 17 Mar 2025 15:35:25 +0000 (16:35 +0100)
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>
gcc/rust/util/rust-hir-map.cc
gcc/rust/util/rust-hir-map.h

index 025b3121b2737acf9aca53c951de15319293c965..e2c3b98eff5bb5433c06a18b8454d9bf23143dde 100644 (file)
@@ -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;
 }
index f6db83d6e117e3c46c0c234c376fe52b00929844..6f97dcb6bc6a375863dd7f99557f88ed03f9a54c 100644 (file)
@@ -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);