[Lldb-commits] [lldb] r220432 - Fixed name lookups for names that contain "::" but aren't actually C++ qualified C++ names.

Greg Clayton gclayton at apple.com
Wed Oct 22 14:47:13 PDT 2014


Author: gclayton
Date: Wed Oct 22 16:47:13 2014
New Revision: 220432

URL: http://llvm.org/viewvc/llvm-project?rev=220432&view=rev
Log:
Fixed name lookups for names that contain "::" but aren't actually C++ qualified C++ names.

To do this, I fixed the  CPPLanguageRuntime::StripNamespacesFromVariableName() function to use a regular expression that correctly determines if the name passed to it is a qualfied C++ name like "a::b::c" or "b::c". The old version of this function was treating '__54-[NSUserScriptTask executeWithInterpreter:arguments::]_block_invoke' as a match with a basename of ']_block_invoke'.

Also fixed a case in the by name lookup of functions where we wouldn't look for the full name if we actually tried to call CPPLanguageRuntime::StripNamespacesFromVariableName() and got an empty basename back.

<rdar://problem/18527866>


Modified:
    lldb/trunk/source/Core/Module.cpp
    lldb/trunk/source/Target/CPPLanguageRuntime.cpp

Modified: lldb/trunk/source/Core/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=220432&r1=220431&r2=220432&view=diff
==============================================================================
--- lldb/trunk/source/Core/Module.cpp (original)
+++ lldb/trunk/source/Core/Module.cpp Wed Oct 22 16:47:13 2014
@@ -1730,6 +1730,8 @@ Module::PrepareForFunctionNameLookup (co
             {
                 if (CPPLanguageRuntime::StripNamespacesFromVariableName (name_cstr, base_name_start, base_name_end))
                     lookup_name_type_mask |= (eFunctionNameTypeMethod | eFunctionNameTypeBase);
+                else
+                    lookup_name_type_mask = eFunctionNameTypeFull;
             }
             else
             {

Modified: lldb/trunk/source/Target/CPPLanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/CPPLanguageRuntime.cpp?rev=220432&r1=220431&r2=220432&view=diff
==============================================================================
--- lldb/trunk/source/Target/CPPLanguageRuntime.cpp (original)
+++ lldb/trunk/source/Target/CPPLanguageRuntime.cpp Wed Oct 22 16:47:13 2014
@@ -192,28 +192,19 @@ CPPLanguageRuntime::IsCPPMangledName (co
 bool
 CPPLanguageRuntime::StripNamespacesFromVariableName (const char *name, const char *&base_name_start, const char *&base_name_end)
 {
-    if (base_name_end == NULL)
-        base_name_end = name + strlen (name);
-    
-    const char *last_colon = strrchr (name, ':');
-    
-    if (last_colon == NULL)
+    static RegularExpression g_basename_regex("([A-Za-z_][A-Za-z_0-9]*::)+([A-Za-z_][A-Za-z_0-9]*)$");
+    RegularExpression::Match match(2);
+    if (g_basename_regex.Execute (name, &match))
     {
-        base_name_start = name;
-        return true;
-    }
-    
-    // Can't have a C++ name that begins with a single ':', nor contains an internal single ':'
-    if (last_colon == name)
-        return false;
-    else if (last_colon[-1] != ':')
-        return false;
-    else
-    {
-        // FIXME: should check if there is
-        base_name_start = last_colon + 1;
-        return true;
+        llvm::StringRef basename;
+        if (match.GetMatchAtIndex(name, 2, basename))
+        {
+            base_name_start = basename.data();
+            base_name_end = base_name_start + basename.size();
+            return true;
+        }
     }
+    return false;
 }
 
 uint32_t





More information about the lldb-commits mailing list