llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.13k stars 12.02k forks source link

[clangd] Incorrect navigation caused by deducing this #116335

Open ymyh opened 2 days ago

ymyh commented 2 days ago
struct B
{
    template<typename Self>
    auto bar(this Self &&) 
    {
        return 0;
    }

    auto bar2(this B &&)
    {
        return 0;
    }
};

struct A
{
    auto foo()
    {
        return B{};
    }
};

auto baz(int n)
{
    return n;
}

int main()
{
    A a{};
    baz(a.foo().bar());

    A a2{};
    int n  = a2.foo().bar2();
}

incorrect navigation of a.foo and a to baz, a2.foo and a2 to n

llvmbot commented 1 day ago

@llvm/issue-subscribers-clangd

Author: dayDreamingSaltyFish (ymyh)

```c++ struct B { template<typename Self> auto bar(this Self &&) { return 0; } auto bar2(this B &&) { return 0; } }; struct A { auto foo() { return B{}; } }; auto baz(int n) { return n; } int main() { A a{}; baz(a.foo().bar()); A a2{}; int n = a2.foo().bar2(); } ``` incorrect navigation of a.foo and a to baz, a2.foo and a2 to n