public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Arthur Cohen <cohenarthur@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-7975] gccrs: Make is_builtin a member function Date: Tue, 16 Jan 2024 18:10:13 +0000 (GMT) [thread overview] Message-ID: <20240116181013.EBD1A3857738@sourceware.org> (raw) https://gcc.gnu.org/g:ad1f51084946125ceb33a0086d42fac0f42460be commit r14-7975-gad1f51084946125ceb33a0086d42fac0f42460be Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> Date: Fri Jul 28 17:26:50 2023 +0200 gccrs: Make is_builtin a member function This function will be used in the multiple other places, therefore we should make it easily usable from there. gcc/rust/ChangeLog: * ast/rust-ast.cc (Attribute::is_derive): Add member function. * ast/rust-ast.h: Likewise. * expand/rust-expand-visitor.cc (is_derive): Remove old function. (ExpandVisitor::expand_inner_stmts): Update function call. (ExpandVisitor::visit_inner_using_attrs): Likewise. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> Diff: --- gcc/rust/ast/rust-ast.cc | 9 +++++++++ gcc/rust/ast/rust-ast.h | 2 ++ gcc/rust/expand/rust-expand-visitor.cc | 16 +++------------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/gcc/rust/ast/rust-ast.cc b/gcc/rust/ast/rust-ast.cc index eb133aaec24..434c2768bc5 100644 --- a/gcc/rust/ast/rust-ast.cc +++ b/gcc/rust/ast/rust-ast.cc @@ -81,6 +81,15 @@ Attribute::as_string () const return path_str + attr_input->as_string (); } +bool +Attribute::is_derive () const +{ + return has_attr_input () + && get_attr_input ().get_attr_input_type () + == AST::AttrInput::TOKEN_TREE + && get_path () == "derive"; +} + // Copy constructor must deep copy attr_input as unique pointer Attribute::Attribute (Attribute const &other) : path (other.path), locus (other.locus) diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index 7c2e1224a23..08b511f4019 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -517,6 +517,8 @@ public: inner_attribute (inner_attribute) {} + bool is_derive () const; + // default destructor ~Attribute () = default; diff --git a/gcc/rust/expand/rust-expand-visitor.cc b/gcc/rust/expand/rust-expand-visitor.cc index 8cbf73dcb08..77dfdcb6d6a 100644 --- a/gcc/rust/expand/rust-expand-visitor.cc +++ b/gcc/rust/expand/rust-expand-visitor.cc @@ -25,16 +25,6 @@ namespace Rust { -bool -is_derive (AST::Attribute &attr) -{ - auto path = attr.get_path (); - return attr.has_attr_input () - && attr.get_attr_input ().get_attr_input_type () - == AST::AttrInput::TOKEN_TREE - && path == "derive"; -} - bool is_builtin (AST::Attribute &attr) { @@ -258,7 +248,7 @@ ExpandVisitor::expand_inner_items ( { auto current = *attr_it; - if (is_derive (current)) + if (current.is_derive ()) { current.parse_attr_to_meta_item (); attr_it = attrs.erase (attr_it); @@ -345,7 +335,7 @@ ExpandVisitor::expand_inner_stmts (AST::BlockExpr &expr) { auto current = *attr_it; - if (is_derive (current)) + if (current.is_derive ()) { attr_it = attrs.erase (attr_it); // Get traits to derive in the current attribute @@ -1683,7 +1673,7 @@ ExpandVisitor::visit_inner_using_attrs (T &item, { auto current = *it; - if (!is_builtin (current) && !is_derive (current)) + if (!is_builtin (current) && !current.is_derive ()) { it = attrs.erase (it); expand_inner_attribute (item, current.get_path ());
reply other threads:[~2024-01-16 18:10 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240116181013.EBD1A3857738@sourceware.org \ --to=cohenarthur@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).