<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/124445>124445</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Improve `auto` type deduction in HeuristicResolver
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
            HighCommander4
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          HighCommander4
      </td>
    </tr>
</table>

<pre>
    In https://github.com/clangd/clangd/issues/897 I added rudimentary support for `auto` type deduction to `HeuristicResolver`, but the accuracy could be improved further.

As an example, the implementation does not currently propagate the `const` when deducing `const auto`.

This can be seen in clangd with the following code example:

```c++
template <typename T>
struct A {
  void waldo();
  void waldo() const;
};
template <typename T>
void foo(A<T> a) {
  const auto copy = a;
 copy.waldo();
}
```

Go-to-definition on the `waldo` token in `copy.waldo()` offers both overloads as candidates, but it should only offer the `const` overload.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx8VN2OqzYQfhpzM9oI7ADJBRecbNOzt9V5AWMP4NZ4kH-S5u0rQ87ZbbdayRLG4_m-b_4sQzCTQ-xY_Y1x_t1M84WWRTqN_sg4Z_VrIVOcyXf_thUD6Uf35mCOcQ1M9IxfGb9OJs5pOChaGL8qK92kP25MCAkD49fTuYU3kFqjBp-0WdBF6R8Q0rqSjzCSB9aUMkViTQnxsSJo1ElFQw4iZeN3TN6EaNQfGMje0LOmZPwCQ4oQZwSpVPJSPUBRshoGBLOsnm6oYUw-zugPrOxZ2fcBpAP8Wy6rxYyQvU3-2WRtlJowgKMIKnmPLtoHrJ5WOcmI233WlIpciFnufUa3yzVu-mWBZzRP1h-zCaCky8ICogPjYE8U3E2cN9CRrKV7BlGk8ZdE0e8QOeBtKca_5VX2EZfVZk1MXHLWnFwQfjDxGyv7EH1SEXpgbb4KcCOj4S6tJsZPjJ-Z-P9z2CPbrKx93TdfMW0AI2X3nolLPgWZgX4yvycEFK0PYOIV5JM-Hxw-qcq8HyLeE_A7vUR60TgaZ7Yy5ebYi7ED5N6hv_bkbnX4D3RTAo0j-gADxRnoht6S1AHkVhtttIy5YfeuMhHCvDUTOfvYPT8V_yfGodCd0GdxlgV2VSvaU3NuhSjmTkg8Yd3IqtVjq_hYjVWl1ak980E3kh8L0_GS12XFm7IWtRCHsS6HutLt2J60bqRgxxIXaezB2ttyID8V22R1FT8ej3Vh5YA2PGd66ykm-tGTi-j0c6p9l31fhjQFdiytCTG8o0UTLXZv-7h8MYjGwacpLJK33RevQiZ5fl5WT3-iih9fhmcIt47_EwAA__-W-3uO">