From: Pierre-Emmanuel Patry <[email protected]>
Remove attribute specific checking, use default ast visitor instead.
gcc/rust/ChangeLog:
* util/rust-attributes.cc (AttributeChecker::visit): Rename function
and make call to ast default visitor.
(AttributeChecker::check_attribute): Remove function.
* util/rust-attributes.h: Add function prototype.
Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.
Commit on github:
https://github.com/Rust-GCC/gccrs/commit/f1d8340fa3a27530f20665e3af3c70025a82d354
The commit has been mentioned in the following pull-request(s):
- https://github.com/Rust-GCC/gccrs/pull/4425
gcc/rust/util/rust-attributes.cc | 9 ++++-----
gcc/rust/util/rust-attributes.h | 2 +-
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/gcc/rust/util/rust-attributes.cc b/gcc/rust/util/rust-attributes.cc
index 719a972c9..3fe01c4ff 100644
--- a/gcc/rust/util/rust-attributes.cc
+++ b/gcc/rust/util/rust-attributes.cc
@@ -192,7 +192,6 @@ AttributeChecker::visit (AST::Crate &crate)
for (auto &attr : crate.get_inner_attrs ())
{
check_inner_attribute (attr);
- check_attribute (attr);
}
for (auto &item : crate.items)
@@ -551,7 +550,7 @@ check_lint_attribute (const AST::Attribute &attribute,
const char *name)
}
void
-AttributeChecker::check_attribute (const AST::Attribute &attribute)
+AttributeChecker::visit (AST::Attribute &attribute)
{
if (!attribute.empty_input ())
{
@@ -892,7 +891,6 @@ AttributeChecker::visit (AST::Module &module)
for (auto &attr : module.get_outer_attrs ())
{
check_valid_attribute_for_item (attr, module);
- check_attribute (attr);
check_proc_macro_non_function (attr);
}
@@ -1067,9 +1065,10 @@ AttributeChecker::visit (AST::StructStruct &struct_item)
for (auto &attr : struct_item.get_outer_attrs ())
{
check_valid_attribute_for_item (attr, struct_item);
- check_attribute (attr);
check_proc_macro_non_function (attr);
}
+
+ AST::DefaultASTVisitor::visit (struct_item);
}
void
@@ -1157,8 +1156,8 @@ AttributeChecker::visit (AST::Trait &trait)
{
check_valid_attribute_for_item (attr, trait);
check_proc_macro_non_function (attr);
- check_attribute (attr);
}
+ AST::DefaultASTVisitor::visit (trait);
}
void
diff --git a/gcc/rust/util/rust-attributes.h b/gcc/rust/util/rust-attributes.h
index bae160167..f63f90236 100644
--- a/gcc/rust/util/rust-attributes.h
+++ b/gcc/rust/util/rust-attributes.h
@@ -106,9 +106,9 @@ private:
/* Check the validity of an inner attribute */
void check_inner_attribute (const AST::Attribute &attribute);
/* Check the validity of a given attribute */
- void check_attribute (const AST::Attribute &attribute);
// rust-ast.h
+ void visit (AST::Attribute &attribute) override;
void visit (AST::Crate &crate) override;
void visit (AST::Token &tok) override;
void visit (AST::DelimTokenTree &delim_tok_tree) override;
--
2.53.0