Skip to content

Commit

Permalink
clang-tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
d-frey committed Apr 28, 2023
1 parent 22a7c30 commit 0f19e06
Show file tree
Hide file tree
Showing 25 changed files with 96 additions and 102 deletions.
4 changes: 2 additions & 2 deletions include/tao/json/binding/versions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace tao::json::binding
else {
static_assert( std::is_void_v< V >, "neither V::to() nor V::as() found" );
}
return std::exception_ptr();
return {};
}
catch( ... ) {
return std::current_exception();
Expand Down Expand Up @@ -96,7 +96,7 @@ namespace tao::json::binding
auto m = parser.mark();
V::template consume< Traits >( parser, x );
(void)m( true );
return std::exception_ptr();
return {};
}
catch( ... ) {
return std::current_exception();
Expand Down
4 changes: 2 additions & 2 deletions include/tao/json/cbor/events/to_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ namespace tao::json::cbor::events
void string( const std::string_view v )
{
number( internal::major::STRING, v.size() );
os.write( v.data(), v.size() );
os.write( v.data(), static_cast< std::streamsize >( v.size() ) );
}

void binary( const tao::binary_view v )
{
number( internal::major::BINARY, v.size() );
os.write( reinterpret_cast< const char* >( v.data() ), v.size() );
os.write( reinterpret_cast< const char* >( v.data() ), static_cast< std::streamsize >( v.size() ) );
}

void begin_array()
Expand Down
4 changes: 2 additions & 2 deletions include/tao/json/contrib/schema.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ namespace tao::json
}
break;
case HAS_MULTIPLE_OF_DOUBLE:
if( !is_multiple_of( double( v ), m_node->m_multiple_of.d ) ) {
if( !is_multiple_of( static_cast< double >( v ), m_node->m_multiple_of.d ) ) {
m_match = false;
}
break;
Expand All @@ -1031,7 +1031,7 @@ namespace tao::json
}
break;
case HAS_MULTIPLE_OF_DOUBLE:
if( !is_multiple_of( double( v ), m_node->m_multiple_of.d ) ) {
if( !is_multiple_of( static_cast< double >( v ), m_node->m_multiple_of.d ) ) {
m_match = false;
}
break;
Expand Down
4 changes: 2 additions & 2 deletions include/tao/json/contrib/vector_bool_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace tao::json
v.emplace_array();
v.get_array().reserve( o.size() );
for( const auto e : o ) {
v.emplace_back( bool( e ) );
v.emplace_back( static_cast< bool >( e ) );
}
}

Expand All @@ -31,7 +31,7 @@ namespace tao::json
{
c.begin_array( o.size() );
for( const auto i : o ) {
json::events::produce< Traits >( c, bool( i ) );
json::events::produce< Traits >( c, static_cast< bool >( i ) );
c.element();
}
c.end_array( o.size() );
Expand Down
4 changes: 2 additions & 2 deletions include/tao/json/events/hash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ namespace tao::json::events
{
if( v >= 0 ) {
const auto u = static_cast< std::uint64_t >( v );
if( u == v ) {
if( static_cast< double >( u ) == v ) {
number( u );
return;
}
}
else {
const auto i = static_cast< std::int64_t >( v );
if( i == v ) {
if( static_cast< double >( i ) == v ) {
number( i );
return;
}
Expand Down
2 changes: 1 addition & 1 deletion include/tao/json/events/prefer_signed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace tao::json::events
void number( const std::uint64_t v )
{
if( v <= 9223372036854775807ULL ) {
Consumer::number( std::int64_t( v ) );
Consumer::number( static_cast< std::int64_t >( v ) );
}
else {
Consumer::number( v );
Expand Down
2 changes: 1 addition & 1 deletion include/tao/json/events/prefer_unsigned.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace tao::json::events
void number( const std::int64_t v )
{
if( v >= 0 ) {
Consumer::number( std::uint64_t( v ) );
Consumer::number( static_cast< std::uint64_t >( v ) );
}
else {
Consumer::number( v );
Expand Down
5 changes: 2 additions & 3 deletions include/tao/json/events/to_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace tao::json::events
{
protected:
std::ostream& os;
bool first;
bool first = true;

void next()
{
Expand All @@ -38,8 +38,7 @@ namespace tao::json::events

public:
explicit to_stream( std::ostream& in_os ) noexcept
: os( in_os ),
first( true )
: os( in_os )
{}

void null()
Expand Down
2 changes: 1 addition & 1 deletion include/tao/json/events/transformer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace tao::json
T,
decltype( std::declval< T< B > >().null(),
std::declval< T< B > >().boolean( true ),
std::declval< T< B > >().number( double( 0.0 ) ),
std::declval< T< B > >().number( static_cast< double >( 0.0 ) ),
std::declval< T< B > >().string( "" ),
std::declval< T< B > >().element(),
std::declval< T< B > >().member(),
Expand Down
4 changes: 2 additions & 2 deletions include/tao/json/internal/action.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ namespace tao::json::internal
template< typename Consumer >
static void apply0( Consumer& consumer )
{
consumer.number( std::uint64_t( 0 ) );
consumer.number( static_cast< std::uint64_t >( 0 ) );
}
};

Expand All @@ -129,7 +129,7 @@ namespace tao::json::internal
template< typename Consumer >
static void apply0( Consumer& consumer )
{
consumer.number( std::int64_t( 0 ) );
consumer.number( static_cast< std::int64_t >( 0 ) );
}
};

Expand Down
12 changes: 6 additions & 6 deletions include/tao/json/internal/endian_gcc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace tao::json::internal
{
[[nodiscard]] static std::int16_t convert( const std::int16_t n ) noexcept
{
return __builtin_bswap16( n );
return static_cast< std::int16_t >( __builtin_bswap16( n ) );
}

[[nodiscard]] static std::uint16_t convert( const std::uint16_t n ) noexcept
Expand All @@ -68,7 +68,7 @@ namespace tao::json::internal

[[nodiscard]] static std::int32_t convert( const std::int32_t n ) noexcept
{
return __builtin_bswap32( n );
return static_cast< std::int32_t >( __builtin_bswap32( n ) );
}

[[nodiscard]] static std::uint32_t convert( const std::uint32_t n ) noexcept
Expand All @@ -91,7 +91,7 @@ namespace tao::json::internal

[[nodiscard]] static std::int64_t convert( const std::int64_t n ) noexcept
{
return __builtin_bswap64( n );
return static_cast< std::int64_t >( __builtin_bswap64( n ) );
}

[[nodiscard]] static std::uint64_t convert( const std::uint64_t n ) noexcept
Expand Down Expand Up @@ -134,7 +134,7 @@ namespace tao::json::internal
{
[[nodiscard]] static std::int16_t convert( const std::int16_t n ) noexcept
{
return __builtin_bswap16( n );
return static_cast< std::int16_t >( __builtin_bswap16( n ) );
}

[[nodiscard]] static std::uint16_t convert( const std::uint16_t n ) noexcept
Expand All @@ -157,7 +157,7 @@ namespace tao::json::internal

[[nodiscard]] static std::int32_t convert( const std::int32_t n ) noexcept
{
return __builtin_bswap32( n );
return static_cast< std::int32_t >( __builtin_bswap32( n ) );
}

[[nodiscard]] static std::uint32_t convert( const std::uint32_t n ) noexcept
Expand All @@ -180,7 +180,7 @@ namespace tao::json::internal

[[nodiscard]] static std::uint64_t convert( const std::uint64_t n ) noexcept
{
return __builtin_bswap64( n );
return static_cast< std::int64_t >( __builtin_bswap64( n ) );
}

[[nodiscard]] static std::int64_t convert( const std::int64_t n ) noexcept
Expand Down
2 changes: 1 addition & 1 deletion include/tao/json/internal/escape.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace tao::json::internal
os.write( l, p - l );
l = ++p;
os.put( '\\' );
os.put( c );
os.put( static_cast< char >( c ) );
}
else if( c < 32 || c == 127 ) {
os.write( l, p - l );
Expand Down
2 changes: 1 addition & 1 deletion include/tao/json/internal/uri_fragment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ namespace tao::json::internal
break;
default:
if( allowed_uri_fragment_characters[ c ] ) {
result += c;
result += static_cast< char >( c );
}
else {
result += '%';
Expand Down
2 changes: 1 addition & 1 deletion include/tao/json/jaxn/events/to_pretty_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace tao::json::jaxn::events
{
if( jaxn::is_identifier( v ) ) {
next();
os.write( v.data(), v.size() );
os.write( v.data(), static_cast< std::streamsize >( v.size() ) );
}
else {
string( v );
Expand Down
2 changes: 1 addition & 1 deletion include/tao/json/jaxn/events/to_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace tao::json::jaxn::events
{
if( jaxn::is_identifier( v ) ) {
next();
os.write( v.data(), v.size() );
os.write( v.data(), static_cast< std::streamsize >( v.size() ) );
}
else {
string( v );
Expand Down
4 changes: 2 additions & 2 deletions include/tao/json/jaxn/internal/action.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ namespace tao::json::jaxn::internal
template< typename Consumer >
static void apply0( Consumer& consumer )
{
consumer.number( std::uint64_t( 0 ) );
consumer.number( static_cast< std::uint64_t >( 0 ) );
}
};

Expand All @@ -175,7 +175,7 @@ namespace tao::json::jaxn::internal
template< typename Consumer >
static void apply0( Consumer& consumer )
{
consumer.number( std::int64_t( 0 ) );
consumer.number( static_cast< std::int64_t >( 0 ) );
}
};

Expand Down
22 changes: 11 additions & 11 deletions include/tao/json/jaxn/internal/bunescape_action.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,47 +28,47 @@ namespace tao::json::jaxn::internal
{
switch( *in.begin() ) {
case '"':
value.push_back( std::byte( '"' ) );
value.push_back( static_cast< std::byte >( '"' ) );
break;

case '\'':
value.push_back( std::byte( '\'' ) );
value.push_back( static_cast< std::byte >( '\'' ) );
break;

case '\\':
value.push_back( std::byte( '\\' ) );
value.push_back( static_cast< std::byte >( '\\' ) );
break;

case '/':
value.push_back( std::byte( '/' ) );
value.push_back( static_cast< std::byte >( '/' ) );
break;

case 'b':
value.push_back( std::byte( '\b' ) );
value.push_back( static_cast< std::byte >( '\b' ) );
break;

case 'f':
value.push_back( std::byte( '\f' ) );
value.push_back( static_cast< std::byte >( '\f' ) );
break;

case 'n':
value.push_back( std::byte( '\n' ) );
value.push_back( static_cast< std::byte >( '\n' ) );
break;

case 'r':
value.push_back( std::byte( '\r' ) );
value.push_back( static_cast< std::byte >( '\r' ) );
break;

case 't':
value.push_back( std::byte( '\t' ) );
value.push_back( static_cast< std::byte >( '\t' ) );
break;

case 'v':
value.push_back( std::byte( '\v' ) );
value.push_back( static_cast< std::byte >( '\v' ) );
break;

case '0':
value.push_back( std::byte( '\0' ) );
value.push_back( static_cast< std::byte >( '\0' ) );
break;

default:
Expand Down
2 changes: 1 addition & 1 deletion include/tao/json/jaxn/internal/integer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ namespace tao::json::jaxn::internal::integer
if( input[ 0 ] == '-' ) {
return convert_hex_negative< Signed >( result, std::string_view( input.data() + 3, input.size() - 3 ) );
}
const auto offset = unsigned( input[ 0 ] == '+' ) + 2; // The "0x" prefix has length 2.
const auto offset = static_cast< unsigned >( input[ 0 ] == '+' ) + 2; // The "0x" prefix has length 2.
return convert_hex_positive< Signed >( result, std::string_view( input.data() + offset, input.size() - offset ) );
}

Expand Down
Loading

0 comments on commit 0f19e06

Please sign in to comment.