[PATCH] D141800: [clangd] Fix qualifier not being dropped for using declaration referring to scoped enum
Tom Praschan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 18 10:48:56 PST 2023
tom-anders added inline comments.
================
Comment at: clang-tools-extra/clangd/CodeComplete.cpp:1993
Builder.emplace(Recorder ? &Recorder->CCSema->getASTContext() : nullptr,
- Item, SemaCCS, QueryScopes, *Inserter, FileName,
+ Recorder ? Recorder->CCSema->CurContext : nullptr, Item,
+ SemaCCS, QueryScopes, *Inserter, FileName,
----------------
kadircet wrote:
> instead of passing it here, can we just do the traversal as part of `getQueryScopes` and let these be handled uniformly by the shortest qualifier logic ?
Yeah that was my initial idea, however the problem is that it looses the information about whether the enum is scoped or not:
1) QueryScopes only stores strings
2) The index has no flag for indicating whether an EnumConstant belongs to a scoped or unscoped enum
Thus, we get a small problem, consider the following code:
```
namespace ns {
enum class Scoped { Foo };
enum class Unscoped { Bar };
}
int main() {
using ns::Scoped;
using ns::Unscoped;
Foo^
Bar^
}
```
Here we want to complete Foo^ to ns::Scoped::Foo, but for Bar^ we want only ns::Bar. To resolve this, the scoped/unscoped information needs to be available when building the completion candidate.
Hope this was clear, maybe I missed something.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D141800/new/
https://reviews.llvm.org/D141800
More information about the cfe-commits
mailing list