diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-08-29 15:59:58 +0200 |
---|---|---|
committer | P-E-P <32375388+P-E-P@users.noreply.github.com> | 2023-09-06 11:50:30 +0000 |
commit | 32fea09d30f2db75727be2e7dbd3b636cef5284c (patch) | |
tree | b3a90081f2f0f9e71cfac0e1d850eb0f856d5b29 /gcc/rust | |
parent | 99276280aa1865bab5b1f9c950cddbed5f67f1fb (diff) | |
download | gcc-32fea09d30f2db75727be2e7dbd3b636cef5284c.zip gcc-32fea09d30f2db75727be2e7dbd3b636cef5284c.tar.gz gcc-32fea09d30f2db75727be2e7dbd3b636cef5284c.tar.bz2 |
Retrieve def for derive & attribute proc macros
Add definition retrieval for derive and attribute proc macro types.
gcc/rust/ChangeLog:
* resolve/rust-early-name-resolver-2.0.cc (Early::visit_attributes):
Add proc macro handle retrieval for attribute and derive proc macros.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust')
-rw-r--r-- | gcc/rust/resolve/rust-early-name-resolver-2.0.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc index 7373e62..57a3807 100644 --- a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc +++ b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc @@ -177,6 +177,8 @@ Early::visit (AST::UseTreeGlob &use) void Early::visit_attributes (std::vector<AST::Attribute> &attrs) { + auto mappings = Analysis::Mappings::get (); + for (auto &attr : attrs) { auto name = attr.get_path ().get_segments ().at (0).get_segment_name (); @@ -192,7 +194,16 @@ Early::visit_attributes (std::vector<AST::Attribute> &attrs) // FIXME: Change to proper error message rust_error_at (trait.get ().get_locus (), "could not resolve trait"); + continue; } + + auto pm_def + = mappings->lookup_derive_proc_macro_def (definition.value ()); + + rust_assert (pm_def.has_value ()); + + mappings->insert_derive_proc_macro_invocation (trait, + pm_def.value ()); } } else if (Analysis::BuiltinAttributeMappings::get () @@ -207,6 +218,13 @@ Early::visit_attributes (std::vector<AST::Attribute> &attrs) "could not resolve attribute macro invocation"); return; } + auto pm_def + = mappings->lookup_attribute_proc_macro_def (definition.value ()); + + rust_assert (pm_def.has_value ()); + + mappings->insert_attribute_proc_macro_invocation (attr.get_path (), + pm_def.value ()); } } } |