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-deprecated-headers,
modernize-loop-convert,
modernize-use-default-member-init,
modernize-use-equals-default,
modernize-use-equals-delete,
modernize-use-nullptr,

View File

@ -54,7 +54,7 @@ public:
}
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:
std::string m_name;
bool m_isLoaded;
bool m_isLoaded{};
// NOLINTNEXTLINE(readability-identifier-naming)
static const sf::Font* s_font;

View File

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

View File

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

View File

@ -359,7 +359,7 @@ private:
GlyphTable glyphs; //!< Table mapping code points to their corresponding glyph
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
};

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
sf::Image image;

View File

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

View File

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

View File

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