Add clang-tidy bugprone-* checks

This commit is contained in:
Chris Thrasher 2023-02-02 23:31:48 -07:00
parent 9269edcccc
commit 82b9821a8a
6 changed files with 23 additions and 12 deletions

View File

@ -1,11 +1,25 @@
Checks: >
-*,
bugprone-*,
clang-analyzer-*,
misc-*,
modernize-*,
performance-*,
portability-*,
readability-*,
-bugprone-assignment-in-if-condition,
-bugprone-branch-clone,
-bugprone-easily-swappable-parameters,
-bugprone-exception-escape,
-bugprone-implicit-widening-of-multiplication-result,
-bugprone-incorrect-roundings,
-bugprone-integer-division,
-bugprone-misplaced-widening-cast,
-bugprone-narrowing-conversions,
-bugprone-signed-char-misuse,
-bugprone-string-integer-assignment,
-bugprone-suspicious-include,
-bugprone-unchecked-optional-access,
-clang-analyzer-nullability.NullablePassedToNonnull,
-clang-analyzer-optin.cplusplus.VirtualCall,
-clang-analyzer-optin.osx.*,

View File

@ -32,9 +32,6 @@
namespace sf
{
class Context;
using ContextDestroyCallback = void (*)(void*);
////////////////////////////////////////////////////////////

View File

@ -31,7 +31,7 @@
// Windows' HWND is a type alias for struct HWND__*
#if defined(SFML_SYSTEM_WINDOWS)
struct HWND__;
struct HWND__; // NOLINT(bugprone-reserved-identifier)
#endif
namespace sf

View File

@ -33,7 +33,7 @@
#endif
#ifndef _WIN32_WINDOWS
#define _WIN32_WINDOWS 0x0501
#define _WIN32_WINDOWS 0x0501 // NOLINT(bugprone-reserved-identifier)
#endif
#ifndef _WIN32_WINNT
@ -49,7 +49,7 @@
#endif
#ifndef _UNICODE
#define _UNICODE 1
#define _UNICODE 1 // NOLINT(bugprone-reserved-identifier)
#endif
#include <windows.h>

View File

@ -93,10 +93,10 @@ void uninitFileDescriptors()
}
#define BITS_PER_LONG (sizeof(unsigned long) * 8)
#define NBITS(x) (((x - 1) / BITS_PER_LONG) + 1)
#define OFF(x) (x % BITS_PER_LONG)
#define LONG(x) (x / BITS_PER_LONG)
#define TEST_BIT(bit, array) ((array[LONG(bit)] >> OFF(bit)) & 1)
#define NBITS(x) ((((x)-1) / BITS_PER_LONG) + 1)
#define OFF(x) ((x) % BITS_PER_LONG)
#define LONG(x) ((x) / BITS_PER_LONG)
#define TEST_BIT(bit, array) (((array)[LONG(bit)] >> OFF(bit)) & 1)
// Only keep fileDescriptors that we think are a keyboard, mouse or touchpad/touchscreen
// Joysticks are handled in /src/SFML/Window/Unix/JoystickImpl.cpp

View File

@ -15,7 +15,7 @@ static_assert(std::is_nothrow_move_assignable_v<sf::Packet>);
do \
{ \
sf::Packet packet; \
packet << expected; \
packet << (expected); \
CHECK(packet.getReadPosition() == 0); \
CHECK(packet.getData() != nullptr); \
CHECK(packet.getDataSize() == sizeof(expected)); \
@ -29,7 +29,7 @@ static_assert(std::is_nothrow_move_assignable_v<sf::Packet>);
CHECK(packet.getDataSize() == sizeof(expected)); \
CHECK(packet.endOfPacket()); \
CHECK(static_cast<bool>(packet)); \
CHECK(expected == received); \
CHECK((expected) == received); \
} while (false)
TEST_CASE("[Network] sf::Packet")