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

    <tr>
        <th>Summary</th>
        <td>
            [clang-cl] Cannot mangle `decltype` when used in an unevaluated context
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:codegen,
            platform:windows
      </td>
    </tr>

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

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

<pre>
    https://godbolt.org/z/cGsG8T4G7
```
template<typename T, typename = void>
struct Widget;

template <class T>
struct Widget<T, decltype(T::test2([](){}))> 
{
};

struct Baz
{
    template<typename F>
    static constexpr decltype(auto) test2(F&& f) {}
};

void test()
{
    Widget<Baz> w;
}
```

Similar issue as https://github.com/llvm/llvm-project/issues/115990 which is fixed here https://github.com/llvm/llvm-project/pull/117845.

`test2` must be instantiated since it has a deduced return type. The instantiation of the lambda is within the context of the uninstantiated Widget template. CodeGen has no way to know that a template argument is defined inside an uninstantiated template. So the functions get put into `DeferredDecls` which is keyed off of the mangled name of the function so we need to mangle the `decltype`.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUlMuO4r4Sxp-m2JQGOU5IyCILGppendUgzdrYFeIzjo3iStM9T_-XzaUvms0IJIJd_r5fXWIVoz15og5WT7DaLdTMQ5i6_6m351-NaBbHYN67gfkcodyA3IPcn4I5BsfLMJ1A7v-A3OuX-LI-VC8NiA3U4vYVG6bx7BQTlFt-P5NXI-EB5BYf_6Dc4WuwBspnEJvI06wZf1lzIobyKcl9qCCUW-1UjHj4a_g2SxvSLsmDXB8ScrlhiixBrq8ZpgfZQvMEzS49yBbKZ0xOTfZrdg_jm_6T-vPYRkT8W1b7K1HajqzYatTBR6a38_SZSM0cQLZ4R9qDrEHW2KfFG9NXhlScHH7j_gzySDwRls94uZ26inzqA4jNTztapya0Mc6EKuK3nloe5uNShxHk3rnX-8-P8xT-T5pB7vPJCHJfFKu2FXgZrB7QRuztGxkcaKJ_Fz3PzmXJZl2tlldUqMW1PrXAcY6MR0LrIyvPVjEZjNZrQss4qIgKDZlZk8GJeJ58nq0lHobPh2zwGHrkgdCp8WhU4r5YHqzPizp4pje-x8z-i9-1zo--L3EbDL2Qz_4-4EW9Iwf87cMFeVCM6hGLajrNI3lOhoZ668kkLmsIlf9u9OHwM2SQfvY6wUdMAOeZ0XoOCLXYUU_TRGZH2sVUqUc7ftM7GQx9f89mVP7kyGAe1NvaXRhjwAuhp-QebqE5AmrxGNxaLBemK01btmpBXdGUZSFWoi4WQ9cei1bXVa9aqRvZKilasypVXxXlujLtemE7KWRVSJE-lSyWa12Kslmbpjmu2krVUAkalXXLNBvpVlnkUeuKYi2rYuHUkVzM95OU2il_gnKjg6ETeZAS5BakTGXrwzRCublYb8Ilpq3VbjF1eeKO8ylCJZyNHD982LLLN1-W_aEdrHa4Vd4HvpfiaxnwMpDHOeYmXhtIr8rNuXu3IVrMk_t-Y_7T25Wzfu3kfwEAAP__Jn7J9Q">