nico wrote:
Demo:
```cpp
% cat demo-note-snippets.cc
struct Foo {};
void consume(int i);
void consume(double d);
void consume(const char *s);
void consume(bool b, int extra);
template <typename T> void level3(T t) { consume(t); }
template <typename T> void level2(T t) { level3(t); }
template <typename T> void level1(T t) { level2(t); }
int main() {
level1(Foo{});
}
```
```
% out/gn/bin/clang -fno-diagnostics-show-note-snippets demo.cc
demo.cc:8:42: error: no matching function for call to 'consume'
8 | template <typename T> void level3(T t) { consume(t); }
| ^~~~~~~
demo.cc:9:42: note: in instantiation of function template specialization
'level3<Foo>' requested here
demo.cc:10:42: note: in instantiation of function template specialization
'level2<Foo>' requested here
demo.cc:13:3: note: in instantiation of function template specialization
'level1<Foo>' requested here
demo.cc:3:6: note: candidate function not viable: no known conversion from
'Foo' to 'int' for 1st argument
demo.cc:4:6: note: candidate function not viable: no known conversion from
'Foo' to 'double' for 1st argument
demo.cc:5:6: note: candidate function not viable: no known conversion from
'Foo' to 'const char *' for 1st argument
demo.cc:6:6: note: candidate function not viable: requires 2 arguments, but 1
was provided
1 error generated.
```
```
% out/gn/bin/clang demo.cc
demo.cc:8:42: error: no matching function for call to 'consume'
8 | template <typename T> void level3(T t) { consume(t); }
| ^~~~~~~
demo.cc:9:42: note: in instantiation of function template specialization
'level3<Foo>' requested here
9 | template <typename T> void level2(T t) { level3(t); }
| ^
demo.cc:10:42: note: in instantiation of function template specialization
'level2<Foo>' requested here
10 | template <typename T> void level1(T t) { level2(t); }
| ^
demo.cc:13:3: note: in instantiation of function template specialization
'level1<Foo>' requested here
13 | level1(Foo{});
| ^
demo.cc:3:6: note: candidate function not viable: no known conversion from
'Foo' to 'int' for 1st argument
3 | void consume(int i);
| ^ ~~~~~
demo.cc:4:6: note: candidate function not viable: no known conversion from
'Foo' to 'double' for 1st argument
4 | void consume(double d);
| ^ ~~~~~~~~
demo.cc:5:6: note: candidate function not viable: no known conversion from
'Foo' to 'const char *' for 1st argument
5 | void consume(const char *s);
| ^ ~~~~~~~~~~~~~
demo.cc:6:6: note: candidate function not viable: requires 2 arguments, but 1
was provided
6 | void consume(bool b, int extra);
| ^ ~~~~~~~~~~~~~~~~~
1 error generated.
```
https://github.com/llvm/llvm-project/pull/216250
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits