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

    <tr>
        <th>Summary</th>
        <td>
            [clang] Improve diagnostics for CTAD
        </td>
    </tr>

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

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

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

<pre>
    Consider the following example:

```cpp
template<typename> concept False = false;

template <class T> 
struct Foo { 
    template <class U>
    requires False<U>
    Foo(T, U);
};

Foo abc(1, 2); // CTAD fails
```

This code is invalid as class template argument deduction fails, and the diagnostics emitted by clang are:

```cpp
<source>:10:5: error: no viable constructor or deduction guide for deduction of template arguments of 'Foo'
   10 | Foo abc(1, 2);
      |     ^
<source>:7:5: note: candidate template ignored: constraints not satisfied [with T = int, U = int]
    7 | Foo(T, U);
      |     ^
<source>:6:14: note: because 'int' does not satisfy 'False'
    6 |     requires False<U>
      | ^
<source>:1:36: note: because 'false' evaluated to false
    1 | template<typename> concept False = false;
      | ^
<source>:4:8: note: candidate function template not viable: requires 1 argument, but 2 were provided
```

We have two template candidates (`auto(T, U) -> Foo<T>`, `auto (Foo<T>) -> Foo<T>`), and both of them are not viable during the function overload resolution. 

As noticed, the above diagnostic messages only mention "candidate template ignored", making it hard to identify which template candidate. The diagnostic position doesn't give much useful information as these templates are synthesized.

I think we can improve this by printing the function signature in the diagnostic message.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVluv4jgM_jXhxRrUJpTCAw8cGKR5Z7TPaeO22WkTNhdY9tevnHLpuc1ZrYRoycX-_PmzjfRetwZxw4oXVuxnMobOuk1nf6E2s8qq62ZnjdcKHYQOobF9by_atIB_y-HUIxNblu1Zdv9eZuOnPp3GlYDDqZcBmdiF6wmNHJCJ71BbU-MpwEH2HoGJPTT0xsTL1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