From 6c304d215a331e4977cef91ab0d120942ba1d44c Mon Sep 17 00:00:00 2001 From: Om Swaroop Nayak <96killerat96@gmail.com> Date: Thu, 2 Jan 2025 09:38:56 -0800 Subject: [PATCH] gcc/rust/ChangeLog: * resolve/rust-early-name-resolver.cc (is_macro_use_module): "removed checker fn" (EarlyNameResolver::accumulate_escaped_macros): "modified " * util/rust-attributes.cc (Attributes::is_macro_use_module):"added checker fn" * util/rust-attributes.h: "added " Signed-off-by: Om Swaroop Nayak <96killerat96@gmail.com> --- gcc/rust/resolve/rust-early-name-resolver.cc | 12 ++---------- gcc/rust/util/rust-attributes.cc | 9 +++++++++ gcc/rust/util/rust-attributes.h | 1 + 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/gcc/rust/resolve/rust-early-name-resolver.cc b/gcc/rust/resolve/rust-early-name-resolver.cc index 634523181139..342ab906e866 100644 --- a/gcc/rust/resolve/rust-early-name-resolver.cc +++ b/gcc/rust/resolve/rust-early-name-resolver.cc @@ -21,25 +21,17 @@ #include "rust-name-resolver.h" #include "rust-macro-builtins.h" #include "rust-attribute-values.h" +#include "rust-attributes.h" namespace Rust { namespace Resolver { // Check if a module contains the `#[macro_use]` attribute -static bool -is_macro_use_module (const AST::Module &mod) -{ - for (const auto &attr : mod.get_outer_attrs ()) - if (attr.get_path ().as_string () == Values::Attributes::MACRO_USE) - return true; - - return false; -} std::vector> EarlyNameResolver::accumulate_escaped_macros (AST::Module &module) { - if (!is_macro_use_module (module)) + if (!Analysis::Attributes::is_macro_use_module (module)) return {}; // Parse the module's items if they haven't been expanded and the file diff --git a/gcc/rust/util/rust-attributes.cc b/gcc/rust/util/rust-attributes.cc index 45ebf8c65461..7a4ee8811a59 100644 --- a/gcc/rust/util/rust-attributes.cc +++ b/gcc/rust/util/rust-attributes.cc @@ -37,6 +37,15 @@ Attributes::is_known (const std::string &attribute_path) return !lookup.is_error (); } +bool +Attributes::is_macro_use_module (const AST::Module &mod) +{ + for (const auto &attr : mod.get_outer_attrs ()) + if (attr.get_path ().as_string () == Values::Attributes::MACRO_USE) + return true; + + return false; +} using Attrs = Values::Attributes; diff --git a/gcc/rust/util/rust-attributes.h b/gcc/rust/util/rust-attributes.h index c341b3e0a5db..434b8604f13d 100644 --- a/gcc/rust/util/rust-attributes.h +++ b/gcc/rust/util/rust-attributes.h @@ -29,6 +29,7 @@ class Attributes { public: static bool is_known (const std::string &attribute_path); + static bool is_macro_use_module (const AST::Module &mod); }; enum CompilerPass