diff --git a/include/tao/pegtl/internal/unhex_utility.hpp b/include/tao/pegtl/internal/unhex_utility.hpp index 674ee33c..0acd03ab 100644 --- a/include/tao/pegtl/internal/unhex_utility.hpp +++ b/include/tao/pegtl/internal/unhex_utility.hpp @@ -44,8 +44,12 @@ namespace TAO_PEGTL_NAMESPACE::internal } template< typename I > - [[nodiscard]] constexpr I unhex_string_impl( const char* begin, const char* end, I result = 0 ) + [[nodiscard]] constexpr I unhex_string_impl( const char* begin, const char* end ) { + if( begin == end ) { + return 0; + } + I result = unhex_char_impl< I >( *begin++ ); while( begin != end ) { result <<= 4; result += unhex_char_impl< I >( *begin++ ); diff --git a/src/example/pegtl/iri.cpp b/src/example/pegtl/iri.cpp index bb5517f8..7c1f0d9d 100644 --- a/src/example/pegtl/iri.cpp +++ b/src/example/pegtl/iri.cpp @@ -31,7 +31,7 @@ struct IRI std::string query; std::string fragment; - explicit IRI( pegtl::argv_input< pegtl::scan::lf_crlf >& ); + explicit IRI( pegtl::argv_input< pegtl::scan::lf_crlf >& in ); }; namespace iri diff --git a/src/example/pegtl/token_input_1.cpp b/src/example/pegtl/token_input_1.cpp index c359b0e0..0cfbcd3a 100644 --- a/src/example/pegtl/token_input_1.cpp +++ b/src/example/pegtl/token_input_1.cpp @@ -95,7 +95,7 @@ struct my_grammar int main() { const std::vector< my_token > v{ - { my_type::beta, "first" }, + { my_type::beta, "first" }, { my_type::beta, "second" } }; token_input< my_token > in( v ); diff --git a/src/example/pegtl/token_input_2.cpp b/src/example/pegtl/token_input_2.cpp index da599903..6f3e49af 100644 --- a/src/example/pegtl/token_input_2.cpp +++ b/src/example/pegtl/token_input_2.cpp @@ -65,7 +65,7 @@ struct my_grammar int main() { const std::vector< my_token > v{ - { my_type::beta, "first" }, + { my_type::beta, "first" }, { my_type::beta, "second" } }; token_input in( v ); diff --git a/src/example/pegtl/uri.cpp b/src/example/pegtl/uri.cpp index ef14afa1..5d5f95b5 100644 --- a/src/example/pegtl/uri.cpp +++ b/src/example/pegtl/uri.cpp @@ -30,7 +30,7 @@ struct URI std::string query; std::string fragment; - explicit URI( pegtl::argv_input< pegtl::scan::lf_crlf >& ); + explicit URI( pegtl::argv_input< pegtl::scan::lf_crlf >& in ); }; namespace uri diff --git a/src/test/pegtl/action_apply_2.cpp b/src/test/pegtl/action_apply_2.cpp index 6f6f162b..c82af681 100644 --- a/src/test/pegtl/action_apply_2.cpp +++ b/src/test/pegtl/action_apply_2.cpp @@ -91,7 +91,12 @@ namespace TAO_PEGTL_NAMESPACE } std::size_t count = 0; - text_position pos[] = { { 1, 1, 0 }, { 1, 2, 1 }, { 2, 1, 2 }, { 2, 2, 3 } }; + text_position pos[] = { + {1, 1, 0}, + { 1, 2, 1}, + { 2, 1, 2}, + { 2, 2, 3} + }; template< typename Rule > struct count_action diff --git a/src/test/pegtl/ascii_atomics.cpp b/src/test/pegtl/ascii_atomics.cpp index ac758c0f..4c4a3edf 100644 --- a/src/test/pegtl/ascii_atomics.cpp +++ b/src/test/pegtl/ascii_atomics.cpp @@ -43,7 +43,7 @@ namespace TAO_PEGTL_NAMESPACE verify_rule< ascii::ranges< 'a', 'z', '4' > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); for( int i = 0; i < 128; ++i ) { - const int c = char( i ); + const auto c = char( i ); const bool is_one = ( c == '#' ) || ( c == 'a' ) || ( c == ' ' ); const bool is_range = ( 20 <= c ) && ( c <= 120 ); diff --git a/src/test/pegtl/ascii_classes.cpp b/src/test/pegtl/ascii_classes.cpp index b0292ad4..7b142e27 100644 --- a/src/test/pegtl/ascii_classes.cpp +++ b/src/test/pegtl/ascii_classes.cpp @@ -45,7 +45,7 @@ namespace TAO_PEGTL_NAMESPACE verify_rule< ascii::xdigit >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); for( int i = 0; i < 128; ++i ) { - const int c = char( i ); + const auto c = char( i ); // NOLINT(bugprone-signed-char-misuse) const bool is_blank = ( c == ' ' ) || ( c == '\t' ); const bool is_digit = ( '0' <= c ) && ( c <= '9' ); diff --git a/src/test/pegtl/buffer_buffer_common.cpp b/src/test/pegtl/buffer_buffer_common.cpp index 6da7c4ab..143c1c5a 100644 --- a/src/test/pegtl/buffer_buffer_common.cpp +++ b/src/test/pegtl/buffer_buffer_common.cpp @@ -13,7 +13,7 @@ namespace TAO_PEGTL_NAMESPACE { template< typename Buffer, typename... As > - void test_common( As&&... as ) + void test_common( As&&... as ) // NOLINT(readability-function-size) { const std::string st = "abcdefghijklmnopqrstuvwxyz"; diff --git a/src/test/pegtl/contrib_nested_exceptions.cpp b/src/test/pegtl/contrib_nested_exceptions.cpp index 694c6a26..8a9b3c6e 100644 --- a/src/test/pegtl/contrib_nested_exceptions.cpp +++ b/src/test/pegtl/contrib_nested_exceptions.cpp @@ -46,7 +46,7 @@ namespace TAO_PEGTL_NAMESPACE void test1() { try { - throw s1; + throw std::string( s1 ); } catch( ... ) { visitor v; @@ -60,7 +60,7 @@ namespace TAO_PEGTL_NAMESPACE void test2() { try { - throw s1; + throw std::string( s1 ); } catch( const std::string& s ) { visitor v; @@ -75,7 +75,7 @@ namespace TAO_PEGTL_NAMESPACE { try { try { - throw s1; + throw std::string( s1 ); } catch( ... ) { std::throw_with_nested( std::runtime_error( s2 ) ); diff --git a/src/test/pegtl/internal_data_and_size.cpp b/src/test/pegtl/internal_data_and_size.cpp index 9f84c13a..a9c393eb 100644 --- a/src/test/pegtl/internal_data_and_size.cpp +++ b/src/test/pegtl/internal_data_and_size.cpp @@ -22,7 +22,7 @@ namespace TAO_PEGTL_NAMESPACE static_assert( std::is_same_v< decltype( das.data() ), std::int32_t > ); TAO_PEGTL_TEST_ASSERT( !das ); TAO_PEGTL_TEST_ASSERT( das.empty() ); - TAO_PEGTL_TEST_ASSERT( das.size() == 0 ); + TAO_PEGTL_TEST_ASSERT( das.size() == 0 ); // NOLINT(readability-container-size-empty) } { internal::data_and_size< std::int32_t, void > das; @@ -30,7 +30,7 @@ namespace TAO_PEGTL_NAMESPACE static_assert( std::is_same_v< decltype( das.data() ), const std::int32_t& > ); TAO_PEGTL_TEST_ASSERT( !das ); TAO_PEGTL_TEST_ASSERT( das.empty() ); - TAO_PEGTL_TEST_ASSERT( das.size() == 0 ); + TAO_PEGTL_TEST_ASSERT( das.size() == 0 ); // NOLINT(readability-container-size-empty) TAO_PEGTL_TEST_ASSERT( das.pointer() == nullptr ); } { diff --git a/src/test/pegtl/internal_extract_position.cpp b/src/test/pegtl/internal_extract_position.cpp index d9bad689..a59d384d 100644 --- a/src/test/pegtl/internal_extract_position.cpp +++ b/src/test/pegtl/internal_extract_position.cpp @@ -22,7 +22,7 @@ namespace TAO_PEGTL_NAMESPACE return &m_int; } - [[nodiscard]] test_type_1 current_position() const noexcept + [[nodiscard]] static test_type_1 current_position() noexcept { return {}; } @@ -46,7 +46,7 @@ namespace TAO_PEGTL_NAMESPACE struct test_type_4 { - [[nodiscard]] test_type_1 current_position() const noexcept + [[nodiscard]] static test_type_1 current_position() noexcept { return {}; } @@ -61,7 +61,7 @@ namespace TAO_PEGTL_NAMESPACE return &m_tok; } - [[nodiscard]] int current_position() const noexcept + [[nodiscard]] static int current_position() noexcept { return 0; } @@ -86,7 +86,7 @@ namespace TAO_PEGTL_NAMESPACE return &m_tok; } - [[nodiscard]] int current_position() const noexcept + [[nodiscard]] static int current_position() noexcept { return 0; } @@ -98,26 +98,31 @@ namespace TAO_PEGTL_NAMESPACE test_type_1 t1; auto e1 = internal::extract_position( t1 ); static_assert( std::is_same_v< decltype( e1 ), test_type_1 > ); + (void)e1; } { test_type_2 t2; decltype( auto ) e2 = internal::extract_position( t2 ); static_assert( std::is_same_v< decltype( e2 ), test_type_1 > ); + (void)e2; } { test_type_3 t3; decltype( auto ) e3 = internal::extract_position( t3 ); static_assert( std::is_same_v< decltype( e3 ), const test_type_1& > ); + (void)e3; } { test_type_5 t5; decltype( auto ) e5 = internal::extract_position( t5 ); static_assert( std::is_same_v< decltype( e5 ), test_type_1 > ); + (void)e5; } { test_type_7 t7; decltype( auto ) e7 = internal::extract_position( t7 ); static_assert( std::is_same_v< decltype( e7 ), const test_type_1& > ); + (void)e7; } } diff --git a/src/test/pegtl/internal_get_eol_rule_char.cpp b/src/test/pegtl/internal_get_eol_rule_char.cpp index 7c5379b5..d6acecca 100644 --- a/src/test/pegtl/internal_get_eol_rule_char.cpp +++ b/src/test/pegtl/internal_get_eol_rule_char.cpp @@ -14,29 +14,29 @@ using namespace TAO_PEGTL_NAMESPACE; int main() { - static_assert( internal::get_eol_rule_char_v< void > == false ); + static_assert( !internal::get_eol_rule_char_v< void > ); static_assert( std::is_same_v< decltype( internal::get_eol_rule_char_v< void > ), const bool > ); - static_assert( internal::get_eol_rule_char_v< char > == false ); + static_assert( !internal::get_eol_rule_char_v< char > ); static_assert( std::is_same_v< decltype( internal::get_eol_rule_char_v< char > ), const bool > ); - static_assert( internal::get_eol_rule_char_v< std::string > == false ); + static_assert( !internal::get_eol_rule_char_v< std::string > ); static_assert( std::is_same_v< decltype( internal::get_eol_rule_char_v< std::string > ), const bool > ); static_assert( internal::get_eol_rule_char_v< ascii::lf > == '\n' ); static_assert( std::is_same_v< decltype( internal::get_eol_rule_char_v< ascii::lf > ), const char > ); - static_assert( internal::get_eol_rule_char_v< ascii::cr_lf > == false ); + static_assert( !internal::get_eol_rule_char_v< ascii::cr_lf > ); static_assert( std::is_same_v< decltype( internal::get_eol_rule_char_v< ascii::cr_lf > ), const bool > ); static_assert( internal::get_eol_rule_char_v< utf8::lf > == '\n' ); static_assert( std::is_same_v< decltype( internal::get_eol_rule_char_v< utf8::lf > ), const char > ); - static_assert( internal::get_eol_rule_char_v< utf8::cr_lf > == false ); + static_assert( !internal::get_eol_rule_char_v< utf8::cr_lf > ); static_assert( std::is_same_v< decltype( internal::get_eol_rule_char_v< utf8::cr_lf > ), const bool > ); static_assert( internal::get_eol_rule_char_v< utf32::lf > == '\n' ); static_assert( std::is_same_v< decltype( internal::get_eol_rule_char_v< utf32::lf > ), const char32_t > ); - static_assert( internal::get_eol_rule_char_v< utf32::cr_lf > == false ); + static_assert( !internal::get_eol_rule_char_v< utf32::cr_lf > ); static_assert( std::is_same_v< decltype( internal::get_eol_rule_char_v< utf32::cr_lf > ), const bool > ); - static_assert( internal::get_eol_rule_char_v< ascii::digit > == false ); + static_assert( !internal::get_eol_rule_char_v< ascii::digit > ); static_assert( std::is_same_v< decltype( internal::get_eol_rule_char_v< ascii::digit > ), const bool > ); return 0; diff --git a/src/test/pegtl/internal_peek_ascii.cpp b/src/test/pegtl/internal_peek_ascii.cpp index 9f1ea1e4..bed7db11 100644 --- a/src/test/pegtl/internal_peek_ascii.cpp +++ b/src/test/pegtl/internal_peek_ascii.cpp @@ -51,17 +51,17 @@ namespace TAO_PEGTL_NAMESPACE { const auto pair = peek7::peek( in, 3 ); TAO_PEGTL_TEST_ASSERT( !pair ); - TAO_PEGTL_TEST_ASSERT( pair.size() == 0 ); + TAO_PEGTL_TEST_ASSERT( pair.empty() ); } { const auto pair = peek7::peek( in, 4 ); TAO_PEGTL_TEST_ASSERT( !pair ); - TAO_PEGTL_TEST_ASSERT( pair.size() == 0 ); + TAO_PEGTL_TEST_ASSERT( pair.empty() ); } { const auto pair = peek7::peek( in, 5 ); TAO_PEGTL_TEST_ASSERT( !pair ); - TAO_PEGTL_TEST_ASSERT( pair.size() == 0 ); + TAO_PEGTL_TEST_ASSERT( pair.empty() ); } } } diff --git a/src/test/pegtl/internal_peek_member.cpp b/src/test/pegtl/internal_peek_member.cpp index 51eb69cf..d10ea908 100644 --- a/src/test/pegtl/internal_peek_member.cpp +++ b/src/test/pegtl/internal_peek_member.cpp @@ -29,7 +29,7 @@ namespace TAO_PEGTL_NAMESPACE int* const global3 = &the_integer; const int* const global4 = &the_integer; - [[nodiscard]] int method1() const noexcept + [[nodiscard]] int method1() const noexcept // NOLINT(readability-convert-member-functions-to-static) { return 503; } diff --git a/src/test/pegtl/internal_stream_to_string.cpp b/src/test/pegtl/internal_stream_to_string.cpp index 1e32d7bd..1ca55ac3 100644 --- a/src/test/pegtl/internal_stream_to_string.cpp +++ b/src/test/pegtl/internal_stream_to_string.cpp @@ -10,7 +10,7 @@ namespace TAO_PEGTL_NAMESPACE { void unit_test() { - TAO_PEGTL_TEST_ASSERT( internal::stream_to_string() == "" ); + TAO_PEGTL_TEST_ASSERT( internal::stream_to_string().empty() ); TAO_PEGTL_TEST_ASSERT( internal::stream_to_string( "foo" ) == "foo" ); TAO_PEGTL_TEST_ASSERT( internal::stream_to_string( "foo", 42, "bar" ) == "foo42bar" ); } diff --git a/src/test/pegtl/internal_text_inputs.cpp b/src/test/pegtl/internal_text_inputs.cpp index b35be8a0..cb20e91b 100644 --- a/src/test/pegtl/internal_text_inputs.cpp +++ b/src/test/pegtl/internal_text_inputs.cpp @@ -140,6 +140,10 @@ namespace TAO_PEGTL_NAMESPACE TAO_PEGTL_TEST_ASSERT( test::equal( in.current_position(), 2, 2, 3 ) ); TAO_PEGTL_TEST_ASSERT( in.direct_position() == in.current_position() ); } + } + + void test_02_text() + { using input_1 = text_view_input< ascii::lf >; { input_1 in( "" ); @@ -238,6 +242,7 @@ namespace TAO_PEGTL_NAMESPACE void unit_test() { test_01_text(); + test_02_text(); } } // namespace TAO_PEGTL_NAMESPACE diff --git a/src/test/pegtl/internal_unwind_guard.cpp b/src/test/pegtl/internal_unwind_guard.cpp index bd4e7a0c..ef52e978 100644 --- a/src/test/pegtl/internal_unwind_guard.cpp +++ b/src/test/pegtl/internal_unwind_guard.cpp @@ -25,7 +25,7 @@ namespace TAO_PEGTL_NAMESPACE void test2() { int i = 1; - internal::unwind_guard( [ & ]() { i = 2; } ); // Anonymous object. + internal::unwind_guard( [ & ]() { i = 2; } ); // NOLINT(bugprone-unused-raii) TAO_PEGTL_TEST_ASSERT( i == 2 ); } diff --git a/src/test/pegtl/rule_nested.cpp b/src/test/pegtl/rule_nested.cpp index 2d980cfa..56edc23f 100644 --- a/src/test/pegtl/rule_nested.cpp +++ b/src/test/pegtl/rule_nested.cpp @@ -33,7 +33,9 @@ namespace TAO_PEGTL_NAMESPACE void test_success() { - outer_input in( { { "foo", 1 } } ); + outer_input in( { + {"foo", 1} + } ); TAO_PEGTL_TEST_ASSERT( in.size() == 1 ); const auto b = parse< outer_grammar >( in ); TAO_PEGTL_TEST_ASSERT( b ); @@ -41,7 +43,9 @@ namespace TAO_PEGTL_NAMESPACE void test_failure1() { - outer_input in( { { "bar", 1 } } ); + outer_input in( { + {"bar", 1} + } ); TAO_PEGTL_TEST_ASSERT( in.size() == 1 ); const auto b = parse< outer_grammar >( in ); TAO_PEGTL_TEST_ASSERT( !b ); @@ -57,7 +61,10 @@ namespace TAO_PEGTL_NAMESPACE void test_failure3() { - outer_input in( { { "foo", 1 }, { "foo", 1 } } ); + outer_input in( { + {"foo", 1}, + { "foo", 1} + } ); TAO_PEGTL_TEST_ASSERT( in.size() == 2 ); const auto b = parse< outer_grammar >( in ); TAO_PEGTL_TEST_ASSERT( !b );