[libcxxabi] r292963 - cxa_demangle: avoid butchering the last parameter type

Saleem Abdulrasool via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 24 10:42:57 PST 2017


Author: compnerd
Date: Tue Jan 24 12:42:56 2017
New Revision: 292963

URL: http://llvm.org/viewvc/llvm-project?rev=292963&view=rev
Log:
cxa_demangle: avoid butchering the last parameter type

Fix an off-by-one case which would destroy the final parameter in a
CV-qualified function type with a reference.  We still get the CV
qualification incorrect, but at least we do not clobber the type name
any longer.

Partially fixes PR31741.

Modified:
    libcxxabi/trunk/src/cxa_demangle.cpp
    libcxxabi/trunk/test/test_demangle.pass.cpp

Modified: libcxxabi/trunk/src/cxa_demangle.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=292963&r1=292962&r2=292963&view=diff
==============================================================================
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Tue Jan 24 12:42:56 2017
@@ -1928,9 +1928,9 @@ parse_type(const char* first, const char
                             {
                                 size_t p = db.names[k].second.size();
                                 if (db.names[k].second[p-2] == '&')
-                                    p -= 3;
-                                else if (db.names[k].second.back() == '&')
                                     p -= 2;
+                                else if (db.names[k].second.back() == '&')
+                                    p -= 1;
                                 if (cv & 1)
                                 {
                                     db.names[k].second.insert(p, " const");

Modified: libcxxabi/trunk/test/test_demangle.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_demangle.pass.cpp?rev=292963&r1=292962&r2=292963&view=diff
==============================================================================
--- libcxxabi/trunk/test/test_demangle.pass.cpp (original)
+++ libcxxabi/trunk/test/test_demangle.pass.cpp Tue Jan 24 12:42:56 2017
@@ -29597,6 +29597,12 @@ const char* cases[][2] =
 
     // mangled names can include type manglings too, which don't start with _Z:
     {"i", "int"},
+
+    // FIXME(compnerd) this should be void (int &) const
+    {"PKFvRiE", "void (*)(int const&)"},
+    // TODO(compnerd) pretty print this as void (*)(unsigned long&) volatile &&"
+    {"PVFvRmOE", "void (*)(unsigned long&)  volatile&&"},
+    {"PFvRmOE", "void (*)(unsigned long&) &&"},
 };
 
 const unsigned N = sizeof(cases) / sizeof(cases[0]);




More information about the cfe-commits mailing list