]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
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)
committerP-E-P <32375388+P-E-P@users.noreply.github.com>
Fri, 17 May 2024 15:28:30 +0000 (15:28 +0000)
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 3083f2c4d6f31727cc3fd903c98dd06340f008f1..3fb64960373930062c799c0f94177acafbb7edcb 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 15b1142447114b093309be260e66cd915fe01908..f8c3cb1809c4c65b18dd323f5fd5f5ac4fb31a80 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);