aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/util/rust-proc-macro-invocation.h
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-06-19 12:51:34 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 18:55:58 +0100
commited866110ef0f90f24c60a91a7141565b706ad185 (patch)
treea3e6c06b4b808e38b4f59ed476b30607397489cd /gcc/rust/util/rust-proc-macro-invocation.h
parent00f79c773bc247830b29b6cef02d89337123c167 (diff)
downloadgcc-ed866110ef0f90f24c60a91a7141565b706ad185.zip
gcc-ed866110ef0f90f24c60a91a7141565b706ad185.tar.gz
gcc-ed866110ef0f90f24c60a91a7141565b706ad185.tar.bz2
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>
Diffstat (limited to 'gcc/rust/util/rust-proc-macro-invocation.h')
-rw-r--r--gcc/rust/util/rust-proc-macro-invocation.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/gcc/rust/util/rust-proc-macro-invocation.h b/gcc/rust/util/rust-proc-macro-invocation.h
new file mode 100644
index 0000000..b45e013
--- /dev/null
+++ b/gcc/rust/util/rust-proc-macro-invocation.h
@@ -0,0 +1,21 @@
+#ifndef RUST_PROC_MACRO_INVOCATION_H
+#define RUST_PROC_MACRO_INVOCATION_H
+
+#include "rust-mapping-common.h"
+#include "rust-location.h"
+
+namespace Rust {
+
+class ProcMacroInvocable
+{
+public:
+ virtual NodeId get_node_id () const = 0;
+ virtual const std::string as_string () const = 0;
+ virtual Location get_locus () const = 0;
+
+ virtual ~ProcMacroInvocable () {}
+};
+
+} // namespace Rust
+
+#endif /* ! RUST_PROC_MACRO_INVOCATION_H*/