Add iOS clang-tidy job

This commit is contained in:
Chris Thrasher 2023-07-27 19:59:15 -06:00
parent b99a4e341e
commit 3d63de9a21
10 changed files with 46 additions and 42 deletions

View File

@ -239,6 +239,7 @@ jobs:
- { name: Linux, os: ubuntu-22.04 }
- { name: Linux DRM, os: ubuntu-22.04, flags: -DSFML_USE_DRM=TRUE }
- { name: macOS, os: macos-12 }
- { name: iOS, os: macos-12, flags: -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_ARCHITECTURES=arm64 }
- { name: Android, os: ubuntu-22.04, flags: -DCMAKE_ANDROID_ARCH_ABI=x86 -DCMAKE_SYSTEM_NAME=Android -DSFML_BUILD_TEST_SUITE=FALSE -DCMAKE_ANDROID_NDK=$GITHUB_WORKSPACE/android-ndk-r23b -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang -DCMAKE_ANDROID_STL_TYPE=c++_shared -DCMAKE_ANDROID_API=26 }
steps:

View File

@ -118,7 +118,7 @@ unsigned int RenderTextureImplFBO::getMaximumAntialiasingLevel()
{
const TransientContextLock lock;
GLint samples = 0;
GLint samples = 0; // NOLINT(misc-const-correctness)
#ifndef SFML_OPENGL_ES

View File

@ -37,13 +37,13 @@ namespace sf::priv
////////////////////////////////////////////////////////////
String ClipboardImpl::getString()
{
UIPasteboard* pboard = [UIPasteboard generalPasteboard];
UIPasteboard* const pboard = [UIPasteboard generalPasteboard];
if (pboard.hasStrings)
{
NSString* data = pboard.string;
const NSString* const data = pboard.string;
const char* utf8 = [data cStringUsingEncoding:NSUTF8StringEncoding];
NSUInteger length = [data lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
const char* utf8 = [data cStringUsingEncoding:NSUTF8StringEncoding];
const NSUInteger length = [data lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
return String::fromUtf8(utf8, utf8 + length);
}
@ -58,10 +58,13 @@ String ClipboardImpl::getString()
void ClipboardImpl::setString(const String& text)
{
std::basic_string<std::uint8_t> utf8 = text.toUtf8();
NSString* data = [[NSString alloc] initWithBytes:utf8.data() length:utf8.length() encoding:NSUTF8StringEncoding];
NSString* const data = [[NSString alloc]
initWithBytes:utf8.data()
length:utf8.length()
encoding:NSUTF8StringEncoding];
UIPasteboard* pboard = [UIPasteboard generalPasteboard];
pboard.string = data;
UIPasteboard* const pboard = [UIPasteboard generalPasteboard];
pboard.string = data;
}
} // namespace sf::priv

View File

@ -85,7 +85,7 @@ public:
/// \brief Destructor
///
////////////////////////////////////////////////////////////
~EaglContext();
~EaglContext() override;
////////////////////////////////////////////////////////////
/// \brief Get the address of an OpenGL function

View File

@ -45,16 +45,16 @@
namespace
{
PFNGLBINDFRAMEBUFFEROESPROC glBindFramebufferOESFunc = 0;
PFNGLBINDRENDERBUFFEROESPROC glBindRenderbufferOESFunc = 0;
PFNGLCHECKFRAMEBUFFERSTATUSOESPROC glCheckFramebufferStatusOESFunc = 0;
PFNGLDELETEFRAMEBUFFERSOESPROC glDeleteFramebuffersOESFunc = 0;
PFNGLDELETERENDERBUFFERSOESPROC glDeleteRenderbuffersOESFunc = 0;
PFNGLFRAMEBUFFERRENDERBUFFEROESPROC glFramebufferRenderbufferOESFunc = 0;
PFNGLGENFRAMEBUFFERSOESPROC glGenFramebuffersOESFunc = 0;
PFNGLGENRENDERBUFFERSOESPROC glGenRenderbuffersOESFunc = 0;
PFNGLGETRENDERBUFFERPARAMETERIVOESPROC glGetRenderbufferParameterivOESFunc = 0;
PFNGLRENDERBUFFERSTORAGEOESPROC glRenderbufferStorageOESFunc = 0;
PFNGLBINDFRAMEBUFFEROESPROC glBindFramebufferOESFunc = nullptr;
PFNGLBINDRENDERBUFFEROESPROC glBindRenderbufferOESFunc = nullptr;
PFNGLCHECKFRAMEBUFFERSTATUSOESPROC glCheckFramebufferStatusOESFunc = nullptr;
PFNGLDELETEFRAMEBUFFERSOESPROC glDeleteFramebuffersOESFunc = nullptr;
PFNGLDELETERENDERBUFFERSOESPROC glDeleteRenderbuffersOESFunc = nullptr;
PFNGLFRAMEBUFFERRENDERBUFFEROESPROC glFramebufferRenderbufferOESFunc = nullptr;
PFNGLGENFRAMEBUFFERSOESPROC glGenFramebuffersOESFunc = nullptr;
PFNGLGENRENDERBUFFERSOESPROC glGenRenderbuffersOESFunc = nullptr;
PFNGLGETRENDERBUFFERPARAMETERIVOESPROC glGetRenderbufferParameterivOESFunc = nullptr;
PFNGLRENDERBUFFERSTORAGEOESPROC glRenderbufferStorageOESFunc = nullptr;
void ensureInit()
@ -137,7 +137,7 @@ EaglContext::~EaglContext()
if (m_context)
{
// Activate the context, so that we can destroy the buffers
EAGLContext* previousContext = [EAGLContext currentContext];
EAGLContext* const previousContext = [EAGLContext currentContext];
[EAGLContext setCurrentContext:m_context];
// Destroy the buffers
@ -160,23 +160,23 @@ EaglContext::~EaglContext()
////////////////////////////////////////////////////////////
GlFunctionPointer EaglContext::getFunction(const char* name)
{
static void* module = 0;
static void* module = nullptr;
const int libCount = 3;
const char* libs[libCount] = {"libGLESv1_CM.dylib",
"/System/Library/Frameworks/OpenGLES.framework/OpenGLES",
"OpenGLES.framework/OpenGLES"};
for (int i = 0; i < libCount; ++i)
for (auto& lib : libs)
{
if (!module)
module = dlopen(libs[i], RTLD_LAZY | RTLD_LOCAL);
module = dlopen(lib, RTLD_LAZY | RTLD_LOCAL);
}
if (module)
return reinterpret_cast<GlFunctionPointer>(reinterpret_cast<uintptr_t>(dlsym(module, name)));
return 0;
return nullptr;
}
@ -184,7 +184,7 @@ GlFunctionPointer EaglContext::getFunction(const char* name)
void EaglContext::recreateRenderBuffers(SFView* glView)
{
// Activate the context
EAGLContext* previousContext = [EAGLContext currentContext];
EAGLContext* const previousContext = [EAGLContext currentContext];
[EAGLContext setCurrentContext:m_context];
// Bind the frame buffer
@ -207,12 +207,13 @@ void EaglContext::recreateRenderBuffers(SFView* glView)
if (m_settings.depthBits > 0)
{
// Find the best internal format
GLenum format = m_settings.depthBits > 16
? (m_settings.stencilBits == 0 ? GL_DEPTH_COMPONENT24_OES : GL_DEPTH24_STENCIL8_OES)
: GL_DEPTH_COMPONENT16_OES;
const GLenum format = m_settings.depthBits > 16
? (m_settings.stencilBits == 0 ? GL_DEPTH_COMPONENT24_OES : GL_DEPTH24_STENCIL8_OES)
: GL_DEPTH_COMPONENT16_OES;
// Get the size of the color-buffer (which fits the current size of the GL view)
GLint width, height;
GLint width;
GLint height;
glGetRenderbufferParameterivOESFunc(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &width);
glGetRenderbufferParameterivOESFunc(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &height);
@ -226,7 +227,7 @@ void EaglContext::recreateRenderBuffers(SFView* glView)
}
// Make sure that everything's ok
GLenum status = glCheckFramebufferStatusOESFunc(GL_FRAMEBUFFER_OES);
const GLenum status = glCheckFramebufferStatusOESFunc(GL_FRAMEBUFFER_OES);
if (status != GL_FRAMEBUFFER_COMPLETE_OES)
err() << "Failed to create a valid frame buffer (error code: " << status << ")" << std::endl;

View File

@ -192,7 +192,7 @@
self.touches = [NSMutableArray array];
// Configure the EAGL layer
CAEAGLLayer* eaglLayer = static_cast<CAEAGLLayer*>(self.layer);
auto* eaglLayer = static_cast<CAEAGLLayer*>(self.layer);
eaglLayer.opaque = YES;
eaglLayer.drawableProperties = [NSDictionary
dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:FALSE],

View File

@ -132,8 +132,8 @@ void SensorImpl::close()
////////////////////////////////////////////////////////////
Vector3f SensorImpl::update()
{
Vector3f value;
CMMotionManager* manager = [SFAppDelegate getInstance].motionManager;
Vector3f value;
CMMotionManager* const manager = [SFAppDelegate getInstance].motionManager;
switch (m_sensor)
{

View File

@ -45,8 +45,8 @@ std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
////////////////////////////////////////////////////////////
VideoMode VideoModeImpl::getDesktopMode()
{
CGRect bounds = [[UIScreen mainScreen] bounds];
double backingScale = [SFAppDelegate getInstance].backingScaleFactor;
const CGRect bounds = [[UIScreen mainScreen] bounds];
const double backingScale = [SFAppDelegate getInstance].backingScaleFactor;
return VideoMode({static_cast<unsigned int>(bounds.size.width * backingScale),
static_cast<unsigned int>(bounds.size.height * backingScale)});
}

View File

@ -197,7 +197,6 @@ public:
////////////////////////////////////////////////////////////
bool hasFocus() const override;
public:
////////////////////////////////////////////////////////////
/// \brief Notify an event
///

View File

@ -61,14 +61,14 @@ WindowImplUIKit::WindowImplUIKit(VideoMode mode, const String& /* title */, unsi
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
// Create the window
CGRect frame = [UIScreen mainScreen].bounds; // Ignore user size, it wouldn't make sense to use something else
m_window = [[UIWindow alloc] initWithFrame:frame];
m_hasFocus = true;
const CGRect frame = [UIScreen mainScreen].bounds; // Ignore user size, it wouldn't make sense to use something else
m_window = [[UIWindow alloc] initWithFrame:frame];
m_hasFocus = true;
// Assign it to the application delegate
[SFAppDelegate getInstance].sfWindow = this;
CGRect viewRect = frame;
const CGRect viewRect = frame;
// Create the view
m_view = [[SFView alloc] initWithFrame:viewRect andContentScaleFactor:(static_cast<double>(m_backingScale))];
@ -108,7 +108,7 @@ WindowHandle WindowImplUIKit::getSystemHandle() const
////////////////////////////////////////////////////////////
Vector2i WindowImplUIKit::getPosition() const
{
CGPoint origin = m_window.frame.origin;
const CGPoint origin = m_window.frame.origin;
return Vector2i(static_cast<int>(origin.x * static_cast<double>(m_backingScale)),
static_cast<int>(origin.y * static_cast<double>(m_backingScale)));
}
@ -123,7 +123,7 @@ void WindowImplUIKit::setPosition(const Vector2i& /* position */)
////////////////////////////////////////////////////////////
Vector2u WindowImplUIKit::getSize() const
{
CGRect physicalFrame = m_window.frame;
const CGRect physicalFrame = m_window.frame;
return Vector2u(static_cast<unsigned int>(physicalFrame.size.width * static_cast<double>(m_backingScale)),
static_cast<unsigned int>(physicalFrame.size.height * static_cast<double>(m_backingScale)));
}