Skip to content

Commit

Permalink
gcc/rust/ChangeLog:
Browse files Browse the repository at this point in the history
	* 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>
  • Loading branch information
saeitoshi-10 committed Jan 2, 2025
1 parent 6205877 commit 6c304d2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
12 changes: 2 additions & 10 deletions gcc/rust/resolve/rust-early-name-resolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::unique_ptr<AST::Item>>
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
Expand Down
9 changes: 9 additions & 0 deletions gcc/rust/util/rust-attributes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions gcc/rust/util/rust-attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6c304d2

Please sign in to comment.