From f5d26bb142fa0bf2e4297fda8c1b6a6f29f844c8 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Tue, 24 Jan 2017 19:57:05 +0000 Subject: [PATCH] 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! llvm-svn: 292973 --- libcxxabi/src/cxa_demangle.cpp | 3 ++- libcxxabi/test/test_demangle.pass.cpp | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libcxxabi/src/cxa_demangle.cpp b/libcxxabi/src/cxa_demangle.cpp index 18a095b9b3fb..8f5cb3024ade 100644 --- a/libcxxabi/src/cxa_demangle.cpp +++ b/libcxxabi/src/cxa_demangle.cpp @@ -1927,7 +1927,8 @@ parse_type(const char* first, const char* last, C& db) 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; diff --git a/libcxxabi/test/test_demangle.pass.cpp b/libcxxabi/test/test_demangle.pass.cpp index b307300a8fa2..4eb6a882abee 100644 --- a/libcxxabi/test/test_demangle.pass.cpp +++ b/libcxxabi/test/test_demangle.pass.cpp @@ -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&) &&"}, };