diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2024-05-03 20:08:14 +0200 |
---|---|---|
committer | P-E-P <32375388+P-E-P@users.noreply.github.com> | 2024-05-17 15:28:30 +0000 |
commit | 1746979fc55534bd8a2b26ac6d9fdf6b5fdca66e (patch) | |
tree | 854d10ad163ba6bb11fcd2a49d5f78595bec6b60 | |
parent | 1e6a3ee55ed907f6e71e6fccbd872b6f80e8298e (diff) | |
download | gcc-1746979fc55534bd8a2b26ac6d9fdf6b5fdca66e.zip gcc-1746979fc55534bd8a2b26ac6d9fdf6b5fdca66e.tar.gz gcc-1746979fc55534bd8a2b26ac6d9fdf6b5fdca66e.tar.bz2 |
Change lookup_hir_type return type with an optional
Wrap the function's return type with an optional in order to tell
appart a null pointer from a missing value.
gcc/rust/ChangeLog:
* util/rust-hir-map.cc (Mappings::insert_hir_type): Change call site
to accomodate the new return type.
(Mappings::lookup_hir_type): 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>
-rw-r--r-- | gcc/rust/util/rust-hir-map.cc | 6 | ||||
-rw-r--r-- | gcc/rust/util/rust-hir-map.h | 2 |
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 457e8af..de6cb4d 100644 --- a/gcc/rust/util/rust-hir-map.cc +++ b/gcc/rust/util/rust-hir-map.cc @@ -592,18 +592,18 @@ void Mappings::insert_hir_type (HIR::Type *type) { auto id = type->get_mappings ().get_hirid (); - rust_assert (lookup_hir_type (id) == nullptr); + rust_assert (!lookup_hir_type (id)); hirTypeMappings[id] = type; insert_node_to_hir (type->get_mappings ().get_nodeid (), id); } -HIR::Type * +tl::optional<HIR::Type *> Mappings::lookup_hir_type (HirId id) { auto it = hirTypeMappings.find (id); if (it == hirTypeMappings.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 2c15097..583f630 100644 --- a/gcc/rust/util/rust-hir-map.h +++ b/gcc/rust/util/rust-hir-map.h @@ -155,7 +155,7 @@ public: tl::optional<HIR::GenericParam *> lookup_hir_generic_param (HirId id); void insert_hir_type (HIR::Type *type); - HIR::Type *lookup_hir_type (HirId id); + tl::optional<HIR::Type *> lookup_hir_type (HirId id); void insert_hir_stmt (HIR::Stmt *stmt); HIR::Stmt *lookup_hir_stmt (HirId id); |