]> git.ipfire.org Git - thirdparty/gcc.git/commit
gccrs: resolve: Add mappings for proc macros and resolving
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Mon, 19 Jun 2023 10:51:34 +0000 (12:51 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:55:58 +0000 (18:55 +0100)
commited866110ef0f90f24c60a91a7141565b706ad185
treea3e6c06b4b808e38b4f59ed476b30607397489cd
parent00f79c773bc247830b29b6cef02d89337123c167
gccrs: resolve: Add mappings for proc macros and resolving

Add multiple mappings for procedural macro name resolution.
Procedural macros were not resolved using name resolution and mapping
but rather with some hacky path comparison.

gcc/rust/ChangeLog:

* expand/rust-macro-expand.cc (MacroExpander::import_proc_macros):
Remove function.
* expand/rust-macro-expand.h (struct MacroExpander): Remove
import_proc_macro function.
* util/rust-hir-map.cc (Mappings::insert_derive_proc_macro_def):
Add a function to insert a derive proc macro definition.
(Mappings::insert_bang_proc_macro): Remove function.
(Mappings::insert_bang_proc_macro_def): Add function to insert a
bang proc macro definition.
(Mappings::insert_attribute_proc_macro_def): Likewise with
attribute proc macros.
(Mappings::lookup_derive_proc_macro_def): Add a function to
lookup a defined derive proc macro definition.
(Mappings::lookup_bang_proc_macro): Remove function.
(Mappings::lookup_bang_proc_macro_def): Add a function to lookup
a bang proc macro definition.
(Mappings::lookup_attribute_proc_macro_def): Add a function to
lookup an attribute prod macro definition.
(Mappings::insert_derive_proc_macro_invocation): Add a function
to insert a derive proc macro invocation.
(Mappings::lookup_derive_proc_macro_invocation): Add a function
to lookup a derive proc macro invocation.
(Mappings::insert_bang_proc_macro_invocation): Add a function to
insert a bang proc macro invocation.
(Mappings::lookup_bang_proc_macro_invocation): Add a function to
lookup a bang proc macro invocation.
(Mappings::insert_attribute_proc_macro_invocation): Add a
function to insert an attribute proc macro invocation.
(Mappings::lookup_attribute_proc_macro_invocation): Add a
function to lookup an attribute proc macro invocation.
* util/rust-hir-map.h: Add different proc macro mappings
and change function prototypes.
* expand/rust-expand-visitor.cc (get_traits_to_derive): Return a
vector of SimplePath instead.
(derive_item): Accept SimplePath instead of a string.
* ast/rust-ast.h: Add common ProcMacroInvocable interface to
Identifiers and SimplePath nodes.
* ast/rust-ast.cc: Add const modifier.
* ast/rust-macro.h: Change path and identifier getters.
* ast/rust-path.h: Change return type to reference.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ast/rust-ast.cc
gcc/rust/ast/rust-ast.h
gcc/rust/ast/rust-macro.h
gcc/rust/ast/rust-path.h
gcc/rust/expand/rust-expand-visitor.cc
gcc/rust/expand/rust-macro-expand.cc
gcc/rust/expand/rust-macro-expand.h
gcc/rust/util/rust-hir-map.cc
gcc/rust/util/rust-hir-map.h
gcc/rust/util/rust-proc-macro-invocation.h [new file with mode: 0644]