Demangle: correct demangling for CV-qualified functions

When demangling a CV-qualified function type with a final reference type
parameter, we would treat the reference type parameter as a r-value ref
accidentally.  This would result in the improper decoration of the
function type itself.

Resolves PR31741!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292976 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Saleem Abdulrasool 2017-01-24 20:04:58 +00:00
parent ed1b025f1b
commit 815bff1cc4

View File

@ -1669,21 +1669,24 @@ static const char *parse_type(const char *first, const char *last, C &db) {
db.subs.emplace_back(); db.subs.emplace_back();
for (size_t k = k0; k < k1; ++k) { for (size_t k = k0; k < k1; ++k) {
if (is_function) { if (is_function) {
size_t p = db.names[k].second.size(); auto &name = db.names[k].second;
if (db.names[k].second[p - 2] == '&') size_t p = name.size();
if (name[p - 2] == '&' && name[p - 1] == '&')
p -= 2; p -= 2;
else if (db.names[k].second.back() == '&') else if (name.back() == '&')
p -= 1; p -= 1;
if (cv & CV_const) { if (cv & CV_const) {
db.names[k].second.insert(p, " const"); name.insert(p, " const");
p += 6; p += 6;
} }
if (cv & CV_volatile) { if (cv & CV_volatile) {
db.names[k].second.insert(p, " volatile"); name.insert(p, " volatile");
p += 9; p += 9;
} }
if (cv & CV_restrict) if (cv & CV_restrict)
db.names[k].second.insert(p, " restrict"); name.insert(p, " restrict");
} else { } else {
if (cv & CV_const) if (cv & CV_const)
db.names[k].first.append(" const"); db.names[k].first.append(" const");