[libcxxabi] r292973 - cxa_demangle: fix rvalue ref check

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


Author: compnerd
Date: Tue Jan 24 13:57:05 2017
New Revision: 292973

URL: http://llvm.org/viewvc/llvm-project?rev=292973&view=rev
Log:
cxa_demangle: fix rvalue ref check

When checking if the type is a r-value ref, we would not do a complete
check.  This would result in us treating a trailing parameter reference
`&)` as a r-value ref, and improperly inject the cv qualifier on the
type.  We now correctly demangle the type `KFvRmE` as a constant
function rather than a constant reference.

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=292973&r1=292972&r2=292973&view=diff
==============================================================================
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Tue Jan 24 13:57:05 2017
@@ -1927,7 +1927,8 @@ parse_type(const char* first, const char
                             if (is_function)
                             {
                                 size_t p = db.names[k].second.size();
-                                if (db.names[k].second[p-2] == '&')
+                                if (db.names[k].second[p - 2] == '&' &&
+                                    db.names[k].second[p - 1] == '&')
                                     p -= 2;
                                 else if (db.names[k].second.back() == '&')
                                     p -= 1;

Modified: libcxxabi/trunk/test/test_demangle.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_demangle.pass.cpp?rev=292973&r1=292972&r2=292973&view=diff
==============================================================================
--- libcxxabi/trunk/test/test_demangle.pass.cpp (original)
+++ libcxxabi/trunk/test/test_demangle.pass.cpp Tue Jan 24 13:57:05 2017
@@ -29598,9 +29598,8 @@ 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 &&"
+    {"PKFvRiE", "void (*)(int&) const"},
+    // FIXME(compnerd) pretty print this as void (*)(unsigned long &) volatile &&
     {"PVFvRmOE", "void (*)(unsigned long&)  volatile&&"},
     {"PFvRmOE", "void (*)(unsigned long&) &&"},
 };




More information about the cfe-commits mailing list