]> git.ipfire.org Git - thirdparty/gcc.git/commit
gccrs: expand: Move cfg-attrs related functions out of MacroExpander
authorArthur Cohen <arthur.cohen@embecosm.com>
Mon, 20 Mar 2023 02:10:26 +0000 (03:10 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:28:38 +0000 (18:28 +0100)
commita7382ca757ed535e7bc74782038104ef5ac59694
tree939a5582f211aa160731b65b3feb4972b6460bda
parent9946ef210f40985ce8ab7e5faae43b23f08988a8
gccrs: expand: Move cfg-attrs related functions out of MacroExpander

The current situation where the MacroExpander and AttrVisitor recursively
call into each other is not great, and causes pains for macro imports. We
need to split this pass in two, with one pass being responsible for cfg-attr
checking and stripping, and one being responsible for macro expansion.

gcc/rust/ChangeLog:

* expand/rust-macro-expand.cc (MacroExpander::expand_crate): Do not cfg-attr
strip in MacroExpander
(MacroExpander::fails_cfg): Function moved...
(MacroExpander::fails_cfg_with_expand): Function moved...
(MacroExpander::expand_cfg_attrs): Function moved...
* expand/rust-attribute-visitor.cc (fails_cfg): ...here.
(fails_cfg_with_expand): ...here.
(expand_cfg_attrs): ...here.
(AttrVisitor::expand_struct_fields): Use new functions.
(AttrVisitor::expand_tuple_fields): Likewise.
(AttrVisitor::expand_function_params): Likewise.
(AttrVisitor::visit): Likewise.
(AttrVisitor::go): New function.
* expand/rust-attribute-visitor.h: Declare AttrVisitor::go.
* expand/rust-macro-expand.h (struct MacroExpander): Remove cfg-attr related
functions.
gcc/rust/expand/rust-attribute-visitor.cc
gcc/rust/expand/rust-attribute-visitor.h
gcc/rust/expand/rust-macro-expand.cc
gcc/rust/expand/rust-macro-expand.h