-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[LLDB] Fix crash when using tab completion on class variables #83234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write If you have received no comments on your PR for a week, you can request a review If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
a7d84af
to
87c442c
Compare
87c442c
to
cf1359a
Compare
@llvm/pr-subscribers-lldb Author: Sudharsan Veeravalli (svs-quic) ChangesWe weren't checking to see if the partial_path was empty before adding completions and this led to crashes when the class object and a variable both start with the same substring. Fixes #81536 Full diff: https://github.com/llvm/llvm-project/pull/83234.diff 1 Files Affected:
diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp
index 2bb2ff7db4b721..a33c3433d9e245 100644
--- a/lldb/source/Symbol/Variable.cpp
+++ b/lldb/source/Symbol/Variable.cpp
@@ -509,15 +509,17 @@ static void PrivateAutoCompleteMembers(
CompilerType member_compiler_type = compiler_type.GetFieldAtIndex(
i, member_name, nullptr, nullptr, nullptr);
- if (partial_member_name.empty() ||
- llvm::StringRef(member_name).starts_with(partial_member_name)) {
+ if (partial_member_name.empty()) {
+ request.AddCompletion((prefix_path + member_name).str());
+ } else if (llvm::StringRef(member_name)
+ .starts_with(partial_member_name)) {
if (member_name == partial_member_name) {
PrivateAutoComplete(
frame, partial_path,
prefix_path + member_name, // Anything that has been resolved
// already will be in here
member_compiler_type.GetCanonicalType(), request);
- } else {
+ } else if (partial_path.empty()) {
request.AddCompletion((prefix_path + member_name).str());
}
}
|
Change itself is fine. But could you please add a test in |
✅ With the latest revision this PR passed the C/C++ code formatter. |
Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm thanks!
Thanks. I dont think I have commit access . Would you be able to merge this for me? |
@svs-quic Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested Please check whether problems have been caused by your change specifically, as How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
self.complete_from_to(f"{command} fooo.dd", f"{command} fooo.dd") | ||
|
||
self.complete_from_to(f"{command} ptr_fooo->", f"{command} ptr_fooo->") | ||
self.complete_from_to(f"{command} ptr_fooo->", f"{command} ptr_fooo->t") | ||
self.complete_from_to(f"{command} ptr_fooo->t", f"{command} ptr_fooo->t.x") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have been ptr_fooo->t.
Will fix this in a follow up patch
…3234) We weren't checking to see if the partial_path was empty before adding completions and this led to crashes when the class object and a variable both start with the same substring. Fixes [llvm#81536](llvm#81536) --------- Co-authored-by: Michael Buch <[email protected]> (cherry picked from commit de55188)
Missed adding a . in the test check (cherry picked from commit ee297a7)
We weren't checking to see if the partial_path was empty before adding completions and this led to crashes when the class object and a variable both start with the same substring.
Fixes #81536