File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,11 @@ void AvoidDefaultLambdaCaptureCheck::check(
54
54
ImplicitCaptures.push_back (generateCaptureText (Capture));
55
55
}
56
56
57
+ // For template-dependent lambdas, the list of captures hasn't been created
58
+ // yet, so the list of implicit captures is empty.
59
+ if (ImplicitCaptures.empty () && Lambda->isGenericLambda ())
60
+ return ;
61
+
57
62
const auto ReplacementText = [&ImplicitCaptures]() {
58
63
return llvm::join (ImplicitCaptures, " , " );
59
64
}();
Original file line number Diff line number Diff line change @@ -95,13 +95,13 @@ class TestClass {
95
95
}
96
96
};
97
97
98
+ // Lambda captures dependent on a template parameter don't have a fix it
98
99
template <typename T>
99
100
void test_template_lambdas () {
100
101
T value{};
101
102
102
103
auto lambda = [=](T x) { return value + x; };
103
104
// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [readability-avoid-default-lambda-capture]
104
- // CHECK-FIXES: auto lambda = [value](T x) { return value + x; };
105
105
}
106
106
107
107
void instantiate_templates () {
You can’t perform that action at this time.
0 commit comments