[clang] [Clang] Clarify diagnostic notes for implicitly generated deduction guides (PR #96084)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 21 02:44:47 PDT 2024


================
@@ -12114,6 +12115,35 @@ static void NoteFunctionCandidate(Sema &S, OverloadCandidate *Cand,
     return;
   }
 
+  // If this is an implicit deduction guide against an implicitly defined
+  // constructor, add a note for it. Neither these deduction guides nor their
+  // corresponding constructors are explicitly spelled in the source code,
----------------
zyn0217 wrote:

Yeah, we would have a deduction guide with combined template parameters; however, my concern is that we already have sufficient code contexts in the snippets of a diagnostic for users to understand the error. For example,
```cpp
template <class T> struct Outer {
    template <class U> struct Inner {
	template <class V>
	Inner(U, V, V) {}
    };
};

Outer<int>::Inner i(42, "hello");
```
https://clang.godbolt.org/z/1bEfqrrMv

we currently have a note followed by a code snippet:
```
<source>:4:2: note: candidate function template not viable: requires 3 arguments, but 2 were provided
    4 |         Inner(U, V, V) {}
      |         ^     ~~~~~~~
```
although we don't have the synthesized template parameters presented, I think (subjectively) this is probably already legible.

> (this covers the using-alias case.)

With the filter currently in place, I have seen a bunch of additional notes following the using-alias cases. However, I'm not sure I have handled them all.

https://github.com/llvm/llvm-project/pull/96084


More information about the cfe-commits mailing list