This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

[patch][libstdc++ patch][c++ patch] Update mangling and demangling for rvalue references


The attached patch updates the mangling of rvalue reference types to
use 'O' rather than 'RR'. The use of 'O' is being discussed on the
cxx-abi-dev list and has been in CodeWarrior for some time. This patch
also updates the demangler to handle 'O' and introduces a test in
libstdc++ to make sure rvalue references are demangled properly.

Tested on powerpc-apple-darwin8.10.0; okay for mainline, assuming we
have agreement on cxx-abi-dev?

- Doug

2007-06-29 Douglas Gregor <doug.gregor@gmail.com>

       * mangle.c (write_type): Change mangling of rvalue reference from
       `RR' to `O'.

2007-06-29 Douglas Gregor <doug.gregor@gmail.com>

       * include/demangle.h (enum demangle_component_type): Add
       DEMANGLE_COMPONENT_RVALUE_REFERENCE.
       cp-demangle.c ():
       * libiberty/cp-demangle.c (d_dump): Handle
       DEMANGLE_COMPONENT_RVALUE_REFERENCE.
       (d_make_comp): Ditto.
       (cplus_demangle_type): Ditto.
       (d_print_comp): Ditto.
       (d_print_mod): Ditto.
       (d_print_function_type): Ditto.

2007-06-29 Douglas Gregor <doug.gregor@gmail.com>

* testsuite/abi/demangle/cxx0x/rref.cc: New.
Index: gcc/cp/mangle.c
===================================================================
--- gcc/cp/mangle.c	(revision 126081)
+++ gcc/cp/mangle.c	(working copy)
@@ -1640,8 +1640,9 @@ write_type (tree type)
 
 	case REFERENCE_TYPE:
 	  if (TYPE_REF_IS_RVALUE (type))
-            write_char('R');
-	  write_char ('R');
+            write_char ('O');
+          else
+            write_char ('R');
 	  write_type (TREE_TYPE (type));
 	  break;
 
Index: libstdc++-v3/testsuite/abi/demangle/cxx0x/rref.cc
===================================================================
--- libstdc++-v3/testsuite/abi/demangle/cxx0x/rref.cc	(revision 0)
+++ libstdc++-v3/testsuite/abi/demangle/cxx0x/rref.cc	(revision 0)
@@ -0,0 +1,32 @@
+// 2007-06-28 Douglas Gregor  <doug.gregor@gmail.com>
+
+// Copyright (C) 2007 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// IA 64 C++ ABI - 5.1 External Names (a.k.a. Mangling)
+
+#include <testsuite_hooks.h>
+
+int main()
+{
+  using namespace __gnu_test;
+
+  verify_demangle("_Z1fOi", "f(int&&)");
+
+  return 0;
+}
Index: include/demangle.h
===================================================================
--- include/demangle.h	(revision 126081)
+++ include/demangle.h	(working copy)
@@ -359,7 +359,10 @@ enum demangle_component_type
      using 'n' instead of '-', we want a way to indicate a negative
      number which involves neither modifying the mangled string nor
      allocating a new copy of the literal in memory.  */
-  DEMANGLE_COMPONENT_LITERAL_NEG
+  DEMANGLE_COMPONENT_LITERAL_NEG,
+  /* C++0x: An rvalue reference.  The one subtree is the type which is
+     being referenced.  */
+  DEMANGLE_COMPONENT_RVALUE_REFERENCE
 };
 
 /* Types which are only used internally.  */
Index: libiberty/cp-demangle.c
===================================================================
--- libiberty/cp-demangle.c	(revision 126081)
+++ libiberty/cp-demangle.c	(working copy)
@@ -596,6 +596,9 @@ d_dump (struct demangle_component *dc, i
     case DEMANGLE_COMPONENT_REFERENCE:
       printf ("reference\n");
       break;
+    case DEMANGLE_COMPONENT_RVALUE_REFERENCE:
+      printf ("rvalue reference\n");
+      break;
     case DEMANGLE_COMPONENT_COMPLEX:
       printf ("complex\n");
       break;
@@ -785,6 +788,7 @@ d_make_comp (struct d_info *di, enum dem
     case DEMANGLE_COMPONENT_HIDDEN_ALIAS:
     case DEMANGLE_COMPONENT_POINTER:
     case DEMANGLE_COMPONENT_REFERENCE:
+    case DEMANGLE_COMPONENT_RVALUE_REFERENCE:
     case DEMANGLE_COMPONENT_COMPLEX:
     case DEMANGLE_COMPONENT_IMAGINARY:
     case DEMANGLE_COMPONENT_VENDOR_TYPE:
@@ -1726,6 +1730,7 @@ d_ctor_dtor_name (struct d_info *di)
           ::= <CV-qualifiers> <type>
           ::= P <type>
           ::= R <type>
+          ::= RR <type> (C++0x)
           ::= C <type>
           ::= G <type>
           ::= U <source-name> <type>
@@ -1892,6 +1897,12 @@ cplus_demangle_type (struct d_info *di)
       }
       break;
 
+    case 'O':
+      d_advance (di, 1);
+      ret = d_make_comp (di, DEMANGLE_COMPONENT_RVALUE_REFERENCE,
+                         cplus_demangle_type (di), NULL);
+      break;
+
     case 'P':
       d_advance (di, 1);
       ret = d_make_comp (di, DEMANGLE_COMPONENT_POINTER,
@@ -1901,7 +1912,7 @@ cplus_demangle_type (struct d_info *di)
     case 'R':
       d_advance (di, 1);
       ret = d_make_comp (di, DEMANGLE_COMPONENT_REFERENCE,
-			 cplus_demangle_type (di), NULL);
+                         cplus_demangle_type (di), NULL);
       break;
 
     case 'C':
@@ -3178,6 +3189,7 @@ d_print_comp (struct d_print_info *dpi,
     case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL:
     case DEMANGLE_COMPONENT_POINTER:
     case DEMANGLE_COMPONENT_REFERENCE:
+    case DEMANGLE_COMPONENT_RVALUE_REFERENCE:
     case DEMANGLE_COMPONENT_COMPLEX:
     case DEMANGLE_COMPONENT_IMAGINARY:
       {
@@ -3702,6 +3714,9 @@ d_print_mod (struct d_print_info *dpi,
     case DEMANGLE_COMPONENT_REFERENCE:
       d_append_char (dpi, '&');
       return;
+    case DEMANGLE_COMPONENT_RVALUE_REFERENCE:
+      d_append_string (dpi, "&&");
+      return;
     case DEMANGLE_COMPONENT_COMPLEX:
       d_append_string (dpi, "complex ");
       return;
@@ -3751,6 +3766,7 @@ d_print_function_type (struct d_print_in
 	{
 	case DEMANGLE_COMPONENT_POINTER:
 	case DEMANGLE_COMPONENT_REFERENCE:
+	case DEMANGLE_COMPONENT_RVALUE_REFERENCE:
 	  need_paren = 1;
 	  break;
 	case DEMANGLE_COMPONENT_RESTRICT:

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