[Lldb-commits] [PATCH] D65498: Fix completion for functions in anonymous namespaces
Jonas Devlieghere via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Jul 30 23:01:11 PDT 2019
JDevlieghere created this revision.
JDevlieghere added reviewers: labath, teemperor, jingham.
JDevlieghere added a project: LLDB.
Herald added subscribers: abidh, aprantl.
I was going through some of the old bugs and came across PR21069 which I was able to reproduce. The issue is that we match the regex `^foo` against the `DW_AT_name` in the DWARF, which for our anonymous function is indeed `foo`. However, when we get the function name from the symbol context, the result is `(anonymous namespace)::foo()`. This throws off completions, which assumes that it's appending to whatever is already present on the input, resulting in a bogus `b fooonymous\ namespace)::foo()`.
I'm not super familiar with the completion framework, so please let me know if there's a better way to solve this issue.
https://bugs.llvm.org/show_bug.cgi?id=21069
Repository:
rLLDB LLDB
https://reviews.llvm.org/D65498
Files:
lldb/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
lldb/packages/Python/lldbsuite/test/functionalities/completion/main.cpp
lldb/source/Commands/CommandCompletions.cpp
Index: lldb/source/Commands/CommandCompletions.cpp
===================================================================
--- lldb/source/Commands/CommandCompletions.cpp
+++ lldb/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);
}
}
Index: lldb/packages/Python/lldbsuite/test/functionalities/completion/main.cpp
===================================================================
--- lldb/packages/Python/lldbsuite/test/functionalities/completion/main.cpp
+++ lldb/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/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
+++ lldb/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', '')
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65498.212505.patch
Type: text/x-patch
Size: 2131 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190731/82926779/attachment.bin>
More information about the lldb-commits
mailing list