[llvm] r292976 - Demangle: correct demangling for CV-qualified functions

Saleem Abdulrasool via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 24 12:04:59 PST 2017


Author: compnerd
Date: Tue Jan 24 14:04:58 2017
New Revision: 292976

URL: http://llvm.org/viewvc/llvm-project?rev=292976&view=rev
Log:
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!

Modified:
    llvm/trunk/lib/Demangle/ItaniumDemangle.cpp

Modified: llvm/trunk/lib/Demangle/ItaniumDemangle.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Demangle/ItaniumDemangle.cpp?rev=292976&r1=292975&r2=292976&view=diff
==============================================================================
--- llvm/trunk/lib/Demangle/ItaniumDemangle.cpp (original)
+++ llvm/trunk/lib/Demangle/ItaniumDemangle.cpp Tue Jan 24 14:04:58 2017
@@ -1669,21 +1669,24 @@ static const char *parse_type(const char
           db.subs.emplace_back();
           for (size_t k = k0; k < k1; ++k) {
             if (is_function) {
-              size_t p = db.names[k].second.size();
-              if (db.names[k].second[p - 2] == '&')
+              auto &name = db.names[k].second;
+              size_t p = name.size();
+
+              if (name[p - 2] == '&' && name[p - 1] == '&')
                 p -= 2;
-              else if (db.names[k].second.back() == '&')
+              else if (name.back() == '&')
                 p -= 1;
+
               if (cv & CV_const) {
-                db.names[k].second.insert(p, " const");
+                name.insert(p, " const");
                 p += 6;
               }
               if (cv & CV_volatile) {
-                db.names[k].second.insert(p, " volatile");
+                name.insert(p, " volatile");
                 p += 9;
               }
               if (cv & CV_restrict)
-                db.names[k].second.insert(p, " restrict");
+                name.insert(p, " restrict");
             } else {
               if (cv & CV_const)
                 db.names[k].first.append(" const");




More information about the llvm-commits mailing list