srctree

Robin Linden parent 919d5702 e2a720a0
meta: Enable clang-tidy's modernize-* checks

inlinesplit
.clang-tidy added: 37, removed: 18, total 19
@@ -32,10 +32,20 @@
# -misc-no-recursion: We use a lot of recursion.
#
# -misc-non-private-member-variables-in-classes: TODO(robinlinden): Fix.
#
# -modernize-make-unique, -modernize-use-emplace: Clang doesn't implement p0960
# yet, and we're not adding c-tors to all our structs.
#
# -modernize-use-nodiscard: Very noisy, and probably more meaningful if we only
# add it where it matters.
#
# -modernize-use-trailing-return-type: Stylistic change, and something we
# haven't been doing so far.
Checks: >
bugprone-*,
google-*,
misc-*,
modernize-*,
readability-identifier-naming,
-bugprone-exception-escape,
-bugprone-narrowing-conversions,
@@ -48,6 +58,10 @@ Checks: >
-misc-const-correctness,
-misc-no-recursion,
-misc-non-private-member-variables-in-classes,
-modernize-make-unique,
-modernize-use-emplace,
-modernize-use-nodiscard,
-modernize-use-trailing-return-type,
 
WarningsAsErrors: "*"
 
 
css2/tokenizer.h added: 37, removed: 18, total 19
@@ -12,6 +12,7 @@
#include <functional>
#include <optional>
#include <string_view>
#include <utility>
 
namespace css2 {
 
@@ -37,7 +38,7 @@ enum class ParseError {
class Tokenizer {
public:
Tokenizer(std::string_view input, std::function<void(Token &&)> on_emit, std::function<void(ParseError)> on_error)
: input_(input), on_emit_(on_emit), on_error_(on_error) {}
: input_(input), on_emit_(std::move(on_emit)), on_error_(std::move(on_error)) {}
 
void run();
 
 
dom/dom_test.cpp added: 37, removed: 18, total 19
@@ -37,8 +37,8 @@ void descendant_axis_tests() {
 
etest::test("descendant axis, nested matches", [] {
dom::Element const &first{"div", {}, {dom::Element{"div", {}, {dom::Element{"div"}}}}};
dom::Element const &second = std::get<dom::Element>(first.children[0]);
dom::Element const &third = std::get<dom::Element>(second.children[0]);
auto const &second = std::get<dom::Element>(first.children[0]);
auto const &third = std::get<dom::Element>(second.children[0]);
 
auto nodes = nodes_by_xpath(first, "//div");
expect_eq(nodes, std::vector{&first, &second, &third});
@@ -66,11 +66,11 @@ void descendant_axis_tests() {
},
};
 
dom::Element const &div_first_span = std::get<dom::Element>(div.children[0]);
dom::Element const &p = std::get<dom::Element>(div.children[1]);
dom::Element const &p_span = std::get<dom::Element>(p.children[0]);
dom::Element const &p_span_a = std::get<dom::Element>(p_span.children[0]);
dom::Element const &div_last_span = std::get<dom::Element>(div.children[2]);
auto const &div_first_span = std::get<dom::Element>(div.children[0]);
auto const &p = std::get<dom::Element>(div.children[1]);
auto const &p_span = std::get<dom::Element>(p.children[0]);
auto const &p_span_a = std::get<dom::Element>(p_span.children[0]);
auto const &div_last_span = std::get<dom::Element>(div.children[2]);
 
auto nodes = nodes_by_xpath(div, "//p");
expect_eq(nodes, std::vector{&p});
 
js/ast.h added: 37, removed: 18, total 19
@@ -13,8 +13,7 @@
#include <variant>
#include <vector>
 
namespace js {
namespace ast {
namespace js::ast {
 
class Value;
struct NativeFunction;
@@ -180,7 +179,6 @@ struct WhileStatement {
std::shared_ptr<Statement> body;
};
 
} // namespace ast
} // namespace js
} // namespace js::ast
 
#endif
 
os/linux_test.cpp added: 37, removed: 18, total 19
@@ -13,6 +13,8 @@
 
#include "etest/etest.h"
 
// This is the header POSIX says we need to include.
// NOLINTNEXTLINE(modernize-deprecated-headers)
#include <stdlib.h>
 
using etest::expect_eq;
 
wasm/leb128_test.cpp added: 37, removed: 18, total 19
@@ -27,6 +27,9 @@ void expect_decode_failure(std::string bytes, etest::source_location loc = etest
} // namespace
 
int main() {
// Clang-tidy's modernize-raw-string-literal wants all escaped literals that
// can be written as characters to be written as characters.
// NOLINTBEGIN(modernize-raw-string-literal)
etest::test("decode unsigned", [] {
expect_decoded<std::uint32_t>("\x80\x7f", 16256);
 
@@ -146,6 +149,7 @@ int main() {
expect_decode_failure<std::int64_t>("\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7e");
expect_decode_failure<std::int64_t>("\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00"s);
});
// NOLINTEND(modernize-raw-string-literal)
 
return etest::run_all_tests();
}