This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

handle <local-source-name> in demangler


Following up on
<http://gcc.gnu.org/ml/gcc/2006-10/msg00441.html>,
this patch implements Mark's preferred option,

    <unqualified-name> ::= <operator-name>
                       ::= <ctor-dtor-name>
                       ::= <source-name>
		       ::= <local-source-name>   // new

    <local-source-name> ::= Z <source-name> <discriminator>  // new

Note that this is used only for names which are local to a single .o
file, so there are no ABI implications; and that 'discriminator' has
no special semantics in a <local-source-name>, unlike in <local-name>
where the ABI says exactly what value it has to have.

Tested (by 'make really-check' in libiberty/testsuite) on
powerpc-darwin8.

Comments?

-- 
- Geoffrey Keating <geoffk@apple.com>

===File ~/patches/libiberty-demangle-localsourcename-2.patch===
2006-11-07  Geoffrey Keating  <geoffk@apple.com>

	* cp-demangle.c (d_name): Handle local-source-name vs. local-name
	ambiguity.
	(d_unqualified_name): Handle local-source-name.
	* testsuite/demangle-expected: Add tests for local-source-name.

Index: libiberty/testsuite/demangle-expected
===================================================================
--- libiberty/testsuite/demangle-expected	(.../branches/for-fsf-4_3/libiberty)	(revision 119079)
+++ libiberty/testsuite/demangle-expected	(.../geoffk/cpp-ima/libiberty)	(revision 119834)
@@ -3816,3 +3816,15 @@
 SASDASDFASDF_sdfsdf
 SASDASDFASDF_sdfsdf
 SASDASDFASDF_sdfsdf
+# <local-source-name> test 1
+--format=gnu-v3
+_ZZ3foo_2
+foo
+# <local-source-name> test 2
+--format=gnu-v3
+_ZZZ3foo_2vE4var1
+foo()::var1
+# <local-source-name> test 3
+--format=gnu-v3
+_ZZZ3foo_2vE4var1_0
+foo()::var1
Index: libiberty/cp-demangle.c
===================================================================
--- libiberty/cp-demangle.c	(.../branches/for-fsf-4_3/libiberty)	(revision 119079)
+++ libiberty/cp-demangle.c	(.../geoffk/cpp-ima/libiberty)	(revision 119834)
@@ -1052,6 +1052,27 @@
       return d_nested_name (di);
 
     case 'Z':
+      /* This will be followed by a source-name, and then
+	 either an '_' if the source-name was part of an local-source-name
+	 or some other character if it is a local-name.  */
+      
+      if (IS_DIGIT (d_peek_next_char (di)))
+	{
+	  const char * savedpos = di->n;
+	  
+	  di->n++;
+	  dc = d_source_name (di);
+	  if (dc == NULL)
+	    return NULL;
+	  if (d_peek_char (di) == '_')
+	    {
+	      if (! d_discriminator (di))
+		return NULL;
+	      return dc;
+	    }
+	  di->n = savedpos;
+	}
+
       return d_local_name (di);
 
     case 'S':
@@ -1208,6 +1229,9 @@
 /* <unqualified-name> ::= <operator-name>
                       ::= <ctor-dtor-name>
                       ::= <source-name>
+		      ::= <local-source-name> 
+
+    <local-source-name>	::= Z <source-name> <discriminator>
 */
 
 static struct demangle_component *
@@ -1229,6 +1253,17 @@
     }
   else if (peek == 'C' || peek == 'D')
     return d_ctor_dtor_name (di);
+  else if (peek == 'Z')
+    {
+      struct demangle_component * ret;
+
+      ret = d_source_name (di);
+      if (ret == NULL)
+	return NULL;
+      if (! d_discriminator (di))
+	return NULL;
+      return ret;
+    }
   else
     return NULL;
 }
============================================================


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]