[clang][Sema] Provide source range to several Wunused warnings
authorTakuya Shimizu <shimizu2486@gmail.com>
Fri, 16 Jun 2023 10:26:53 +0000 (19:26 +0900)
committerTakuya Shimizu <shimizu2486@gmail.com>
Fri, 16 Jun 2023 10:26:53 +0000 (19:26 +0900)
commit64083172eea26e50c8b22b85697a825be8bda424
tree41e30820aabe76acd4b8338c55b821ebfa5831d0
parent6223b1e76d51fca557582648efbd3710d3ce44ea
[clang][Sema] Provide source range to several Wunused warnings

When the diagnosed function/variable is a template specialization, the source range covers the specialization arguments.
e.g.
```
warning: unused function 'func<int>' [-Wunused-function]
template <> int func<int> () {}
                ^~~~~~~~~
```
This comes in line with the printed text in the warning message. In the above case, `func<int>`

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D152707
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaDecl.cpp
clang/test/Misc/Inputs/diag-unused-source-ranges.h [new file with mode: 0644]
clang/test/Misc/diag-unused-source-ranges.cpp [new file with mode: 0644]