Skip to content

Commit b68466f

Browse files
committed
move check to misc module
1 parent 3b8a308 commit b68466f

14 files changed

+215
-215
lines changed

clang-tools-extra/clang-tidy/performance/BoolBitwiseOperationCheck.cpp renamed to clang-tools-extra/clang-tidy/misc/BoolBitwiseOperationCheck.cpp

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

1717
using namespace clang::ast_matchers;
1818

19-
namespace clang::tidy::performance {
19+
namespace clang::tidy::misc {
2020

2121
static const NamedDecl *
2222
getLHSNamedDeclIfCompoundAssign(const BinaryOperator *BO) {
@@ -217,4 +217,4 @@ void BoolBitwiseOperationCheck::check(const MatchFinder::MatchResult &Result) {
217217
<< InsertBrace2;
218218
}
219219

220-
} // namespace clang::tidy::performance
220+
} // namespace clang::tidy::misc

clang-tools-extra/clang-tidy/performance/BoolBitwiseOperationCheck.h renamed to clang-tools-extra/clang-tidy/misc/BoolBitwiseOperationCheck.h

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

9-
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_BOOLBITWISEOPERATIONCHECK_H
10-
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_BOOLBITWISEOPERATIONCHECK_H
9+
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_BOOLBITWISEOPERATIONCHECK_H
10+
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_BOOLBITWISEOPERATIONCHECK_H
1111

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

14-
namespace clang::tidy::performance {
14+
namespace clang::tidy::misc {
1515

1616
/// Finds potentially inefficient use of bitwise operators such as ``&``, ``|``
1717
/// and their compound analogues on Boolean values where logical operators like
1818
/// ``&&`` and ``||`` would be more appropriate.
1919
///
2020
/// For the user-facing documentation see:
21-
/// http://clang.llvm.org/extra/clang-tidy/checks/performance/bool-bitwise-operation.html
21+
/// http://clang.llvm.org/extra/clang-tidy/checks/misc/bool-bitwise-operation.html
2222
class BoolBitwiseOperationCheck : public ClangTidyCheck {
2323
public:
2424
BoolBitwiseOperationCheck(StringRef Name, ClangTidyContext *Context);
@@ -37,6 +37,6 @@ class BoolBitwiseOperationCheck : public ClangTidyCheck {
3737
bool IgnoreMacros;
3838
};
3939

40-
} // namespace clang::tidy::performance
40+
} // namespace clang::tidy::misc
4141

42-
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_BOOLBITWISEOPERATIONCHECK_H
42+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_BOOLBITWISEOPERATIONCHECK_H

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ add_custom_target(genconfusable DEPENDS Confusables.inc)
1818
set_target_properties(genconfusable PROPERTIES FOLDER "Clang Tools Extra/Sourcegenning")
1919

2020
add_clang_library(clangTidyMiscModule STATIC
21+
BoolBitwiseOperationCheck.cpp
2122
ConstCorrectnessCheck.cpp
2223
CoroutineHostileRAIICheck.cpp
2324
DefinitionsInHeadersCheck.cpp

clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "../ClangTidy.h"
1010
#include "../ClangTidyModule.h"
1111
#include "../ClangTidyModuleRegistry.h"
12+
#include "BoolBitwiseOperationCheck.h"
1213
#include "ConfusableIdentifierCheck.h"
1314
#include "ConstCorrectnessCheck.h"
1415
#include "CoroutineHostileRAIICheck.h"
@@ -39,6 +40,8 @@ namespace misc {
3940
class MiscModule : public ClangTidyModule {
4041
public:
4142
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
43+
CheckFactories.registerCheck<BoolBitwiseOperationCheck>(
44+
"misc-bool-bitwise-operation");
4245
CheckFactories.registerCheck<ConfusableIdentifierCheck>(
4346
"misc-confusable-identifiers");
4447
CheckFactories.registerCheck<ConstCorrectnessCheck>(

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ set(LLVM_LINK_COMPONENTS
55

66
add_clang_library(clangTidyPerformanceModule STATIC
77
AvoidEndlCheck.cpp
8-
BoolBitwiseOperationCheck.cpp
98
EnumSizeCheck.cpp
109
FasterStringFindCheck.cpp
1110
ForRangeCopyCheck.cpp

clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "../ClangTidyModule.h"
1111
#include "../ClangTidyModuleRegistry.h"
1212
#include "AvoidEndlCheck.h"
13-
#include "BoolBitwiseOperationCheck.h"
1413
#include "EnumSizeCheck.h"
1514
#include "FasterStringFindCheck.h"
1615
#include "ForRangeCopyCheck.h"
@@ -37,8 +36,6 @@ class PerformanceModule : public ClangTidyModule {
3736
public:
3837
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
3938
CheckFactories.registerCheck<AvoidEndlCheck>("performance-avoid-endl");
40-
CheckFactories.registerCheck<BoolBitwiseOperationCheck>(
41-
"performance-bool-bitwise-operation");
4239
CheckFactories.registerCheck<EnumSizeCheck>("performance-enum-size");
4340
CheckFactories.registerCheck<FasterStringFindCheck>(
4441
"performance-faster-string-find");

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ New checks
136136
Finds unintended character output from ``unsigned char`` and ``signed char``
137137
to an ``ostream``.
138138

139-
- New :doc:`performance-bool-bitwise-operation
140-
<clang-tidy/checks/performance/bool-bitwise-operation>` check.
139+
- New :doc:`misc-bool-bitwise-operation
140+
<clang-tidy/checks/misc/bool-bitwise-operation>` check.
141141

142142
Finds potentially inefficient use of bitwise operators such as ``&``, ``|``
143143
and their compound analogues on Boolean values where logical operators like

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ Clang-Tidy Checks
254254
:doc:`llvmlibc-implementation-in-namespace <llvmlibc/implementation-in-namespace>`,
255255
:doc:`llvmlibc-inline-function-decl <llvmlibc/inline-function-decl>`, "Yes"
256256
:doc:`llvmlibc-restrict-system-libc-headers <llvmlibc/restrict-system-libc-headers>`, "Yes"
257+
:doc:`misc-bool-bitwise-operation <misc/bool-bitwise-operation>`, "Yes"
257258
:doc:`misc-confusable-identifiers <misc/confusable-identifiers>`,
258259
:doc:`misc-const-correctness <misc/const-correctness>`, "Yes"
259260
:doc:`misc-coroutine-hostile-raii <misc/coroutine-hostile-raii>`,
@@ -333,7 +334,6 @@ Clang-Tidy Checks
333334
:doc:`openmp-exception-escape <openmp/exception-escape>`,
334335
:doc:`openmp-use-default-none <openmp/use-default-none>`,
335336
:doc:`performance-avoid-endl <performance/avoid-endl>`, "Yes"
336-
:doc:`performance-bool-bitwise-operation <performance/bool-bitwise-operation>`, "Yes"
337337
:doc:`performance-enum-size <performance/enum-size>`,
338338
:doc:`performance-faster-string-find <performance/faster-string-find>`, "Yes"
339339
:doc:`performance-for-range-copy <performance/for-range-copy>`, "Yes"

clang-tools-extra/docs/clang-tidy/checks/performance/bool-bitwise-operation.rst renamed to clang-tools-extra/docs/clang-tidy/checks/misc/bool-bitwise-operation.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
.. title:: clang-tidy - performance-bool-bitwise-operation
1+
.. title:: clang-tidy - misc-bool-bitwise-operation
22

3-
performance-bool-bitwise-operation
4-
==================================
3+
misc-bool-bitwise-operation
4+
===========================
55

66
Finds potentially inefficient use of bitwise operators such as ``&``, ``|``
77
and their compound analogues on Boolean values where logical operators like
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1-
// RUN: %check_clang_tidy %s performance-bool-bitwise-operation %t \
1+
// RUN: %check_clang_tidy %s misc-bool-bitwise-operation %t \
22
// RUN: -config="{CheckOptions: { \
3-
// RUN: performance-bool-bitwise-operation.StrictMode: false }}"
3+
// RUN: misc-bool-bitwise-operation.StrictMode: false }}"
44

55
bool function_with_possible_side_effects();
66

77
void bad_possible_side_effects() {
88
bool a = true, b = false;
99

1010
a | function_with_possible_side_effects();
11-
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [performance-bool-bitwise-operation]
11+
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation]
1212
// CHECK-FIXES: a || function_with_possible_side_effects();
1313

1414
a & function_with_possible_side_effects();
15-
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '&&' for boolean values instead of bitwise operator '&' [performance-bool-bitwise-operation]
15+
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '&&' for boolean values instead of bitwise operator '&' [misc-bool-bitwise-operation]
1616
// CHECK-FIXES: a && function_with_possible_side_effects();
1717

1818
a |= function_with_possible_side_effects();
19-
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '||' for boolean variable 'a' instead of bitwise operator '|=' [performance-bool-bitwise-operation]
19+
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '||' for boolean variable 'a' instead of bitwise operator '|=' [misc-bool-bitwise-operation]
2020
// CHECK-FIXES: a = a || function_with_possible_side_effects();
2121

2222
a &= function_with_possible_side_effects();
23-
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '&&' for boolean variable 'a' instead of bitwise operator '&=' [performance-bool-bitwise-operation]
23+
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '&&' for boolean variable 'a' instead of bitwise operator '&=' [misc-bool-bitwise-operation]
2424
// CHECK-FIXES: a = a && function_with_possible_side_effects();
2525

2626
bool c = true;
2727

2828
a &= function_with_possible_side_effects() && c;
29-
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '&&' for boolean variable 'a' instead of bitwise operator '&=' [performance-bool-bitwise-operation]
29+
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '&&' for boolean variable 'a' instead of bitwise operator '&=' [misc-bool-bitwise-operation]
3030
// CHECK-FIXES: a = a && function_with_possible_side_effects() && c;
3131

3232
a &= b && function_with_possible_side_effects();
33-
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '&&' for boolean variable 'a' instead of bitwise operator '&=' [performance-bool-bitwise-operation]
33+
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '&&' for boolean variable 'a' instead of bitwise operator '&=' [misc-bool-bitwise-operation]
3434
// CHECK-FIXES: a = a && b && function_with_possible_side_effects();
3535

3636
a |= function_with_possible_side_effects() || c;
37-
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '||' for boolean variable 'a' instead of bitwise operator '|=' [performance-bool-bitwise-operation]
37+
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '||' for boolean variable 'a' instead of bitwise operator '|=' [misc-bool-bitwise-operation]
3838
// CHECK-FIXES: a = a || function_with_possible_side_effects() || c;
3939

4040
a |= b || function_with_possible_side_effects();
41-
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '||' for boolean variable 'a' instead of bitwise operator '|=' [performance-bool-bitwise-operation]
41+
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '||' for boolean variable 'a' instead of bitwise operator '|=' [misc-bool-bitwise-operation]
4242
// CHECK-FIXES: a = a || b || function_with_possible_side_effects();
4343
}
4444

@@ -47,37 +47,37 @@ void bad_definitely_side_effects() {
4747
int acc = 0;
4848

4949
a | (acc++, b);
50-
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [performance-bool-bitwise-operation]
50+
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '||' for boolean values instead of bitwise operator '|' [misc-bool-bitwise-operation]
5151
// CHECK-MESSAGES-NOT: :[[@LINE-2]]:{{.*}}: note: FIX-IT applied suggested code changes
5252

5353
a & (acc++, b);
54-
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '&&' for boolean values instead of bitwise operator '&' [performance-bool-bitwise-operation]
54+
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '&&' for boolean values instead of bitwise operator '&' [misc-bool-bitwise-operation]
5555
// CHECK-MESSAGES-NOT: :[[@LINE-2]]:{{.*}}: note: FIX-IT applied suggested code changes
5656

5757
a |= (acc++, b);
58-
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '||' for boolean variable 'a' instead of bitwise operator '|=' [performance-bool-bitwise-operation]
58+
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '||' for boolean variable 'a' instead of bitwise operator '|=' [misc-bool-bitwise-operation]
5959
// CHECK-MESSAGES-NOT: :[[@LINE-2]]:{{.*}}: note: FIX-IT applied suggested code changes
6060

6161
a &= (acc++, b);
62-
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '&&' for boolean variable 'a' instead of bitwise operator '&=' [performance-bool-bitwise-operation]
62+
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '&&' for boolean variable 'a' instead of bitwise operator '&=' [misc-bool-bitwise-operation]
6363
// CHECK-MESSAGES-NOT: :[[@LINE-2]]:{{.*}}: note: FIX-IT applied suggested code changes
6464

6565
bool c = true;
6666

6767
a &= (acc++, b) && c;
68-
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '&&' for boolean variable 'a' instead of bitwise operator '&=' [performance-bool-bitwise-operation]
68+
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '&&' for boolean variable 'a' instead of bitwise operator '&=' [misc-bool-bitwise-operation]
6969
// CHECK-MESSAGES-NOT: :[[@LINE-2]]:{{.*}}: note: FIX-IT applied suggested code changes
7070

7171
a &= b && (acc++, c);
72-
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '&&' for boolean variable 'a' instead of bitwise operator '&=' [performance-bool-bitwise-operation]
72+
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '&&' for boolean variable 'a' instead of bitwise operator '&=' [misc-bool-bitwise-operation]
7373
// CHECK-MESSAGES-NOT: :[[@LINE-2]]:{{.*}}: note: FIX-IT applied suggested code changes
7474

7575
a |= (acc++, b) || c;
76-
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '||' for boolean variable 'a' instead of bitwise operator '|=' [performance-bool-bitwise-operation]
76+
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '||' for boolean variable 'a' instead of bitwise operator '|=' [misc-bool-bitwise-operation]
7777
// CHECK-MESSAGES-NOT: :[[@LINE-2]]:{{.*}}: note: FIX-IT applied suggested code changes
7878

7979
a |= b || (acc++, c);
80-
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '||' for boolean variable 'a' instead of bitwise operator '|=' [performance-bool-bitwise-operation]
80+
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use logical operator '||' for boolean variable 'a' instead of bitwise operator '|=' [misc-bool-bitwise-operation]
8181
// CHECK-MESSAGES-NOT: :[[@LINE-2]]:{{.*}}: note: FIX-IT applied suggested code changes
8282
}
8383

0 commit comments

Comments
 (0)