From a4bca20567d744c04929b1fc7135cdb845c7c4f6 Mon Sep 17 00:00:00 2001 From: Norm Evangelista Date: Wed, 11 Jan 2023 23:27:56 -0800 Subject: [PATCH] Added modernize-use-equals-default, modernize-use-equals-delete Fixed formatting issues per review Implemented copy constructor since operator= is implemented Reverted operator=, add NOLINT for copy constructor per review Fixed clang-tidy escape in examples Fixed OSX clang-tidy escapes --- .clang-tidy | 2 ++ examples/shader/Effect.hpp | 4 +--- src/SFML/Graphics/Font.cpp | 1 + src/SFML/Graphics/ImageLoader.hpp | 24 ++++++++++----------- src/SFML/System/String.cpp | 10 ++------- src/SFML/Window/JoystickManager.hpp | 24 ++++++++++----------- src/SFML/Window/OSX/HIDInputManager.hpp | 24 ++++++++++----------- src/SFML/Window/OSX/HIDJoystickManager.hpp | 25 +++++++++++----------- src/SFML/Window/SensorManager.hpp | 24 ++++++++++----------- 9 files changed, 67 insertions(+), 71 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 40473e05..409d22a0 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -2,6 +2,8 @@ Checks: > -*, clang-analyzer-*, modernize-concat-nested-namespaces, + modernize-use-equals-default, + modernize-use-equals-delete, modernize-use-nullptr, readability-identifier-naming, -clang-analyzer-core.NonNullParamChecker, diff --git a/examples/shader/Effect.hpp b/examples/shader/Effect.hpp index 2eaf6dfa..e82f4e1c 100644 --- a/examples/shader/Effect.hpp +++ b/examples/shader/Effect.hpp @@ -15,9 +15,7 @@ class Effect : public sf::Drawable { public: - ~Effect() override - { - } + ~Effect() override = default; static void setFont(const sf::Font& font) { diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index ee94afc4..af67b2c4 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -124,6 +124,7 @@ Font::Font() = default; //////////////////////////////////////////////////////////// +// NOLINTNEXTLINE(modernize-use-equals-default) Font::Font(const Font& copy) : m_fontHandles(copy.m_fontHandles), m_isSmooth(copy.m_isSmooth), diff --git a/src/SFML/Graphics/ImageLoader.hpp b/src/SFML/Graphics/ImageLoader.hpp index 78ea2370..6f1c67cb 100644 --- a/src/SFML/Graphics/ImageLoader.hpp +++ b/src/SFML/Graphics/ImageLoader.hpp @@ -49,6 +49,18 @@ namespace priv class ImageLoader { public: + //////////////////////////////////////////////////////////// + /// \brief Deleted copy constructor + /// + //////////////////////////////////////////////////////////// + ImageLoader(const ImageLoader&) = delete; + + //////////////////////////////////////////////////////////// + /// \brief Deleted copy assignment + /// + //////////////////////////////////////////////////////////// + ImageLoader& operator=(const ImageLoader&) = delete; + //////////////////////////////////////////////////////////// /// \brief Get the unique instance of the class /// @@ -128,18 +140,6 @@ private: /// //////////////////////////////////////////////////////////// ImageLoader(); - - //////////////////////////////////////////////////////////// - /// \brief Deleted copy constructor - /// - //////////////////////////////////////////////////////////// - ImageLoader(const ImageLoader&) = delete; - - //////////////////////////////////////////////////////////// - /// \brief Deleted copy assignment - /// - //////////////////////////////////////////////////////////// - ImageLoader& operator=(const ImageLoader&) = delete; }; } // namespace priv diff --git a/src/SFML/System/String.cpp b/src/SFML/System/String.cpp index 280332d3..0e44ebc6 100644 --- a/src/SFML/System/String.cpp +++ b/src/SFML/System/String.cpp @@ -120,9 +120,7 @@ String::String(const std::basic_string& utf32String) : m_string(u //////////////////////////////////////////////////////////// -String::String(const String& copy) : m_string(copy.m_string) -{ -} +String::String(const String& copy) = default; //////////////////////////////////////////////////////////// @@ -211,11 +209,7 @@ std::basic_string String::toUtf32() const //////////////////////////////////////////////////////////// -String& String::operator=(const String& right) -{ - m_string = right.m_string; - return *this; -} +String& String::operator=(const String& right) = default; //////////////////////////////////////////////////////////// diff --git a/src/SFML/Window/JoystickManager.hpp b/src/SFML/Window/JoystickManager.hpp index 39b72e20..12278b00 100644 --- a/src/SFML/Window/JoystickManager.hpp +++ b/src/SFML/Window/JoystickManager.hpp @@ -40,6 +40,18 @@ namespace sf::priv class JoystickManager { public: + //////////////////////////////////////////////////////////// + /// \brief Deleted copy constructor + /// + //////////////////////////////////////////////////////////// + JoystickManager(const JoystickManager&) = delete; + + //////////////////////////////////////////////////////////// + /// \brief Deleted copy assignment + /// + //////////////////////////////////////////////////////////// + JoystickManager& operator=(const JoystickManager&) = delete; + //////////////////////////////////////////////////////////// /// \brief Get the global unique instance of the manager /// @@ -97,18 +109,6 @@ private: //////////////////////////////////////////////////////////// ~JoystickManager(); - //////////////////////////////////////////////////////////// - /// \brief Deleted copy constructor - /// - //////////////////////////////////////////////////////////// - JoystickManager(const JoystickManager&) = delete; - - //////////////////////////////////////////////////////////// - /// \brief Deleted copy assignment - /// - //////////////////////////////////////////////////////////// - JoystickManager& operator=(const JoystickManager&) = delete; - //////////////////////////////////////////////////////////// /// \brief Joystick information and state /// diff --git a/src/SFML/Window/OSX/HIDInputManager.hpp b/src/SFML/Window/OSX/HIDInputManager.hpp index 6803699c..3ee15d07 100644 --- a/src/SFML/Window/OSX/HIDInputManager.hpp +++ b/src/SFML/Window/OSX/HIDInputManager.hpp @@ -51,6 +51,18 @@ using IOHIDElements = std::vector; class HIDInputManager { public: + //////////////////////////////////////////////////////////// + /// \brief Deleted copy constructor + /// + //////////////////////////////////////////////////////////// + HIDInputManager(const HIDInputManager&) = delete; + + //////////////////////////////////////////////////////////// + /// \brief Deleted copy assignment + /// + //////////////////////////////////////////////////////////// + HIDInputManager& operator=(const HIDInputManager&) = delete; + //////////////////////////////////////////////////////////// /// \brief Get the unique instance of the class /// @@ -127,18 +139,6 @@ private: //////////////////////////////////////////////////////////// ~HIDInputManager(); - //////////////////////////////////////////////////////////// - /// \brief Deleted copy constructor - /// - //////////////////////////////////////////////////////////// - HIDInputManager(const HIDInputManager&) = delete; - - //////////////////////////////////////////////////////////// - /// \brief Deleted copy assignment - /// - //////////////////////////////////////////////////////////// - HIDInputManager& operator=(const HIDInputManager&) = delete; - //////////////////////////////////////////////////////////// /// \brief Initialize the keyboard part of this class /// diff --git a/src/SFML/Window/OSX/HIDJoystickManager.hpp b/src/SFML/Window/OSX/HIDJoystickManager.hpp index 674a9a0e..29d5425a 100644 --- a/src/SFML/Window/OSX/HIDJoystickManager.hpp +++ b/src/SFML/Window/OSX/HIDJoystickManager.hpp @@ -43,6 +43,19 @@ namespace sf::priv class HIDJoystickManager { public: + //////////////////////////////////////////////////////////// + /// \brief Deleted copy constructor + /// + //////////////////////////////////////////////////////////// + HIDJoystickManager(const HIDJoystickManager&) = delete; + + //////////////////////////////////////////////////////////// + /// \brief Deleted copy assignment + /// + //////////////////////////////////////////////////////////// + HIDJoystickManager& operator=(const HIDJoystickManager&) = delete; + + //////////////////////////////////////////////////////////// /// \brief Get the unique instance of the class /// @@ -81,18 +94,6 @@ private: //////////////////////////////////////////////////////////// ~HIDJoystickManager(); - //////////////////////////////////////////////////////////// - /// \brief Deleted copy constructor - /// - //////////////////////////////////////////////////////////// - HIDJoystickManager(const HIDJoystickManager&) = delete; - - //////////////////////////////////////////////////////////// - /// \brief Deleted copy assignment - /// - //////////////////////////////////////////////////////////// - HIDJoystickManager& operator=(const HIDJoystickManager&) = delete; - //////////////////////////////////////////////////////////// /// \brief Make sure all event have been processed in the run loop /// diff --git a/src/SFML/Window/SensorManager.hpp b/src/SFML/Window/SensorManager.hpp index e62f1782..8e7c3143 100644 --- a/src/SFML/Window/SensorManager.hpp +++ b/src/SFML/Window/SensorManager.hpp @@ -40,6 +40,18 @@ namespace sf::priv class SensorManager { public: + //////////////////////////////////////////////////////////// + /// \brief Deleted copy constructor + /// + //////////////////////////////////////////////////////////// + SensorManager(const SensorManager&) = delete; + + //////////////////////////////////////////////////////////// + /// \brief Deleted copy assignment + /// + //////////////////////////////////////////////////////////// + SensorManager& operator=(const SensorManager&) = delete; + //////////////////////////////////////////////////////////// /// \brief Get the global unique instance of the manager /// @@ -106,18 +118,6 @@ private: //////////////////////////////////////////////////////////// ~SensorManager(); - //////////////////////////////////////////////////////////// - /// \brief Deleted copy constructor - /// - //////////////////////////////////////////////////////////// - SensorManager(const SensorManager&) = delete; - - //////////////////////////////////////////////////////////// - /// \brief Deleted copy assignment - /// - //////////////////////////////////////////////////////////// - SensorManager& operator=(const SensorManager&) = delete; - //////////////////////////////////////////////////////////// /// \brief Sensor information and state ///