[clang-tools-extra] [clangd] Avoid invalid include-fixer fuzzy-find queries (PR #212134)
Aleksandr Platonov via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 29 04:11:33 PDT 2026
ArcsinX wrote:
> Investigated this further. `DeclarationNameInfo` is correct here: parser recognizes `operator ::align_val_t` as a conversion-function-id, and Sema constructs a `CXXConversionFunctionName` with a target type.
>
> The incorrect step was in `UnresolvedNameRecorder`: it unconditionally called `Typo.getAsString()` and treated the diagnostic presentation string as `UnresolvedName::Name`. For this kind, that string contains the target type and can contain `std::`, which is not an outer lookup scope that IncludeFixer can split into `Name + Scopes`.
>
> I updated the patch to reject only `CXXConversionFunctionName` before this lossy conversion. This removes the string-based `contains("::")` check. I intentionally do not reject all non-identifier names: e.g. overloaded operators may still be valid unqualified index names.
I’m not sure it’s right to always reject `CXXConversionFunctionName`.
E.g.
`test.h`
```cpp
#pragma once
struct Something { int I = 0; };
```
`test.cpp`
```cpp
struct Wrapper {
template <typename T>
operator T() const { return T(); }
};
void f() {
Wrapper W;
auto V = W.operator::Something();
}
```
test.cpp will have compilation error, which can be fixed with test.h include.
So, the question is, will we reject such a case with this patch or not?
https://github.com/llvm/llvm-project/pull/212134
More information about the cfe-commits
mailing list