Add clang-tidy modernize- checks

This commit is contained in:
Chris Thrasher committed 2024-09-02 20:02:29 -06:00
1 parent afc07ec565
commit 497b261acd
22 files changed
+57 -50

No files matched your search

+6
View File
@@ -1,10 +1,16 @@
Checks: >
bugprone-*,
clang-analyzer-*,
modernize-*,
-bugprone-easily-swappable-parameters,
-bugprone-narrowing-conversions,
-clang-analyzer-core.NonNullParamChecker,
-clang-analyzer-security.insecureAPI.strcpy,
-modernize-avoid-c-arrays,
-modernize-macro-to-enum,
-modernize-redundant-void-arg,
-modernize-use-trailing-return-type,
-modernize-use-using,
HeaderFilterRegex: '.*'
WarningsAsErrors: '*'
UseColor: true
+4 -4
View File
@@ -33,7 +33,7 @@
////////////////////////////////////////////////////////////
sfMusic* sfMusic_createFromFile(const char* filename)
{
sfMusic* music = new sfMusic;
auto* music = new sfMusic;
if (!music->This.openFromFile(filename))
{
delete music;
@@ -47,7 +47,7 @@ sfMusic* sfMusic_createFromFile(const char* filename)
////////////////////////////////////////////////////////////
sfMusic* sfMusic_createFromMemory(const void* data, size_t sizeInBytes)
{
sfMusic* music = new sfMusic;
auto* music = new sfMusic;
if (!music->This.openFromMemory(data, sizeInBytes))
{
delete music;
@@ -63,8 +63,8 @@ sfMusic* sfMusic_createFromStream(sfInputStream* stream)
{
assert(stream);
sfMusic* music = new sfMusic;
music->Stream = CallbackStream(stream);
auto* music = new sfMusic;
music->Stream = CallbackStream(stream);
if (!music->This.openFromStream(music->Stream))
{
delete music;
+2 -2
View File
@@ -31,7 +31,7 @@
#include <SFML/System/String.hpp>
#include <string.h>
#include <cstring>
////////////////////////////////////////////////////////////
@@ -49,7 +49,7 @@ static_assert(alignof(sfChar32) == alignof(char32_t));
inline sfChar32* copyToChar32(const sf::String& str)
{
std::size_t byteCount = sizeof(sfChar32) * str.getSize();
sfChar32* utf32 = static_cast<sfChar32*>(malloc(byteCount + sizeof(sfChar32)));
auto* utf32 = static_cast<sfChar32*>(malloc(byteCount + sizeof(sfChar32)));
memcpy(utf32, str.getData(), byteCount);
utf32[str.getSize()] = 0;
+2 -2
View File
@@ -38,8 +38,8 @@
////////////////////////////////////////////////////////////
sfCircleShape* sfCircleShape_create()
{
sfCircleShape* shape = new sfCircleShape;
shape->Texture = nullptr;
auto* shape = new sfCircleShape;
shape->Texture = nullptr;
return shape;
}
+4 -4
View File
@@ -66,10 +66,10 @@ sfColor sfColor_fromRGBA(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha
////////////////////////////////////////////////////////////
sfColor sfColor_fromInteger(uint32_t color)
{
uint8_t red = static_cast<uint8_t>((color & 0xff000000) >> 24);
uint8_t green = static_cast<uint8_t>((color & 0x00ff0000) >> 16);
uint8_t blue = static_cast<uint8_t>((color & 0x0000ff00) >> 8);
uint8_t alpha = static_cast<uint8_t>((color & 0x000000ff) >> 0);
auto red = static_cast<uint8_t>((color & 0xff000000) >> 24);
auto green = static_cast<uint8_t>((color & 0x00ff0000) >> 16);
auto blue = static_cast<uint8_t>((color & 0x0000ff00) >> 8);
auto alpha = static_cast<uint8_t>((color & 0x000000ff) >> 0);
return sfColor_fromRGBA(red, green, blue, alpha);
}
+1 -1
View File
@@ -58,7 +58,7 @@ sfFont* sfFont_createFromStream(sfInputStream* stream)
{
assert(stream);
sfFont* font = new sfFont;
auto* font = new sfFont;
font->Stream = CallbackStream(stream);
if (!font->This.openFromStream(font->Stream))
{
+3 -3
View File
@@ -59,7 +59,7 @@ sfRenderWindow* sfRenderWindow_create(sfVideoMode mode,
const sf::ContextSettings params = settings ? convertContextSettings(*settings) : sf::ContextSettings();
// Create the window
sfRenderWindow* renderWindow = new sfRenderWindow;
auto* renderWindow = new sfRenderWindow;
renderWindow->This.create(convertVideoMode(mode), title, style, static_cast<sf::State>(state), params);
renderWindow->DefaultView.This = renderWindow->This.getDefaultView();
renderWindow->CurrentView.This = renderWindow->This.getView();
@@ -79,7 +79,7 @@ sfRenderWindow* sfRenderWindow_createUnicode(
const sf::ContextSettings params = settings ? convertContextSettings(*settings) : sf::ContextSettings();
// Create the window
sfRenderWindow* renderWindow = new sfRenderWindow;
auto* renderWindow = new sfRenderWindow;
renderWindow->This.create(convertVideoMode(mode),
reinterpret_cast<const char32_t*>(title),
style,
@@ -99,7 +99,7 @@ sfRenderWindow* sfRenderWindow_createFromHandle(sfWindowHandle handle, const sfC
const sf::ContextSettings params = settings ? convertContextSettings(*settings) : sf::ContextSettings();
// Create the window
sfRenderWindow* renderWindow = new sfRenderWindow;
auto* renderWindow = new sfRenderWindow;
renderWindow->This.create(handle, params);
renderWindow->DefaultView.This = renderWindow->This.getDefaultView();
renderWindow->CurrentView.This = renderWindow->This.getView();
+9 -9
View File
@@ -38,7 +38,7 @@
////////////////////////////////////////////////////////////
sfTexture* sfTexture_create(sfVector2u size)
{
sfTexture* texture = new sfTexture;
auto* texture = new sfTexture;
if (!texture->This->resize(convertVector2(size)))
{
@@ -53,7 +53,7 @@ sfTexture* sfTexture_create(sfVector2u size)
////////////////////////////////////////////////////////////
sfTexture* sfTexture_createFromFile(const char* filename, const sfIntRect* area)
{
sfTexture* texture = new sfTexture;
auto* texture = new sfTexture;
const sf::IntRect rect = area ? convertRect(*area) : sf::IntRect();
@@ -69,7 +69,7 @@ sfTexture* sfTexture_createFromFile(const char* filename, const sfIntRect* area)
////////////////////////////////////////////////////////////
sfTexture* sfTexture_createSrgbFromFile(const char* filename, const sfIntRect* area)
{
sfTexture* texture = new sfTexture;
auto* texture = new sfTexture;
const sf::IntRect rect = area ? convertRect(*area) : sf::IntRect();
@@ -85,7 +85,7 @@ sfTexture* sfTexture_createSrgbFromFile(const char* filename, const sfIntRect* a
////////////////////////////////////////////////////////////
sfTexture* sfTexture_createFromMemory(const void* data, size_t sizeInBytes, const sfIntRect* area)
{
sfTexture* texture = new sfTexture;
auto* texture = new sfTexture;
const sf::IntRect rect = area ? convertRect(*area) : sf::IntRect();
@@ -101,7 +101,7 @@ sfTexture* sfTexture_createFromMemory(const void* data, size_t sizeInBytes, cons
////////////////////////////////////////////////////////////
sfTexture* sfTexture_createSrgbFromMemory(const void* data, size_t sizeInBytes, const sfIntRect* area)
{
sfTexture* texture = new sfTexture;
auto* texture = new sfTexture;
const sf::IntRect rect = area ? convertRect(*area) : sf::IntRect();
@@ -120,7 +120,7 @@ sfTexture* sfTexture_createFromStream(sfInputStream* stream, const sfIntRect* ar
{
assert(stream);
sfTexture* texture = new sfTexture;
auto* texture = new sfTexture;
const sf::IntRect rect = area ? convertRect(*area) : sf::IntRect();
@@ -139,7 +139,7 @@ sfTexture* sfTexture_createSrgbFromStream(sfInputStream* stream, const sfIntRect
{
assert(stream);
sfTexture* texture = new sfTexture;
auto* texture = new sfTexture;
const sf::IntRect rect = area ? convertRect(*area) : sf::IntRect();
@@ -159,7 +159,7 @@ sfTexture* sfTexture_createFromImage(const sfImage* image, const sfIntRect* area
{
assert(image);
sfTexture* texture = new sfTexture;
auto* texture = new sfTexture;
const sf::IntRect rect = area ? convertRect(*area) : sf::IntRect();
@@ -177,7 +177,7 @@ sfTexture* sfTexture_createSrgbFromImage(const sfImage* image, const sfIntRect*
{
assert(image);
sfTexture* texture = new sfTexture;
auto* texture = new sfTexture;
const sf::IntRect rect = area ? convertRect(*area) : sf::IntRect();
+1 -1
View File
@@ -34,7 +34,7 @@
////////////////////////////////////////////////////////////
sfTransformable* sfTransformable_create()
{
sfTransformable* transformable = new sfTransformable;
auto* transformable = new sfTransformable;
return transformable;
}
+3 -3
View File
@@ -32,7 +32,7 @@
////////////////////////////////////////////////////////////
sfVertexBuffer* sfVertexBuffer_create(unsigned int vertexCount, sfPrimitiveType type, sfVertexBufferUsage usage)
{
sfVertexBuffer* buffer = new sfVertexBuffer;
auto* buffer = new sfVertexBuffer;
if (!buffer->This.create(vertexCount))
{
@@ -52,8 +52,8 @@ sfVertexBuffer* sfVertexBuffer_create(unsigned int vertexCount, sfPrimitiveType
////////////////////////////////////////////////////////////
sfVertexBuffer* sfVertexBuffer_copy(const sfVertexBuffer* vertexBuffer)
{
sfVertexBuffer* buffer = new sfVertexBuffer;
buffer->This = sf::VertexBuffer(vertexBuffer->This);
auto* buffer = new sfVertexBuffer;
buffer->This = sf::VertexBuffer(vertexBuffer->This);
return buffer;
}
+1 -1
View File
@@ -32,7 +32,7 @@
#include <SFML/Network/IpAddress.hpp>
#include <SFML/System/String.hpp>
#include <string.h>
#include <cstring>
////////////////////////////////////////////////////////////
+4 -3
View File
@@ -29,6 +29,7 @@
////////////////////////////////////////////////////////////
#include <SFML/Network/Ftp.hpp>
#include <utility>
#include <vector>
@@ -46,7 +47,7 @@ struct sfFtp
////////////////////////////////////////////////////////////
struct sfFtpResponse
{
sfFtpResponse(const sf::Ftp::Response& Response) : This(Response)
sfFtpResponse(sf::Ftp::Response Response) : This(std::move(Response))
{
}
@@ -59,7 +60,7 @@ struct sfFtpResponse
////////////////////////////////////////////////////////////
struct sfFtpDirectoryResponse
{
sfFtpDirectoryResponse(const sf::Ftp::DirectoryResponse& Response) : This(Response)
sfFtpDirectoryResponse(sf::Ftp::DirectoryResponse Response) : This(std::move(Response))
{
}
@@ -72,7 +73,7 @@ struct sfFtpDirectoryResponse
////////////////////////////////////////////////////////////
struct sfFtpListingResponse
{
sfFtpListingResponse(const sf::Ftp::ListingResponse& Response) : This(Response)
sfFtpListingResponse(sf::Ftp::ListingResponse Response) : This(std::move(Response))
{
}
+2 -2
View File
@@ -162,8 +162,8 @@ sfHttpResponse* sfHttp_sendRequest(sfHttp* http, const sfHttpRequest* request, s
assert(http);
assert(request);
sfHttpResponse* response = new sfHttpResponse;
response->This = http->This.sendRequest(request->This, sf::microseconds(timeout.microseconds));
auto* response = new sfHttpResponse;
response->This = http->This.sendRequest(request->This, sf::microseconds(timeout.microseconds));
return response;
}
+1 -1
View File
@@ -29,7 +29,7 @@
#include <SFML/Network/IpAddress.hpp>
#include <string.h>
#include <cstring>
namespace
+2 -2
View File
@@ -90,8 +90,8 @@ sfSocketStatus sfTcpListener_accept(sfTcpListener* listener, sfTcpSocket** conne
assert(listener);
assert(connected);
*connected = new sfTcpSocket;
sfSocketStatus status = static_cast<sfSocketStatus>(listener->This.accept((*connected)->This));
*connected = new sfTcpSocket;
auto status = static_cast<sfSocketStatus>(listener->This.accept((*connected)->This));
if (status != sfSocketDone)
{
+1 -1
View File
@@ -31,7 +31,7 @@
#include <SFML/Network/IpAddress.hpp>
#include <string.h>
#include <cstring>
////////////////////////////////////////////////////////////
+1 -1
View File
@@ -31,7 +31,7 @@
#include <SFML/Network/IpAddress.hpp>
#include <string.h>
#include <cstring>
////////////////////////////////////////////////////////////
+1 -1
View File
@@ -27,7 +27,7 @@
////////////////////////////////////////////////////////////
#include <CSFML/System/Alloc.h>
#include <stdlib.h>
#include <cstdlib>
////////////////////////////////////////////////////////////
+1 -1
View File
@@ -30,7 +30,7 @@
#include <SFML/System/String.hpp>
#include <SFML/Window/Keyboard.hpp>
#include <string.h>
#include <cstring>
////////////////////////////////////////////////////////////
+2 -2
View File
@@ -31,8 +31,8 @@
#include <SFML/Window/Vulkan.hpp>
#include <stdlib.h>
#include <string.h>
#include <cstdlib>
#include <cstring>
////////////////////////////////////////////////////////////
+3 -3
View File
@@ -41,7 +41,7 @@ sfWindow* sfWindow_create(sfVideoMode mode, const char* title, uint32_t style, s
const sf::ContextSettings params = settings ? convertContextSettings(*settings) : sf::ContextSettings();
// Create the window
sfWindow* window = new sfWindow;
auto* window = new sfWindow;
window->This.create(convertVideoMode(mode), title, style, static_cast<sf::State>(state), params);
return window;
@@ -58,7 +58,7 @@ sfWindow* sfWindow_createUnicode(sfVideoMode mode,
const sf::ContextSettings params = settings ? convertContextSettings(*settings) : sf::ContextSettings();
// Create the window
sfWindow* window = new sfWindow;
auto* window = new sfWindow;
window->This.create(convertVideoMode(mode),
reinterpret_cast<const char32_t*>(title),
style,
@@ -76,7 +76,7 @@ sfWindow* sfWindow_createFromHandle(sfWindowHandle handle, const sfContextSettin
const sf::ContextSettings params = settings ? convertContextSettings(*settings) : sf::ContextSettings();
// Create the window
sfWindow* window = new sfWindow;
auto* window = new sfWindow;
window->This.create(handle, params);
return window;
+3 -3
View File
@@ -39,7 +39,7 @@
sfWindowBase* sfWindowBase_create(sfVideoMode mode, const char* title, uint32_t style)
{
// Create the window
sfWindowBase* windowBase = new sfWindowBase;
auto* windowBase = new sfWindowBase;
windowBase->This.create(convertVideoMode(mode), title, style);
return windowBase;
@@ -50,7 +50,7 @@ sfWindowBase* sfWindowBase_create(sfVideoMode mode, const char* title, uint32_t
sfWindowBase* sfWindowBase_createUnicode(sfVideoMode mode, const sfChar32* title, uint32_t style)
{
// Create the window
sfWindowBase* windowBase = new sfWindowBase;
auto* windowBase = new sfWindowBase;
windowBase->This.create(convertVideoMode(mode), reinterpret_cast<const char32_t*>(title), style);
return windowBase;
@@ -61,7 +61,7 @@ sfWindowBase* sfWindowBase_createUnicode(sfVideoMode mode, const sfChar32* title
sfWindowBase* sfWindowBase_createFromHandle(sfWindowHandle handle)
{
// Create the window
sfWindowBase* windowBase = new sfWindowBase;
auto* windowBase = new sfWindowBase;
windowBase->This.create(handle);
return windowBase;