This is an archive of the discontinued LLVM Phabricator instance.

Fix completion for functions in anonymous namespaces
ClosedPublic

Authored by JDevlieghere on Jul 30 2019, 11:00 PM.

Details

Summary

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

Diff Detail

Repository
rL LLVM

Event Timeline

JDevlieghere created this revision.Jul 30 2019, 11:00 PM

I don't immediately see a better way to fix this, but I'm not terribly familiar with this machinery either. I guess one day we may want to extend the completion machinery to be able to expand "foo<TAB>" into "(anonymous namespace)::foobar", but that's likely to be a larger undertaking...

I don't immediately see a better way to fix this, but I'm not terribly familiar with this machinery either. I guess one day we may want to extend the completion machinery to be able to expand "foo<TAB>" into "(anonymous namespace)::foobar", but that's likely to be a larger undertaking...

Yep, that's how I wanted to fix this before I discovered that was going to be a lot harder than I hoped. :-)

I think it's possible to rewrite the line when doing a completion, but I remember that I got annoyed when I tried understand the code responsible for that (and decipher the magic return values). Can you file a radar maybe and I'll fix this once I got around to refactor the related code? This patch can go IMHO, so LGTM.

teemperor accepted this revision.Jul 31 2019, 12:18 AM
This revision is now accepted and ready to land.Jul 31 2019, 12:18 AM

I think it's possible to rewrite the line when doing a completion, but I remember that I got annoyed when I tried understand the code responsible for that (and decipher the magic return values). Can you file a radar maybe and I'll fix this once I got around to refactor the related code? This patch can go IMHO, so LGTM.

I think we could solve this issue by storing more information with the candidates, like a bit that says that we should clear (part) of the current line. However, currently candidates are stored in StringLists, which do not have such capabilities. The part that rewrites the line should be relatively straightforward.

I've filed rdar://53769355. I might come back to it myself as I'd like to have this non-prefix completion functionality.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 31 2019, 11:01 AM