This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch for anonymous namespace demangling (was: Re: libiberty (was: Re: Mangle question))
- To: gcc-patches at gcc dot gnu dot org
- Subject: Patch for anonymous namespace demangling (was: Re: libiberty (was: Re: Mangle question))
- From: Hans-Peter Nilsson <hp at axis dot com>
- Date: Sun, 10 Sep 2000 23:44:55 +0200
- CC: carlo at alinoe dot com
> Date: Fri, 1 Sep 2000 18:32:46 +0200
> From: Carlo Wood <carlo@alinoe.com>
Thanks for reporting, Carlo. I'll try to keep up with any
demangler bugs you send to gcc-bugs. Please report if you see
some more.
> [...]
> Everything, except one variable, works :)
> That last one doesn't seem to be a problem in the demangler,
> it is (output of nm:)
>
> 0805d0e4 B _27_GLOBAL_.N.__12burst_app_ct.app_instance
>
> This is a variable that is declared as follows:
>
> namespace {
> // reserve static space for the application object:
> SingletonInstance<burst_app_ct> app_instance __attribute__ ((unused));
> }
There was no support for demangling anonymous namespaces with
GNU demangling. I used the notation from ARM/EDG demangling.
> The `SingletonInstance' is pretty complex, let me know if you
> really need it.
Global variables (objects?) are not mangled for type, only for
qualifiers, so the above when mangled does not and should not
mention SingletonInstance<burst_app_ct>. When demangled, it
should say "{anonymous}::app_instance". With this patch it
does. Code mostly borrowed from demangle_arm_hp_template, but
not worth it IMHO to break out to a common function.
I'll commit this in a few days, but will let people (e.g. Dan
Berlin) chime in, if there's an issue over how it should really
be demangled or something else I've overlooked.
2000-09-10 Hans-Peter Nilsson <hp@axis.com>
* testsuite/demangle-expected: Add two tests for anonymous
namespaces.
* cplus-dem.c (gnu_special): Handle anonymous namespaces.
Index: demangle-expected
===================================================================
RCS file: /cvs/gcc/egcs/libiberty/testsuite/demangle-expected,v
retrieving revision 1.6
diff -p -c -r1.6 demangle-expected
*** demangle-expected 2000/09/10 19:35:16 1.6
--- demangle-expected 2000/09/10 21:25:00
*************** sockaddr * type_info node
*** 2558,2560 ****
--- 2558,2568 ----
--format=gnu
__tiPQ25libcwt16option_event_tct1Z12burst_app_ct
libcw::option_event_tct<burst_app_ct> * type_info node
+ #
+ --format=gnu
+ _27_GLOBAL_.N.__12burst_app_ct.app_instance
+ {anonymous}::app_instance
+ #
+ --format=gnu
+ _26_GLOBAL_\$N\$_tmp_n.iilg4Gya\$app_instance
+ {anonymous}::app_instance
Index: cplus-dem.c
===================================================================
RCS file: /cvs/gcc/egcs/libiberty/cplus-dem.c,v
retrieving revision 1.62
diff -p -c -r1.62 cplus-dem.c
*** cplus-dem.c 2000/09/10 19:35:16 1.62
--- cplus-dem.c 2000/09/10 20:56:56
*************** gnu_special (work, mangled, declp)
*** 2811,2816 ****
--- 2811,2835 ----
success = 0;
break;
}
+
+ if (n > 10 && strncmp (*mangled, "_GLOBAL_", 8) == 0
+ && (*mangled)[9] == 'N'
+ && (*mangled)[8] == (*mangled)[10]
+ && strchr (cplus_markers, (*mangled)[8]))
+ {
+ /* A member of the anonymous namespace. There's information
+ about what identifier or filename it was keyed to, but
+ it's just there to make the mangled name unique; we just
+ step over it. */
+ string_append (declp, "{anonymous}");
+ (*mangled) += n;
+
+ /* Now p points to the marker before the N, so we need to
+ update it to the first marker after what we consumed. */
+ p = strpbrk (*mangled, cplus_markers);
+ break;
+ }
+
string_appendn (declp, *mangled, n);
(*mangled) += n;
}
brgds, H-P