Skip to content

[FixIt] Improve Source Ranges and Fix-It Hints for Unused Lambda Captures #106445 #117953

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 60 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
b886394
Update SemaLambda.cpp
charan-003 Nov 28, 2024
ccb3952
Update fixit-unused-lambda-capture.cpp
charan-003 Nov 28, 2024
6b5fff5
Update SemaLambda.cpp
charan-003 Nov 28, 2024
46fd602
Update SemaLambda.cpp
charan-003 Nov 28, 2024
3e48830
Update SemaLambda.cpp
charan-003 Nov 28, 2024
41adf62
Update SemaLambda.cpp
charan-003 Nov 28, 2024
420d7d0
Update DiagnosticSemaKinds.td
charan-003 Nov 29, 2024
ffd9f20
Update ParseExprCXX.cpp
charan-003 Nov 29, 2024
c355082
Update SemaLambda.cpp
charan-003 Nov 29, 2024
ff42abb
Update SemaLambda.cpp
charan-003 Dec 20, 2024
3ee7a72
Update fixit-unused-lambda-capture.cpp
charan-003 Dec 20, 2024
5cb9c15
Update ParseExprCXX.cpp
charan-003 Dec 20, 2024
0326d6e
Update DiagnosticSemaKinds.td
charan-003 Dec 20, 2024
c1326a9
Update DiagnosticSemaKinds.td
charan-003 Dec 20, 2024
34807aa
Update ParseExprCXX.cpp
charan-003 Dec 20, 2024
cbda68a
Update SemaLambda.cpp
charan-003 Dec 20, 2024
f899a90
Update fixit-unused-lambda-capture.cpp
charan-003 Dec 20, 2024
e41a05a
Update DiagnosticSemaKinds.td
charan-003 Dec 21, 2024
a830c8a
Update ParseExprCXX.cpp
charan-003 Dec 21, 2024
a7c1d16
Update ParseExprCXX.cpp
charan-003 Dec 21, 2024
82a1667
Update SemaLambda.cpp
charan-003 Dec 21, 2024
cd72b63
Update lambda-expressions.cpp
charan-003 Dec 26, 2024
0f9b9f8
Update SemaLambda.cpp
charan-003 Feb 13, 2025
e0cdf27
Update SemaLambda.cpp
charan-003 Feb 13, 2025
d5bcc61
Update lambda-expressions.cpp
charan-003 May 2, 2025
9a57baf
Update lambda-misplaced-capture-default.cpp
charan-003 May 2, 2025
fa58b4f
Update init-capture.cpp
charan-003 May 2, 2025
6f38efc
Update cxx1y-init-captures.cpp
charan-003 May 2, 2025
524d0cc
Update lambda-expressions.cpp
charan-003 May 3, 2025
f5ef37c
Update fold_lambda_with_variadics.cpp
charan-003 May 3, 2025
fb23624
Update SemaLambda.cpp
charan-003 May 3, 2025
c6fe811
Update p11-1y.cpp
charan-003 May 3, 2025
24004a0
Update p23.cpp
charan-003 May 3, 2025
56d2d59
Update p11-1y.cpp
charan-003 May 3, 2025
22b40e1
Update fold_lambda_with_variadics.cpp
charan-003 May 3, 2025
c553055
Update fold_lambda_with_variadics.cpp
charan-003 May 4, 2025
9779723
Merge branch 'main' into main
charan-003 May 4, 2025
46ab97b
Update SemaLambda.cpp
charan-003 May 6, 2025
0fa8171
Update SemaLambda.cpp
charan-003 May 6, 2025
961c26c
Update SemaLambda.cpp
charan-003 May 6, 2025
73866bc
Update SemaLambda.cpp
charan-003 May 6, 2025
8b64a3a
Update recovery.cpp
charan-003 May 7, 2025
a2c7116
Fix unused lambda capture source ranges and tests
May 7, 2025
b55c1e9
Merge remote-tracking branch 'origin/main'
May 7, 2025
119e23c
Merge branch 'main' into main
charan-003 May 7, 2025
40e6697
Update lambda-expressions.cpp
charan-003 May 13, 2025
be57824
Update fold_lambda_with_variadics.cpp
charan-003 May 13, 2025
e2adf7c
Update SemaLambda.cpp
charan-003 May 14, 2025
15dde87
Update SemaLambda.cpp
charan-003 May 19, 2025
30b5880
Update recovery.cpp
charan-003 May 20, 2025
4959dab
Update p11-1y.cpp
charan-003 May 20, 2025
1ac52d5
Update lambda-misplaced-capture-default.cpp
charan-003 May 20, 2025
9ce2043
Update p23.cpp
charan-003 May 20, 2025
e6ec625
Update init-capture.cpp
charan-003 May 20, 2025
d30c84b
Update cxx1y-init-captures.cpp
charan-003 May 20, 2025
675199f
Update fold_lambda_with_variadics.cpp
charan-003 May 20, 2025
146b98b
Update lambda-expressions.cpp
charan-003 May 20, 2025
746f00e
Update SemaLambda.cpp
charan-003 May 21, 2025
2687f42
Update DiagnosticSemaKinds.td
charan-003 May 22, 2025
bb74e5f
Update DiagnosticSemaKinds.td
charan-003 May 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ def note_replace_abs_function : Note<"use function '%0' instead">;
def warn_pointer_abs : Warning<
"taking the absolute value of %select{pointer|function|array}0 type %1 is suspicious">,
InGroup<AbsoluteValue>;

def warn_max_unsigned_zero : Warning<
"taking the max of "
"%select{a value and unsigned zero|unsigned zero and a value}0 "
Expand Down
6 changes: 4 additions & 2 deletions clang/lib/Parse/ParseExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,9 @@ static void tryConsumeLambdaSpecifierToken(Parser &P,
DeclEndLoc = SpecifierLoc;
};

while (true) {
// Process lambda specifiers until an invalid token is found
while (P.getCurToken().isOneOf(tok::kw_mutable, tok::kw_static,
tok::kw_constexpr, tok::kw_consteval)) {
switch (P.getCurToken().getKind()) {
case tok::kw_mutable:
ConsumeLocation(MutableLoc, 0);
Expand All @@ -1284,7 +1286,7 @@ static void tryConsumeLambdaSpecifierToken(Parser &P,
ConsumeLocation(ConstevalLoc, 3);
break;
default:
return;
llvm_unreachable("Unexpected token in lambda specifier parsing");
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions clang/test/CXX/temp/temp.decls/temp.variadic/init-capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ template<typename ...T> void f(T ...t) {
// Not OK: can't expand 'x' outside its scope.
weird((void)[&...x = t] {
return &x; // expected-error {{unexpanded parameter pack 'x'}}
}... // expected-error {{does not contain any unexpanded}}
}... // expected-error {{pack expansion does not contain any unexpanded parameter packs}}
);

// OK, capture only one 'slice' of 'x'.
Expand All @@ -34,7 +34,7 @@ template<typename ...T> void f(T ...t) {
// 'x' is not expanded by the outer '...', but 'T' is.
weird((void)[&... x = t] {
return T() + &x; // expected-error {{unexpanded parameter pack 'x'}}
}... // expected-error {{does not contain any unexpanded}}
}... // expected-error {{pack expansion does not contain any unexpanded parameter packs}}
);
}

Expand All @@ -43,7 +43,7 @@ static_assert(x<1,2,3>([](int a, int b, int c) { return 100 * a + 10 * b + c; })
static_assert(x<1,2,3>([](int a, int b, int c) { return 100 * a + 10 * b + c; }) == 124); // expected-error {{failed}} \
// expected-note {{evaluates to '123 == 124'}}

template<int ...a> constexpr auto y = [z = a...] (auto F) { return F(z...); }; // expected-error {{must appear before the name of the capture}}
template<int ...a> constexpr auto y = [z = a...] (auto F) { return F(z...); }; // expected-error {{ellipsis in pack init-capture must appear before the name of the capture}}
static_assert(y<1,2,3>([](int a, int b, int c) { return 100 * a + 10 * b + c; }) == 123);
static_assert(y<1,2,3>([](int a, int b, int c) { return 100 * a + 10 * b + c; }) == 124); // expected-error {{failed}} \
// expected-note {{evaluates to '123 == 124'}}