Skip to content

Commit 554c045

Browse files
authored
enable two new clang-tidy checks (#3988)
* enable two new clang-tidy checks * Use better loop var for char
1 parent 42a41bf commit 554c045

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

.clang-tidy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ cppcoreguidelines-pro-type-static-cast-downcast,
1010
cppcoreguidelines-slicing,
1111
google-explicit-constructor,
1212
llvm-namespace-comment,
13+
misc-definitions-in-headers,
1314
misc-misplaced-const,
1415
misc-non-copyable-objects,
1516
misc-static-assert,
1617
misc-throw-by-value-catch-by-reference,
1718
misc-uniqueptr-reset-release,
1819
misc-unused-parameters,
1920
modernize-avoid-bind,
21+
modernize-loop-convert,
2022
modernize-make-shared,
2123
modernize-redundant-void-arg,
2224
modernize-replace-auto-ptr,
@@ -63,6 +65,8 @@ readability-uniqueptr-delete-release,
6365
CheckOptions:
6466
- key: performance-for-range-copy.WarnOnAllAutoCopies
6567
value: true
68+
- key: performance-inefficient-string-concatenation.StrictMode
69+
value: true
6670
- key: performance-unnecessary-value-param.AllowedTypes
6771
value: 'exception_ptr$;'
6872
- key: readability-implicit-bool-conversion.AllowPointerConditions

tests/test_constants_and_functions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ py::bytes return_bytes() {
3131
std::string print_bytes(const py::bytes &bytes) {
3232
std::string ret = "bytes[";
3333
const auto value = static_cast<std::string>(bytes);
34-
for (size_t i = 0; i < value.length(); ++i) {
35-
ret += std::to_string(static_cast<int>(value[i])) + " ";
34+
for (char c : value) {
35+
ret += std::to_string(static_cast<int>(c)) + ' ';
3636
}
3737
ret.back() = ']';
3838
return ret;

0 commit comments

Comments
 (0)