public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-7998] gccrs: Add proc macro definition insertion
@ 2024-01-16 18:12 Arthur Cohen
  0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-01-16 18:12 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:e6cd1103050c48242923ae6f862437110331beb9

commit r14-7998-ge6cd1103050c48242923ae6f862437110331beb9
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date:   Tue Aug 29 16:49:31 2023 +0200

    gccrs: Add proc macro definition insertion
    
    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>

Diff:
---
 gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
index 33a20cc64c0..f24c91de922 100644
--- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
@@ -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 ())

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-16 18:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16 18:12 [gcc r14-7998] gccrs: Add proc macro definition insertion Arthur Cohen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).