Skip to content

Commit 5d4c2ca

Browse files
committed
Rename check to readability-default-lambda-capture
on-behalf-of: @amd <[email protected]>
1 parent ac709f4 commit 5d4c2ca

File tree

10 files changed

+33
-33
lines changed

10 files changed

+33
-33
lines changed

clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "CopyConstructorInitCheck.h"
2424
#include "CrtpConstructorAccessibilityCheck.h"
2525
#include "DanglingHandleCheck.h"
26-
#include "DefaultLambdaCaptureCheck.h"
2726
#include "DerivedMethodShadowingBaseMethodCheck.h"
2827
#include "DynamicStaticInitializersCheck.h"
2928
#include "EasilySwappableParametersCheck.h"
@@ -137,8 +136,6 @@ class BugproneModule : public ClangTidyModule {
137136
"bugprone-copy-constructor-init");
138137
CheckFactories.registerCheck<DanglingHandleCheck>(
139138
"bugprone-dangling-handle");
140-
CheckFactories.registerCheck<DefaultLambdaCaptureCheck>(
141-
"bugprone-default-lambda-capture");
142139
CheckFactories.registerCheck<DerivedMethodShadowingBaseMethodCheck>(
143140
"bugprone-derived-method-shadowing-base-method");
144141
CheckFactories.registerCheck<DynamicStaticInitializersCheck>(

clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ add_clang_library(clangTidyBugproneModule STATIC
1919
CopyConstructorInitCheck.cpp
2020
CrtpConstructorAccessibilityCheck.cpp
2121
DanglingHandleCheck.cpp
22-
DefaultLambdaCaptureCheck.cpp
2322
DerivedMethodShadowingBaseMethodCheck.cpp
2423
DynamicStaticInitializersCheck.cpp
2524
EasilySwappableParametersCheck.cpp

clang-tools-extra/clang-tidy/readability/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ add_clang_library(clangTidyReadabilityModule STATIC
1515
ContainerDataPointerCheck.cpp
1616
ContainerSizeEmptyCheck.cpp
1717
ConvertMemberFunctionsToStatic.cpp
18+
DefaultLambdaCaptureCheck.cpp
1819
DeleteNullPointerCheck.cpp
1920
DuplicateIncludeCheck.cpp
2021
ElseAfterReturnCheck.cpp

clang-tools-extra/clang-tidy/bugprone/DefaultLambdaCaptureCheck.cpp renamed to clang-tools-extra/clang-tidy/readability/DefaultLambdaCaptureCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
using namespace clang::ast_matchers;
1313

14-
namespace clang::tidy::bugprone {
14+
namespace clang::tidy::readability {
1515

1616
namespace {
1717
AST_MATCHER(LambdaExpr, hasDefaultCapture) {
@@ -36,4 +36,4 @@ void DefaultLambdaCaptureCheck::check(const MatchFinder::MatchResult &Result) {
3636
"prefer to capture specific variables explicitly");
3737
}
3838

39-
} // namespace clang::tidy::bugprone
39+
} // namespace clang::tidy::readability

clang-tools-extra/clang-tidy/bugprone/DefaultLambdaCaptureCheck.h renamed to clang-tools-extra/clang-tidy/readability/DefaultLambdaCaptureCheck.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_DEFAULTLAMBDACAPTURECHECK_H
10-
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_DEFAULTLAMBDACAPTURECHECK_H
9+
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_DEFAULTLAMBDACAPTURECHECK_H
10+
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_DEFAULTLAMBDACAPTURECHECK_H
1111

1212
#include "../ClangTidyCheck.h"
1313

14-
namespace clang::tidy::bugprone {
14+
namespace clang::tidy::readability {
1515

1616
/** Flags lambdas that use default capture modes
1717
*
1818
* For the user-facing documentation see:
19-
* https://clang.llvm.org/extra/clang-tidy/checks/bugprone/default-lambda-capture.html
19+
* https://clang.llvm.org/extra/clang-tidy/checks/readability/default-lambda-capture.html
2020
*/
2121
class DefaultLambdaCaptureCheck : public ClangTidyCheck {
2222
public:
@@ -29,6 +29,6 @@ class DefaultLambdaCaptureCheck : public ClangTidyCheck {
2929
}
3030
};
3131

32-
} // namespace clang::tidy::bugprone
32+
} // namespace clang::tidy::readability
3333

34-
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_DEFAULTLAMBDACAPTURECHECK_H
34+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_DEFAULTLAMBDACAPTURECHECK_H

clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "ContainerDataPointerCheck.h"
2121
#include "ContainerSizeEmptyCheck.h"
2222
#include "ConvertMemberFunctionsToStatic.h"
23+
#include "DefaultLambdaCaptureCheck.h"
2324
#include "DeleteNullPointerCheck.h"
2425
#include "DuplicateIncludeCheck.h"
2526
#include "ElseAfterReturnCheck.h"
@@ -92,6 +93,8 @@ class ReadabilityModule : public ClangTidyModule {
9293
"readability-container-size-empty");
9394
CheckFactories.registerCheck<ConvertMemberFunctionsToStatic>(
9495
"readability-convert-member-functions-to-static");
96+
CheckFactories.registerCheck<DefaultLambdaCaptureCheck>(
97+
"readability-default-lambda-capture");
9598
CheckFactories.registerCheck<DeleteNullPointerCheck>(
9699
"readability-delete-null-pointer");
97100
CheckFactories.registerCheck<DuplicateIncludeCheck>(

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,6 @@ New checks
167167
Detects default initialization (to 0) of variables with ``enum`` type where
168168
the enum has no enumerator with value of 0.
169169

170-
- New :doc:`bugprone-default-lambda-capture
171-
<clang-tidy/checks/bugprone/default-lambda-capture>` check.
172-
173-
Warns on default lambda captures (e.g. ``[&](){ ... }``, ``[=](){ ... }``)
174-
175170
- New :doc:`bugprone-derived-method-shadowing-base-method
176171
<clang-tidy/checks/bugprone/derived-method-shadowing-base-method>` check.
177172

@@ -356,6 +351,11 @@ Changes in existing checks
356351
<clang-tidy/checks/readability/uppercase-literal-suffix>` check to recognize
357352
literal suffixes added in C++23 and C23.
358353

354+
- New :doc:`readability-default-lambda-capture
355+
<clang-tidy/checks/readability/default-lambda-capture>` check.
356+
357+
Warns on default lambda captures (e.g. ``[&](){ ... }``, ``[=](){ ... }``)
358+
359359
Removed checks
360360
^^^^^^^^^^^^^^
361361

clang-tools-extra/docs/clang-tidy/checks/list.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ Clang-Tidy Checks
9191
:doc:`bugprone-copy-constructor-init <bugprone/copy-constructor-init>`, "Yes"
9292
:doc:`bugprone-crtp-constructor-accessibility <bugprone/crtp-constructor-accessibility>`, "Yes"
9393
:doc:`bugprone-dangling-handle <bugprone/dangling-handle>`,
94-
:doc:`bugprone-default-lambda-capture <bugprone/default-lambda-capture>`,
9594
:doc:`bugprone-derived-method-shadowing-base-method <bugprone/derived-method-shadowing-base-method>`,
9695
:doc:`bugprone-dynamic-static-initializers <bugprone/dynamic-static-initializers>`,
9796
:doc:`bugprone-easily-swappable-parameters <bugprone/easily-swappable-parameters>`,
@@ -378,6 +377,7 @@ Clang-Tidy Checks
378377
:doc:`readability-container-data-pointer <readability/container-data-pointer>`, "Yes"
379378
:doc:`readability-container-size-empty <readability/container-size-empty>`, "Yes"
380379
:doc:`readability-convert-member-functions-to-static <readability/convert-member-functions-to-static>`, "Yes"
380+
:doc:`readability-default-lambda-capture <readability/default-lambda-capture>`,
381381
:doc:`readability-delete-null-pointer <readability/delete-null-pointer>`, "Yes"
382382
:doc:`readability-duplicate-include <readability/duplicate-include>`, "Yes"
383383
:doc:`readability-else-after-return <readability/else-after-return>`, "Yes"

clang-tools-extra/docs/clang-tidy/checks/bugprone/default-lambda-capture.rst renamed to clang-tools-extra/docs/clang-tidy/checks/readability/default-lambda-capture.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
.. title:: clang-tidy - bugprone-default-lambda-capture
1+
.. title:: clang-tidy - readability-default-lambda-capture
22

3-
bugprone-default-lambda-capture
3+
readability-default-lambda-capture
44
===============================
55

66
Warns on default lambda captures (e.g. ``[&](){ ... }``, ``[=](){ ... }``)

clang-tools-extra/test/clang-tidy/checkers/bugprone/default-lambda-capture.cpp renamed to clang-tools-extra/test/clang-tidy/checkers/readability/default-lambda-capture.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
// RUN: %check_clang_tidy %s bugprone-default-lambda-capture %t
1+
// RUN: %check_clang_tidy %s readability-default-lambda-capture %t
22

33
void test_default_captures() {
44
int value = 42;
55
int another = 10;
66

77
auto lambda1 = [=](int x) { return value + x; };
8-
// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [bugprone-default-lambda-capture]
8+
// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [readability-default-lambda-capture]
99

1010
auto lambda2 = [&](int x) { return value + x; };
11-
// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [bugprone-default-lambda-capture]
11+
// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [readability-default-lambda-capture]
1212

1313
auto lambda3 = [=, &another](int x) { return value + another + x; };
14-
// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [bugprone-default-lambda-capture]
14+
// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [readability-default-lambda-capture]
1515

1616
auto lambda4 = [&, value](int x) { return value + another + x; };
17-
// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [bugprone-default-lambda-capture]
17+
// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [readability-default-lambda-capture]
1818
}
1919

2020
void test_acceptable_captures() {
@@ -42,10 +42,10 @@ void test_nested_lambdas() {
4242
int inner_var = 3;
4343

4444
auto outer = [=]() {
45-
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [bugprone-default-lambda-capture]
45+
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [readability-default-lambda-capture]
4646

4747
auto inner = [&](int x) { return outer_var + middle_var + inner_var + x; };
48-
// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [bugprone-default-lambda-capture]
48+
// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [readability-default-lambda-capture]
4949

5050
return inner(10);
5151
};
@@ -55,15 +55,15 @@ void test_lambda_returns() {
5555
int a = 1, b = 2, c = 3;
5656

5757
auto create_adder = [=](int x) {
58-
// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [bugprone-default-lambda-capture]
58+
// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [readability-default-lambda-capture]
5959
return [x](int y) { return x + y; }; // Inner lambda is fine - explicit capture
6060
};
6161

6262
auto func1 = [&]() { return a; };
63-
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [bugprone-default-lambda-capture]
63+
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [readability-default-lambda-capture]
6464

6565
auto func2 = [=]() { return b; };
66-
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [bugprone-default-lambda-capture]
66+
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [readability-default-lambda-capture]
6767
}
6868

6969
class TestClass {
@@ -74,10 +74,10 @@ class TestClass {
7474
int local = 10;
7575

7676
auto lambda1 = [=]() { return member + local; };
77-
// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [bugprone-default-lambda-capture]
77+
// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [readability-default-lambda-capture]
7878

7979
auto lambda2 = [&]() { return member + local; };
80-
// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [bugprone-default-lambda-capture]
80+
// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [readability-default-lambda-capture]
8181

8282
auto lambda3 = [this, local]() { return member + local; };
8383
auto lambda4 = [this, &local]() { return member + local; };
@@ -89,7 +89,7 @@ void test_template_lambdas() {
8989
T value{};
9090

9191
auto lambda = [=](T x) { return value + x; };
92-
// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [bugprone-default-lambda-capture]
92+
// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [readability-default-lambda-capture]
9393
}
9494

9595
void instantiate_templates() {

0 commit comments

Comments
 (0)