]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Add proc macro definition insertion
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Tue, 29 Aug 2023 14:49:31 +0000 (16:49 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:04:34 +0000 (19:04 +0100)
Insert proc macro definition from extern crates.

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit):
Add proc macro definition insertion.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc

index 33a20cc64c0b45f74b624cfd63987d469597c1f2..f24c91de9221a9d31224cbc9d196e9e2c5ca7a9a 100644 (file)
@@ -104,12 +104,25 @@ TopLevel::visit (AST::ExternCrate &crate)
     = Analysis::Mappings::get ()->lookup_derive_proc_macros (num);
 
   auto sub_visitor = [&] () {
+    // TODO: Find a way to keep this part clean without the double dispatch.
     if (derive_macros.has_value ())
-      insert_macros (derive_macros.value (), ctx);
+      {
+       insert_macros (derive_macros.value (), ctx);
+       for (auto &macro : derive_macros.value ())
+         Analysis::Mappings::get ()->insert_derive_proc_macro_def (macro);
+      }
     if (attribute_macros.has_value ())
-      insert_macros (attribute_macros.value (), ctx);
+      {
+       insert_macros (attribute_macros.value (), ctx);
+       for (auto &macro : attribute_macros.value ())
+         Analysis::Mappings::get ()->insert_attribute_proc_macro_def (macro);
+      }
     if (bang_macros.has_value ())
-      insert_macros (bang_macros.value (), ctx);
+      {
+       insert_macros (bang_macros.value (), ctx);
+       for (auto &macro : bang_macros.value ())
+         Analysis::Mappings::get ()->insert_bang_proc_macro_def (macro);
+      }
   };
 
   if (crate.has_as_clause ())