This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB 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]

[binutils-gdb/gdb-7.10-branch] Demangler: Fix constructor names with ABI tags


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=99eda040d8214d2d691ba804d6354c99b6df5269

commit 99eda040d8214d2d691ba804d6354c99b6df5269
Author: Ian Lance Taylor <iant@google.com>
Date:   Sat Aug 15 13:23:30 2015 +0000

    Demangler: Fix constructor names with ABI tags
    
    The symbol _ZNSt8ios_base7failureB5cxx11C1EPKcRKSt10error_code, which
    appears in libstdc++, was being demangled as
    
    std::ios_base::failure[abi:cxx11]::cxx11(char const*, std::error_code const&)
    
    That is clearly incorrect: std::ios_base::failure does not have a
    method cxx11, and anyhow if you look closely at the mangled name you
    will see that it is supposed to be a constructor.  This patch fixes
    the demangler to generate the correct demangling, namely
    
    std::ios_base::failure[abi:cxx11]::failure(char const*, std::error_code const&)
    
    Bootstrapped and ran libiberty and libstdc++-v3 tests on
    x86_64-unknown-linux-gnu.
    
    2015-08-15  Ian Lance Taylor  <iant@google.com>
    
    	* cp-demangle.c (d_abi_tags): Preserve di->last_name across any
    	ABI tags.

Diff:
---
 libiberty/ChangeLog                   | 5 +++++
 libiberty/cp-demangle.c               | 8 ++++++++
 libiberty/testsuite/demangle-expected | 6 ++++++
 3 files changed, 19 insertions(+)

diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 71aa886..5f0bb93 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,8 @@
+2015-11-28  Ian Lance Taylor  <iant@google.com>
+
+	* cp-demangle.c (d_abi_tags): Preserve di->last_name across any
+	ABI tags.
+
 2015-11-28  Mikhail Maltsev  <maltsevm@gmail.com>
 
 	* cp-demangle.c (d_dump): Fix syntax error.
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index 8254100..c587895 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -1306,7 +1306,12 @@ d_encoding (struct d_info *di, int top_level)
 static struct demangle_component *
 d_abi_tags (struct d_info *di, struct demangle_component *dc)
 {
+  struct demangle_component *hold_last_name;
   char peek;
+
+  /* Preserve the last name, so the ABI tag doesn't clobber it.  */
+  hold_last_name = di->last_name;
+
   while (peek = d_peek_char (di),
 	 peek == 'B')
     {
@@ -1315,6 +1320,9 @@ d_abi_tags (struct d_info *di, struct demangle_component *dc)
       tag = d_source_name (di);
       dc = d_make_comp (di, DEMANGLE_COMPONENT_TAGGED_NAME, dc, tag);
     }
+
+  di->last_name = hold_last_name;
+
   return dc;
 }
 
diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected
index 4c6359e..5200cb3 100644
--- a/libiberty/testsuite/demangle-expected
+++ b/libiberty/testsuite/demangle-expected
@@ -4389,3 +4389,9 @@ f(std::string[abi:foo], std::string[abi:foo])
 --format=gnu-v3
 _Z18IndirectExternCallIPU7stdcallU7regparmILi3EEFviiEiEvT_T0_S3_
 void IndirectExternCall<void ( regparm<3> stdcall*)(int, int), int>(void ( regparm<3> stdcall*)(int, int), int, void ( regparm<3> stdcall*)(int, int))
+# 
+# ABI tags used to confuse the constructor name calculation.
+--format=gnu-v3 --no-params
+_ZNSt8ios_base7failureB5cxx11C1EPKcRKSt10error_code
+std::ios_base::failure[abi:cxx11]::failure(char const*, std::error_code const&)
+std::ios_base::failure[abi:cxx11]::failure


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