From d26aabff0401690d6dd1332558b40f5cb64e4428 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Mon, 17 Oct 2022 00:06:11 +0200 Subject: [PATCH] Everywhere: Run clang-format --- AK/Array.h | 18 +- AK/Assertions.h | 2 +- AK/Atomic.h | 40 ++--- AK/BinaryHeap.h | 4 +- AK/BitCast.h | 2 +- AK/CheckedFormatString.h | 7 +- AK/CircularQueue.h | 10 +- AK/Complex.h | 26 +-- AK/DisjointChunks.h | 12 +- AK/DoublyLinkedList.h | 12 +- AK/Error.h | 6 +- AK/Find.h | 3 +- AK/FixedPoint.h | 6 +- AK/FloatingPoint.h | 14 +- AK/FloatingPointStringConversions.cpp | 2 +- AK/Format.h | 14 +- AK/Function.h | 12 +- AK/GenericLexer.h | 2 +- AK/HashMap.h | 33 ++-- AK/HashTable.h | 10 +- AK/IntrusiveRedBlackTree.h | 2 +- AK/MemMem.h | 5 +- AK/NeverDestroyed.h | 6 +- AK/NonnullOwnPtr.h | 6 +- AK/NonnullRefPtr.h | 27 ++- AK/Optional.h | 49 ++++-- AK/OwnPtr.h | 2 +- AK/PrintfImplementation.h | 2 +- AK/Queue.h | 2 +- AK/RedBlackTree.h | 2 +- AK/RefPtr.h | 36 ++-- AK/ScopedValueRollback.h | 2 +- AK/SinglyLinkedList.h | 14 +- AK/SinglyLinkedListWithCount.h | 10 +- AK/Span.h | 2 +- AK/Stack.h | 4 +- AK/StdLibExtraDetails.h | 12 +- AK/StdLibExtras.h | 15 +- AK/Stream.h | 12 +- AK/String.h | 3 +- AK/Time.h | 21 ++- AK/Traits.h | 2 +- AK/Trie.h | 42 +++-- AK/Tuple.h | 13 +- AK/UFixedBigInt.h | 154 +++++++++------- AK/Utf16View.cpp | 3 +- AK/Variant.h | 80 ++++++--- AK/Vector.h | 64 ++++--- AK/WeakPtr.h | 40 +++-- AK/Weakable.h | 2 +- Kernel/Devices/DeviceManagement.h | 3 +- Kernel/Graphics/VMWare/GraphicsAdapter.cpp | 2 +- Kernel/Graphics/VMWare/GraphicsAdapter.h | 2 +- Kernel/Heap/kmalloc.h | 28 +-- Kernel/IOWindow.cpp | 6 +- Kernel/IOWindow.h | 8 +- Kernel/Library/LockRefPtr.h | 65 ++++--- Kernel/Library/LockWeakPtr.h | 46 +++-- Kernel/Library/LockWeakable.h | 2 +- Kernel/Library/NonnullLockRefPtr.h | 21 ++- Kernel/Locking/MutexProtected.h | 18 +- Kernel/Memory/TypedMapping.h | 6 +- Kernel/Random.h | 4 +- Kernel/StdLib.cpp | 4 +- Kernel/StdLib.h | 18 +- Kernel/Storage/NVMe/NVMeInterruptQueue.cpp | 2 +- Kernel/Storage/NVMe/NVMeInterruptQueue.h | 2 +- Kernel/Storage/NVMe/NVMePollQueue.cpp | 2 +- Kernel/Storage/NVMe/NVMePollQueue.h | 2 +- Kernel/Storage/NVMe/NVMeQueue.cpp | 4 +- .../CodeGenerators/LibUnicode/GeneratorUtil.h | 6 +- Tests/AK/TestBitCast.cpp | 2 +- Tests/AK/TestSpan.cpp | 2 +- Tests/AK/TestTypeTraits.cpp | 8 +- Tests/LibRegex/Regex.cpp | 3 +- .../Applications/Spreadsheet/Readers/XSV.h | 14 +- .../LanguageClients/ConnectionsToServer.h | 5 +- .../DevTools/UserspaceEmulator/SoftCPU.cpp | 165 +++++++++++++----- Userland/DevTools/UserspaceEmulator/SoftCPU.h | 6 +- Userland/DevTools/UserspaceEmulator/SoftMMU.h | 3 +- .../UserspaceEmulator/ValueWithShadow.h | 12 +- Userland/Libraries/LibC/assert.h | 2 +- Userland/Libraries/LibC/stdio.cpp | 2 +- Userland/Libraries/LibC/stubs.cpp | 4 +- .../Shell/ShellComprehensionEngine.cpp | 8 +- Userland/Libraries/LibCore/AnonymousBuffer.h | 4 +- Userland/Libraries/LibCore/ArgsParser.cpp | 3 +- Userland/Libraries/LibCore/ArgsParser.h | 3 +- Userland/Libraries/LibCore/Object.h | 32 ++-- Userland/Libraries/LibCore/Stream.h | 3 +- Userland/Libraries/LibCpp/Parser.h | 2 +- Userland/Libraries/LibCrypto/ASN1/DER.cpp | 2 +- .../LibCrypto/BigInt/SignedBigInteger.h | 2 +- .../LibCrypto/BigInt/UnsignedBigInteger.h | 2 +- .../Libraries/LibCrypto/Cipher/Mode/Mode.h | 2 +- .../Libraries/LibDSP/ProcessorParameter.h | 3 +- Userland/Libraries/LibEDID/EDID.cpp | 8 +- Userland/Libraries/LibEDID/EDID.h | 8 +- Userland/Libraries/LibGL/GLContext.cpp | 3 +- Userland/Libraries/LibGUI/ItemListModel.h | 23 +-- Userland/Libraries/LibGUI/TreeViewModel.h | 6 +- Userland/Libraries/LibGUI/Variant.h | 6 +- Userland/Libraries/LibGUI/Widget.h | 2 +- Userland/Libraries/LibGfx/Line.h | 2 +- Userland/Libraries/LibGfx/Matrix.h | 3 +- Userland/Libraries/LibGfx/PNGLoader.cpp | 2 +- Userland/Libraries/LibGfx/Point.h | 2 +- Userland/Libraries/LibGfx/Rect.h | 2 +- Userland/Libraries/LibGfx/Size.h | 2 +- Userland/Libraries/LibGfx/VectorN.h | 44 +++-- Userland/Libraries/LibJS/AST.h | 19 +- Userland/Libraries/LibJS/Bytecode/Generator.h | 3 +- Userland/Libraries/LibJS/Bytecode/Op.h | 70 ++++---- Userland/Libraries/LibJS/Heap/GCPtr.h | 30 ++-- Userland/Libraries/LibJS/Interpreter.h | 3 +- Userland/Libraries/LibJS/Print.cpp | 3 +- .../LibJS/Runtime/AbstractOperations.h | 3 +- Userland/Libraries/LibJS/Runtime/Completion.h | 21 ++- Userland/Libraries/LibJS/Runtime/Map.h | 6 +- .../Libraries/LibJS/Runtime/PrototypeObject.h | 5 +- Userland/Libraries/LibJS/Runtime/Value.h | 3 +- Userland/Libraries/LibJS/SafeFunction.h | 12 +- Userland/Libraries/LibPDF/Encoding.h | 50 +++--- Userland/Libraries/LibPDF/Object.h | 13 +- Userland/Libraries/LibPDF/Parser.h | 3 +- Userland/Libraries/LibPDF/Reader.h | 2 +- Userland/Libraries/LibPDF/Value.h | 3 +- Userland/Libraries/LibRegex/RegexByteCode.h | 6 +- .../LibSoftGPU/Buffer/Typed2DBuffer.h | 3 +- .../Libraries/LibSoftGPU/PixelConverter.cpp | 3 +- Userland/Libraries/LibTLS/TLSv12.h | 27 +-- Userland/Libraries/LibTest/TestCase.h | 49 +++--- .../Libraries/LibVT/EscapeSequenceParser.h | 6 +- .../LibWasm/AbstractMachine/Operators.h | 18 +- Userland/Libraries/LibWasm/Parser/Parser.cpp | 3 +- .../Libraries/LibWeb/WebIDL/ExceptionOr.h | 9 +- Userland/Services/DHCPClient/DHCPv4.h | 3 +- Userland/Utilities/expr.cpp | 2 +- Userland/Utilities/strace.cpp | 7 +- Userland/Utilities/test-pthread.cpp | 13 +- 140 files changed, 1202 insertions(+), 723 deletions(-) diff --git a/AK/Array.h b/AK/Array.h index 640de1bbac..bf41eb6018 100644 --- a/AK/Array.h +++ b/AK/Array.h @@ -37,8 +37,16 @@ struct Array { [[nodiscard]] constexpr T const& first() const { return at(0); } [[nodiscard]] constexpr T& first() { return at(0); } - [[nodiscard]] constexpr T const& last() const requires(Size > 0) { return at(Size - 1); } - [[nodiscard]] constexpr T& last() requires(Size > 0) { return at(Size - 1); } + [[nodiscard]] constexpr T const& last() const + requires(Size > 0) + { + return at(Size - 1); + } + [[nodiscard]] constexpr T& last() + requires(Size > 0) + { + return at(Size - 1); + } [[nodiscard]] constexpr bool is_empty() const { return size() == 0; } @@ -68,7 +76,8 @@ struct Array { return Size; } - [[nodiscard]] constexpr T max() const requires(requires(T x, T y) { x < y; }) + [[nodiscard]] constexpr T max() const + requires(requires(T x, T y) { x < y; }) { static_assert(Size > 0, "No values to max() over"); @@ -78,7 +87,8 @@ struct Array { return value; } - [[nodiscard]] constexpr T min() const requires(requires(T x, T y) { x > y; }) + [[nodiscard]] constexpr T min() const + requires(requires(T x, T y) { x > y; }) { static_assert(Size > 0, "No values to min() over"); diff --git a/AK/Assertions.h b/AK/Assertions.h index 55e3eb7cad..d3de619a72 100644 --- a/AK/Assertions.h +++ b/AK/Assertions.h @@ -13,7 +13,7 @@ # ifndef NDEBUG # define VERIFY assert # else -# define __stringify_helper(x) # x +# define __stringify_helper(x) #x # define __stringify(x) __stringify_helper(x) extern "C" __attribute__((noreturn)) void ak_verification_failed(char const*); # define VERIFY(expr) \ diff --git a/AK/Atomic.h b/AK/Atomic.h index 81bbe8169f..ce0a34351d 100644 --- a/AK/Atomic.h +++ b/AK/Atomic.h @@ -29,25 +29,25 @@ static inline void full_memory_barrier() noexcept } template -static inline T atomic_exchange(volatile T* var, T desired, MemoryOrder order = memory_order_seq_cst) noexcept +static inline T atomic_exchange(T volatile* var, T desired, MemoryOrder order = memory_order_seq_cst) noexcept { return __atomic_exchange_n(var, desired, order); } template> -static inline V* atomic_exchange(volatile T** var, V* desired, MemoryOrder order = memory_order_seq_cst) noexcept +static inline V* atomic_exchange(T volatile** var, V* desired, MemoryOrder order = memory_order_seq_cst) noexcept { return __atomic_exchange_n(var, desired, order); } template> -static inline V* atomic_exchange(volatile T** var, std::nullptr_t, MemoryOrder order = memory_order_seq_cst) noexcept +static inline V* atomic_exchange(T volatile** var, std::nullptr_t, MemoryOrder order = memory_order_seq_cst) noexcept { return __atomic_exchange_n(const_cast(var), nullptr, order); } template -[[nodiscard]] static inline bool atomic_compare_exchange_strong(volatile T* var, T& expected, T desired, MemoryOrder order = memory_order_seq_cst) noexcept +[[nodiscard]] static inline bool atomic_compare_exchange_strong(T volatile* var, T& expected, T desired, MemoryOrder order = memory_order_seq_cst) noexcept { if (order == memory_order_acq_rel || order == memory_order_release) return __atomic_compare_exchange_n(var, &expected, desired, false, memory_order_release, memory_order_acquire); @@ -55,7 +55,7 @@ template } template> -[[nodiscard]] static inline bool atomic_compare_exchange_strong(volatile T** var, V*& expected, V* desired, MemoryOrder order = memory_order_seq_cst) noexcept +[[nodiscard]] static inline bool atomic_compare_exchange_strong(T volatile** var, V*& expected, V* desired, MemoryOrder order = memory_order_seq_cst) noexcept { if (order == memory_order_acq_rel || order == memory_order_release) return __atomic_compare_exchange_n(var, &expected, desired, false, memory_order_release, memory_order_acquire); @@ -63,7 +63,7 @@ template> } template> -[[nodiscard]] static inline bool atomic_compare_exchange_strong(volatile T** var, V*& expected, std::nullptr_t, MemoryOrder order = memory_order_seq_cst) noexcept +[[nodiscard]] static inline bool atomic_compare_exchange_strong(T volatile** var, V*& expected, std::nullptr_t, MemoryOrder order = memory_order_seq_cst) noexcept { if (order == memory_order_acq_rel || order == memory_order_release) return __atomic_compare_exchange_n(const_cast(var), &expected, nullptr, false, memory_order_release, memory_order_acquire); @@ -71,67 +71,67 @@ template> } template -static inline T atomic_fetch_add(volatile T* var, T val, MemoryOrder order = memory_order_seq_cst) noexcept +static inline T atomic_fetch_add(T volatile* var, T val, MemoryOrder order = memory_order_seq_cst) noexcept { return __atomic_fetch_add(var, val, order); } template -static inline T atomic_fetch_sub(volatile T* var, T val, MemoryOrder order = memory_order_seq_cst) noexcept +static inline T atomic_fetch_sub(T volatile* var, T val, MemoryOrder order = memory_order_seq_cst) noexcept { return __atomic_fetch_sub(var, val, order); } template -static inline T atomic_fetch_and(volatile T* var, T val, MemoryOrder order = memory_order_seq_cst) noexcept +static inline T atomic_fetch_and(T volatile* var, T val, MemoryOrder order = memory_order_seq_cst) noexcept { return __atomic_fetch_and(var, val, order); } template -static inline T atomic_fetch_or(volatile T* var, T val, MemoryOrder order = memory_order_seq_cst) noexcept +static inline T atomic_fetch_or(T volatile* var, T val, MemoryOrder order = memory_order_seq_cst) noexcept { return __atomic_fetch_or(var, val, order); } template -static inline T atomic_fetch_xor(volatile T* var, T val, MemoryOrder order = memory_order_seq_cst) noexcept +static inline T atomic_fetch_xor(T volatile* var, T val, MemoryOrder order = memory_order_seq_cst) noexcept { return __atomic_fetch_xor(var, val, order); } template -static inline T atomic_load(volatile T* var, MemoryOrder order = memory_order_seq_cst) noexcept +static inline T atomic_load(T volatile* var, MemoryOrder order = memory_order_seq_cst) noexcept { return __atomic_load_n(var, order); } template> -static inline V* atomic_load(volatile T** var, MemoryOrder order = memory_order_seq_cst) noexcept +static inline V* atomic_load(T volatile** var, MemoryOrder order = memory_order_seq_cst) noexcept { return __atomic_load_n(const_cast(var), order); } template -static inline void atomic_store(volatile T* var, T desired, MemoryOrder order = memory_order_seq_cst) noexcept +static inline void atomic_store(T volatile* var, T desired, MemoryOrder order = memory_order_seq_cst) noexcept { __atomic_store_n(var, desired, order); } template> -static inline void atomic_store(volatile T** var, V* desired, MemoryOrder order = memory_order_seq_cst) noexcept +static inline void atomic_store(T volatile** var, V* desired, MemoryOrder order = memory_order_seq_cst) noexcept { __atomic_store_n(var, desired, order); } template> -static inline void atomic_store(volatile T** var, std::nullptr_t, MemoryOrder order = memory_order_seq_cst) noexcept +static inline void atomic_store(T volatile** var, std::nullptr_t, MemoryOrder order = memory_order_seq_cst) noexcept { __atomic_store_n(const_cast(var), nullptr, order); } template -static inline bool atomic_is_lock_free(volatile T* ptr = nullptr) noexcept +static inline bool atomic_is_lock_free(T volatile* ptr = nullptr) noexcept { return __atomic_is_lock_free(sizeof(T), ptr); } @@ -156,7 +156,7 @@ public: { } - volatile T* ptr() noexcept + T volatile* ptr() noexcept { return &m_value; } @@ -225,7 +225,7 @@ public: { } - volatile T* ptr() noexcept + T volatile* ptr() noexcept { return &m_value; } @@ -356,7 +356,7 @@ public: { } - volatile T** ptr() noexcept + T volatile** ptr() noexcept { return &m_value; } diff --git a/AK/BinaryHeap.h b/AK/BinaryHeap.h index 56d82bf826..98a24e1352 100644 --- a/AK/BinaryHeap.h +++ b/AK/BinaryHeap.h @@ -52,13 +52,13 @@ public: return m_elements[index].value; } - [[nodiscard]] const V& peek_min() const + [[nodiscard]] V const& peek_min() const { VERIFY(!is_empty()); return m_elements[0].value; } - [[nodiscard]] const K& peek_min_key() const + [[nodiscard]] K const& peek_min_key() const { VERIFY(!is_empty()); return m_elements[0].key; diff --git a/AK/BitCast.h b/AK/BitCast.h index a893bb858b..a1f6f17d39 100644 --- a/AK/BitCast.h +++ b/AK/BitCast.h @@ -11,7 +11,7 @@ namespace AK { template -[[nodiscard]] constexpr inline T bit_cast(const U& a) +[[nodiscard]] constexpr inline T bit_cast(U const& a) { #if (__has_builtin(__builtin_bit_cast)) return __builtin_bit_cast(T, a); diff --git a/AK/CheckedFormatString.h b/AK/CheckedFormatString.h index 6c55163b68..556f25c809 100644 --- a/AK/CheckedFormatString.h +++ b/AK/CheckedFormatString.h @@ -27,9 +27,9 @@ namespace AK::Format::Detail { template struct Array { constexpr static size_t size() { return Size; } - constexpr const T& operator[](size_t index) const { return __data[index]; } + constexpr T const& operator[](size_t index) const { return __data[index]; } constexpr T& operator[](size_t index) { return __data[index]; } - using ConstIterator = SimpleIterator; + using ConstIterator = SimpleIterator; using Iterator = SimpleIterator; constexpr ConstIterator begin() const { return ConstIterator::begin(*this); } @@ -155,7 +155,8 @@ struct CheckedFormatString { } template - CheckedFormatString(const T& unchecked_fmt) requires(requires(T t) { StringView { t }; }) + CheckedFormatString(T const& unchecked_fmt) + requires(requires(T t) { StringView { t }; }) : m_string(unchecked_fmt) { } diff --git a/AK/CircularQueue.h b/AK/CircularQueue.h index 856a9d6bd9..6e7a4f57f2 100644 --- a/AK/CircularQueue.h +++ b/AK/CircularQueue.h @@ -63,11 +63,11 @@ public: return value; } - const T& at(size_t index) const { return elements()[(m_head + index) % Capacity]; } + T const& at(size_t index) const { return elements()[(m_head + index) % Capacity]; } T& at(size_t index) { return elements()[(m_head + index) % Capacity]; } - const T& first() const { return at(0); } - const T& last() const { return at(size() - 1); } + T const& first() const { return at(0); } + T const& last() const { return at(size() - 1); } class ConstIterator { public: @@ -78,7 +78,7 @@ public: return *this; } - const T& operator*() const { return m_queue.at(m_index); } + T const& operator*() const { return m_queue.at(m_index); } private: friend class CircularQueue; @@ -123,7 +123,7 @@ public: protected: T* elements() { return reinterpret_cast(m_storage); } - const T* elements() const { return reinterpret_cast(m_storage); } + T const* elements() const { return reinterpret_cast(m_storage); } friend class ConstIterator; alignas(T) u8 m_storage[sizeof(T) * Capacity]; diff --git a/AK/Complex.h b/AK/Complex.h index f2655314cc..ece1770189 100644 --- a/AK/Complex.h +++ b/AK/Complex.h @@ -69,7 +69,7 @@ public: } template - constexpr Complex& operator=(const U& x) + constexpr Complex& operator=(U const& x) { m_real = x; m_imag = 0; @@ -85,7 +85,7 @@ public: } template - constexpr Complex operator+=(const U& x) + constexpr Complex operator+=(U const& x) { m_real += x.real(); return *this; @@ -100,7 +100,7 @@ public: } template - constexpr Complex operator-=(const U& x) + constexpr Complex operator-=(U const& x) { m_real -= x.real(); return *this; @@ -116,7 +116,7 @@ public: } template - constexpr Complex operator*=(const U& x) + constexpr Complex operator*=(U const& x) { m_real *= x; m_imag *= x; @@ -134,7 +134,7 @@ public: } template - constexpr Complex operator/=(const U& x) + constexpr Complex operator/=(U const& x) { m_real /= x; m_imag /= x; @@ -150,7 +150,7 @@ public: } template - constexpr Complex operator+(const U& a) + constexpr Complex operator+(U const& a) { Complex x = *this; x += a; @@ -166,7 +166,7 @@ public: } template - constexpr Complex operator-(const U& a) + constexpr Complex operator-(U const& a) { Complex x = *this; x -= a; @@ -182,7 +182,7 @@ public: } template - constexpr Complex operator*(const U& a) + constexpr Complex operator*(U const& a) { Complex x = *this; x *= a; @@ -198,7 +198,7 @@ public: } template - constexpr Complex operator/(const U& a) + constexpr Complex operator/(U const& a) { Complex x = *this; x /= a; @@ -228,7 +228,7 @@ private: // reverse associativity operators for scalars template -constexpr Complex operator+(const U& b, Complex const& a) +constexpr Complex operator+(U const& b, Complex const& a) { Complex x = a; x += b; @@ -236,7 +236,7 @@ constexpr Complex operator+(const U& b, Complex const& a) } template -constexpr Complex operator-(const U& b, Complex const& a) +constexpr Complex operator-(U const& b, Complex const& a) { Complex x = a; x -= b; @@ -244,7 +244,7 @@ constexpr Complex operator-(const U& b, Complex const& a) } template -constexpr Complex operator*(const U& b, Complex const& a) +constexpr Complex operator*(U const& b, Complex const& a) { Complex x = a; x *= b; @@ -252,7 +252,7 @@ constexpr Complex operator*(const U& b, Complex const& a) } template -constexpr Complex operator/(const U& b, Complex const& a) +constexpr Complex operator/(U const& b, Complex const& a) { Complex x = a; x /= b; diff --git a/AK/DisjointChunks.h b/AK/DisjointChunks.h index e9c9da544d..596c3f3435 100644 --- a/AK/DisjointChunks.h +++ b/AK/DisjointChunks.h @@ -59,8 +59,16 @@ struct DisjointIterator { return &other.m_chunks == &m_chunks && other.m_index_in_chunk == m_index_in_chunk && other.m_chunk_index == m_chunk_index; } - auto& operator*() requires(!IsConst) { return m_chunks[m_chunk_index][m_index_in_chunk]; } - auto* operator->() requires(!IsConst) { return &m_chunks[m_chunk_index][m_index_in_chunk]; } + auto& operator*() + requires(!IsConst) + { + return m_chunks[m_chunk_index][m_index_in_chunk]; + } + auto* operator->() + requires(!IsConst) + { + return &m_chunks[m_chunk_index][m_index_in_chunk]; + } auto const& operator*() const { return m_chunks[m_chunk_index][m_index_in_chunk]; } auto const* operator->() const { return &m_chunks[m_chunk_index][m_index_in_chunk]; } diff --git a/AK/DoublyLinkedList.h b/AK/DoublyLinkedList.h index 9789fec8b5..afe53c88b8 100644 --- a/AK/DoublyLinkedList.h +++ b/AK/DoublyLinkedList.h @@ -75,7 +75,7 @@ public: VERIFY(m_head); return m_head->value; } - [[nodiscard]] const T& first() const + [[nodiscard]] T const& first() const { VERIFY(m_head); return m_head->value; @@ -85,7 +85,7 @@ public: VERIFY(m_head); return m_tail->value; } - [[nodiscard]] const T& last() const + [[nodiscard]] T const& last() const { VERIFY(m_head); return m_tail->value; @@ -148,7 +148,7 @@ public: } #endif - [[nodiscard]] bool contains_slow(const T& value) const + [[nodiscard]] bool contains_slow(T const& value) const { return find(value) != end(); } @@ -158,17 +158,17 @@ public: Iterator begin() { return Iterator(m_head); } Iterator end() { return Iterator::universal_end(); } - using ConstIterator = DoublyLinkedListIterator; + using ConstIterator = DoublyLinkedListIterator; friend ConstIterator; ConstIterator begin() const { return ConstIterator(m_head); } ConstIterator end() const { return ConstIterator::universal_end(); } - ConstIterator find(const T& value) const + ConstIterator find(T const& value) const { return AK::find(begin(), end(), value); } - Iterator find(const T& value) + Iterator find(T const& value) { return AK::find(begin(), end(), value); } diff --git a/AK/Error.h b/AK/Error.h index 398066a356..4e2109c99a 100644 --- a/AK/Error.h +++ b/AK/Error.h @@ -75,13 +75,15 @@ private: template class [[nodiscard]] ErrorOr { public: - ErrorOr() requires(IsSame) + ErrorOr() + requires(IsSame) : m_value_or_error(Empty {}) { } template - ALWAYS_INLINE ErrorOr(U&& value) requires(!IsSame, ErrorOr>) + ALWAYS_INLINE ErrorOr(U&& value) + requires(!IsSame, ErrorOr>) : m_value_or_error(forward(value)) { } diff --git a/AK/Find.h b/AK/Find.h index 4b77d9a8f1..fcdab746ba 100644 --- a/AK/Find.h +++ b/AK/Find.h @@ -30,7 +30,8 @@ template TIterator, typena } template TIterator, typename T> -[[nodiscard]] constexpr size_t find_index(TIterator first, TEndIterator last, T const& value) requires(requires(TIterator it) { it.index(); }) +[[nodiscard]] constexpr size_t find_index(TIterator first, TEndIterator last, T const& value) +requires(requires(TIterator it) { it.index(); }) { return find_if(first, last, [&](auto const& v) { return Traits::equals(value, v); }).index(); } diff --git a/AK/FixedPoint.h b/AK/FixedPoint.h index 69618e4972..d409251300 100644 --- a/AK/FixedPoint.h +++ b/AK/FixedPoint.h @@ -157,12 +157,14 @@ public: return y; } - constexpr bool signbit() const requires(IsSigned) + constexpr bool signbit() const + requires(IsSigned) { return m_value >> (sizeof(Underlying) * 8 - 1); } - constexpr This operator-() const requires(IsSigned) + constexpr This operator-() const + requires(IsSigned) { return create_raw(-m_value); } diff --git a/AK/FloatingPoint.h b/AK/FloatingPoint.h index fea42d575c..691b190e18 100644 --- a/AK/FloatingPoint.h +++ b/AK/FloatingPoint.h @@ -90,7 +90,7 @@ public: static const size_t mantissabits = M; template - requires(IsIntegral&& IsUnsigned && sizeof(T) <= 8) constexpr FloatingPointBits(T bits) + requires(IsIntegral && IsUnsigned && sizeof(T) <= 8) constexpr FloatingPointBits(T bits) : m_bits(bits) { } @@ -105,8 +105,16 @@ public: { } - double as_double() const requires(S == 1 && E == 11 && M == 52) { return bit_cast(m_bits); } - float as_float() const requires(S == 1 && E == 8 && M == 23) { return bit_cast(static_cast(m_bits)); } + double as_double() const + requires(S == 1 && E == 11 && M == 52) + { + return bit_cast(m_bits); + } + float as_float() const + requires(S == 1 && E == 8 && M == 23) + { + return bit_cast(static_cast(m_bits)); + } u64 bits() const { return m_bits; } private: diff --git a/AK/FloatingPointStringConversions.cpp b/AK/FloatingPointStringConversions.cpp index 96cedd7f83..0dfddd1746 100644 --- a/AK/FloatingPointStringConversions.cpp +++ b/AK/FloatingPointStringConversions.cpp @@ -20,7 +20,7 @@ namespace AK { // at https://nigeltao.github.io/blog/2020/eisel-lemire.html template -concept ParseableFloatingPoint = IsFloatingPoint &&(sizeof(T) == sizeof(u32) || sizeof(T) == sizeof(u64)); +concept ParseableFloatingPoint = IsFloatingPoint && (sizeof(T) == sizeof(u32) || sizeof(T) == sizeof(u64)); template struct FloatingPointInfo { diff --git a/AK/Format.h b/AK/Format.h index 15cc184e16..1634417296 100644 --- a/AK/Format.h +++ b/AK/Format.h @@ -239,13 +239,13 @@ private: class TypeErasedFormatParams { public: - Span parameters() const { return m_parameters; } + Span parameters() const { return m_parameters; } - void set_parameters(Span parameters) { m_parameters = parameters; } + void set_parameters(Span parameters) { m_parameters = parameters; } size_t take_next_index() { return m_next_index++; } private: - Span m_parameters; + Span m_parameters; size_t m_next_index { 0 }; }; @@ -255,7 +255,7 @@ ErrorOr __format_value(TypeErasedFormatParams& params, FormatBuilder& buil Formatter formatter; formatter.parse(params, parser); - return formatter.format(builder, *static_cast(value)); + return formatter.format(builder, *static_cast(value)); } template @@ -624,15 +624,15 @@ void critical_dmesgln(CheckedFormatString&& fmt, Parameters const template class FormatIfSupported { public: - explicit FormatIfSupported(const T& value) + explicit FormatIfSupported(T const& value) : m_value(value) { } - const T& value() const { return m_value; } + T const& value() const { return m_value; } private: - const T& m_value; + T const& m_value; }; template struct __FormatIfSupported : Formatter { diff --git a/AK/Function.h b/AK/Function.h index 79a56eb482..16ad355e93 100644 --- a/AK/Function.h +++ b/AK/Function.h @@ -64,13 +64,15 @@ public: } template - Function(CallableType&& callable) requires((IsFunctionObject && IsCallableWithArguments && !IsSame, Function>)) + Function(CallableType&& callable) + requires((IsFunctionObject && IsCallableWithArguments && !IsSame, Function>)) { init_with_callable(forward(callable)); } template - Function(FunctionType f) requires((IsFunctionPointer && IsCallableWithArguments, In...> && !IsSame, Function>)) + Function(FunctionType f) + requires((IsFunctionPointer && IsCallableWithArguments, In...> && !IsSame, Function>)) { init_with_callable(move(f)); } @@ -96,7 +98,8 @@ public: explicit operator bool() const { return !!callable_wrapper(); } template - Function& operator=(CallableType&& callable) requires((IsFunctionObject && IsCallableWithArguments)) + Function& operator=(CallableType&& callable) + requires((IsFunctionObject && IsCallableWithArguments)) { clear(); init_with_callable(forward(callable)); @@ -104,7 +107,8 @@ public: } template - Function& operator=(FunctionType f) requires((IsFunctionPointer && IsCallableWithArguments, In...>)) + Function& operator=(FunctionType f) + requires((IsFunctionPointer && IsCallableWithArguments, In...>)) { clear(); if (f) diff --git a/AK/GenericLexer.h b/AK/GenericLexer.h index 0ac347245e..50d98adb57 100644 --- a/AK/GenericLexer.h +++ b/AK/GenericLexer.h @@ -70,7 +70,7 @@ public: } template - constexpr bool consume_specific(const T& next) + constexpr bool consume_specific(T const& next) { if (!next_is(next)) return false; diff --git a/AK/HashMap.h b/AK/HashMap.h index 7ae9b26187..dd959728af 100644 --- a/AK/HashMap.h +++ b/AK/HashMap.h @@ -48,14 +48,14 @@ public: void clear() { m_table.clear(); } void clear_with_capacity() { m_table.clear_with_capacity(); } - HashSetResult set(const K& key, const V& value) { return m_table.set({ key, value }); } - HashSetResult set(const K& key, V&& value) { return m_table.set({ key, move(value) }); } + HashSetResult set(K const& key, V const& value) { return m_table.set({ key, value }); } + HashSetResult set(K const& key, V&& value) { return m_table.set({ key, move(value) }); } HashSetResult set(K&& key, V&& value) { return m_table.set({ move(key), move(value) }); } - ErrorOr try_set(const K& key, const V& value) { return m_table.try_set({ key, value }); } - ErrorOr try_set(const K& key, V&& value) { return m_table.try_set({ key, move(value) }); } + ErrorOr try_set(K const& key, V const& value) { return m_table.try_set({ key, value }); } + ErrorOr try_set(K const& key, V&& value) { return m_table.try_set({ key, move(value) }); } ErrorOr try_set(K&& key, V&& value) { return m_table.try_set({ move(key), move(value) }); } - bool remove(const K& key) + bool remove(K const& key) { auto it = find(key); if (it != end()) { @@ -90,7 +90,7 @@ public: [[nodiscard]] IteratorType begin() { return m_table.begin(); } [[nodiscard]] IteratorType end() { return m_table.end(); } - [[nodiscard]] IteratorType find(const K& key) + [[nodiscard]] IteratorType find(K const& key) { return m_table.find(KeyTraits::hash(key), [&](auto& entry) { return KeyTraits::equals(key, entry.key); }); } @@ -102,7 +102,7 @@ public: [[nodiscard]] ConstIteratorType begin() const { return m_table.begin(); } [[nodiscard]] ConstIteratorType end() const { return m_table.end(); } - [[nodiscard]] ConstIteratorType find(const K& key) const + [[nodiscard]] ConstIteratorType find(K const& key) const { return m_table.find(KeyTraits::hash(key), [&](auto& entry) { return KeyTraits::equals(key, entry.key); }); } @@ -127,7 +127,8 @@ public: void ensure_capacity(size_t capacity) { m_table.ensure_capacity(capacity); } ErrorOr try_ensure_capacity(size_t capacity) { return m_table.try_ensure_capacity(capacity); } - Optional::ConstPeekType> get(const K& key) const requires(!IsPointer::PeekType>) + Optional::ConstPeekType> get(K const& key) const + requires(!IsPointer::PeekType>) { auto it = find(key); if (it == end()) @@ -135,7 +136,8 @@ public: return (*it).value; } - Optional::ConstPeekType> get(const K& key) const requires(IsPointer::PeekType>) + Optional::ConstPeekType> get(K const& key) const + requires(IsPointer::PeekType>) { auto it = find(key); if (it == end()) @@ -143,7 +145,8 @@ public: return (*it).value; } - Optional::PeekType> get(const K& key) requires(!IsConst::PeekType>) + Optional::PeekType> get(K const& key) + requires(!IsConst::PeekType>) { auto it = find(key); if (it == end()) @@ -153,7 +156,8 @@ public: template Key> requires(IsSame>) Optional::PeekType> get(Key const& key) - const requires(!IsPointer::PeekType>) + const + requires(!IsPointer::PeekType>) { auto it = find(key); if (it == end()) @@ -163,7 +167,8 @@ public: template Key> requires(IsSame>) Optional::ConstPeekType> get(Key const& key) - const requires(IsPointer::PeekType>) + const + requires(IsPointer::PeekType>) { auto it = find(key); if (it == end()) @@ -181,7 +186,7 @@ public: return (*it).value; } - [[nodiscard]] bool contains(const K& key) const + [[nodiscard]] bool contains(K const& key) const { return find(key) != end(); } @@ -197,7 +202,7 @@ public: m_table.remove(it); } - V& ensure(const K& key) + V& ensure(K const& key) { auto it = find(key); if (it != end()) diff --git a/AK/HashTable.h b/AK/HashTable.h index 65e7ac9e4e..e2eee6d78a 100644 --- a/AK/HashTable.h +++ b/AK/HashTable.h @@ -115,7 +115,7 @@ class HashTable { alignas(T) u8 storage[sizeof(T)]; T* slot() { return reinterpret_cast(storage); } - const T* slot() const { return reinterpret_cast(storage); } + T const* slot() const { return reinterpret_cast(storage); } }; struct OrderedBucket { @@ -124,7 +124,7 @@ class HashTable { BucketState state; alignas(T) u8 storage[sizeof(T)]; T* slot() { return reinterpret_cast(storage); } - const T* slot() const { return reinterpret_cast(storage); } + T const* slot() const { return reinterpret_cast(storage); } }; using BucketType = Conditional; @@ -265,8 +265,8 @@ public: } using ConstIterator = Conditional, - HashTableIterator>; + OrderedHashTableIterator, + HashTableIterator>; [[nodiscard]] ConstIterator begin() const { @@ -389,7 +389,7 @@ public: return find(Traits::hash(value), move(predicate)); } - bool remove(const T& value) + bool remove(T const& value) { auto it = find(value); if (it != end()) { diff --git a/AK/IntrusiveRedBlackTree.h b/AK/IntrusiveRedBlackTree.h index 097e479b59..9dbf2b24dc 100644 --- a/AK/IntrusiveRedBlackTree.h +++ b/AK/IntrusiveRedBlackTree.h @@ -127,7 +127,7 @@ public: Iterator begin_from(K key) { return Iterator(static_cast(BaseTree::find(this->m_root, key))); } Iterator begin_from(V& value) { return Iterator(&(value.*member)); } - using ConstIterator = BaseIterator; + using ConstIterator = BaseIterator; ConstIterator begin() const { return ConstIterator(static_cast(this->m_minimum)); } ConstIterator end() const { return {}; } ConstIterator begin_from(K key) const { return ConstIterator(static_cast(BaseTree::find(this->m_rootF, key))); } diff --git a/AK/MemMem.h b/AK/MemMem.h index 33473eb658..1d36550f09 100644 --- a/AK/MemMem.h +++ b/AK/MemMem.h @@ -43,7 +43,8 @@ constexpr void const* bitap_bitwise(void const* haystack, size_t haystack_length } template -inline Optional memmem(HaystackIterT const& haystack_begin, HaystackIterT const& haystack_end, Span needle) requires(requires { (*haystack_begin).data(); (*haystack_begin).size(); }) +inline Optional memmem(HaystackIterT const& haystack_begin, HaystackIterT const& haystack_end, Span needle) +requires(requires { (*haystack_begin).data(); (*haystack_begin).size(); }) { auto prepare_kmp_partial_table = [&] { Vector table; @@ -122,7 +123,7 @@ inline Optional memmem_optional(void const* haystack, size_t haystack_le } // Fallback to KMP. - Array, 1> spans { Span { (u8 const*)haystack, haystack_length } }; + Array, 1> spans { Span { (u8 const*)haystack, haystack_length } }; return memmem(spans.begin(), spans.end(), { (u8 const*)needle, needle_length }); } diff --git a/AK/NeverDestroyed.h b/AK/NeverDestroyed.h index 2014407d43..0600244281 100644 --- a/AK/NeverDestroyed.h +++ b/AK/NeverDestroyed.h @@ -26,13 +26,13 @@ public: ~NeverDestroyed() = default; T* operator->() { return &get(); } - const T* operator->() const { return &get(); } + T const* operator->() const { return &get(); } T& operator*() { return get(); } - const T& operator*() const { return get(); } + T const& operator*() const { return get(); } T& get() { return reinterpret_cast(storage); } - const T& get() const { return reinterpret_cast(storage); } + T const& get() const { return reinterpret_cast(storage); } private: alignas(T) u8 storage[sizeof(T)]; diff --git a/AK/NonnullOwnPtr.h b/AK/NonnullOwnPtr.h index d9b48b1c10..1d693d2975 100644 --- a/AK/NonnullOwnPtr.h +++ b/AK/NonnullOwnPtr.h @@ -164,7 +164,7 @@ inline NonnullOwnPtr make(Args&&... args) template struct Traits> : public GenericTraits> { using PeekType = T*; - using ConstPeekType = const T*; + using ConstPeekType = T const*; static unsigned hash(NonnullOwnPtr const& p) { return ptr_hash((FlatPtr)p.ptr()); } static bool equals(NonnullOwnPtr const& a, NonnullOwnPtr const& b) { return a.ptr() == b.ptr(); } }; @@ -176,10 +176,10 @@ inline void swap(NonnullOwnPtr& a, NonnullOwnPtr& b) } template -struct Formatter> : Formatter { +struct Formatter> : Formatter { ErrorOr format(FormatBuilder& builder, NonnullOwnPtr const& value) { - return Formatter::format(builder, value.ptr()); + return Formatter::format(builder, value.ptr()); } }; diff --git a/AK/NonnullRefPtr.h b/AK/NonnullRefPtr.h index 11d1a4aca7..4b888282c0 100644 --- a/AK/NonnullRefPtr.h +++ b/AK/NonnullRefPtr.h @@ -56,7 +56,8 @@ public: } template - ALWAYS_INLINE NonnullRefPtr(U const& object) requires(IsConvertible) + ALWAYS_INLINE NonnullRefPtr(U const& object) + requires(IsConvertible) : m_ptr(const_cast(static_cast(&object))) { m_ptr->ref(); @@ -73,7 +74,8 @@ public: } template - ALWAYS_INLINE NonnullRefPtr(NonnullRefPtr&& other) requires(IsConvertible) + ALWAYS_INLINE NonnullRefPtr(NonnullRefPtr&& other) + requires(IsConvertible) : m_ptr(static_cast(&other.leak_ref())) { } @@ -85,7 +87,8 @@ public: } template - ALWAYS_INLINE NonnullRefPtr(NonnullRefPtr const& other) requires(IsConvertible) + ALWAYS_INLINE NonnullRefPtr(NonnullRefPtr const& other) + requires(IsConvertible) : m_ptr(const_cast(static_cast(other.ptr()))) { m_ptr->ref(); @@ -120,7 +123,8 @@ public: } template - NonnullRefPtr& operator=(NonnullRefPtr const& other) requires(IsConvertible) + NonnullRefPtr& operator=(NonnullRefPtr const& other) + requires(IsConvertible) { NonnullRefPtr tmp { other }; swap(tmp); @@ -135,7 +139,8 @@ public: } template - NonnullRefPtr& operator=(NonnullRefPtr&& other) requires(IsConvertible) + NonnullRefPtr& operator=(NonnullRefPtr&& other) + requires(IsConvertible) { NonnullRefPtr tmp { move(other) }; swap(tmp); @@ -190,7 +195,8 @@ public: } template - void swap(NonnullRefPtr& other) requires(IsConvertible) + void swap(NonnullRefPtr& other) + requires(IsConvertible) { AK::swap(m_ptr, other.m_ptr); } @@ -198,7 +204,11 @@ public: bool operator==(NonnullRefPtr const& other) const { return m_ptr == other.m_ptr; } template - bool operator==(RawPtr other) const requires(IsPointer) { return m_ptr == other; } + bool operator==(RawPtr other) const + requires(IsPointer) + { + return m_ptr == other; + } // clang-format off private: @@ -229,7 +239,8 @@ struct Formatter> : Formatter { }; template -inline void swap(NonnullRefPtr& a, NonnullRefPtr& b) requires(IsConvertible) +inline void swap(NonnullRefPtr& a, NonnullRefPtr& b) +requires(IsConvertible) { a.swap(b); } diff --git a/AK/Optional.h b/AK/Optional.h index eafb343bb9..a5f1c51540 100644 --- a/AK/Optional.h +++ b/AK/Optional.h @@ -38,23 +38,33 @@ public: ALWAYS_INLINE Optional() = default; #ifdef AK_HAS_CONDITIONALLY_TRIVIAL - Optional(Optional const& other) requires(!IsCopyConstructible) = delete; + Optional(Optional const& other) + requires(!IsCopyConstructible) + = delete; Optional(Optional const& other) = default; - Optional(Optional&& other) requires(!IsMoveConstructible) = delete; + Optional(Optional&& other) + requires(!IsMoveConstructible) + = delete; - Optional& operator=(Optional const&) requires(!IsCopyConstructible || !IsDestructible) = delete; + Optional& operator=(Optional const&) + requires(!IsCopyConstructible || !IsDestructible) + = delete; Optional& operator=(Optional const&) = default; - Optional& operator=(Optional&& other) requires(!IsMoveConstructible || !IsDestructible) = delete; + Optional& operator=(Optional&& other) + requires(!IsMoveConstructible || !IsDestructible) + = delete; - ~Optional() requires(!IsDestructible) = delete; + ~Optional() + requires(!IsDestructible) + = delete; ~Optional() = default; #endif ALWAYS_INLINE Optional(Optional const& other) #ifdef AK_HAS_CONDITIONALLY_TRIVIAL - requires(!IsTriviallyCopyConstructible) + requires(!IsTriviallyCopyConstructible) #endif : m_has_value(other.m_has_value) { @@ -78,7 +88,7 @@ public: } template - requires(IsConstructible && !IsSpecializationOf && !IsSpecializationOf) ALWAYS_INLINE explicit Optional(Optional&& other) + requires(IsConstructible && !IsSpecializationOf && !IsSpecializationOf) ALWAYS_INLINE explicit Optional(Optional&& other) : m_has_value(other.m_has_value) { if (other.has_value()) @@ -86,7 +96,8 @@ public: } template - ALWAYS_INLINE explicit(!IsConvertible) Optional(U&& value) requires(!IsSame, Optional> && IsConstructible) + ALWAYS_INLINE explicit(!IsConvertible) Optional(U&& value) + requires(!IsSame, Optional> && IsConstructible) : m_has_value(true) { new (&m_storage) T(forward(value)); @@ -94,7 +105,7 @@ public: ALWAYS_INLINE Optional& operator=(Optional const& other) #ifdef AK_HAS_CONDITIONALLY_TRIVIAL - requires(!IsTriviallyCopyConstructible || !IsTriviallyDestructible) + requires(!IsTriviallyCopyConstructible || !IsTriviallyDestructible) #endif { if (this != &other) { @@ -133,7 +144,7 @@ public: ALWAYS_INLINE ~Optional() #ifdef AK_HAS_CONDITIONALLY_TRIVIAL - requires(!IsTriviallyDestructible) + requires(!IsTriviallyDestructible) #endif { clear(); @@ -222,7 +233,8 @@ public: ALWAYS_INLINE Optional() = default; template - ALWAYS_INLINE Optional(U& value) requires(CanBePlacedInOptional) + ALWAYS_INLINE Optional(U& value) + requires(CanBePlacedInOptional) : m_pointer(&value) { } @@ -244,13 +256,15 @@ public: } template - ALWAYS_INLINE Optional(Optional const& other) requires(CanBePlacedInOptional) + ALWAYS_INLINE Optional(Optional const& other) + requires(CanBePlacedInOptional) : m_pointer(other.m_pointer) { } template - ALWAYS_INLINE Optional(Optional&& other) requires(CanBePlacedInOptional) + ALWAYS_INLINE Optional(Optional&& other) + requires(CanBePlacedInOptional) : m_pointer(other.m_pointer) { other.m_pointer = nullptr; @@ -270,14 +284,16 @@ public: } template - ALWAYS_INLINE Optional& operator=(Optional const& other) requires(CanBePlacedInOptional) + ALWAYS_INLINE Optional& operator=(Optional const& other) + requires(CanBePlacedInOptional) { m_pointer = other.m_pointer; return *this; } template - ALWAYS_INLINE Optional& operator=(Optional&& other) requires(CanBePlacedInOptional) + ALWAYS_INLINE Optional& operator=(Optional&& other) + requires(CanBePlacedInOptional) { m_pointer = other.m_pointer; other.m_pointer = nullptr; @@ -286,7 +302,8 @@ public: // Note: Disallows assignment from a temporary as this does not do any lifetime extension. template - ALWAYS_INLINE Optional& operator=(U&& value) requires(CanBePlacedInOptional&& IsLvalueReference) + ALWAYS_INLINE Optional& operator=(U&& value) + requires(CanBePlacedInOptional && IsLvalueReference) { m_pointer = &value; return *this; diff --git a/AK/OwnPtr.h b/AK/OwnPtr.h index efab35a12b..8de5eeb37d 100644 --- a/AK/OwnPtr.h +++ b/AK/OwnPtr.h @@ -217,7 +217,7 @@ inline ErrorOr> try_make(Args&&... args) template struct Traits> : public GenericTraits> { using PeekType = T*; - using ConstPeekType = const T*; + using ConstPeekType = T const*; static unsigned hash(OwnPtr const& p) { return ptr_hash(p.ptr()); } static bool equals(OwnPtr const& a, OwnPtr const& b) { return a.ptr() == b.ptr(); } }; diff --git a/AK/PrintfImplementation.h b/AK/PrintfImplementation.h index 5d590f1d5c..e67f480c59 100644 --- a/AK/PrintfImplementation.h +++ b/AK/PrintfImplementation.h @@ -475,7 +475,7 @@ struct VaArgNextArgument { }; #define PRINTF_IMPL_DELEGATE_TO_IMPL(c) \ - case* #c: \ + case *#c: \ ret += impl.format_##c(state, ap); \ break; diff --git a/AK/Queue.h b/AK/Queue.h index c3c6805140..bd4f806631 100644 --- a/AK/Queue.h +++ b/AK/Queue.h @@ -56,7 +56,7 @@ public: return value; } - const T& head() const + T const& head() const { VERIFY(!is_empty()); return m_segments.first()->data[m_index_into_first]; diff --git a/AK/RedBlackTree.h b/AK/RedBlackTree.h index 43d044ca58..54a0f357f1 100644 --- a/AK/RedBlackTree.h +++ b/AK/RedBlackTree.h @@ -505,7 +505,7 @@ public: Iterator end() { return {}; } Iterator begin_from(K key) { return Iterator(static_cast(BaseTree::find(this->m_root, key))); } - using ConstIterator = RedBlackTreeIterator; + using ConstIterator = RedBlackTreeIterator; friend ConstIterator; ConstIterator begin() const { return ConstIterator(static_cast(this->m_minimum)); } ConstIterator end() const { return {}; } diff --git a/AK/RefPtr.h b/AK/RefPtr.h index a98fddd7f3..f60af914af 100644 --- a/AK/RefPtr.h +++ b/AK/RefPtr.h @@ -66,20 +66,23 @@ public: } template - ALWAYS_INLINE RefPtr(NonnullRefPtr const& other) requires(IsConvertible) + ALWAYS_INLINE RefPtr(NonnullRefPtr const& other) + requires(IsConvertible) : m_ptr(const_cast(static_cast(other.ptr()))) { m_ptr->ref(); } template - ALWAYS_INLINE RefPtr(NonnullRefPtr&& other) requires(IsConvertible) + ALWAYS_INLINE RefPtr(NonnullRefPtr&& other) + requires(IsConvertible) : m_ptr(static_cast(&other.leak_ref())) { } template - RefPtr(RefPtr&& other) requires(IsConvertible) + RefPtr(RefPtr&& other) + requires(IsConvertible) : m_ptr(static_cast(other.leak_ref())) { } @@ -91,7 +94,8 @@ public: } template - RefPtr(RefPtr const& other) requires(IsConvertible) + RefPtr(RefPtr const& other) + requires(IsConvertible) : m_ptr(const_cast(static_cast(other.ptr()))) { ref_if_not_null(m_ptr); @@ -116,7 +120,8 @@ public: } template - void swap(RefPtr& other) requires(IsConvertible) + void swap(RefPtr& other) + requires(IsConvertible) { AK::swap(m_ptr, other.m_ptr); } @@ -129,7 +134,8 @@ public: } template - ALWAYS_INLINE RefPtr& operator=(RefPtr&& other) requires(IsConvertible) + ALWAYS_INLINE RefPtr& operator=(RefPtr&& other) + requires(IsConvertible) { RefPtr tmp { move(other) }; swap(tmp); @@ -137,7 +143,8 @@ public: } template - ALWAYS_INLINE RefPtr& operator=(NonnullRefPtr&& other) requires(IsConvertible) + ALWAYS_INLINE RefPtr& operator=(NonnullRefPtr&& other) + requires(IsConvertible) { RefPtr tmp { move(other) }; swap(tmp); @@ -152,7 +159,8 @@ public: } template - ALWAYS_INLINE RefPtr& operator=(NonnullRefPtr const& other) requires(IsConvertible) + ALWAYS_INLINE RefPtr& operator=(NonnullRefPtr const& other) + requires(IsConvertible) { RefPtr tmp { other }; swap(tmp); @@ -167,7 +175,8 @@ public: } template - ALWAYS_INLINE RefPtr& operator=(RefPtr const& other) requires(IsConvertible) + ALWAYS_INLINE RefPtr& operator=(RefPtr const& other) + requires(IsConvertible) { RefPtr tmp { other }; swap(tmp); @@ -255,7 +264,11 @@ public: bool operator==(NonnullRefPtr const& other) const { return as_ptr() == other.m_ptr; } template - bool operator==(RawPtr other) const requires(IsPointer) { return as_ptr() == other; } + bool operator==(RawPtr other) const + requires(IsPointer) + { + return as_ptr() == other; + } ALWAYS_INLINE bool is_null() const { return !m_ptr; } @@ -303,7 +316,8 @@ inline RefPtr static_ptr_cast(RefPtr const& ptr) } template -inline void swap(RefPtr& a, RefPtr& b) requires(IsConvertible) +inline void swap(RefPtr& a, RefPtr& b) +requires(IsConvertible) { a.swap(b); } diff --git a/AK/ScopedValueRollback.h b/AK/ScopedValueRollback.h index 156bc98421..d3159e9bb9 100644 --- a/AK/ScopedValueRollback.h +++ b/AK/ScopedValueRollback.h @@ -22,7 +22,7 @@ public: m_variable = m_saved_value; } - void set_override_rollback_value(const T& value) + void set_override_rollback_value(T const& value) { m_saved_value = value; } diff --git a/AK/SinglyLinkedList.h b/AK/SinglyLinkedList.h index 151ff93c2d..06b7c0eedb 100644 --- a/AK/SinglyLinkedList.h +++ b/AK/SinglyLinkedList.h @@ -71,7 +71,7 @@ private: : value(move(v)) { } - explicit Node(const T& v) + explicit Node(T const& v) : value(v) { } @@ -120,7 +120,7 @@ public: VERIFY(head()); return head()->value; } - const T& first() const + T const& first() const { VERIFY(head()); return head()->value; @@ -130,7 +130,7 @@ public: VERIFY(head()); return tail()->value; } - const T& last() const + T const& last() const { VERIFY(head()); return tail()->value; @@ -194,7 +194,7 @@ public: } #endif - bool contains_slow(const T& value) const + bool contains_slow(T const& value) const { return find(value) != end(); } @@ -204,7 +204,7 @@ public: Iterator begin() { return Iterator(m_head); } Iterator end() { return {}; } - using ConstIterator = SinglyLinkedListIterator; + using ConstIterator = SinglyLinkedListIterator; friend ConstIterator; ConstIterator begin() const { return ConstIterator(m_head); } ConstIterator end() const { return {}; } @@ -221,12 +221,12 @@ public: return AK::find_if(begin(), end(), forward(pred)); } - ConstIterator find(const T& value) const + ConstIterator find(T const& value) const { return find_if([&](auto& other) { return Traits::equals(value, other); }); } - Iterator find(const T& value) + Iterator find(T const& value) { return find_if([&](auto& other) { return Traits::equals(value, other); }); } diff --git a/AK/SinglyLinkedListWithCount.h b/AK/SinglyLinkedListWithCount.h index 04be949996..5fad36955f 100644 --- a/AK/SinglyLinkedListWithCount.h +++ b/AK/SinglyLinkedListWithCount.h @@ -38,7 +38,7 @@ public: return List::first(); } - const T& first() const + T const& first() const { return List::first(); } @@ -48,7 +48,7 @@ public: return List::last(); } - const T& last() const + T const& last() const { return List::last(); } @@ -76,7 +76,7 @@ public: } #endif - bool contains_slow(const T& value) const + bool contains_slow(T const& value) const { return List::contains_slow(value); } @@ -103,12 +103,12 @@ public: return List::find_if(forward(pred)); } - ConstIterator find(const T& value) const + ConstIterator find(T const& value) const { return List::find(value); } - Iterator find(const T& value) + Iterator find(T const& value) { return List::find(value); } diff --git a/AK/Span.h b/AK/Span.h index ab559ee927..383d2ae434 100644 --- a/AK/Span.h +++ b/AK/Span.h @@ -43,7 +43,7 @@ public: template requires(IsConst) - ALWAYS_INLINE constexpr Span(Array const& array) + ALWAYS_INLINE constexpr Span(Array const& array) : m_values(array.data()) , m_size(size) { diff --git a/AK/Stack.h b/AK/Stack.h index 4d177ce9d6..acdc3830fa 100644 --- a/AK/Stack.h +++ b/AK/Stack.h @@ -16,7 +16,7 @@ public: Stack() = default; ~Stack() = default; - bool push(const T& item) + bool push(T const& item) { if (m_stack.size() >= stack_size) return false; @@ -58,7 +58,7 @@ public: return m_stack.last(); } - const T& top() const + T const& top() const { return m_stack.last(); } diff --git a/AK/StdLibExtraDetails.h b/AK/StdLibExtraDetails.h index 69c3669ada..446cf5adfe 100644 --- a/AK/StdLibExtraDetails.h +++ b/AK/StdLibExtraDetails.h @@ -50,7 +50,7 @@ struct __RemoveConst { using Type = T; }; template -struct __RemoveConst { +struct __RemoveConst { using Type = T; }; template @@ -62,7 +62,7 @@ struct __RemoveVolatile { }; template -struct __RemoveVolatile { +struct __RemoveVolatile { using Type = T; }; @@ -125,9 +125,9 @@ inline constexpr bool IsFunction = true; template inline constexpr bool IsFunction = true; template -inline constexpr bool IsFunction = true; +inline constexpr bool IsFunction = true; template -inline constexpr bool IsFunction = true; +inline constexpr bool IsFunction = true; template inline constexpr bool IsFunction = true; template @@ -373,7 +373,7 @@ template inline constexpr bool IsConst = false; template -inline constexpr bool IsConst = true; +inline constexpr bool IsConst = true; template inline constexpr bool IsEnum = __is_enum(T); @@ -597,7 +597,7 @@ template using Decay = typename __Decay::type; template -inline constexpr bool IsPointerOfType = IsPointer>&& IsSame>>>; +inline constexpr bool IsPointerOfType = IsPointer> && IsSame>>>; template inline constexpr bool IsHashCompatible = false; diff --git a/AK/StdLibExtras.h b/AK/StdLibExtras.h index dcd1fa8985..d23d283aa2 100644 --- a/AK/StdLibExtras.h +++ b/AK/StdLibExtras.h @@ -17,13 +17,15 @@ #include template -constexpr auto round_up_to_power_of_two(T value, U power_of_two) requires(AK::Detail::IsIntegral&& AK::Detail::IsIntegral) +constexpr auto round_up_to_power_of_two(T value, U power_of_two) +requires(AK::Detail::IsIntegral && AK::Detail::IsIntegral) { return ((value - 1) & ~(power_of_two - 1)) + power_of_two; } template -constexpr bool is_power_of_two(T value) requires(AK::Detail::IsIntegral) +constexpr bool is_power_of_two(T value) +requires(AK::Detail::IsIntegral) { return value && !((value) & (value - 1)); } @@ -81,19 +83,19 @@ constexpr SizeType array_size(T (&)[N]) } template -constexpr T min(const T& a, IdentityType const& b) +constexpr T min(T const& a, IdentityType const& b) { return b < a ? b : a; } template -constexpr T max(const T& a, IdentityType const& b) +constexpr T max(T const& a, IdentityType const& b) { return a < b ? b : a; } template -constexpr T clamp(const T& value, IdentityType const& min, IdentityType const& max) +constexpr T clamp(T const& value, IdentityType const& min, IdentityType const& max) { VERIFY(max >= min); if (value > max) @@ -141,7 +143,8 @@ template using RawPtr = typename Detail::_RawPtr::Type; template -constexpr decltype(auto) to_underlying(V value) requires(IsEnum) +constexpr decltype(auto) to_underlying(V value) +requires(IsEnum) { return static_cast>(value); } diff --git a/AK/Stream.h b/AK/Stream.h index b8f7f8bee8..552466657d 100644 --- a/AK/Stream.h +++ b/AK/Stream.h @@ -135,13 +135,15 @@ InputStream& operator>>(InputStream& stream, Optional& value) } template -InputStream& operator>>(InputStream& stream, Integral& value) requires IsIntegral +InputStream& operator>>(InputStream& stream, Integral& value) +requires IsIntegral { stream.read_or_error({ &value, sizeof(value) }); return stream; } template -OutputStream& operator<<(OutputStream& stream, Integral value) requires IsIntegral +OutputStream& operator<<(OutputStream& stream, Integral value) +requires IsIntegral { stream.write_or_error({ &value, sizeof(value) }); return stream; @@ -150,13 +152,15 @@ OutputStream& operator<<(OutputStream& stream, Integral value) requires IsIntegr #ifndef KERNEL template -InputStream& operator>>(InputStream& stream, FloatingPoint& value) requires IsFloatingPoint +InputStream& operator>>(InputStream& stream, FloatingPoint& value) +requires IsFloatingPoint { stream.read_or_error({ &value, sizeof(value) }); return stream; } template -OutputStream& operator<<(OutputStream& stream, FloatingPoint value) requires IsFloatingPoint +OutputStream& operator<<(OutputStream& stream, FloatingPoint value) +requires IsFloatingPoint { stream.write_or_error({ &value, sizeof(value) }); return stream; diff --git a/AK/String.h b/AK/String.h index 8001728308..a304f0d1da 100644 --- a/AK/String.h +++ b/AK/String.h @@ -283,7 +283,8 @@ public: } template - [[nodiscard]] static String number(T value) requires IsArithmetic + [[nodiscard]] static String number(T value) + requires IsArithmetic { return formatted("{}", value); } diff --git a/AK/Time.h b/AK/Time.h index 9398a84a75..0137de2030 100644 --- a/AK/Time.h +++ b/AK/Time.h @@ -24,11 +24,10 @@ namespace AK { // Concept to detect types which look like timespec without requiring the type. template -concept TimeSpecType = requires(T t) -{ - t.tv_sec; - t.tv_nsec; -}; +concept TimeSpecType = requires(T t) { + t.tv_sec; + t.tv_nsec; + }; constexpr bool is_leap_year(int year) { @@ -315,38 +314,38 @@ inline void timespec_to_timeval(TimespecType const& ts, TimevalType& tv) } template -inline bool operator>=(const T& a, const T& b) +inline bool operator>=(T const& a, T const& b) { return a.tv_sec > b.tv_sec || (a.tv_sec == b.tv_sec && a.tv_nsec >= b.tv_nsec); } template -inline bool operator>(const T& a, const T& b) +inline bool operator>(T const& a, T const& b) { return a.tv_sec > b.tv_sec || (a.tv_sec == b.tv_sec && a.tv_nsec > b.tv_nsec); } template -inline bool operator<(const T& a, const T& b) +inline bool operator<(T const& a, T const& b) { return a.tv_sec < b.tv_sec || (a.tv_sec == b.tv_sec && a.tv_nsec < b.tv_nsec); } template -inline bool operator<=(const T& a, const T& b) +inline bool operator<=(T const& a, T const& b) { return a.tv_sec < b.tv_sec || (a.tv_sec == b.tv_sec && a.tv_nsec <= b.tv_nsec); } template -inline bool operator==(const T& a, const T& b) +inline bool operator==(T const& a, T const& b) { return a.tv_sec == b.tv_sec && a.tv_nsec == b.tv_nsec; } template -inline bool operator!=(const T& a, const T& b) +inline bool operator!=(T const& a, T const& b) { return a.tv_sec != b.tv_sec || a.tv_nsec != b.tv_nsec; } diff --git a/AK/Traits.h b/AK/Traits.h index 3410424aba..aa49b3795d 100644 --- a/AK/Traits.h +++ b/AK/Traits.h @@ -20,7 +20,7 @@ struct GenericTraits { using PeekType = T&; using ConstPeekType = T const&; static constexpr bool is_trivial() { return false; } - static constexpr bool equals(const T& a, const T& b) { return a == b; } + static constexpr bool equals(T const& a, T const& b) { return a == b; } template U> static bool equals(U const& a, T const& b) { return a == b; } }; diff --git a/AK/Trie.h b/AK/Trie.h index f2b9f09361..62a451312d 100644 --- a/AK/Trie.h +++ b/AK/Trie.h @@ -69,10 +69,26 @@ public: return const_cast(this)->traverse_until_last_accessible_node(it, end); } - Optional metadata() const requires(!IsNullPointer) { return m_metadata; } - void set_metadata(MetadataType metadata) requires(!IsNullPointer) { m_metadata = move(metadata); } - MetadataType const& metadata_value() const requires(!IsNullPointer) { return m_metadata.value(); } - MetadataType& metadata_value() requires(!IsNullPointer) { return m_metadata.value(); } + Optional metadata() const + requires(!IsNullPointer) + { + return m_metadata; + } + void set_metadata(MetadataType metadata) + requires(!IsNullPointer) + { + m_metadata = move(metadata); + } + MetadataType const& metadata_value() const + requires(!IsNullPointer) + { + return m_metadata.value(); + } + MetadataType& metadata_value() + requires(!IsNullPointer) + { + return m_metadata.value(); + } ValueType const& value() const { return m_value; } ValueType& value() { return m_value; } @@ -99,7 +115,8 @@ public: template ErrorOr insert( - It& it, It const& end, MetadataType metadata, ProvideMetadataFunction provide_missing_metadata) requires(!IsNullPointer) + It& it, It const& end, MetadataType metadata, ProvideMetadataFunction provide_missing_metadata) + requires(!IsNullPointer) { Trie* last_root_node = &traverse_until_last_accessible_node(it, end); auto invoke_provide_missing_metadata = [&](Ts&&... args) -> ErrorOr> { @@ -119,7 +136,8 @@ public: } template - ErrorOr insert(It& it, It const& end) requires(IsNullPointer) + ErrorOr insert(It& it, It const& end) + requires(IsNullPointer) { Trie* last_root_node = &traverse_until_last_accessible_node(it, end); for (; it != end; ++it) { @@ -133,14 +151,16 @@ public: template ErrorOr insert( - It const& begin, It const& end, MetadataType metadata, ProvideMetadataFunction provide_missing_metadata) requires(!IsNullPointer) + It const& begin, It const& end, MetadataType metadata, ProvideMetadataFunction provide_missing_metadata) + requires(!IsNullPointer) { auto it = begin; return insert(it, end, move(metadata), move(provide_missing_metadata)); } template - ErrorOr insert(It const& begin, It const& end) requires(IsNullPointer) + ErrorOr insert(It const& begin, It const& end) + requires(IsNullPointer) { auto it = begin; return insert(it, end); @@ -185,7 +205,8 @@ public: [[nodiscard]] bool is_empty() const { return m_children.is_empty(); } void clear() { m_children.clear(); } - ErrorOr deep_copy() requires(requires(ValueType value) { { value->try_clone() } -> SpecializationOf; }) + ErrorOr deep_copy() + requires(requires(ValueType value) { { value->try_clone() } -> SpecializationOf; }) { Trie root(TRY(m_value->try_clone()), TRY(copy_metadata(m_metadata))); for (auto& it : m_children) @@ -260,7 +281,8 @@ public: using DetailTrie = Detail::Trie, ValueType, MetadataT, ValueTraits>; using MetadataType = typename DetailTrie::MetadataType; - Trie(ValueType value, MetadataType metadata) requires(!IsVoid && !IsNullPointer) + Trie(ValueType value, MetadataType metadata) + requires(!IsVoid && !IsNullPointer) : DetailTrie(move(value), move(metadata)) { } diff --git a/AK/Tuple.h b/AK/Tuple.h index 658b0863ab..46c3ba4113 100644 --- a/AK/Tuple.h +++ b/AK/Tuple.h @@ -17,12 +17,13 @@ struct Tuple { template struct Tuple { - Tuple(T&& value) requires(!IsSame) + Tuple(T&& value) + requires(!IsSame < T &&, T const& >) : value(forward(value)) { } - Tuple(const T& value) + Tuple(T const& value) : value(value) { } @@ -35,7 +36,7 @@ struct Tuple { } template - const U& get() const + U const& get() const { return const_cast&>(*this).get(); } @@ -48,7 +49,7 @@ struct Tuple { } template - const U& get_with_index() const + U const& get_with_index() const { return const_cast&>(*this).get_with_index(); } @@ -83,7 +84,7 @@ struct Tuple : Tuple { } template - const U& get() const + U const& get() const { return const_cast&>(*this).get(); } @@ -98,7 +99,7 @@ struct Tuple : Tuple { } template - const U& get_with_index() const + U const& get_with_index() const { return const_cast&>(*this).get_with_index(); } diff --git a/AK/UFixedBigInt.h b/AK/UFixedBigInt.h index 584d762cf9..22ae0129f8 100644 --- a/AK/UFixedBigInt.h +++ b/AK/UFixedBigInt.h @@ -64,7 +64,7 @@ public: { return m_low; } - constexpr const T& low() const + constexpr T const& low() const { return m_low; } @@ -72,7 +72,7 @@ public: { return m_high; } - constexpr const T& high() const + constexpr T const& high() const { return m_high; } @@ -81,9 +81,9 @@ public: { return Span(reinterpret_cast(this), sizeof(R)); } - Span bytes() const + Span bytes() const { - return Span(reinterpret_cast(this), sizeof(R)); + return Span(reinterpret_cast(this), sizeof(R)); } template @@ -93,39 +93,45 @@ public: } // Utils - constexpr size_t clz() const requires(IsSame) + constexpr size_t clz() const + requires(IsSame) { if (m_high) return count_leading_zeroes(m_high); else return sizeof(T) * 8 + count_leading_zeroes(m_low); } - constexpr size_t clz() const requires(!IsSame) + constexpr size_t clz() const + requires(!IsSame) { if (m_high) return m_high.clz(); else return sizeof(T) * 8 + m_low.clz(); } - constexpr size_t ctz() const requires(IsSame) + constexpr size_t ctz() const + requires(IsSame) { if (m_low) return count_trailing_zeroes(m_low); else return sizeof(T) * 8 + count_trailing_zeroes(m_high); } - constexpr size_t ctz() const requires(!IsSame) + constexpr size_t ctz() const + requires(!IsSame) { if (m_low) return m_low.ctz(); else return sizeof(T) * 8 + m_high.ctz(); } - constexpr size_t popcnt() const requires(IsSame) + constexpr size_t popcnt() const + requires(IsSame) { return __builtin_popcntll(m_low) + __builtin_popcntll(m_high); } - constexpr size_t popcnt() const requires(!IsSame) + constexpr size_t popcnt() const + requires(!IsSame) { return m_low.popcnt() + m_high.popcnt(); } @@ -140,59 +146,59 @@ public: return m_low || m_high; } template - requires(sizeof(T) >= sizeof(U)) constexpr bool operator==(const U& other) const + requires(sizeof(T) >= sizeof(U)) constexpr bool operator==(U const& other) const { return !m_high && m_low == other; } template - requires(sizeof(T) >= sizeof(U)) constexpr bool operator!=(const U& other) const + requires(sizeof(T) >= sizeof(U)) constexpr bool operator!=(U const& other) const { return m_high || m_low != other; } template - requires(sizeof(T) >= sizeof(U)) constexpr bool operator>(const U& other) const + requires(sizeof(T) >= sizeof(U)) constexpr bool operator>(U const& other) const { return m_high || m_low > other; } template - requires(sizeof(T) >= sizeof(U)) constexpr bool operator<(const U& other) const + requires(sizeof(T) >= sizeof(U)) constexpr bool operator<(U const& other) const { return !m_high && m_low < other; } template - requires(sizeof(T) >= sizeof(U)) constexpr bool operator>=(const U& other) const + requires(sizeof(T) >= sizeof(U)) constexpr bool operator>=(U const& other) const { return *this == other || *this > other; } template - requires(sizeof(T) >= sizeof(U)) constexpr bool operator<=(const U& other) const + requires(sizeof(T) >= sizeof(U)) constexpr bool operator<=(U const& other) const { return *this == other || *this < other; } - constexpr bool operator==(const R& other) const + constexpr bool operator==(R const& other) const { return m_low == other.low() && m_high == other.high(); } - constexpr bool operator!=(const R& other) const + constexpr bool operator!=(R const& other) const { return m_low != other.low() || m_high != other.high(); } - constexpr bool operator>(const R& other) const + constexpr bool operator>(R const& other) const { return m_high > other.high() || (m_high == other.high() && m_low > other.low()); } - constexpr bool operator<(const R& other) const + constexpr bool operator<(R const& other) const { return m_high < other.high() || (m_high == other.high() && m_low < other.low()); } - constexpr bool operator>=(const R& other) const + constexpr bool operator>=(R const& other) const { return *this == other || *this > other; } - constexpr bool operator<=(const R& other) const + constexpr bool operator<=(R const& other) const { return *this == other || *this < other; } @@ -203,22 +209,22 @@ public: return { ~m_low, ~m_high }; } template - requires(sizeof(T) >= sizeof(U)) constexpr U operator&(const U& other) const + requires(sizeof(T) >= sizeof(U)) constexpr U operator&(U const& other) const { - return static_cast(m_low) & other; + return static_cast(m_low) & other; } template - requires(sizeof(T) >= sizeof(U)) constexpr R operator|(const U& other) const + requires(sizeof(T) >= sizeof(U)) constexpr R operator|(U const& other) const { return { m_low | other, m_high }; } template - requires(sizeof(T) >= sizeof(U)) constexpr R operator^(const U& other) const + requires(sizeof(T) >= sizeof(U)) constexpr R operator^(U const& other) const { return { m_low ^ other, m_high }; } template - constexpr R operator<<(const U& shift) const + constexpr R operator<<(U const& shift) const { if (shift >= sizeof(R) * 8u) return 0u; @@ -231,7 +237,7 @@ public: return R { m_low << shift, (m_high << shift) | overflow }; } template - constexpr R operator>>(const U& shift) const + constexpr R operator>>(U const& shift) const { if (shift >= sizeof(R) * 8u) return 0u; @@ -244,75 +250,75 @@ public: return R { (m_low >> shift) | underflow, m_high >> shift }; } template - constexpr R rol(const U& shift) const + constexpr R rol(U const& shift) const { return (*this >> sizeof(T) * 8u - shift) | (*this << shift); } template - constexpr R ror(const U& shift) const + constexpr R ror(U const& shift) const { return (*this << sizeof(T) * 8u - shift) | (*this >> shift); } - constexpr R operator&(const R& other) const + constexpr R operator&(R const& other) const { return { m_low & other.low(), m_high & other.high() }; } - constexpr R operator|(const R& other) const + constexpr R operator|(R const& other) const { return { m_low | other.low(), m_high | other.high() }; } - constexpr R operator^(const R& other) const + constexpr R operator^(R const& other) const { return { m_low ^ other.low(), m_high ^ other.high() }; } // Bitwise assignment template - requires(sizeof(T) >= sizeof(U)) constexpr R& operator&=(const U& other) + requires(sizeof(T) >= sizeof(U)) constexpr R& operator&=(U const& other) { m_high = 0u; m_low &= other; return *this; } template - requires(sizeof(T) >= sizeof(U)) constexpr R& operator|=(const U& other) + requires(sizeof(T) >= sizeof(U)) constexpr R& operator|=(U const& other) { m_low |= other; return *this; } template - requires(sizeof(T) >= sizeof(U)) constexpr R& operator^=(const U& other) + requires(sizeof(T) >= sizeof(U)) constexpr R& operator^=(U const& other) { m_low ^= other; return *this; } template - constexpr R& operator>>=(const U& other) + constexpr R& operator>>=(U const& other) { *this = *this >> other; return *this; } template - constexpr R& operator<<=(const U& other) + constexpr R& operator<<=(U const& other) { *this = *this << other; return *this; } - constexpr R& operator&=(const R& other) + constexpr R& operator&=(R const& other) { m_high &= other.high(); m_low &= other.low(); return *this; } - constexpr R& operator|=(const R& other) + constexpr R& operator|=(R const& other) { m_high |= other.high(); m_low |= other.low(); return *this; } - constexpr R& operator^=(const R& other) + constexpr R& operator^=(R const& other) { m_high ^= other.high(); m_low ^= other.low(); @@ -345,7 +351,7 @@ public: }; } template - requires(my_size() > sizeof(U) && sizeof(T) > sizeof(u64)) constexpr R addc(const U& other, bool& carry) const + requires(my_size() > sizeof(U) && sizeof(T) > sizeof(u64)) constexpr R addc(U const& other, bool& carry) const { T lower = m_low.addc(other, carry); T higher = m_high.addc(0u, carry); @@ -356,7 +362,7 @@ public: }; } template - requires(IsSame&& IsSame) constexpr R addc(const U& other, bool& carry) const + requires(IsSame && IsSame) constexpr R addc(U const& other, bool& carry) const { bool low_carry = Checked::addition_would_overflow(m_low, other.low()); bool high_carry = Checked::addition_would_overflow(m_high, other.high()); @@ -376,7 +382,7 @@ public: }; } template - requires(IsSame && sizeof(T) > sizeof(u64)) constexpr R addc(const U& other, bool& carry) const + requires(IsSame && sizeof(T) > sizeof(u64)) constexpr R addc(U const& other, bool& carry) const { T lower = m_low.addc(other.low(), carry); T higher = m_high.addc(other.high(), carry); @@ -387,14 +393,14 @@ public: }; } template - requires(my_size() < sizeof(U)) constexpr U addc(const U& other, bool& carry) const + requires(my_size() < sizeof(U)) constexpr U addc(U const& other, bool& carry) const { return other.addc(*this, carry); } // FIXME: subc for sizeof(T) < sizeof(U) template - requires(sizeof(T) >= sizeof(U)) constexpr R subc(const U& other, bool& carry) const + requires(sizeof(T) >= sizeof(U)) constexpr R subc(U const& other, bool& carry) const { bool low_carry = (!m_low && carry) || (m_low - carry) < other; bool high_carry = !m_high && low_carry; @@ -405,7 +411,7 @@ public: return { lower, higher }; } - constexpr R subc(const R& other, bool& carry) const + constexpr R subc(R const& other, bool& carry) const { bool low_carry = (!m_low && carry) || (m_low - carry) < other.low(); bool high_carry = (!m_high && low_carry) || (m_high - low_carry) < other.high(); @@ -423,7 +429,7 @@ public: return addc((u8)other, carry); } template - constexpr R operator+(const U& other) const + constexpr R operator+(U const& other) const { bool carry = false; // unused return addc(other, carry); @@ -436,20 +442,20 @@ public: } template - constexpr R operator-(const U& other) const + constexpr R operator-(U const& other) const { bool carry = false; // unused return subc(other, carry); } template - constexpr R& operator+=(const U& other) + constexpr R& operator+=(U const& other) { *this = *this + other; return *this; } template - constexpr R& operator-=(const U& other) + constexpr R& operator-=(U const& other) { *this = *this - other; return *this; @@ -484,7 +490,7 @@ public: // FIXME: no restraints on this template - requires(my_size() >= sizeof(U)) constexpr R div_mod(const U& divisor, U& remainder) const + requires(my_size() >= sizeof(U)) constexpr R div_mod(U const& divisor, U& remainder) const { // FIXME: Is there a better way to raise a division by 0? // Maybe as a compiletime warning? @@ -540,7 +546,7 @@ public: } template - requires(IsSame&& IsSame) constexpr UFixedBigIntMultiplicationResult wide_multiply(U const& other) const + requires(IsSame && IsSame) constexpr UFixedBigIntMultiplicationResult wide_multiply(U const& other) const { auto mult_64_to_128 = [](u64 a, u64 b) -> UFixedBigIntMultiplicationResult { #ifdef __SIZEOF_INT128__ @@ -606,13 +612,13 @@ public: } template - constexpr R operator/(const U& other) const + constexpr R operator/(U const& other) const { U mod { 0u }; // unused return div_mod(other, mod); } template - constexpr U operator%(const U& other) const + constexpr U operator%(U const& other) const { R res { 0u }; div_mod(other, res); @@ -620,19 +626,19 @@ public: } template - constexpr R& operator*=(const U& other) + constexpr R& operator*=(U const& other) { *this = *this * other; return *this; } template - constexpr R& operator/=(const U& other) + constexpr R& operator/=(U const& other) { *this = *this / other; return *this; } template - constexpr R& operator%=(const U& other) + constexpr R& operator%=(U const& other) { *this = *this % other; return *this; @@ -763,11 +769,13 @@ public: return log2() / base.log2(); } - constexpr u64 fold_or() const requires(IsSame) + constexpr u64 fold_or() const + requires(IsSame) { return m_low | m_high; } - constexpr u64 fold_or() const requires(!IsSame) + constexpr u64 fold_or() const + requires(!IsSame) { return m_low.fold_or() | m_high.fold_or(); } @@ -776,11 +784,13 @@ public: return fold_or() == 0; } - constexpr u64 fold_xor_pair(R& other) const requires(IsSame) + constexpr u64 fold_xor_pair(R& other) const + requires(IsSame) { return (m_low ^ other.low()) | (m_high ^ other.high()); } - constexpr u64 fold_xor_pair(R& other) const requires(!IsSame) + constexpr u64 fold_xor_pair(R& other) const + requires(!IsSame) { return (m_low.fold_xor_pair(other.low())) | (m_high.fold_xor_pair(other.high())); } @@ -796,13 +806,25 @@ private: // reverse operators template -requires(sizeof(U) < sizeof(T) * 2) constexpr bool operator<(const U a, UFixedBigInt const& b) { return b >= a; } +requires(sizeof(U) < sizeof(T) * 2) constexpr bool operator<(const U a, UFixedBigInt const& b) +{ + return b >= a; +} template -requires(sizeof(U) < sizeof(T) * 2) constexpr bool operator>(const U a, UFixedBigInt const& b) { return b <= a; } +requires(sizeof(U) < sizeof(T) * 2) constexpr bool operator>(const U a, UFixedBigInt const& b) +{ + return b <= a; +} template -requires(sizeof(U) < sizeof(T) * 2) constexpr bool operator<=(const U a, UFixedBigInt const& b) { return b > a; } +requires(sizeof(U) < sizeof(T) * 2) constexpr bool operator<=(const U a, UFixedBigInt const& b) +{ + return b > a; +} template -requires(sizeof(U) < sizeof(T) * 2) constexpr bool operator>=(const U a, UFixedBigInt const& b) { return b < a; } +requires(sizeof(U) < sizeof(T) * 2) constexpr bool operator>=(const U a, UFixedBigInt const& b) +{ + return b < a; +} template struct Formatter> : StandardFormatter { diff --git a/AK/Utf16View.cpp b/AK/Utf16View.cpp index 287b006bd3..6d492edbda 100644 --- a/AK/Utf16View.cpp +++ b/AK/Utf16View.cpp @@ -21,7 +21,8 @@ static constexpr u32 replacement_code_point = 0xfffd; static constexpr u32 first_supplementary_plane_code_point = 0x10000; template -static Vector to_utf16_impl(UtfViewType const& view) requires(IsSame || IsSame) +static Vector to_utf16_impl(UtfViewType const& view) +requires(IsSame || IsSame) { Vector utf16_data; utf16_data.ensure_capacity(view.length()); diff --git a/AK/Variant.h b/AK/Variant.h index 6cc3430cfd..01e52dd6ee 100644 --- a/AK/Variant.h +++ b/AK/Variant.h @@ -97,7 +97,8 @@ struct VisitImpl { } template - ALWAYS_INLINE static constexpr decltype(auto) visit(Self& self, IndexType id, void const* data, Visitor&& visitor) requires(CurrentIndex < sizeof...(Ts)) + ALWAYS_INLINE static constexpr decltype(auto) visit(Self& self, IndexType id, void const* data, Visitor&& visitor) + requires(CurrentIndex < sizeof...(Ts)) { using T = typename TypeList::template Type; @@ -129,13 +130,15 @@ struct VariantConstructTag { template struct VariantConstructors { - ALWAYS_INLINE VariantConstructors(T&& t) requires(requires { T(move(t)); }) + ALWAYS_INLINE VariantConstructors(T&& t) + requires(requires { T(move(t)); }) { internal_cast().clear_without_destruction(); internal_cast().set(move(t), VariantNoClearTag {}); } - ALWAYS_INLINE VariantConstructors(const T& t) requires(requires { T(t); }) + ALWAYS_INLINE VariantConstructors(T const& t) + requires(requires { T(t); }) { internal_cast().clear_without_destruction(); internal_cast().set(t, VariantNoClearTag {}); @@ -216,7 +219,8 @@ struct Empty { }; template -concept NotLvalueReference = !IsLvalueReference; +concept NotLvalueReference = ! +IsLvalueReference; template struct Variant @@ -236,13 +240,15 @@ public: } template - Variant(Variant&& old) requires((can_contain() && ...)) + Variant(Variant&& old) + requires((can_contain() && ...)) : Variant(move(old).template downcast()) { } template - Variant(Variant const& old) requires((can_contain() && ...)) + Variant(Variant const& old) + requires((can_contain() && ...)) : Variant(old.template downcast()) { } @@ -250,32 +256,45 @@ public: template friend struct Variant; - Variant() requires(!can_contain()) = delete; - Variant() requires(can_contain()) + Variant() + requires(!can_contain()) + = delete; + Variant() + requires(can_contain()) : Variant(Empty()) { } #ifdef AK_HAS_CONDITIONALLY_TRIVIAL - Variant(Variant const&) requires(!(IsCopyConstructible && ...)) = delete; + Variant(Variant const&) + requires(!(IsCopyConstructible && ...)) + = delete; Variant(Variant const&) = default; - Variant(Variant&&) requires(!(IsMoveConstructible && ...)) = delete; + Variant(Variant&&) + requires(!(IsMoveConstructible && ...)) + = delete; Variant(Variant&&) = default; - ~Variant() requires(!(IsDestructible && ...)) = delete; + ~Variant() + requires(!(IsDestructible && ...)) + = delete; ~Variant() = default; - Variant& operator=(Variant const&) requires(!(IsCopyConstructible && ...) || !(IsDestructible && ...)) = delete; + Variant& operator=(Variant const&) + requires(!(IsCopyConstructible && ...) || !(IsDestructible && ...)) + = delete; Variant& operator=(Variant const&) = default; - Variant& operator=(Variant&&) requires(!(IsMoveConstructible && ...) || !(IsDestructible && ...)) = delete; + Variant& operator=(Variant&&) + requires(!(IsMoveConstructible && ...) || !(IsDestructible && ...)) + = delete; Variant& operator=(Variant&&) = default; #endif ALWAYS_INLINE Variant(Variant const& old) #ifdef AK_HAS_CONDITIONALLY_TRIVIAL - requires(!(IsTriviallyCopyConstructible && ...)) + requires(!(IsTriviallyCopyConstructible && ...)) #endif : Detail::MergeAndDeduplicatePacks>...>() , m_data {} @@ -290,7 +309,7 @@ public: // but it will still contain the "moved-from" state of the object it previously contained. ALWAYS_INLINE Variant(Variant&& old) #ifdef AK_HAS_CONDITIONALLY_TRIVIAL - requires(!(IsTriviallyMoveConstructible && ...)) + requires(!(IsTriviallyMoveConstructible && ...)) #endif : Detail::MergeAndDeduplicatePacks>...>() , m_index(old.m_index) @@ -300,7 +319,7 @@ public: ALWAYS_INLINE ~Variant() #ifdef AK_HAS_CONDITIONALLY_TRIVIAL - requires(!(IsTriviallyDestructible && ...)) + requires(!(IsTriviallyDestructible && ...)) #endif { Helper::delete_(m_index, m_data); @@ -308,7 +327,7 @@ public: ALWAYS_INLINE Variant& operator=(Variant const& other) #ifdef AK_HAS_CONDITIONALLY_TRIVIAL - requires(!(IsTriviallyCopyConstructible && ...) || !(IsTriviallyDestructible && ...)) + requires(!(IsTriviallyCopyConstructible && ...) || !(IsTriviallyDestructible && ...)) #endif { if (this != &other) { @@ -323,7 +342,7 @@ public: ALWAYS_INLINE Variant& operator=(Variant&& other) #ifdef AK_HAS_CONDITIONALLY_TRIVIAL - requires(!(IsTriviallyMoveConstructible && ...) || !(IsTriviallyDestructible && ...)) + requires(!(IsTriviallyMoveConstructible && ...) || !(IsTriviallyDestructible && ...)) #endif { if (this != &other) { @@ -339,7 +358,8 @@ public: using Detail::MergeAndDeduplicatePacks>...>::MergeAndDeduplicatePacks; template> - void set(T&& t) requires(can_contain() && requires { StrippedT(forward(t)); }) + void set(T&& t) + requires(can_contain() && requires { StrippedT(forward(t)); }) { constexpr auto new_index = index_of(); Helper::delete_(m_index, m_data); @@ -348,7 +368,8 @@ public: } template> - void set(T&& t, Detail::VariantNoClearTag) requires(can_contain() && requires { StrippedT(forward(t)); }) + void set(T&& t, Detail::VariantNoClearTag) + requires(can_contain() && requires { StrippedT(forward(t)); }) { constexpr auto new_index = index_of(); new (m_data) StrippedT(forward(t)); @@ -356,7 +377,8 @@ public: } template - T* get_pointer() requires(can_contain()) + T* get_pointer() + requires(can_contain()) { if (index_of() == m_index) return bit_cast(&m_data); @@ -364,29 +386,33 @@ public: } template - T& get() requires(can_contain()) + T& get() + requires(can_contain()) { VERIFY(has()); return *bit_cast(&m_data); } template - const T* get_pointer() const requires(can_contain()) + T const* get_pointer() const + requires(can_contain()) { if (index_of() == m_index) - return bit_cast(&m_data); + return bit_cast(&m_data); return nullptr; } template - const T& get() const requires(can_contain()) + T const& get() const + requires(can_contain()) { VERIFY(has()); - return *bit_cast(&m_data); + return *bit_cast(&m_data); } template - [[nodiscard]] bool has() const requires(can_contain()) + [[nodiscard]] bool has() const + requires(can_contain()) { return index_of() == m_index; } diff --git a/AK/Vector.h b/AK/Vector.h index 8ccbaf3a1d..4031f6ec5b 100644 --- a/AK/Vector.h +++ b/AK/Vector.h @@ -31,13 +31,13 @@ struct CanBePlacedInsideVectorHelper; template struct CanBePlacedInsideVectorHelper { template - static constexpr bool value = requires(U&& u) { StorageType { &u }; }; + static constexpr bool value = requires(U && u) { StorageType { &u }; }; }; template struct CanBePlacedInsideVectorHelper { template - static constexpr bool value = requires(U&& u) { StorageType(forward(u)); }; + static constexpr bool value = requires(U && u) { StorageType(forward(u)); }; }; } @@ -59,7 +59,8 @@ public: { } - Vector(std::initializer_list list) requires(!IsLvalueReference) + Vector(std::initializer_list list) + requires(!IsLvalueReference) { ensure_capacity(list.size()); for (auto& item : list) @@ -89,7 +90,8 @@ public: m_size = other.size(); } - explicit Vector(Span other) requires(!IsLvalueReference) + explicit Vector(Span other) + requires(!IsLvalueReference) { ensure_capacity(other.size()); TypedTransfer::copy(data(), other.data(), other.size()); @@ -161,7 +163,8 @@ public: VisibleType& last() { return at(size() - 1); } template - Optional first_matching(TUnaryPredicate const& predicate) requires(!contains_reference) + Optional first_matching(TUnaryPredicate const& predicate) + requires(!contains_reference) { for (size_t i = 0; i < size(); ++i) { if (predicate(at(i))) { @@ -172,7 +175,8 @@ public: } template - Optional first_matching(TUnaryPredicate const& predicate) const requires(!contains_reference) + Optional first_matching(TUnaryPredicate const& predicate) const + requires(!contains_reference) { for (size_t i = 0; i < size(); ++i) { if (predicate(at(i))) { @@ -183,7 +187,8 @@ public: } template - Optional last_matching(TUnaryPredicate const& predicate) requires(!contains_reference) + Optional last_matching(TUnaryPredicate const& predicate) + requires(!contains_reference) { for (ssize_t i = size() - 1; i >= 0; --i) { if (predicate(at(i))) { @@ -225,13 +230,15 @@ public: #ifndef KERNEL template - void insert(size_t index, U&& value) requires(CanBePlacedInsideVector) + void insert(size_t index, U&& value) + requires(CanBePlacedInsideVector) { MUST(try_insert(index, forward(value))); } template - void insert_before_matching(U&& value, TUnaryPredicate const& predicate, size_t first_index = 0, size_t* inserted_index = nullptr) requires(CanBePlacedInsideVector) + void insert_before_matching(U&& value, TUnaryPredicate const& predicate, size_t first_index = 0, size_t* inserted_index = nullptr) + requires(CanBePlacedInsideVector) { MUST(try_insert_before_matching(forward(value), predicate, first_index, inserted_index)); } @@ -256,7 +263,8 @@ public: MUST(try_append(move(value))); } - ALWAYS_INLINE void append(T const& value) requires(!contains_reference) + ALWAYS_INLINE void append(T const& value) + requires(!contains_reference) { MUST(try_append(T(value))); } @@ -269,7 +277,8 @@ public: #endif template - ALWAYS_INLINE void unchecked_append(U&& value) requires(CanBePlacedInsideVector) + ALWAYS_INLINE void unchecked_append(U&& value) + requires(CanBePlacedInsideVector) { VERIFY((size() + 1) <= capacity()); if constexpr (contains_reference) @@ -290,13 +299,15 @@ public: #ifndef KERNEL template - void empend(Args&&... args) requires(!contains_reference) + void empend(Args&&... args) + requires(!contains_reference) { MUST(try_empend(forward(args)...)); } template - void prepend(U&& value) requires(CanBePlacedInsideVector) + void prepend(U&& value) + requires(CanBePlacedInsideVector) { MUST(try_insert(0, forward(value))); } @@ -481,7 +492,8 @@ public: } template - ErrorOr try_insert(size_t index, U&& value) requires(CanBePlacedInsideVector) + ErrorOr try_insert(size_t index, U&& value) + requires(CanBePlacedInsideVector) { if (index > size()) return Error::from_errno(EINVAL); @@ -505,7 +517,8 @@ public: } template - ErrorOr try_insert_before_matching(U&& value, TUnaryPredicate const& predicate, size_t first_index = 0, size_t* inserted_index = nullptr) requires(CanBePlacedInsideVector) + ErrorOr try_insert_before_matching(U&& value, TUnaryPredicate const& predicate, size_t first_index = 0, size_t* inserted_index = nullptr) + requires(CanBePlacedInsideVector) { for (size_t i = first_index; i < size(); ++i) { if (predicate(at(i))) { @@ -554,7 +567,8 @@ public: return {}; } - ErrorOr try_append(T const& value) requires(!contains_reference) + ErrorOr try_append(T const& value) + requires(!contains_reference) { return try_append(T(value)); } @@ -570,7 +584,8 @@ public: } template - ErrorOr try_empend(Args&&... args) requires(!contains_reference) + ErrorOr try_empend(Args&&... args) + requires(!contains_reference) { TRY(try_grow_capacity(m_size + 1)); new (slot(m_size)) StorageType { forward(args)... }; @@ -579,7 +594,8 @@ public: } template - ErrorOr try_prepend(U&& value) requires(CanBePlacedInsideVector) + ErrorOr try_prepend(U&& value) + requires(CanBePlacedInsideVector) { return try_insert(0, forward(value)); } @@ -650,7 +666,8 @@ public: return {}; } - ErrorOr try_resize(size_t new_size, bool keep_capacity = false) requires(!contains_reference) + ErrorOr try_resize(size_t new_size, bool keep_capacity = false) + requires(!contains_reference) { if (new_size <= size()) { shrink(new_size, keep_capacity); @@ -665,7 +682,8 @@ public: return {}; } - ErrorOr try_resize_and_keep_capacity(size_t new_size) requires(!contains_reference) + ErrorOr try_resize_and_keep_capacity(size_t new_size) + requires(!contains_reference) { return try_resize(new_size, true); } @@ -699,12 +717,14 @@ public: m_size = new_size; } - void resize(size_t new_size, bool keep_capacity = false) requires(!contains_reference) + void resize(size_t new_size, bool keep_capacity = false) + requires(!contains_reference) { MUST(try_resize(new_size, keep_capacity)); } - void resize_and_keep_capacity(size_t new_size) requires(!contains_reference) + void resize_and_keep_capacity(size_t new_size) + requires(!contains_reference) { MUST(try_resize_and_keep_capacity(new_size)); } diff --git a/AK/WeakPtr.h b/AK/WeakPtr.h index e7b02005d6..c6d3dc545d 100644 --- a/AK/WeakPtr.h +++ b/AK/WeakPtr.h @@ -19,26 +19,30 @@ public: WeakPtr() = default; template - WeakPtr(WeakPtr const& other) requires(IsBaseOf) + WeakPtr(WeakPtr const& other) + requires(IsBaseOf) : m_link(other.m_link) { } template - WeakPtr(WeakPtr&& other) requires(IsBaseOf) + WeakPtr(WeakPtr&& other) + requires(IsBaseOf) : m_link(other.take_link()) { } template - WeakPtr& operator=(WeakPtr&& other) requires(IsBaseOf) + WeakPtr& operator=(WeakPtr&& other) + requires(IsBaseOf) { m_link = other.take_link(); return *this; } template - WeakPtr& operator=(WeakPtr const& other) requires(IsBaseOf) + WeakPtr& operator=(WeakPtr const& other) + requires(IsBaseOf) { if ((void const*)this != (void const*)&other) m_link = other.m_link; @@ -52,40 +56,46 @@ public: } template - WeakPtr(const U& object) requires(IsBaseOf) + WeakPtr(U const& object) + requires(IsBaseOf) : m_link(object.template make_weak_ptr().take_link()) { } template - WeakPtr(const U* object) requires(IsBaseOf) + WeakPtr(U const* object) + requires(IsBaseOf) { if (object) m_link = object->template make_weak_ptr().take_link(); } template - WeakPtr(RefPtr const& object) requires(IsBaseOf) + WeakPtr(RefPtr const& object) + requires(IsBaseOf) { if (object) m_link = object->template make_weak_ptr().take_link(); } template - WeakPtr(NonnullRefPtr const& object) requires(IsBaseOf) + WeakPtr(NonnullRefPtr const& object) + requires(IsBaseOf) { m_link = object->template make_weak_ptr().take_link(); } template - WeakPtr& operator=(const U& object) requires(IsBaseOf) + WeakPtr& operator=(U const& object) + requires(IsBaseOf) { m_link = object.template make_weak_ptr().take_link(); return *this; } template - WeakPtr& operator=(const U* object) requires(IsBaseOf) + WeakPtr& operator=(U const* object) + requires(IsBaseOf) { if (object) m_link = object->template make_weak_ptr().take_link(); @@ -95,7 +105,8 @@ public: } template - WeakPtr& operator=(RefPtr const& object) requires(IsBaseOf) + WeakPtr& operator=(RefPtr const& object) + requires(IsBaseOf) { if (object) m_link = object->template make_weak_ptr().take_link(); @@ -105,7 +116,8 @@ public: } template - WeakPtr& operator=(NonnullRefPtr const& object) requires(IsBaseOf) + WeakPtr& operator=(NonnullRefPtr const& object) + requires(IsBaseOf) { m_link = object->template make_weak_ptr().take_link(); return *this; @@ -154,10 +166,10 @@ inline ErrorOr> Weakable::try_make_weak_ptr() const } template -struct Formatter> : Formatter { +struct Formatter> : Formatter { ErrorOr format(FormatBuilder& builder, WeakPtr const& value) { - return Formatter::format(builder, value.ptr()); + return Formatter::format(builder, value.ptr()); } }; diff --git a/AK/Weakable.h b/AK/Weakable.h index 8a56dc90f2..38999445f1 100644 --- a/AK/Weakable.h +++ b/AK/Weakable.h @@ -27,7 +27,7 @@ class WeakLink : public RefCounted { public: template RefPtr strong_ref() const - requires(IsBaseOf) + requires(IsBaseOf) { return static_cast(m_ptr); } diff --git a/Kernel/Devices/DeviceManagement.h b/Kernel/Devices/DeviceManagement.h index d6627971b5..e486189c96 100644 --- a/Kernel/Devices/DeviceManagement.h +++ b/Kernel/Devices/DeviceManagement.h @@ -54,7 +54,8 @@ public: ConsoleDevice& console_device(); template - static inline ErrorOr> try_create_device(Args&&... args) requires(requires(Args... args) { DeviceType::try_create(args...); }) + static inline ErrorOr> try_create_device(Args&&... args) + requires(requires(Args... args) { DeviceType::try_create(args...); }) { auto device = TRY(DeviceType::try_create(forward(args)...)); device->after_inserting(); diff --git a/Kernel/Graphics/VMWare/GraphicsAdapter.cpp b/Kernel/Graphics/VMWare/GraphicsAdapter.cpp index ceddafb8ef..8bd413a298 100644 --- a/Kernel/Graphics/VMWare/GraphicsAdapter.cpp +++ b/Kernel/Graphics/VMWare/GraphicsAdapter.cpp @@ -76,7 +76,7 @@ UNMAP_AFTER_INIT ErrorOr VMWareGraphicsAdapter::initialize_fifo_registers( return Error::from_errno(ENOTSUP); } - m_fifo_registers = TRY(Memory::map_typed(fifo_physical_address, fifo_size, Memory::Region::Access::ReadWrite)); + m_fifo_registers = TRY(Memory::map_typed(fifo_physical_address, fifo_size, Memory::Region::Access::ReadWrite)); m_fifo_registers->start = 16; m_fifo_registers->size = 16 + (10 * 1024); m_fifo_registers->next_command = 16; diff --git a/Kernel/Graphics/VMWare/GraphicsAdapter.h b/Kernel/Graphics/VMWare/GraphicsAdapter.h index ae27a30d25..9f414dadb8 100644 --- a/Kernel/Graphics/VMWare/GraphicsAdapter.h +++ b/Kernel/Graphics/VMWare/GraphicsAdapter.h @@ -48,7 +48,7 @@ private: VMWareGraphicsAdapter(PCI::DeviceIdentifier const&, NonnullOwnPtr registers_io_window); - Memory::TypedMapping m_fifo_registers; + Memory::TypedMapping m_fifo_registers; LockRefPtr m_display_connector; mutable NonnullOwnPtr m_registers_io_window; mutable Spinlock m_io_access_lock { LockRank::None }; diff --git a/Kernel/Heap/kmalloc.h b/Kernel/Heap/kmalloc.h index adb698fb18..5eb721b2dd 100644 --- a/Kernel/Heap/kmalloc.h +++ b/Kernel/Heap/kmalloc.h @@ -13,17 +13,23 @@ #define KMALLOC_SCRUB_BYTE 0xbb #define KFREE_SCRUB_BYTE 0xaa -#define MAKE_ALIGNED_ALLOCATED(type, alignment) \ -public: \ - [[nodiscard]] void* operator new(size_t) \ - { \ - void* ptr = kmalloc_aligned(sizeof(type), alignment); \ - VERIFY(ptr); \ - return ptr; \ - } \ - [[nodiscard]] void* operator new(size_t, std::nothrow_t const&) noexcept { return kmalloc_aligned(sizeof(type), alignment); } \ - void operator delete(void* ptr) noexcept { kfree_aligned(ptr); } \ - \ +#define MAKE_ALIGNED_ALLOCATED(type, alignment) \ +public: \ + [[nodiscard]] void* operator new(size_t) \ + { \ + void* ptr = kmalloc_aligned(sizeof(type), alignment); \ + VERIFY(ptr); \ + return ptr; \ + } \ + [[nodiscard]] void* operator new(size_t, std::nothrow_t const&) noexcept \ + { \ + return kmalloc_aligned(sizeof(type), alignment); \ + } \ + void operator delete(void* ptr) noexcept \ + { \ + kfree_aligned(ptr); \ + } \ + \ private: // The C++ standard specifies that the nothrow allocation tag should live in the std namespace. diff --git a/Kernel/IOWindow.cpp b/Kernel/IOWindow.cpp index fd0920d78c..69e3a015ea 100644 --- a/Kernel/IOWindow.cpp +++ b/Kernel/IOWindow.cpp @@ -53,7 +53,7 @@ ErrorOr> IOWindow::create_from_io_window_with_offset(u64 return Error::from_errno(EOVERFLOW); #endif - auto memory_mapped_range = TRY(Memory::adopt_new_nonnull_own_typed_mapping(m_memory_mapped_range->paddr.offset(offset), space_length, Memory::Region::Access::ReadWrite)); + auto memory_mapped_range = TRY(Memory::adopt_new_nonnull_own_typed_mapping(m_memory_mapped_range->paddr.offset(offset), space_length, Memory::Region::Access::ReadWrite)); return TRY(adopt_nonnull_own_or_enomem(new (nothrow) IOWindow(move(memory_mapped_range)))); } @@ -110,7 +110,7 @@ ErrorOr> IOWindow::create_for_pci_device_bar(PCI::Addres return Error::from_errno(EOVERFLOW); if (pci_bar_space_type == PCI::BARSpaceType::Memory64BitSpace && Checked::addition_would_overflow(pci_bar_value, space_length)) return Error::from_errno(EOVERFLOW); - auto memory_mapped_range = TRY(Memory::adopt_new_nonnull_own_typed_mapping(PhysicalAddress(pci_bar_value & 0xfffffff0), space_length, Memory::Region::Access::ReadWrite)); + auto memory_mapped_range = TRY(Memory::adopt_new_nonnull_own_typed_mapping(PhysicalAddress(pci_bar_value & 0xfffffff0), space_length, Memory::Region::Access::ReadWrite)); return TRY(adopt_nonnull_own_or_enomem(new (nothrow) IOWindow(move(memory_mapped_range)))); } @@ -131,7 +131,7 @@ ErrorOr> IOWindow::create_for_pci_device_bar(PCI::Device return create_for_pci_device_bar(pci_device_identifier.address(), pci_bar, space_length); } -IOWindow::IOWindow(NonnullOwnPtr> memory_mapped_range) +IOWindow::IOWindow(NonnullOwnPtr> memory_mapped_range) : m_space_type(SpaceType::Memory) , m_memory_mapped_range(move(memory_mapped_range)) { diff --git a/Kernel/IOWindow.h b/Kernel/IOWindow.h index 89927f2b01..37650fc7df 100644 --- a/Kernel/IOWindow.h +++ b/Kernel/IOWindow.h @@ -75,7 +75,7 @@ public: #endif private: - explicit IOWindow(NonnullOwnPtr>); + explicit IOWindow(NonnullOwnPtr>); u8 volatile* as_memory_address_pointer(); @@ -116,7 +116,7 @@ private: // can cause problems with strict bare metal hardware. For example, some XHCI USB controllers // might completely lock up because of an unaligned memory access to their registers. VERIFY((start_offset % sizeof(T)) == 0); - data = *(volatile T*)(as_memory_address_pointer() + start_offset); + data = *(T volatile*)(as_memory_address_pointer() + start_offset); } template @@ -135,12 +135,12 @@ private: // can cause problems with strict bare metal hardware. For example, some XHCI USB controllers // might completely lock up because of an unaligned memory access to their registers. VERIFY((start_offset % sizeof(T)) == 0); - *(volatile T*)(as_memory_address_pointer() + start_offset) = value; + *(T volatile*)(as_memory_address_pointer() + start_offset) = value; } SpaceType m_space_type { SpaceType::Memory }; - OwnPtr> m_memory_mapped_range; + OwnPtr> m_memory_mapped_range; #if ARCH(I386) || ARCH(X86_64) OwnPtr m_io_range; diff --git a/Kernel/Library/LockRefPtr.h b/Kernel/Library/LockRefPtr.h index 90f5889a8d..4222e17e4f 100644 --- a/Kernel/Library/LockRefPtr.h +++ b/Kernel/Library/LockRefPtr.h @@ -129,12 +129,12 @@ public: }; LockRefPtr() = default; - LockRefPtr(const T* ptr) + LockRefPtr(T const* ptr) : m_bits(PtrTraits::as_bits(const_cast(ptr))) { ref_if_not_null(const_cast(ptr)); } - LockRefPtr(const T& object) + LockRefPtr(T const& object) : m_bits(PtrTraits::as_bits(const_cast(&object))) { T* ptr = const_cast(&object); @@ -156,18 +156,21 @@ public: { } template - ALWAYS_INLINE LockRefPtr(NonnullLockRefPtr const& other) requires(IsConvertible) + ALWAYS_INLINE LockRefPtr(NonnullLockRefPtr const& other) + requires(IsConvertible) : m_bits(PtrTraits::as_bits(const_cast(other.add_ref()))) { } template - ALWAYS_INLINE LockRefPtr(NonnullLockRefPtr&& other) requires(IsConvertible) + ALWAYS_INLINE LockRefPtr(NonnullLockRefPtr&& other) + requires(IsConvertible) : m_bits(PtrTraits::as_bits(&other.leak_ref())) { VERIFY(!is_null()); } template> - LockRefPtr(LockRefPtr&& other) requires(IsConvertible) + LockRefPtr(LockRefPtr&& other) + requires(IsConvertible) : m_bits(PtrTraits::template convert_from(other.leak_ref_raw())) { } @@ -176,7 +179,8 @@ public: { } template> - LockRefPtr(LockRefPtr const& other) requires(IsConvertible) + LockRefPtr(LockRefPtr const& other) + requires(IsConvertible) : m_bits(other.add_ref_raw()) { } @@ -205,7 +209,8 @@ public: } template> - void swap(LockRefPtr& other) requires(IsConvertible) + void swap(LockRefPtr& other) + requires(IsConvertible) { // NOTE: swap is not atomic! FlatPtr other_bits = P::exchange(other.m_bits, P::default_null_value); @@ -221,14 +226,16 @@ public: } template> - ALWAYS_INLINE LockRefPtr& operator=(LockRefPtr&& other) requires(IsConvertible) + ALWAYS_INLINE LockRefPtr& operator=(LockRefPtr&& other) + requires(IsConvertible) { assign_raw(PtrTraits::template convert_from(other.leak_ref_raw())); return *this; } template - ALWAYS_INLINE LockRefPtr& operator=(NonnullLockRefPtr&& other) requires(IsConvertible) + ALWAYS_INLINE LockRefPtr& operator=(NonnullLockRefPtr&& other) + requires(IsConvertible) { assign_raw(PtrTraits::as_bits(&other.leak_ref())); return *this; @@ -241,7 +248,8 @@ public: } template - ALWAYS_INLINE LockRefPtr& operator=(NonnullLockRefPtr const& other) requires(IsConvertible) + ALWAYS_INLINE LockRefPtr& operator=(NonnullLockRefPtr const& other) + requires(IsConvertible) { assign_raw(PtrTraits::as_bits(other.add_ref())); return *this; @@ -255,20 +263,21 @@ public: } template - ALWAYS_INLINE LockRefPtr& operator=(LockRefPtr const& other) requires(IsConvertible) + ALWAYS_INLINE LockRefPtr& operator=(LockRefPtr const& other) + requires(IsConvertible) { assign_raw(other.add_ref_raw()); return *this; } - ALWAYS_INLINE LockRefPtr& operator=(const T* ptr) + ALWAYS_INLINE LockRefPtr& operator=(T const* ptr) { ref_if_not_null(const_cast(ptr)); assign_raw(PtrTraits::as_bits(const_cast(ptr))); return *this; } - ALWAYS_INLINE LockRefPtr& operator=(const T& object) + ALWAYS_INLINE LockRefPtr& operator=(T const& object) { const_cast(object).ref(); assign_raw(PtrTraits::as_bits(const_cast(&object))); @@ -317,14 +326,14 @@ public: } ALWAYS_INLINE T* ptr() { return as_ptr(); } - ALWAYS_INLINE const T* ptr() const { return as_ptr(); } + ALWAYS_INLINE T const* ptr() const { return as_ptr(); } ALWAYS_INLINE T* operator->() { return as_nonnull_ptr(); } - ALWAYS_INLINE const T* operator->() const + ALWAYS_INLINE T const* operator->() const { return as_nonnull_ptr(); } @@ -334,12 +343,12 @@ public: return *as_nonnull_ptr(); } - ALWAYS_INLINE const T& operator*() const + ALWAYS_INLINE T const& operator*() const { return *as_nonnull_ptr(); } - ALWAYS_INLINE operator const T*() const { return as_ptr(); } + ALWAYS_INLINE operator T const*() const { return as_ptr(); } ALWAYS_INLINE operator T*() { return as_ptr(); } ALWAYS_INLINE operator bool() { return !is_null(); } @@ -353,8 +362,8 @@ public: bool operator==(LockRefPtr& other) { return as_ptr() == other.as_ptr(); } bool operator!=(LockRefPtr& other) { return as_ptr() != other.as_ptr(); } - bool operator==(const T* other) const { return as_ptr() == other; } - bool operator!=(const T* other) const { return as_ptr() != other; } + bool operator==(T const* other) const { return as_ptr() == other; } + bool operator!=(T const* other) const { return as_ptr() != other; } bool operator==(T* other) { return as_ptr() == other; } bool operator!=(T* other) { return as_ptr() != other; } @@ -363,7 +372,7 @@ public: template typename PtrTraits::NullType null_value() const - requires(IsSame && !IsNullPointer) + requires(IsSame && !IsNullPointer) { // make sure we are holding a null value FlatPtr bits = m_bits.load(AK::MemoryOrder::memory_order_relaxed); @@ -371,7 +380,8 @@ public: return PtrTraits::to_null_value(bits); } template - void set_null_value(typename PtrTraits::NullType value) requires(IsSame && !IsNullPointer) + void set_null_value(typename PtrTraits::NullType value) + requires(IsSame && !IsNullPointer) { // make sure that new null value would be interpreted as a null value FlatPtr bits = PtrTraits::from_null_value(value); @@ -445,17 +455,17 @@ private: }; template -struct Formatter> : Formatter { +struct Formatter> : Formatter { ErrorOr format(FormatBuilder& builder, LockRefPtr const& value) { - return Formatter::format(builder, value.ptr()); + return Formatter::format(builder, value.ptr()); } }; template struct Traits> : public GenericTraits> { using PeekType = T*; - using ConstPeekType = const T*; + using ConstPeekType = T const*; static unsigned hash(LockRefPtr const& p) { return ptr_hash(p.ptr()); } static bool equals(LockRefPtr const& a, LockRefPtr const& b) { return a.ptr() == b.ptr(); } }; @@ -463,17 +473,18 @@ struct Traits> : public GenericTraits> { template inline NonnullLockRefPtr static_ptr_cast(NonnullLockRefPtr const& ptr) { - return NonnullLockRefPtr(static_cast(*ptr)); + return NonnullLockRefPtr(static_cast(*ptr)); } template> inline LockRefPtr static_ptr_cast(LockRefPtr const& ptr) { - return LockRefPtr(static_cast(ptr.ptr())); + return LockRefPtr(static_cast(ptr.ptr())); } template -inline void swap(LockRefPtr& a, LockRefPtr& b) requires(IsConvertible) +inline void swap(LockRefPtr& a, LockRefPtr& b) +requires(IsConvertible) { a.swap(b); } diff --git a/Kernel/Library/LockWeakPtr.h b/Kernel/Library/LockWeakPtr.h index 3b63864ce2..184be112f3 100644 --- a/Kernel/Library/LockWeakPtr.h +++ b/Kernel/Library/LockWeakPtr.h @@ -19,26 +19,30 @@ public: LockWeakPtr() = default; template - LockWeakPtr(WeakPtr const& other) requires(IsBaseOf) + LockWeakPtr(WeakPtr const& other) + requires(IsBaseOf) : m_link(other.m_link) { } template - LockWeakPtr(WeakPtr&& other) requires(IsBaseOf) + LockWeakPtr(WeakPtr&& other) + requires(IsBaseOf) : m_link(other.take_link()) { } template - LockWeakPtr& operator=(WeakPtr&& other) requires(IsBaseOf) + LockWeakPtr& operator=(WeakPtr&& other) + requires(IsBaseOf) { m_link = other.take_link(); return *this; } template - LockWeakPtr& operator=(WeakPtr const& other) requires(IsBaseOf) + LockWeakPtr& operator=(WeakPtr const& other) + requires(IsBaseOf) { if ((void const*)this != (void const*)&other) m_link = other.m_link; @@ -52,20 +56,23 @@ public: } template - LockWeakPtr(const U& object) requires(IsBaseOf) + LockWeakPtr(U const& object) + requires(IsBaseOf) : m_link(object.template try_make_weak_ptr().release_value_but_fixme_should_propagate_errors().take_link()) { } template - LockWeakPtr(const U* object) requires(IsBaseOf) + LockWeakPtr(U const* object) + requires(IsBaseOf) { if (object) m_link = object->template try_make_weak_ptr().release_value_but_fixme_should_propagate_errors().take_link(); } template - LockWeakPtr(LockRefPtr const& object) requires(IsBaseOf) + LockWeakPtr(LockRefPtr const& object) + requires(IsBaseOf) { object.do_while_locked([&](U* obj) { if (obj) @@ -74,7 +81,8 @@ public: } template - LockWeakPtr(NonnullLockRefPtr const& object) requires(IsBaseOf) + LockWeakPtr(NonnullLockRefPtr const& object) + requires(IsBaseOf) { object.do_while_locked([&](U* obj) { if (obj) @@ -83,14 +91,16 @@ public: } template - LockWeakPtr& operator=(const U& object) requires(IsBaseOf) + LockWeakPtr& operator=(U const& object) + requires(IsBaseOf) { m_link = object.template try_make_weak_ptr().release_value_but_fixme_should_propagate_errors().take_link(); return *this; } template - LockWeakPtr& operator=(const U* object) requires(IsBaseOf) + LockWeakPtr& operator=(U const* object) + requires(IsBaseOf) { if (object) m_link = object->template try_make_weak_ptr().release_value_but_fixme_should_propagate_errors().take_link(); @@ -100,7 +110,8 @@ public: } template - LockWeakPtr& operator=(LockRefPtr const& object) requires(IsBaseOf) + LockWeakPtr& operator=(LockRefPtr const& object) + requires(IsBaseOf) { object.do_while_locked([&](U* obj) { if (obj) @@ -112,7 +123,8 @@ public: } template - LockWeakPtr& operator=(NonnullLockRefPtr const& object) requires(IsBaseOf) + LockWeakPtr& operator=(NonnullLockRefPtr const& object) + requires(IsBaseOf) { object.do_while_locked([&](U* obj) { if (obj) @@ -175,7 +187,7 @@ inline ErrorOr> LockWeakable::try_make_weak_ptr() const // to add a ref (which should fail if the ref count is at 0) so // that we prevent the destructor and revoke_weak_ptrs from being // triggered until we're done. - if (!static_cast(this)->try_ref()) + if (!static_cast(this)->try_ref()) return LockWeakPtr {}; } else { // For non-RefCounted types this means a weak reference can be @@ -187,14 +199,14 @@ inline ErrorOr> LockWeakable::try_make_weak_ptr() const // There is a small chance that we create a new WeakLink and throw // it away because another thread beat us to it. But the window is // pretty small and the overhead isn't terrible. - m_link.assign_if_null(TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) WeakLink(const_cast(static_cast(*this)))))); + m_link.assign_if_null(TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) WeakLink(const_cast(static_cast(*this)))))); } LockWeakPtr weak_ptr(m_link); if constexpr (IsBaseOf) { // Now drop the reference we temporarily added - if (static_cast(this)->unref()) { + if (static_cast(this)->unref()) { // We just dropped the last reference, which should have called // revoke_weak_ptrs, which should have invalidated our weak_ptr VERIFY(!weak_ptr.strong_ref()); @@ -205,11 +217,11 @@ inline ErrorOr> LockWeakable::try_make_weak_ptr() const } template -struct Formatter> : Formatter { +struct Formatter> : Formatter { ErrorOr format(FormatBuilder& builder, LockWeakPtr const& value) { auto ref = value.strong_ref(); - return Formatter::format(builder, ref.ptr()); + return Formatter::format(builder, ref.ptr()); } }; diff --git a/Kernel/Library/LockWeakable.h b/Kernel/Library/LockWeakable.h index ed3e4367d5..0c3776ed72 100644 --- a/Kernel/Library/LockWeakable.h +++ b/Kernel/Library/LockWeakable.h @@ -30,7 +30,7 @@ class WeakLink final : public AtomicRefCounted { public: template> LockRefPtr strong_ref() const - requires(IsBaseOf) + requires(IsBaseOf) { LockRefPtr ref; diff --git a/Kernel/Library/NonnullLockRefPtr.h b/Kernel/Library/NonnullLockRefPtr.h index 44289a3b55..685b6dfe8d 100644 --- a/Kernel/Library/NonnullLockRefPtr.h +++ b/Kernel/Library/NonnullLockRefPtr.h @@ -47,7 +47,8 @@ public: const_cast(object).ref(); } template - ALWAYS_INLINE NonnullLockRefPtr(U const& object) requires(IsConvertible) + ALWAYS_INLINE NonnullLockRefPtr(U const& object) + requires(IsConvertible) : m_bits((FlatPtr) static_cast(&object)) { VERIFY(!(m_bits & 1)); @@ -64,7 +65,8 @@ public: VERIFY(!(m_bits & 1)); } template - ALWAYS_INLINE NonnullLockRefPtr(NonnullLockRefPtr&& other) requires(IsConvertible) + ALWAYS_INLINE NonnullLockRefPtr(NonnullLockRefPtr&& other) + requires(IsConvertible) : m_bits((FlatPtr)&other.leak_ref()) { VERIFY(!(m_bits & 1)); @@ -75,7 +77,8 @@ public: VERIFY(!(m_bits & 1)); } template - ALWAYS_INLINE NonnullLockRefPtr(NonnullLockRefPtr const& other) requires(IsConvertible) + ALWAYS_INLINE NonnullLockRefPtr(NonnullLockRefPtr const& other) + requires(IsConvertible) : m_bits((FlatPtr)other.add_ref()) { VERIFY(!(m_bits & 1)); @@ -108,7 +111,8 @@ public: } template - NonnullLockRefPtr& operator=(NonnullLockRefPtr const& other) requires(IsConvertible) + NonnullLockRefPtr& operator=(NonnullLockRefPtr const& other) + requires(IsConvertible) { assign(other.add_ref()); return *this; @@ -122,7 +126,8 @@ public: } template - NonnullLockRefPtr& operator=(NonnullLockRefPtr&& other) requires(IsConvertible) + NonnullLockRefPtr& operator=(NonnullLockRefPtr&& other) + requires(IsConvertible) { assign(&other.leak_ref()); return *this; @@ -202,7 +207,8 @@ public: } template - void swap(NonnullLockRefPtr& other) requires(IsConvertible) + void swap(NonnullLockRefPtr& other) + requires(IsConvertible) { // NOTE: swap is not atomic! U* other_ptr = other.exchange(nullptr); @@ -318,7 +324,8 @@ struct Formatter> : Formatter { }; template -inline void swap(NonnullLockRefPtr& a, NonnullLockRefPtr& b) requires(IsConvertible) +inline void swap(NonnullLockRefPtr& a, NonnullLockRefPtr& b) +requires(IsConvertible) { a.swap(b); } diff --git a/Kernel/Locking/MutexProtected.h b/Kernel/Locking/MutexProtected.h index 9271d3edfb..d8742601b5 100644 --- a/Kernel/Locking/MutexProtected.h +++ b/Kernel/Locking/MutexProtected.h @@ -32,11 +32,23 @@ private: ALWAYS_INLINE U const* operator->() const { return &m_value; } ALWAYS_INLINE U const& operator*() const { return m_value; } - ALWAYS_INLINE U* operator->() requires(!IsConst) { return &m_value; } - ALWAYS_INLINE U& operator*() requires(!IsConst) { return m_value; } + ALWAYS_INLINE U* operator->() + requires(!IsConst) + { + return &m_value; + } + ALWAYS_INLINE U& operator*() + requires(!IsConst) + { + return m_value; + } ALWAYS_INLINE U const& get() const { return &m_value; } - ALWAYS_INLINE U& get() requires(!IsConst) { return &m_value; } + ALWAYS_INLINE U& get() + requires(!IsConst) + { + return &m_value; + } private: U& m_value; diff --git a/Kernel/Memory/TypedMapping.h b/Kernel/Memory/TypedMapping.h index 4412357579..ab2c82d801 100644 --- a/Kernel/Memory/TypedMapping.h +++ b/Kernel/Memory/TypedMapping.h @@ -15,12 +15,12 @@ namespace Kernel::Memory { template struct TypedMapping { - const T* ptr() const { return reinterpret_cast(region->vaddr().offset(offset).as_ptr()); } + T const* ptr() const { return reinterpret_cast(region->vaddr().offset(offset).as_ptr()); } T* ptr() { return reinterpret_cast(region->vaddr().offset(offset).as_ptr()); } VirtualAddress base_address() const { return region->vaddr().offset(offset); } - const T* operator->() const { return ptr(); } + T const* operator->() const { return ptr(); } T* operator->() { return ptr(); } - const T& operator*() const { return *ptr(); } + T const& operator*() const { return *ptr(); } T& operator*() { return *ptr(); } OwnPtr region; PhysicalAddress paddr; diff --git a/Kernel/Random.h b/Kernel/Random.h index 1fd2b0e3d7..b5cb9f087d 100644 --- a/Kernel/Random.h +++ b/Kernel/Random.h @@ -62,7 +62,7 @@ public: } template - void add_random_event(const T& event_data, size_t pool) + void add_random_event(T const& event_data, size_t pool) { pool %= pool_count; if (pool == 0) { @@ -159,7 +159,7 @@ public: } template - void add_random_event(const T& event_data) + void add_random_event(T const& event_data) { auto& kernel_rng = KernelRng::the(); SpinlockLocker lock(kernel_rng.get_lock()); diff --git a/Kernel/StdLib.cpp b/Kernel/StdLib.cpp index 356204896e..19c7ea30c2 100644 --- a/Kernel/StdLib.cpp +++ b/Kernel/StdLib.cpp @@ -54,11 +54,11 @@ ErrorOr