diff --git a/.clang-tidy b/.clang-tidy index a37e8b2f..f048625b 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -3,16 +3,18 @@ Checks: > bugprone-*, -bugprone-exception-escape, -bugprone-easily-swappable-parameters, - clang-analyzer-*, + -clang-analyzer-*, misc-*, -misc-const-correctness, -misc-definitions-in-headers, + -misc-include-cleaner, -misc-no-recursion, -misc-non-private-member-variables-in-classes, -misc-static-assert, -misc-unused-alias-decls, -misc-use-anonymous-namespace, performance-*, + -performance-enum-size, readability-*, -readability-braces-around-statements, -readability-convert-member-functions-to-static, diff --git a/include/lexy/_detail/code_point.hpp b/include/lexy/_detail/code_point.hpp index bc805b11..13813daa 100644 --- a/include/lexy/_detail/code_point.hpp +++ b/include/lexy/_detail/code_point.hpp @@ -101,7 +101,7 @@ constexpr std::size_t encode_code_point(char32_t cp, typename Encoding::char_typ { LEXY_PRECONDITION(size >= 1); - *buffer = char32_t(cp); + *buffer = cp; return 1; } else diff --git a/include/lexy/action/base.hpp b/include/lexy/action/base.hpp index 84cc15f2..71053032 100644 --- a/include/lexy/action/base.hpp +++ b/include/lexy/action/base.hpp @@ -47,14 +47,15 @@ namespace _detail T value; explicit constexpr parse_context_var(T&& value) - : parse_context_var_base(&type_id), value(LEXY_MOV(value)) + : parse_context_var_base(static_cast(&type_id) /* NOLINT */), + value(LEXY_MOV(value)) {} template static constexpr T& get(const ControlBlock* cb) { for (auto cur = cb->vars; cur; cur = cur->next) - if (cur->id == &type_id) + if (cur->id == static_cast(&type_id) /* NOLINT */) return static_cast(cur)->value; LEXY_ASSERT(false, "context variable hasn't been created"); diff --git a/include/lexy/encoding.hpp b/include/lexy/encoding.hpp index d6347fe8..4529e67a 100644 --- a/include/lexy/encoding.hpp +++ b/include/lexy/encoding.hpp @@ -12,7 +12,7 @@ namespace lexy { /// The endianness used by an encoding. -enum class encoding_endianness // NOLINT(performance-enum-size) +enum class encoding_endianness { /// Little endian. little, diff --git a/include/lexy_ext/shell.hpp b/include/lexy_ext/shell.hpp index 66865bbd..fd0c1e6b 100644 --- a/include/lexy_ext/shell.hpp +++ b/include/lexy_ext/shell.hpp @@ -14,7 +14,7 @@ namespace lexy_ext { -#if 0 +#if 0 // NOLINT /// Controls how the shell performs I/O. class Prompt { diff --git a/tests/lexy/callback/string.cpp b/tests/lexy/callback/string.cpp index 85a4c008..b6d6a6ff 100644 --- a/tests/lexy/callback/string.cpp +++ b/tests/lexy/callback/string.cpp @@ -148,7 +148,7 @@ TEST_CASE("as_string") std::string from_unicode_cp_alloc = lexy::as_string(std::allocator{}, lexy::code_point(0x00E4)); - CHECK(from_unicode_cp == "\u00E4"); + CHECK(from_unicode_cp_alloc == "\u00E4"); std::string from_sink = [&] { auto sink = lexy::as_string.sink(); @@ -209,7 +209,7 @@ TEST_CASE("as_string") std::string from_cp = callback(lexy::code_point(0x00C4)); CHECK(from_cp == "\u00C4"); std::string from_cp_alloc = callback(std::allocator{}, lexy::code_point(0x00C4)); - CHECK(from_cp == "\u00C4"); + CHECK(from_cp_alloc == "\u00C4"); std::string from_sink = [&] { auto sink = callback.sink(); @@ -255,7 +255,7 @@ TEST_CASE("as_string") std::string from_cp = callback(lexy::code_point(0x00C4)); CHECK(from_cp == "\u00E4"); std::string from_cp_alloc = callback(std::allocator{}, lexy::code_point(0x00C4)); - CHECK(from_cp == "\u00E4"); + CHECK(from_cp_alloc == "\u00E4"); std::string from_sink = [&] { auto sink = callback.sink(); diff --git a/tests/lexy/detail/swar.cpp b/tests/lexy/detail/swar.cpp index 549da4ea..c83b9ba3 100644 --- a/tests/lexy/detail/swar.cpp +++ b/tests/lexy/detail/swar.cpp @@ -66,10 +66,10 @@ TEST_CASE("swar_pack") TEST_CASE("swar_find_difference") { REQUIRE(sizeof(swar_int) == 8); - constexpr auto a = swar_pack(char('a')).value; - constexpr auto A = swar_pack(char('A')).value; - constexpr auto abc = swar_pack(char('a'), char('b'), char('c')).value; - constexpr auto aBc = swar_pack(char('a'), char('B'), char('c')).value; + constexpr auto a = swar_pack('a').value; + constexpr auto A = swar_pack('A').value; + constexpr auto abc = swar_pack('a', 'b', 'c').value; + constexpr auto aBc = swar_pack('a', 'B', 'c').value; CHECK(swar_find_difference(a, a) == 8); CHECK(swar_find_difference(a, A) == 0); @@ -89,9 +89,7 @@ TEST_CASE("swar_has_zero") constexpr auto all_high = swar_fill(char(0xAB)); CHECK(!swar_has_zero(all_high)); - constexpr auto contains_zero = swar_pack(char('a'), char('b'), char('c'), char(0), - char('d'), char('e'), char('f'), char('g')) - .value; + constexpr auto contains_zero = swar_pack('a', 'b', 'c', char(0), 'd', 'e', 'f', 'g').value; CHECK(swar_has_zero(contains_zero)); } SUBCASE("char32_t") @@ -123,9 +121,7 @@ TEST_CASE("swar_has_char") constexpr auto all_high = swar_fill(char(0xAB)); CHECK(!swar_has_char(all_high)); - constexpr auto contains_one = swar_pack(char('a'), char('b'), char('c'), char(1), char('d'), - char('e'), char('f'), char('g')) - .value; + constexpr auto contains_one = swar_pack('a', 'b', 'c', char(1), 'd', 'e', 'f', 'g').value; CHECK(swar_has_char(contains_one)); } SUBCASE("char32_t") diff --git a/tests/lexy/dsl/any.cpp b/tests/lexy/dsl/any.cpp index 5aa9e05f..3550682f 100644 --- a/tests/lexy/dsl/any.cpp +++ b/tests/lexy/dsl/any.cpp @@ -12,7 +12,6 @@ TEST_CASE("dsl::any") constexpr auto callback = token_callback; -#if 0 auto empty = LEXY_VERIFY(""); CHECK(empty.status == test_result::success); CHECK(empty.trace == test_trace().token("any", "")); @@ -32,7 +31,6 @@ TEST_CASE("dsl::any") auto swar_long = LEXY_VERIFY(lexy::utf8_char_encoding{}, "123456789012345678901234567890"); CHECK(swar_long.status == test_result::success); CHECK(swar_long.trace == test_trace().token("any", "123456789012345678901234567890")); -#endif auto swar_unicode = LEXY_VERIFY(lexy::utf8_char_encoding{}, "123456789\u00E401234567890\u00E51234567890"); diff --git a/tests/lexy/dsl/integer.cpp b/tests/lexy/dsl/integer.cpp index 915f272e..2f193f24 100644 --- a/tests/lexy/dsl/integer.cpp +++ b/tests/lexy/dsl/integer.cpp @@ -934,7 +934,7 @@ TEST_CASE("dsl::code_unit_id") CHECK(lexy::is_branch_rule); constexpr auto callback - = lexy::callback([](const char*) { return int(0); }, + = lexy::callback([](const char*) { return 0; }, [](const char*, LEXY_CHAR8_T c) { return int(c); }); SUBCASE("as rule")