]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
mappings: Add get_lang_item_node
authorArthur Cohen <arthur.cohen@embecosm.com>
Thu, 26 Dec 2024 23:00:08 +0000 (23:00 +0000)
committerCohenArthur <arthur.cohen@embecosm.com>
Thu, 16 Jan 2025 14:00:31 +0000 (14:00 +0000)
This method errors out if the lang item has not been declared yet.

gcc/rust/ChangeLog:

* util/rust-hir-map.cc (Mappings::get_lang_item_node): New.
* util/rust-hir-map.h: New function.

gcc/rust/util/rust-hir-map.cc
gcc/rust/util/rust-hir-map.h

index 2edf0996276bbc806650ea5cc54a5462ecd6e000..bf09c94543e61764e7dc8761482b9a71cccd5869 100644 (file)
@@ -1299,5 +1299,15 @@ Mappings::lookup_lang_item_node (LangItem::Kind item_type)
   return it->second;
 }
 
+NodeId
+Mappings::get_lang_item_node (LangItem::Kind item_type)
+{
+  if (auto lookup = lookup_lang_item_node (item_type))
+    return *lookup;
+
+  rust_fatal_error (UNKNOWN_LOCATION, "failed to find lang item %qs",
+                   LangItem::ToString (item_type).c_str ());
+}
+
 } // namespace Analysis
 } // namespace Rust
index 6117b0ad8e0089a741e8fc2eeeb69bbbbdf3955d..9cf977a2b6912e6e57234f817a032a83e39822bc 100644 (file)
@@ -261,6 +261,7 @@ public:
 
   void insert_lang_item_node (LangItem::Kind item_type, NodeId node_id);
   tl::optional<NodeId &> lookup_lang_item_node (LangItem::Kind item_type);
+  NodeId get_lang_item_node (LangItem::Kind item_type);
 
   // This will fatal_error when this lang item does not exist
   DefId get_lang_item (LangItem::Kind item_type, location_t locus);