Merge pull request #7084 from ameerj/clang-12

general: Update style to clang-format-12
This commit is contained in:
Morph 2021-09-24 16:44:25 -04:00 committed by GitHub
commit 9a53173e4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 64 additions and 68 deletions

View file

@ -7,7 +7,7 @@ if grep -nrI '\s$' src *.yml *.txt *.md Doxyfile .gitignore .gitmodules .ci* dis
fi fi
# Default clang-format points to default 3.5 version one # Default clang-format points to default 3.5 version one
CLANG_FORMAT=clang-format-10 CLANG_FORMAT=clang-format-12
$CLANG_FORMAT --version $CLANG_FORMAT --version
if [ "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then if [ "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then

View file

@ -780,7 +780,7 @@ endif()
# against all the src files. This should be used before making a pull request. # against all the src files. This should be used before making a pull request.
# ======================================================================= # =======================================================================
set(CLANG_FORMAT_POSTFIX "-10") set(CLANG_FORMAT_POSTFIX "-12")
find_program(CLANG_FORMAT find_program(CLANG_FORMAT
NAMES clang-format${CLANG_FORMAT_POSTFIX} NAMES clang-format${CLANG_FORMAT_POSTFIX}
clang-format clang-format

View file

@ -9,41 +9,48 @@
namespace Common { namespace Common {
template <typename T> template <typename T>
requires std::is_unsigned_v<T>[[nodiscard]] constexpr T AlignUp(T value, size_t size) { requires std::is_unsigned_v<T>
[[nodiscard]] constexpr T AlignUp(T value, size_t size) {
auto mod{static_cast<T>(value % size)}; auto mod{static_cast<T>(value % size)};
value -= mod; value -= mod;
return static_cast<T>(mod == T{0} ? value : value + size); return static_cast<T>(mod == T{0} ? value : value + size);
} }
template <typename T> template <typename T>
requires std::is_unsigned_v<T>[[nodiscard]] constexpr T AlignUpLog2(T value, size_t align_log2) { requires std::is_unsigned_v<T>
[[nodiscard]] constexpr T AlignUpLog2(T value, size_t align_log2) {
return static_cast<T>((value + ((1ULL << align_log2) - 1)) >> align_log2 << align_log2); return static_cast<T>((value + ((1ULL << align_log2) - 1)) >> align_log2 << align_log2);
} }
template <typename T> template <typename T>
requires std::is_unsigned_v<T>[[nodiscard]] constexpr T AlignDown(T value, size_t size) { requires std::is_unsigned_v<T>
[[nodiscard]] constexpr T AlignDown(T value, size_t size) {
return static_cast<T>(value - value % size); return static_cast<T>(value - value % size);
} }
template <typename T> template <typename T>
requires std::is_unsigned_v<T>[[nodiscard]] constexpr bool Is4KBAligned(T value) { requires std::is_unsigned_v<T>
[[nodiscard]] constexpr bool Is4KBAligned(T value) {
return (value & 0xFFF) == 0; return (value & 0xFFF) == 0;
} }
template <typename T> template <typename T>
requires std::is_unsigned_v<T>[[nodiscard]] constexpr bool IsWordAligned(T value) { requires std::is_unsigned_v<T>
[[nodiscard]] constexpr bool IsWordAligned(T value) {
return (value & 0b11) == 0; return (value & 0b11) == 0;
} }
template <typename T> template <typename T>
requires std::is_integral_v<T>[[nodiscard]] constexpr bool IsAligned(T value, size_t alignment) { requires std::is_integral_v<T>
[[nodiscard]] constexpr bool IsAligned(T value, size_t alignment) {
using U = typename std::make_unsigned_t<T>; using U = typename std::make_unsigned_t<T>;
const U mask = static_cast<U>(alignment - 1); const U mask = static_cast<U>(alignment - 1);
return (value & mask) == 0; return (value & mask) == 0;
} }
template <typename T, typename U> template <typename T, typename U>
requires std::is_integral_v<T>[[nodiscard]] constexpr T DivideUp(T x, U y) { requires std::is_integral_v<T>
[[nodiscard]] constexpr T DivideUp(T x, U y) {
return (x + (y - 1)) / y; return (x + (y - 1)) / y;
} }

View file

@ -11,15 +11,15 @@ namespace Common {
/// Ceiled integer division. /// Ceiled integer division.
template <typename N, typename D> template <typename N, typename D>
requires std::is_integral_v<N>&& std::is_unsigned_v<D>[[nodiscard]] constexpr N DivCeil(N number, requires std::is_integral_v<N> && std::is_unsigned_v<D>
D divisor) { [[nodiscard]] constexpr N DivCeil(N number, D divisor) {
return static_cast<N>((static_cast<D>(number) + divisor - 1) / divisor); return static_cast<N>((static_cast<D>(number) + divisor - 1) / divisor);
} }
/// Ceiled integer division with logarithmic divisor in base 2 /// Ceiled integer division with logarithmic divisor in base 2
template <typename N, typename D> template <typename N, typename D>
requires std::is_integral_v<N>&& std::is_unsigned_v<D>[[nodiscard]] constexpr N DivCeilLog2( requires std::is_integral_v<N> && std::is_unsigned_v<D>
N value, D alignment_log2) { [[nodiscard]] constexpr N DivCeilLog2(N value, D alignment_log2) {
return static_cast<N>((static_cast<D>(value) + (D(1) << alignment_log2) - 1) >> alignment_log2); return static_cast<N>((static_cast<D>(value) + (D(1) << alignment_log2) - 1) >> alignment_log2);
} }

View file

@ -235,20 +235,19 @@ public:
template <typename T> template <typename T>
concept HasLightCompareType = requires { concept HasLightCompareType = requires {
{ std::is_same<typename T::LightCompareType, void>::value } { std::is_same<typename T::LightCompareType, void>::value } -> std::convertible_to<bool>;
->std::convertible_to<bool>;
}; };
namespace impl { namespace impl {
template <typename T, typename Default> template <typename T, typename Default>
consteval auto* GetLightCompareType() { consteval auto* GetLightCompareType() {
if constexpr (HasLightCompareType<T>) { if constexpr (HasLightCompareType<T>) {
return static_cast<typename T::LightCompareType*>(nullptr); return static_cast<typename T::LightCompareType*>(nullptr);
} else { } else {
return static_cast<Default*>(nullptr); return static_cast<Default*>(nullptr);
} }
} }
} // namespace impl } // namespace impl

View file

@ -667,8 +667,8 @@ template <typename T>
// linear interpolation via float: 0.0=begin, 1.0=end // linear interpolation via float: 0.0=begin, 1.0=end
template <typename X> template <typename X>
[[nodiscard]] constexpr decltype(X{} * float{} + X{} * float{}) Lerp(const X& begin, const X& end, [[nodiscard]] constexpr decltype(X{} * float{} + X{} * float{})
const float t) { Lerp(const X& begin, const X& end, const float t) {
return begin * (1.f - t) + end * t; return begin * (1.f - t) + end * t;
} }

View file

@ -22,12 +22,10 @@ class KThread;
template <typename T> template <typename T>
concept KPriorityQueueAffinityMask = !std::is_reference_v<T> && requires(T & t) { concept KPriorityQueueAffinityMask = !std::is_reference_v<T> && requires(T & t) {
{ t.GetAffinityMask() } { t.GetAffinityMask() } -> Common::ConvertibleTo<u64>;
->Common::ConvertibleTo<u64>;
{t.SetAffinityMask(0)}; {t.SetAffinityMask(0)};
{ t.GetAffinity(0) } { t.GetAffinity(0) } -> std::same_as<bool>;
->std::same_as<bool>;
{t.SetAffinity(0, false)}; {t.SetAffinity(0, false)};
{t.SetAll()}; {t.SetAll()};
}; };
@ -38,25 +36,20 @@ concept KPriorityQueueMember = !std::is_reference_v<T> && requires(T & t) {
{(typename T::QueueEntry()).Initialize()}; {(typename T::QueueEntry()).Initialize()};
{(typename T::QueueEntry()).SetPrev(std::addressof(t))}; {(typename T::QueueEntry()).SetPrev(std::addressof(t))};
{(typename T::QueueEntry()).SetNext(std::addressof(t))}; {(typename T::QueueEntry()).SetNext(std::addressof(t))};
{ (typename T::QueueEntry()).GetNext() } { (typename T::QueueEntry()).GetNext() } -> std::same_as<T*>;
->std::same_as<T*>; { (typename T::QueueEntry()).GetPrev() } -> std::same_as<T*>;
{ (typename T::QueueEntry()).GetPrev() } { t.GetPriorityQueueEntry(0) } -> std::same_as<typename T::QueueEntry&>;
->std::same_as<T*>;
{ t.GetPriorityQueueEntry(0) }
->std::same_as<typename T::QueueEntry&>;
{t.GetAffinityMask()}; {t.GetAffinityMask()};
{ std::remove_cvref_t<decltype(t.GetAffinityMask())>() } { std::remove_cvref_t<decltype(t.GetAffinityMask())>() } -> KPriorityQueueAffinityMask;
->KPriorityQueueAffinityMask;
{ t.GetActiveCore() } { t.GetActiveCore() } -> Common::ConvertibleTo<s32>;
->Common::ConvertibleTo<s32>; { t.GetPriority() } -> Common::ConvertibleTo<s32>;
{ t.GetPriority() }
->Common::ConvertibleTo<s32>;
}; };
template <typename Member, size_t NumCores_, int LowestPriority, int HighestPriority> template <typename Member, size_t NumCores_, int LowestPriority, int HighestPriority>
requires KPriorityQueueMember<Member> class KPriorityQueue { requires KPriorityQueueMember<Member>
class KPriorityQueue {
public: public:
using AffinityMaskType = std::remove_cv_t< using AffinityMaskType = std::remove_cv_t<
std::remove_reference_t<decltype(std::declval<Member>().GetAffinityMask())>>; std::remove_reference_t<decltype(std::declval<Member>().GetAffinityMask())>>;

View file

@ -197,7 +197,7 @@ private:
class [[nodiscard]] KScopedSchedulerLock : KScopedLock<GlobalSchedulerContext::LockType> { class [[nodiscard]] KScopedSchedulerLock : KScopedLock<GlobalSchedulerContext::LockType> {
public: public:
explicit KScopedSchedulerLock(KernelCore & kernel); explicit KScopedSchedulerLock(KernelCore& kernel);
~KScopedSchedulerLock(); ~KScopedSchedulerLock();
}; };

View file

@ -13,19 +13,18 @@ namespace Kernel {
template <typename T> template <typename T>
concept KLockable = !std::is_reference_v<T> && requires(T & t) { concept KLockable = !std::is_reference_v<T> && requires(T & t) {
{ t.Lock() } { t.Lock() } -> std::same_as<void>;
->std::same_as<void>; { t.Unlock() } -> std::same_as<void>;
{ t.Unlock() }
->std::same_as<void>;
}; };
template <typename T> template <typename T>
requires KLockable<T> class [[nodiscard]] KScopedLock { requires KLockable<T>
class [[nodiscard]] KScopedLock {
public: public:
explicit KScopedLock(T * l) : lock_ptr(l) { explicit KScopedLock(T* l) : lock_ptr(l) {
this->lock_ptr->Lock(); this->lock_ptr->Lock();
} }
explicit KScopedLock(T & l) : KScopedLock(std::addressof(l)) {} explicit KScopedLock(T& l) : KScopedLock(std::addressof(l)) {}
~KScopedLock() { ~KScopedLock() {
this->lock_ptr->Unlock(); this->lock_ptr->Unlock();
@ -34,7 +33,7 @@ public:
KScopedLock(const KScopedLock&) = delete; KScopedLock(const KScopedLock&) = delete;
KScopedLock& operator=(const KScopedLock&) = delete; KScopedLock& operator=(const KScopedLock&) = delete;
KScopedLock(KScopedLock &&) = delete; KScopedLock(KScopedLock&&) = delete;
KScopedLock& operator=(KScopedLock&&) = delete; KScopedLock& operator=(KScopedLock&&) = delete;
private: private:

View file

@ -17,7 +17,7 @@ namespace Kernel {
class [[nodiscard]] KScopedSchedulerLockAndSleep { class [[nodiscard]] KScopedSchedulerLockAndSleep {
public: public:
explicit KScopedSchedulerLockAndSleep(KernelCore & kernel_, KThread * t, s64 timeout) explicit KScopedSchedulerLockAndSleep(KernelCore& kernel_, KThread* t, s64 timeout)
: kernel(kernel_), thread(t), timeout_tick(timeout) { : kernel(kernel_), thread(t), timeout_tick(timeout) {
// Lock the scheduler. // Lock the scheduler.
kernel.GlobalSchedulerContext().scheduler_lock.Lock(); kernel.GlobalSchedulerContext().scheduler_lock.Lock();

View file

@ -346,8 +346,8 @@ void InputSubsystem::ReloadInputDevices() {
impl->udp->ReloadSockets(); impl->udp->ReloadSockets();
} }
std::vector<std::unique_ptr<Polling::DevicePoller>> InputSubsystem::GetPollers([ std::vector<std::unique_ptr<Polling::DevicePoller>> InputSubsystem::GetPollers(
[maybe_unused]] Polling::DeviceType type) const { [[maybe_unused]] Polling::DeviceType type) const {
#ifdef HAVE_SDL2 #ifdef HAVE_SDL2
return impl->sdl->GetPollers(type); return impl->sdl->GetPollers(type);
#else #else

View file

@ -11,14 +11,16 @@
namespace Shader { namespace Shader {
template <typename T> template <typename T>
requires std::is_destructible_v<T> class ObjectPool { requires std::is_destructible_v<T>
class ObjectPool {
public: public:
explicit ObjectPool(size_t chunk_size = 8192) : new_chunk_size{chunk_size} { explicit ObjectPool(size_t chunk_size = 8192) : new_chunk_size{chunk_size} {
node = &chunks.emplace_back(new_chunk_size); node = &chunks.emplace_back(new_chunk_size);
} }
template <typename... Args> template <typename... Args>
requires std::is_constructible_v<T, Args...>[[nodiscard]] T* Create(Args&&... args) { requires std::is_constructible_v<T, Args...>
[[nodiscard]] T* Create(Args&&... args) {
return std::construct_at(Memory(), std::forward<Args>(args)...); return std::construct_at(Memory(), std::forward<Args>(args)...);
} }

View file

@ -97,19 +97,14 @@ RendererVulkan::RendererVulkan(Core::TelemetrySession& telemetry_session_,
Core::Frontend::EmuWindow& emu_window, Core::Frontend::EmuWindow& emu_window,
Core::Memory::Memory& cpu_memory_, Tegra::GPU& gpu_, Core::Memory::Memory& cpu_memory_, Tegra::GPU& gpu_,
std::unique_ptr<Core::Frontend::GraphicsContext> context_) try std::unique_ptr<Core::Frontend::GraphicsContext> context_) try
: RendererBase(emu_window, std::move(context_)), : RendererBase(emu_window, std::move(context_)), telemetry_session(telemetry_session_),
telemetry_session(telemetry_session_), cpu_memory(cpu_memory_), gpu(gpu_), library(OpenLibrary()),
cpu_memory(cpu_memory_),
gpu(gpu_),
library(OpenLibrary()),
instance(CreateInstance(library, dld, VK_API_VERSION_1_1, render_window.GetWindowInfo().type, instance(CreateInstance(library, dld, VK_API_VERSION_1_1, render_window.GetWindowInfo().type,
true, Settings::values.renderer_debug.GetValue())), true, Settings::values.renderer_debug.GetValue())),
debug_callback(Settings::values.renderer_debug ? CreateDebugCallback(instance) : nullptr), debug_callback(Settings::values.renderer_debug ? CreateDebugCallback(instance) : nullptr),
surface(CreateSurface(instance, render_window)), surface(CreateSurface(instance, render_window)),
device(CreateDevice(instance, dld, *surface)), device(CreateDevice(instance, dld, *surface)), memory_allocator(device, false),
memory_allocator(device, false), state_tracker(gpu), scheduler(device, state_tracker),
state_tracker(gpu),
scheduler(device, state_tracker),
swapchain(*surface, device, scheduler, render_window.GetFramebufferLayout().width, swapchain(*surface, device, scheduler, render_window.GetFramebufferLayout().width,
render_window.GetFramebufferLayout().height, false), render_window.GetFramebufferLayout().height, false),
blit_screen(cpu_memory, render_window, device, memory_allocator, swapchain, scheduler, blit_screen(cpu_memory, render_window, device, memory_allocator, swapchain, scheduler,

View file

@ -508,7 +508,8 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) {
.location = static_cast<u32>(index), .location = static_cast<u32>(index),
.binding = 0, .binding = 0,
.format = type == 1 ? VK_FORMAT_R32_SFLOAT .format = type == 1 ? VK_FORMAT_R32_SFLOAT
: type == 2 ? VK_FORMAT_R32_SINT : VK_FORMAT_R32_UINT, : type == 2 ? VK_FORMAT_R32_SINT
: VK_FORMAT_R32_UINT,
.offset = 0, .offset = 0,
}); });
} }

View file

@ -31,8 +31,8 @@ struct SlotId {
}; };
template <class T> template <class T>
requires std::is_nothrow_move_assignable_v<T>&& requires std::is_nothrow_move_assignable_v<T> && std::is_nothrow_move_constructible_v<T>
std::is_nothrow_move_constructible_v<T> class SlotVector { class SlotVector {
public: public:
class Iterator { class Iterator {
friend SlotVector<T>; friend SlotVector<T>;