Add clang-tidy modernize-use-default-member-init check

This commit is contained in:
Chris Thrasher 2023-01-15 11:30:12 -07:00
parent d202f753ed
commit 8a5b206bb8
9 changed files with 52 additions and 88 deletions

View File

@ -4,6 +4,7 @@ Checks: >
modernize-concat-nested-namespaces, modernize-concat-nested-namespaces,
modernize-deprecated-headers, modernize-deprecated-headers,
modernize-loop-convert, modernize-loop-convert,
modernize-use-default-member-init,
modernize-use-equals-default, modernize-use-equals-default,
modernize-use-equals-delete, modernize-use-equals-delete,
modernize-use-nullptr, modernize-use-nullptr,

View File

@ -54,7 +54,7 @@ public:
} }
protected: protected:
Effect(const std::string& name) : m_name(name), m_isLoaded(false) Effect(const std::string& name) : m_name(name)
{ {
} }
@ -72,7 +72,7 @@ private:
private: private:
std::string m_name; std::string m_name;
bool m_isLoaded; bool m_isLoaded{};
// NOLINTNEXTLINE(readability-identifier-naming) // NOLINTNEXTLINE(readability-identifier-naming)
static const sf::Font* s_font; static const sf::Font* s_font;

View File

@ -26,7 +26,7 @@ public:
/// Default constructor /// Default constructor
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
NetworkAudioStream() : m_offset(0), m_hasFinished(false) NetworkAudioStream()
{ {
// Set the sound parameters // Set the sound parameters
initialize(1, 44100); initialize(1, 44100);
@ -161,8 +161,8 @@ private:
std::recursive_mutex m_mutex; std::recursive_mutex m_mutex;
std::vector<std::int16_t> m_samples; std::vector<std::int16_t> m_samples;
std::vector<std::int16_t> m_tempBuffer; std::vector<std::int16_t> m_tempBuffer;
std::size_t m_offset; std::size_t m_offset{};
bool m_hasFinished; bool m_hasFinished{};
}; };

View File

@ -203,42 +203,7 @@ class VulkanExample
{ {
public: public:
// Constructor // Constructor
VulkanExample() : VulkanExample()
window(sf::VideoMode({800, 600}), "SFML window with Vulkan", sf::Style::Default),
vulkanAvailable(sf::Vulkan::isAvailable()),
maxFramesInFlight(2),
currentFrame(0),
swapchainOutOfDate(false),
instance(),
debugReportCallback(),
surface(),
gpu(),
queueFamilyIndex(-1),
device(),
queue(),
swapchainFormat(),
swapchainExtent(),
swapchain(),
depthFormat(VK_FORMAT_UNDEFINED),
depthImage(),
depthImageMemory(),
depthImageView(),
vertexShaderModule(),
fragmentShaderModule(),
descriptorSetLayout(),
pipelineLayout(),
renderPass(),
graphicsPipeline(),
commandPool(),
vertexBuffer(),
vertexBufferMemory(),
indexBuffer(),
indexBufferMemory(),
textureImage(),
textureImageMemory(),
textureImageView(),
textureSampler(),
descriptorPool()
{ {
// Vulkan setup procedure // Vulkan setup procedure
if (vulkanAvailable) if (vulkanAvailable)
@ -2602,50 +2567,50 @@ public:
} }
private: private:
sf::WindowBase window; sf::WindowBase window{sf::VideoMode({800, 600}), "SFML window with Vulkan", sf::Style::Default};
bool vulkanAvailable; bool vulkanAvailable{sf::Vulkan::isAvailable()};
const unsigned int maxFramesInFlight; const unsigned int maxFramesInFlight{2};
unsigned int currentFrame; unsigned int currentFrame{};
bool swapchainOutOfDate; bool swapchainOutOfDate{};
VkInstance instance; VkInstance instance{};
VkDebugReportCallbackEXT debugReportCallback; VkDebugReportCallbackEXT debugReportCallback{};
VkSurfaceKHR surface; VkSurfaceKHR surface{};
VkPhysicalDevice gpu; VkPhysicalDevice gpu{};
int queueFamilyIndex; int queueFamilyIndex{-1};
VkDevice device; VkDevice device{};
VkQueue queue; VkQueue queue{};
VkSurfaceFormatKHR swapchainFormat; VkSurfaceFormatKHR swapchainFormat{};
VkExtent2D swapchainExtent; VkExtent2D swapchainExtent{};
VkSwapchainKHR swapchain; VkSwapchainKHR swapchain{};
std::vector<VkImage> swapchainImages; std::vector<VkImage> swapchainImages;
std::vector<VkImageView> swapchainImageViews; std::vector<VkImageView> swapchainImageViews;
VkFormat depthFormat; VkFormat depthFormat{VK_FORMAT_UNDEFINED};
VkImage depthImage; VkImage depthImage{};
VkDeviceMemory depthImageMemory; VkDeviceMemory depthImageMemory{};
VkImageView depthImageView; VkImageView depthImageView{};
VkShaderModule vertexShaderModule; VkShaderModule vertexShaderModule{};
VkShaderModule fragmentShaderModule; VkShaderModule fragmentShaderModule{};
VkPipelineShaderStageCreateInfo shaderStages[2]; VkPipelineShaderStageCreateInfo shaderStages[2];
VkDescriptorSetLayout descriptorSetLayout; VkDescriptorSetLayout descriptorSetLayout{};
VkPipelineLayout pipelineLayout; VkPipelineLayout pipelineLayout{};
VkRenderPass renderPass; VkRenderPass renderPass{};
VkPipeline graphicsPipeline; VkPipeline graphicsPipeline{};
std::vector<VkFramebuffer> swapchainFramebuffers; std::vector<VkFramebuffer> swapchainFramebuffers;
VkCommandPool commandPool; VkCommandPool commandPool{};
VkBuffer vertexBuffer; VkBuffer vertexBuffer{};
VkDeviceMemory vertexBufferMemory; VkDeviceMemory vertexBufferMemory{};
VkBuffer indexBuffer; VkBuffer indexBuffer{};
VkDeviceMemory indexBufferMemory; VkDeviceMemory indexBufferMemory{};
std::vector<VkBuffer> uniformBuffers; std::vector<VkBuffer> uniformBuffers;
std::vector<VkDeviceMemory> uniformBuffersMemory; std::vector<VkDeviceMemory> uniformBuffersMemory;
VkImage textureImage; VkImage textureImage{};
VkDeviceMemory textureImageMemory; VkDeviceMemory textureImageMemory{};
VkImageView textureImageView; VkImageView textureImageView{};
VkSampler textureSampler; VkSampler textureSampler{};
VkDescriptorPool descriptorPool; VkDescriptorPool descriptorPool{};
std::vector<VkDescriptorSet> descriptorSets; std::vector<VkDescriptorSet> descriptorSets;
std::vector<VkCommandBuffer> commandBuffers; std::vector<VkCommandBuffer> commandBuffers;
std::vector<VkSemaphore> imageAvailableSemaphores; std::vector<VkSemaphore> imageAvailableSemaphores;

View File

@ -357,10 +357,10 @@ private:
{ {
explicit Page(bool smooth); explicit Page(bool smooth);
GlyphTable glyphs; //!< Table mapping code points to their corresponding glyph GlyphTable glyphs; //!< Table mapping code points to their corresponding glyph
Texture texture; //!< Texture containing the pixels of the glyphs Texture texture; //!< Texture containing the pixels of the glyphs
unsigned int nextRow; //!< Y position of the next new row in the texture unsigned int nextRow{3}; //!< Y position of the next new row in the texture
std::vector<Row> rows; //!< List containing the position of all the existing rows std::vector<Row> rows; //!< List containing the position of all the existing rows
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -835,7 +835,7 @@ bool Font::setCurrentSize(unsigned int characterSize) const
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Font::Page::Page(bool smooth) : nextRow(3) Font::Page::Page(bool smooth)
{ {
// Make sure that the texture is initialized by default // Make sure that the texture is initialized by default
sf::Image image; sf::Image image;

View File

@ -199,7 +199,7 @@ struct TransientContext
/// \brief Constructor /// \brief Constructor
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
TransientContext() : referenceCount(0), context(nullptr), sharedContextLock(), useSharedContext(false) TransientContext()
{ {
if (resourceCount == 0) if (resourceCount == 0)
{ {
@ -241,10 +241,10 @@ struct TransientContext
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
unsigned int referenceCount; unsigned int referenceCount{};
std::unique_ptr<sf::Context> context; std::unique_ptr<sf::Context> context;
std::optional<std::lock_guard<std::recursive_mutex>> sharedContextLock; std::optional<std::lock_guard<std::recursive_mutex>> sharedContextLock;
bool useSharedContext; bool useSharedContext{};
}; };
// This per-thread variable tracks if and how a transient // This per-thread variable tracks if and how a transient

View File

@ -104,7 +104,7 @@ private:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
NSCursorRef m_cursor; ///< System cursor handle NSCursorRef m_cursor{}; ///< System cursor handle
}; };
} // namespace sf::priv } // namespace sf::priv

View File

@ -51,9 +51,7 @@ namespace sf::priv
{ {
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CursorImpl::CursorImpl() : m_cursor(nil) CursorImpl::CursorImpl() = default;
{
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////