Skip to content

Commit

Permalink
Fix clang-tidy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
drobilla committed Jan 2, 2021
1 parent f6ca606 commit a0efc40
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 12 deletions.
6 changes: 5 additions & 1 deletion examples/.clang-tidy
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
38 changes: 27 additions & 11 deletions examples/sybok.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -91,7 +100,7 @@ struct NonDispatchableHandle {

#endif

#include <vulkan/vulkan_core.h>
#include <vulkan/vulkan_core.h> // IWYU pragma: export

#include <array>
#include <cassert>
Expand All @@ -116,7 +125,7 @@ namespace sk {
class CommandScope;
class RenderCommandScope;

static inline const char*
inline const char*
string(const VkResult result)
{
switch (result) {
Expand Down Expand Up @@ -177,7 +186,7 @@ string(const VkResult result)
return "Unknown error";
}

static inline const char*
inline const char*
string(const VkPresentModeKHR presentMode)
{
switch (presentMode) {
Expand All @@ -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) {
Expand Down Expand Up @@ -226,6 +235,7 @@ class GlobalDeleter
GlobalDeleter() = default;
~GlobalDeleter() = default;

// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
GlobalDeleter(DestroyFunc destroyFunc) noexcept
: _destroyFunc{destroyFunc}
{}
Expand Down Expand Up @@ -390,6 +400,7 @@ class UniqueDispatchableHandle

const Handle& get() const noexcept { return _handle; }

// NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
operator Handle() const noexcept { return _handle; }

private:
Expand Down Expand Up @@ -533,21 +544,21 @@ 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;

OptionalParameter(OptionalParameter&&) = delete;
OptionalParameter& operator=(OptionalParameter&&) = delete;

const Handle get() const noexcept { return _handle; }
Handle get() const noexcept { return _handle; }

private:
Handle _handle{};
Expand Down Expand Up @@ -810,7 +821,7 @@ class VulkanInitApi
}

private:
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr;
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr{};

#define SK_FUNC(name) \
PFN_##name name {}
Expand Down Expand Up @@ -1779,6 +1790,7 @@ class CommonCommandScope
CommonCommandScope(CommonCommandScope&& scope) noexcept
: _api{scope._api}
, _commandBuffer{scope._commandBuffer}
, _result{scope._result}
{
scope._commandBuffer = {};
}
Expand Down Expand Up @@ -2266,7 +2278,7 @@ class RenderCommandScope : public CommonCommandScope
}
};

CommandScope
inline CommandScope
VulkanApi::beginCommandBuffer(
VkCommandBuffer commandBuffer,
const VkCommandBufferBeginInfo beginInfo) const noexcept
Expand Down Expand Up @@ -2296,4 +2308,8 @@ inline MappedMemory::~MappedMemory() noexcept

} // namespace sk

#ifdef __GNUC__
# pragma GCC diagnostic pop
#endif

#endif // SYBOK_HPP
2 changes: 2 additions & 0 deletions test/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a0efc40

Please sign in to comment.