Improve LLDB's embedded C++ demangler by addressing the following two issues:

1) Preserve ref qualification state in a local variable while parsing a nested name.  Previously, the state was recorded in the shared db reference and could therefore be overwritten when parsing multiple levels of nested names (e.g.: when a qualified name has qualified template args.)

2) Address an off-by-one error when testing whether or not a thunk is non-virtual.  This resulted in the demangled identifying all thunks as non-virtual.

llvm-svn: 213591
diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp
index 60cd80f..8df9fb8 100644
--- a/lldb/source/Core/Mangled.cpp
+++ b/lldb/source/Core/Mangled.cpp
@@ -3932,15 +3932,15 @@
         const char* t0 = parse_cv_qualifiers(first+1, last, cv);
         if (t0 == last)
             return first;
-        db.ref = 0;
+        unsigned ref = 0;
         if (*t0 == 'R')
         {
-            db.ref = 1;
+            ref = 1;
             ++t0;
         }
         else if (*t0 == 'O')
         {
-            db.ref = 2;
+            ref = 2;
             ++t0;
         }
         db.names.emplace_back();
@@ -4054,6 +4054,7 @@
             }
         }
         first = t0 + 1;
+        db.ref = ref;
         db.cv = cv;
         if (pop_subs && !db.subs.empty())
             db.subs.pop_back();
@@ -4413,7 +4414,7 @@
                 {
                     if (db.names.empty())
                         return first;
-                    if (first[2] == 'v')
+                    if (first[1] == 'v')
                     {
                         db.names.back().first.insert(0, "virtual thunk to ");
                         first = t;