Open tbaederr opened 2 months ago
@llvm/issue-subscribers-clang-frontend
Author: Timm Baeder (tbaederr)
Hi!
This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:
test/
create fine-grained testing targets, so you can e.g. use make check-clang-ast
to only run Clang's AST tests.git clang-format HEAD~1
to format your changes.If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below.
@llvm/issue-subscribers-good-first-issue
Author: Timm Baeder (tbaederr)
Note the source range for a
does not include the comma after it if you have whitespace: https://godbolt.org/z/sGEYPaThs
Hi, I would like to work on this.
I believe the issue was introduced in https://github.com/llvm/llvm-project/commit/832f49b90a4907a0bc2b34b688c32f3c9613aab0. Interpreting the source range as the fix-it range rather than the diagnostic range actually makes some kind of sense.
So I’m wondering if this is the intended behavior. If we want to fix it, where should the changes be made? From the perspective of the fix-it suggestion, the comma still needs to be bound to a variable, either the former or the latter.
Right, those aren't just ranges, but delete ranges from the fixme. In that case, I'm not sure what to do. :upside_down_face:
For https://godbolt.org/z/8zdKPxY6K
int main() {
int a = 0, b = 0;
auto F = [&a, &b]() {
};
}
The output is:
<source>:11:16: warning: lambda capture 'a' is not used [-Wunused-lambda-capture]
11 | auto F = [&a, &b]() {
| ~^~
<source>:11:20: warning: lambda capture 'b' is not used [-Wunused-lambda-capture]
11 | auto F = [&a, &b]() {
| ~~~^
<source>:11:10: warning: unused variable 'F' [-Wunused-variable]
11 | auto F = [&a, &b]() {
| ^
So, I assume the third warning output should be:
<source>:11:20: warning: lambda capture 'b' is not used [-Wunused-lambda-capture]
11 | auto F = [&a, &b]() {
| ~^
Because this matches the behavior for a lambda with a single unsued capture?
<source>:11:16: warning: lambda capture 'a' is not used [-Wunused-lambda-capture]
11 | auto F = [&a]() {
| ~^
Kinda, yes. But the output is already correct as it is, when we consider that the source ranges aren't supposed to just highlight the unused parameter. They are fix-it hints that will remove the underlined text when applied.
Hi, can this ticket be assigned to me?
See: https://godbolt.org/z/MKjzsYb9b
The output is:
1) The source range for
&a
includes the comma after it 2) The source range for&b
includes both the comma and the whitespace between that and the captureThe second point is especially fun when inserting some useless whitespace: