[Lldb-commits] [lldb] r183470 - <rdar://problem/14086944>

Greg Clayton gclayton at apple.com
Thu Jun 6 17:35:40 PDT 2013


Author: gclayton
Date: Thu Jun  6 19:35:40 2013
New Revision: 183470

URL: http://llvm.org/viewvc/llvm-project?rev=183470&view=rev
Log:
<rdar://problem/14086944>

lldb doesn't autocomplete objective C class methods. The regular expression was looking for strings that started with the completion string that was passed in. For objective C class methods, this string starts with "+" which wasn't being escaped. Added many other escapes that were missing just in case.


Modified:
    lldb/trunk/source/Commands/CommandCompletions.cpp

Modified: lldb/trunk/source/Commands/CommandCompletions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandCompletions.cpp?rev=183470&r1=183469&r2=183470&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandCompletions.cpp (original)
+++ lldb/trunk/source/Commands/CommandCompletions.cpp Thu Jun  6 19:35:40 2013
@@ -599,7 +599,17 @@ CommandCompletions::SourceFileCompleter:
 static bool
 regex_chars (const char comp)
 {
-    if (comp == '[' || comp == ']' || comp == '(' || comp == ')')
+    if (comp == '[' || comp == ']' ||
+        comp == '(' || comp == ')' ||
+        comp == '{' || comp == '}' ||
+        comp == '+' ||
+        comp == '.' ||
+        comp == '*' ||
+        comp == '|' ||
+        comp == '^' ||
+        comp == '$' ||
+        comp == '\\' ||
+        comp == '?')
         return true;
     else
         return false;
@@ -614,16 +624,22 @@ CommandCompletions::SymbolCompleter::Sym
 ) :
     CommandCompletions::Completer (interpreter, completion_str, match_start_point, max_return_elements, matches)
 {
-    std::string regex_str ("^");
-    regex_str.append(completion_str);
-    regex_str.append(".*");
-    std::string::iterator pos;
-
-    pos = find_if(regex_str.begin(), regex_str.end(), regex_chars);
-    while (pos < regex_str.end()) {
+    std::string regex_str;
+    if (completion_str && completion_str[0])
+    {
+        regex_str.append("^");
+        regex_str.append(completion_str);
+    }
+    else
+    {
+        // Match anything since the completion string is empty
+        regex_str.append(".");
+    }
+    std::string::iterator pos = find_if(regex_str.begin() + 1, regex_str.end(), regex_chars);
+    while (pos < regex_str.end())
+    {
         pos = regex_str.insert(pos, '\\');
-        pos += 2;
-        pos = find_if(pos, regex_str.end(), regex_chars);
+        pos = find_if(pos + 2, regex_str.end(), regex_chars);
     }
     m_regex.Compile(regex_str.c_str());
 }





More information about the lldb-commits mailing list