diff options
author | David Robillard <d@drobilla.net> | 2021-01-02 21:28:04 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-01-02 21:28:04 +0100 |
commit | a0efc4054f0f341a5bcec218c9bab8abffa312a6 (patch) | |
tree | aa39dba903f51b8eff9b3652267b282e343cfd0d | |
parent | f6ca60606561ddbe5dab526ab1bc6b89f6dbe082 (diff) | |
download | pugl-a0efc4054f0f341a5bcec218c9bab8abffa312a6.tar.gz pugl-a0efc4054f0f341a5bcec218c9bab8abffa312a6.tar.bz2 pugl-a0efc4054f0f341a5bcec218c9bab8abffa312a6.zip |
Fix clang-tidy warnings
-rw-r--r-- | examples/.clang-tidy | 6 | ||||
-rw-r--r-- | examples/sybok.hpp | 38 | ||||
-rw-r--r-- | test/.clang-tidy | 2 |
3 files changed, 34 insertions, 12 deletions
diff --git a/examples/.clang-tidy b/examples/.clang-tidy index ad5b75a..3410f19 100644 --- a/examples/.clang-tidy +++ b/examples/.clang-tidy @@ -1,9 +1,11 @@ Checks: > *, + -*-non-private-member-variables-in-classes, -*avoid-c-arrays, -*magic-numbers, -*uppercase-literal-suffix, -android-cloexec-fopen, + -bugprone-macro-parentheses, -bugprone-reserved-identifier, -bugprone-suspicious-string-compare, -cert-dcl37-c, @@ -12,13 +14,16 @@ Checks: > -clang-analyzer-alpha.*, -clang-analyzer-security.FloatLoopCounter, -cppcoreguidelines-avoid-non-const-global-variables, + -cppcoreguidelines-macro-usage, -cppcoreguidelines-pro-bounds-array-to-pointer-decay, -cppcoreguidelines-pro-bounds-constant-array-index, -cppcoreguidelines-pro-bounds-pointer-arithmetic, -cppcoreguidelines-pro-type-reinterpret-cast, + -cppcoreguidelines-pro-type-static-cast-downcast, -cppcoreguidelines-pro-type-vararg, -fuchsia-default-arguments, -fuchsia-default-arguments-calls, + -fuchsia-overloaded-operator, -google-runtime-references, -hicpp-multiway-paths-covered, -hicpp-named-parameter, @@ -29,7 +34,6 @@ Checks: > -llvm-header-guard, -llvmlibc-*, -misc-misplaced-const, - -misc-non-private-member-variables-in-classes, -modernize-use-trailing-return-type, -readability-else-after-return, -readability-implicit-bool-conversion, diff --git a/examples/sybok.hpp b/examples/sybok.hpp index 05b2c3d..6805efa 100644 --- a/examples/sybok.hpp +++ b/examples/sybok.hpp @@ -63,6 +63,15 @@ #ifndef SYBOK_HPP #define SYBOK_HPP +#ifdef VULKAN_CORE_H_ +# error "sybok.hpp must be included before or instead of vulkan headers" +#endif + +#ifdef __GNUC__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wswitch-enum" +#endif + #define VK_NO_PROTOTYPES // On 64-bit platforms, all handles are "dispatchable" pointers @@ -72,7 +81,7 @@ defined(__powerpc64__) # define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) \ - typedef struct object##_T* object; + typedef struct object##_T* object; // NOLINT(bugprone-macro-parentheses) // On 32-bit platforms, some "non-dispatchable" handles are 64 bit integers #else @@ -91,7 +100,7 @@ struct NonDispatchableHandle { #endif -#include <vulkan/vulkan_core.h> +#include <vulkan/vulkan_core.h> // IWYU pragma: export #include <array> #include <cassert> @@ -116,7 +125,7 @@ namespace sk { class CommandScope; class RenderCommandScope; -static inline const char* +inline const char* string(const VkResult result) { switch (result) { @@ -177,7 +186,7 @@ string(const VkResult result) return "Unknown error"; } -static inline const char* +inline const char* string(const VkPresentModeKHR presentMode) { switch (presentMode) { @@ -196,7 +205,7 @@ string(const VkPresentModeKHR presentMode) return "Unknown present mode"; } -static inline const char* +inline const char* string(const VkDebugReportFlagBitsEXT flag) { switch (flag) { @@ -226,6 +235,7 @@ public: GlobalDeleter() = default; ~GlobalDeleter() = default; + // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) GlobalDeleter(DestroyFunc destroyFunc) noexcept : _destroyFunc{destroyFunc} {} @@ -390,6 +400,7 @@ public: const Handle& get() const noexcept { return _handle; } + // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) operator Handle() const noexcept { return _handle; } private: @@ -533,13 +544,13 @@ class OptionalParameter public: using Handle = typename T::Handle; + // NOLINTNEXTLINE(hicpp-explicit-conversions, google-explicit-constructor) OptionalParameter(const T& value) noexcept : _handle{value.get()} {} - OptionalParameter() noexcept - : _handle{} - {} + OptionalParameter() noexcept = default; + ~OptionalParameter() noexcept = default; OptionalParameter(const OptionalParameter&) = delete; OptionalParameter& operator=(const OptionalParameter&) = delete; @@ -547,7 +558,7 @@ public: OptionalParameter(OptionalParameter&&) = delete; OptionalParameter& operator=(OptionalParameter&&) = delete; - const Handle get() const noexcept { return _handle; } + Handle get() const noexcept { return _handle; } private: Handle _handle{}; @@ -810,7 +821,7 @@ public: } private: - PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr; + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr{}; #define SK_FUNC(name) \ PFN_##name name {} @@ -1779,6 +1790,7 @@ public: CommonCommandScope(CommonCommandScope&& scope) noexcept : _api{scope._api} , _commandBuffer{scope._commandBuffer} + , _result{scope._result} { scope._commandBuffer = {}; } @@ -2266,7 +2278,7 @@ public: } }; -CommandScope +inline CommandScope VulkanApi::beginCommandBuffer( VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo beginInfo) const noexcept @@ -2296,4 +2308,8 @@ inline MappedMemory::~MappedMemory() noexcept } // namespace sk +#ifdef __GNUC__ +# pragma GCC diagnostic pop +#endif + #endif // SYBOK_HPP diff --git a/test/.clang-tidy b/test/.clang-tidy index e7c1e2c..8014e6a 100644 --- a/test/.clang-tidy +++ b/test/.clang-tidy @@ -5,6 +5,8 @@ Checks: > -bugprone-reserved-identifier, -cert-dcl37-c, -cert-dcl51-cpp, + -cppcoreguidelines-pro-type-static-cast-downcast, + -google-runtime-references, -hicpp-multiway-paths-covered, -hicpp-signed-bitwise, -llvm-header-guard, |