Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py =================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py @@ -297,3 +297,6 @@ self.complete_from_to('breakpoint set -n Fo', 'breakpoint set -n Foo::Bar(int,\\ int)', turn_off_re_match=True) + # No completion for Qu because the candidate is + # (anonymous namespace)::Quux(). + self.complete_from_to('breakpoint set -n Qu', '') Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/main.cpp =================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/main.cpp +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/main.cpp @@ -7,6 +7,8 @@ } }; +namespace { int Quux (void) { return 0; } } + struct Container { int MemberVar; }; int main() @@ -17,5 +19,6 @@ Container container; Container *ptr_container = &container; + int q = Quux(); return container.MemberVar = 3; // Break here } Index: lldb/trunk/source/Commands/CommandCompletions.cpp =================================================================== --- lldb/trunk/source/Commands/CommandCompletions.cpp +++ lldb/trunk/source/Commands/CommandCompletions.cpp @@ -471,7 +471,11 @@ for (uint32_t i = 0; i < sc_list.GetSize(); i++) { if (sc_list.GetContextAtIndex(i, sc)) { ConstString func_name = sc.GetFunctionName(Mangled::ePreferDemangled); - if (!func_name.IsEmpty()) + // Ensure that the function name matches the regex. This is more than a + // sanity check. It is possible that the demangled function name does + // not start with the prefix, for example when it's in an anonymous + // namespace. + if (!func_name.IsEmpty() && m_regex.Execute(func_name.GetStringRef())) m_match_set.insert(func_name); } }