tberghammer updated this revision to Diff 33692.
tberghammer added a comment.

Address review comment (the function already exists in Args)


http://reviews.llvm.org/D12531

Files:
  source/Interpreter/Options.cpp
  test/functionalities/completion/Makefile
  test/functionalities/completion/TestCompletion.py
  test/functionalities/completion/main.cpp

Index: test/functionalities/completion/main.cpp
===================================================================
--- /dev/null
+++ test/functionalities/completion/main.cpp
@@ -0,0 +1,14 @@
+class Foo
+{
+public:
+    int Bar(int x, int y)
+    {
+        return x + y;
+    }
+};
+
+int main()
+{
+    Foo f;
+    f.Bar(1, 2);
+}
Index: test/functionalities/completion/TestCompletion.py
===================================================================
--- test/functionalities/completion/TestCompletion.py
+++ test/functionalities/completion/TestCompletion.py
@@ -219,6 +219,23 @@
         """Test that 'target va' completes to 'target variable '."""
         self.complete_from_to('target va', 'target variable ')
 
+    @skipUnlessDarwin
+    @dsym_test
+    def test_symbol_name_dsym(self):
+        self.buildDsym()
+        self.complete_from_to('''file a.out
+                                 breakpoint set -n Fo''',
+                              'breakpoint set -n Foo::Bar(int,\\ int)',
+                              turn_off_re_match=True)
+
+    @dwarf_test
+    def test_symbol_name_dwarf(self):
+        self.buildDwarf()
+        self.complete_from_to('''file a.out
+                                 breakpoint set -n Fo''',
+                              'breakpoint set -n Foo::Bar(int,\\ int)',
+                              turn_off_re_match=True)
+
     def complete_from_to(self, str_input, patterns, turn_off_re_match=False):
         """Test that the completion mechanism completes str_input to patterns,
         where patterns could be a pattern-string or a list of 
pattern-strings"""
Index: test/functionalities/completion/Makefile
===================================================================
--- /dev/null
+++ test/functionalities/completion/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
Index: source/Interpreter/Options.cpp
===================================================================
--- source/Interpreter/Options.cpp
+++ source/Interpreter/Options.cpp
@@ -975,15 +975,24 @@
         }
     }
 
-    return CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
-                                                                
completion_mask,
-                                                                
input.GetArgumentAtIndex (opt_arg_pos),
-                                                                
match_start_point,
-                                                                
max_return_elements,
-                                                                
filter_ap.get(),
-                                                                word_complete,
-                                                                matches);
-    
+    bool ret = CommandCompletions::InvokeCommonCompletionCallbacks 
(m_interpreter,
+                                                                    
completion_mask,
+                                                                    
input.GetArgumentAtIndex (opt_arg_pos),
+                                                                    
match_start_point,
+                                                                    
max_return_elements,
+                                                                    
filter_ap.get(),
+                                                                    
word_complete,
+                                                                    matches);
+
+    // Escape spaces and backslashes in the matches list as the arguments 
shouldn't contain any of
+    // these characters without escaping.
+    for (size_t i = 0; i < matches.GetSize(); ++i)
+    {
+        std::string s;
+        Args::GetShellSafeArgument(matches[i].c_str(), s);
+        matches[i] = s;
+    }
+    return ret;
 }
 
 


Index: test/functionalities/completion/main.cpp
===================================================================
--- /dev/null
+++ test/functionalities/completion/main.cpp
@@ -0,0 +1,14 @@
+class Foo
+{
+public:
+    int Bar(int x, int y)
+    {
+        return x + y;
+    }
+};
+
+int main()
+{
+    Foo f;
+    f.Bar(1, 2);
+}
Index: test/functionalities/completion/TestCompletion.py
===================================================================
--- test/functionalities/completion/TestCompletion.py
+++ test/functionalities/completion/TestCompletion.py
@@ -219,6 +219,23 @@
         """Test that 'target va' completes to 'target variable '."""
         self.complete_from_to('target va', 'target variable ')
 
+    @skipUnlessDarwin
+    @dsym_test
+    def test_symbol_name_dsym(self):
+        self.buildDsym()
+        self.complete_from_to('''file a.out
+                                 breakpoint set -n Fo''',
+                              'breakpoint set -n Foo::Bar(int,\\ int)',
+                              turn_off_re_match=True)
+
+    @dwarf_test
+    def test_symbol_name_dwarf(self):
+        self.buildDwarf()
+        self.complete_from_to('''file a.out
+                                 breakpoint set -n Fo''',
+                              'breakpoint set -n Foo::Bar(int,\\ int)',
+                              turn_off_re_match=True)
+
     def complete_from_to(self, str_input, patterns, turn_off_re_match=False):
         """Test that the completion mechanism completes str_input to patterns,
         where patterns could be a pattern-string or a list of pattern-strings"""
Index: test/functionalities/completion/Makefile
===================================================================
--- /dev/null
+++ test/functionalities/completion/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
Index: source/Interpreter/Options.cpp
===================================================================
--- source/Interpreter/Options.cpp
+++ source/Interpreter/Options.cpp
@@ -975,15 +975,24 @@
         }
     }
 
-    return CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
-                                                                completion_mask,
-                                                                input.GetArgumentAtIndex (opt_arg_pos),
-                                                                match_start_point,
-                                                                max_return_elements,
-                                                                filter_ap.get(),
-                                                                word_complete,
-                                                                matches);
-    
+    bool ret = CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
+                                                                    completion_mask,
+                                                                    input.GetArgumentAtIndex (opt_arg_pos),
+                                                                    match_start_point,
+                                                                    max_return_elements,
+                                                                    filter_ap.get(),
+                                                                    word_complete,
+                                                                    matches);
+
+    // Escape spaces and backslashes in the matches list as the arguments shouldn't contain any of
+    // these characters without escaping.
+    for (size_t i = 0; i < matches.GetSize(); ++i)
+    {
+        std::string s;
+        Args::GetShellSafeArgument(matches[i].c_str(), s);
+        matches[i] = s;
+    }
+    return ret;
 }
 
 
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to