public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/c++-modules] Clean up mangling documentation
@ 2020-10-09 14:48 Nathan Sidwell
  0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2020-10-09 14:48 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:8047291fa52c57f51a13bec41f29728f839153dc

commit 8047291fa52c57f51a13bec41f29728f839153dc
Author: Nathan Sidwell <nathan@acm.org>
Date:   Fri Oct 9 06:44:01 2020 -0700

    Clean up mangling documentation
    
            gcc/cp/
            * mangle.c (write_module): Update grammar description.
            * module.cc (module_state::mangle): Clarify why partitions might
            be significant.

Diff:
---
 ChangeLog.modules |  6 ++++++
 gcc/cp/mangle.c   | 18 +++++++++---------
 gcc/cp/module.cc  |  3 ++-
 3 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/ChangeLog.modules b/ChangeLog.modules
index e27864f54aa..4279182e909 100644
--- a/ChangeLog.modules
+++ b/ChangeLog.modules
@@ -1,5 +1,11 @@
 2020-10-09  Nathan Sidwell  <nathan@acm.org>
 
+	Clean up mangling documentation
+	gcc/cp/
+	* mangle.c (write_module): Update grammar description.
+	* module.cc (module_state::mangle): Clarify why partitions might
+	be significant.
+
 	Clean up some c-family pieces
 	gcc/
 	* langhooks.h (struct lang_hooks): Replace
diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index 7b0ad0ce2f0..6f9c93cb571 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -862,15 +862,15 @@ mangle_identifier (char c, tree id)
   write_source_name (id);
 }
 
-/* If the outermost non-namespace context (including DECL itself) is a
-   non-exported module decl, mangle the module information.
-
-   <module-name> ::= W <unqualified-name>+ E
-
-   FIXME: Module mangling is not fully baked.  How moduleness sticks
-   to regular back-references is tricky.  Namespaces cannot have
-   moduleness, but classes can.  However, both are mangled the same,
-   so the demangler doesn't have a clue. 
+/* If the outermost non-namespace context (including DECL itself) is
+   a module-linkage decl, mangle the module information.  For module
+   global initializers we need to include the partition part.
+
+   <module-name> ::= W <module-id>+ E
+   <module-id> :: <unqualified-name>
+               || _ <digit>  ;; short backref
+	       || W <number> _  ;; long backref
+               || P <module-id> ;; partition introducer
 */
 
 static void
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index b241b44b41e..e7dda8e63e9 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -13682,7 +13682,8 @@ module_state::mangle (bool include_partition)
       if (include_partition || !is_partition ())
 	{
 	  char p = 0;
-	  if (is_partition () && !(parent && parent->is_partition ()))
+	  // Partitions are significant for global initializer functions
+	  if (is_partition () && !parent->is_partition ())
 	    p = 'P';
 	  substs.safe_push (this);
 	  subst = substs.length ();


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

only message in thread, other threads:[~2020-10-09 14:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-09 14:48 [gcc/devel/c++-modules] Clean up mangling documentation Nathan Sidwell

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).