Skip to content

Commit

Permalink
fixup! Fix clang-tidy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
foonathan committed Jan 7, 2025
1 parent 02bd751 commit de63cc9
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 22 deletions.
4 changes: 3 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion include/lexy/_detail/code_point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions include/lexy/action/base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const void*>(&type_id) /* NOLINT */),
value(LEXY_MOV(value))
{}

template <typename ControlBlock>
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<const void*>(&type_id) /* NOLINT */)
return static_cast<parse_context_var*>(cur)->value;

LEXY_ASSERT(false, "context variable hasn't been created");
Expand Down
2 changes: 1 addition & 1 deletion include/lexy/encoding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion include/lexy_ext/shell.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace lexy_ext
{
#if 0
#if 0 // NOLINT
/// Controls how the shell performs I/O.
class Prompt
{
Expand Down
6 changes: 3 additions & 3 deletions tests/lexy/callback/string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ TEST_CASE("as_string")
std::string from_unicode_cp_alloc
= lexy::as_string<std::string, lexy::utf8_encoding>(std::allocator<char>{},
lexy::code_point(0x00E4));
CHECK(from_unicode_cp == "\u00E4");
CHECK(from_unicode_cp_alloc == "\u00E4");

std::string from_sink = [&] {
auto sink = lexy::as_string<std::string, lexy::utf8_encoding>.sink();
Expand Down Expand Up @@ -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<char>{}, lexy::code_point(0x00C4));
CHECK(from_cp == "\u00C4");
CHECK(from_cp_alloc == "\u00C4");

std::string from_sink = [&] {
auto sink = callback.sink();
Expand Down Expand Up @@ -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<char>{}, lexy::code_point(0x00C4));
CHECK(from_cp == "\u00E4");
CHECK(from_cp_alloc == "\u00E4");

std::string from_sink = [&] {
auto sink = callback.sink();
Expand Down
16 changes: 6 additions & 10 deletions tests/lexy/detail/swar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<char>(a, a) == 8);
CHECK(swar_find_difference<char>(a, A) == 0);
Expand All @@ -89,9 +89,7 @@ TEST_CASE("swar_has_zero")
constexpr auto all_high = swar_fill(char(0xAB));
CHECK(!swar_has_zero<char>(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<char>(contains_zero));
}
SUBCASE("char32_t")
Expand Down Expand Up @@ -123,9 +121,7 @@ TEST_CASE("swar_has_char")
constexpr auto all_high = swar_fill(char(0xAB));
CHECK(!swar_has_char<char, 1>(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<char, 1>(contains_one));
}
SUBCASE("char32_t")
Expand Down
2 changes: 0 additions & 2 deletions tests/lexy/dsl/any.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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", ""));
Expand All @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion tests/lexy/dsl/integer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ TEST_CASE("dsl::code_unit_id")
CHECK(lexy::is_branch_rule<decltype(id)>);

constexpr auto callback
= lexy::callback<int>([](const char*) { return int(0); },
= lexy::callback<int>([](const char*) { return 0; },
[](const char*, LEXY_CHAR8_T c) { return int(c); });

SUBCASE("as rule")
Expand Down

0 comments on commit de63cc9

Please sign in to comment.