From 0030d011f6b235b04399f0c8915913c2b3e1ecbe Mon Sep 17 00:00:00 2001 From: Om Swaroop Nayak <96killerat96@gmail.com> Date: Wed, 1 Jan 2025 09:02:02 -0800 Subject: [PATCH] gcc/rust/ChangeLog: * ast/rust-collect-lang-items.cc (get_lang_item_attr): "removed checker fn" * util/rust-attributes.cc (Attributes::is_lang_item): "added fn" * util/rust-attributes.h: "added fn" Signed-off-by: Om Swaroop Nayak <96killerat96@gmail.com> --- gcc/rust/ast/rust-collect-lang-items.cc | 7 +------ gcc/rust/util/rust-attributes.cc | 8 ++++++++ gcc/rust/util/rust-attributes.h | 2 ++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/gcc/rust/ast/rust-collect-lang-items.cc b/gcc/rust/ast/rust-collect-lang-items.cc index 50d134a429f5..ec6919dca14e 100644 --- a/gcc/rust/ast/rust-collect-lang-items.cc +++ b/gcc/rust/ast/rust-collect-lang-items.cc @@ -40,12 +40,7 @@ get_lang_item_attr (const T &maybe_lang_item) continue; } - bool is_lang_item = str_path == Values::Attributes::LANG - && attr.has_attr_input () - && attr.get_attr_input ().get_attr_input_type () - == AST::AttrInput::AttrInputType::LITERAL; - - if (is_lang_item) + if (Analysis::Attributes::is_lang_item (str_path, attr)) { auto &literal = static_cast (attr.get_attr_input ()); diff --git a/gcc/rust/util/rust-attributes.cc b/gcc/rust/util/rust-attributes.cc index 45ebf8c65461..1a66be25ccfb 100644 --- a/gcc/rust/util/rust-attributes.cc +++ b/gcc/rust/util/rust-attributes.cc @@ -37,6 +37,14 @@ Attributes::is_known (const std::string &attribute_path) return !lookup.is_error (); } +bool +Attributes::is_lang_item (const std::string &attribute_path, + const AST::Attribute &attr) +{ + return ((attribute_path == Values::Attributes::LANG) && attr.has_attr_input () + && (attr.get_attr_input ().get_attr_input_type () + == AST::AttrInput::AttrInputType::LITERAL)); +} using Attrs = Values::Attributes; diff --git a/gcc/rust/util/rust-attributes.h b/gcc/rust/util/rust-attributes.h index c341b3e0a5db..c0d1bed64455 100644 --- a/gcc/rust/util/rust-attributes.h +++ b/gcc/rust/util/rust-attributes.h @@ -29,6 +29,8 @@ class Attributes { public: static bool is_known (const std::string &attribute_path); + static bool is_lang_item (const std::string &attribute_path, + const AST::Attribute &attr); }; enum CompilerPass