srctree

Robin Linden parent 1cdb98b4 64ee58a2
meta: Enable most google-* clang-tidy checks that make sense

Leaving the explicit-ctor one for a later commit as that touches a lotof files.

inlinesplit
.clang-tidy added: 35, removed: 10, total 25
@@ -11,14 +11,29 @@
# -clang-diagnostic-builtin-macro-redefined: Bazel redefines a lot of builtin
# macros to set up a reproducible build.
#
# -google-build-using-namespace: We use `using namespace` in tests and for std::literals.
#
# -google-explicit-constructor: TODO(robinlinden): Fix.
#
# -google-readability-braces-around-statements: Crashes clang-tidy-14/15.
# Stack dump:
# 0. Program arguments: clang-tidy-15 -p=/home/robin/code/hastur -quiet /home/robin/code/hastur/dom2/character_data_test.cpp
# 1. <eof> parser at end of file
# 2. ASTMatcher: Processing 'google-readability-braces-around-statements' against:
# IfStmt : </usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/x86_64-linux-gnu/c++/12/bits/c++config.h:520:5, col:56>
#
# -misc-no-recursion: We use a lot of recursion.
#
# -misc-non-private-member-variables-in-classes: TODO(robinlinden): Fix.
Checks: >
google-*,
misc-*,
-clang-analyzer-cplusplus.NewDeleteLeaks,
-clang-analyzer-optin.cplusplus.UninitializedObject,
-clang-diagnostic-builtin-macro-redefined,
-google-build-using-namespace,
-google-explicit-constructor,
-google-readability-braces-around-statements,
-misc-no-recursion,
-misc-non-private-member-variables-in-classes,
 
 
html2/tokenizer.cpp added: 35, removed: 10, total 25
@@ -101,6 +101,14 @@ void Tokenizer::set_state(State state) {
state_ = state;
}
 
// While long, this function only contains trivial and short cases for each of
// the parser states.
//
// Splitting it would (very slightly) complicate stopping parsing as instead of
// just returning when we're done, we'd have to keep a member keeping track of
// if we're done and check that after every state, or return an enum value
// telling us if we should continue or return.
// NOLINTNEXTLINE(google-readability-function-size)
void Tokenizer::run() {
while (true) {
switch (state_) {
 
layout/layout.cpp added: 35, removed: 10, total 25
@@ -45,8 +45,9 @@ std::optional<LayoutBox> create_tree(style::StyledNode const &node) {
 
for (auto const &child : node.children) {
auto child_box = create_tree(child);
if (!child_box)
if (!child_box) {
continue;
}
 
if (child_box->type == LayoutType::Inline && box.type != LayoutType::Inline) {
if (!last_node_was_anonymous(box)) {
 
util/overloaded_test.cpp added: 35, removed: 10, total 25
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 Robin Lindén <dev@robinlinden.eu>
// SPDX-FileCopyrightText: 2022-2023 Robin Lindén <dev@robinlinden.eu>
//
// SPDX-License-Identifier: BSD-2-Clause
 
@@ -6,6 +6,7 @@
 
#include "etest/etest.h"
 
#include <cstdint>
#include <string_view>
#include <variant>
 
@@ -17,13 +18,13 @@ int main() {
etest::test("it does what it should", [] {
auto visitor = Overloaded{
[](bool) { return "bool"sv; },
[](int) { return "int"sv; },
[](long) { return "long"sv; },
[](std::int32_t) { return "int32_t"sv; },
[](std::int64_t) { return "int64_t"sv; },
};
 
expect_eq("bool"sv, std::visit(visitor, std::variant<bool>(true)));
expect_eq("int"sv, std::visit(visitor, std::variant<int>(1)));
expect_eq("long"sv, std::visit(visitor, std::variant<long>(1L)));
expect_eq("int32_t"sv, std::visit(visitor, std::variant<std::int32_t>(1)));
expect_eq("int64_t"sv, std::visit(visitor, std::variant<std::int64_t>(1)));
});
 
return etest::run_all_tests();