From 7c136422a14ef57e7f7cc37a4b8c044405914ed9 Mon Sep 17 00:00:00 2001 From: Om Swaroop Nayak <96killerat96@gmail.com> Date: Tue, 31 Dec 2024 10:44:54 -0800 Subject: [PATCH] gcc/rust/ChangeLog: * ast/rust-collect-lang-items.cc (get_lang_item_attr): "removed a static attribute checker function" * util/rust-attributes.cc (Attributes::is_lang_item): "added the checker function" * util/rust-attributes.h: "Header file" Signed-off-by: Om Swaroop Nayak <96killerat96@gmail.com> --- gcc/rust/ast/rust-collect-lang-items.cc | 7 +------ gcc/rust/util/rust-attributes.cc | 9 ++++++++- gcc/rust/util/rust-attributes.h | 2 ++ 3 files changed, 11 insertions(+), 7 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..526922844be5 100644 --- a/gcc/rust/util/rust-attributes.cc +++ b/gcc/rust/util/rust-attributes.cc @@ -37,7 +37,14 @@ Attributes::is_known (const std::string &attribute_path) return !lookup.is_error (); } - +bool +Attributes::is_lang_item (const std::string &attribute_path, + 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; // https://doc.rust-lang.org/stable/nightly-rustc/src/rustc_feature/builtin_attrs.rs.html#248 diff --git a/gcc/rust/util/rust-attributes.h b/gcc/rust/util/rust-attributes.h index c341b3e0a5db..09e500a04bbc 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, + AST::Attribute &attr); }; enum CompilerPass