Skip to content

Commit

Permalink
Everywhere: Run clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
IdanHo authored and linusg committed Apr 1, 2022
1 parent 0376c12 commit 0869692
Show file tree
Hide file tree
Showing 1,665 changed files with 8,491 additions and 8,491 deletions.
12 changes: 6 additions & 6 deletions AK/Atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ class Atomic {

public:
Atomic() noexcept = default;
Atomic& operator=(const Atomic&) volatile = delete;
Atomic& operator=(Atomic const&) volatile = delete;
Atomic& operator=(Atomic&&) volatile = delete;
Atomic(const Atomic&) = delete;
Atomic(Atomic const&) = delete;
Atomic(Atomic&&) = delete;

constexpr Atomic(T val) noexcept
Expand Down Expand Up @@ -215,9 +215,9 @@ class Atomic<T, DefaultMemoryOrder> {

public:
Atomic() noexcept = default;
Atomic& operator=(const Atomic&) volatile = delete;
Atomic& operator=(Atomic const&) volatile = delete;
Atomic& operator=(Atomic&&) volatile = delete;
Atomic(const Atomic&) = delete;
Atomic(Atomic const&) = delete;
Atomic(Atomic&&) = delete;

constexpr Atomic(T val) noexcept
Expand Down Expand Up @@ -346,9 +346,9 @@ class Atomic<T*, DefaultMemoryOrder> {

public:
Atomic() noexcept = default;
Atomic& operator=(const Atomic&) volatile = delete;
Atomic& operator=(Atomic const&) volatile = delete;
Atomic& operator=(Atomic&&) volatile = delete;
Atomic(const Atomic&) = delete;
Atomic(Atomic const&) = delete;
Atomic(Atomic&&) = delete;

constexpr Atomic(T* val) noexcept
Expand Down
4 changes: 2 additions & 2 deletions AK/Badge.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class Badge {
friend T;
constexpr Badge() = default;

Badge(const Badge&) = delete;
Badge& operator=(const Badge&) = delete;
Badge(Badge const&) = delete;
Badge& operator=(Badge const&) = delete;

Badge(Badge&&) = delete;
Badge& operator=(Badge&&) = delete;
Expand Down
8 changes: 4 additions & 4 deletions AK/Base64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ String encode_base64(ReadonlyBytes input)
const u8 index2 = ((in1 << 2) | (in2 >> 6)) & 0x3f;
const u8 index3 = in2 & 0x3f;

const char out0 = alphabet[index0];
const char out1 = alphabet[index1];
const char out2 = is_16bit ? '=' : alphabet[index2];
const char out3 = is_8bit ? '=' : alphabet[index3];
char const out0 = alphabet[index0];
char const out1 = alphabet[index1];
char const out2 = is_16bit ? '=' : alphabet[index2];
char const out3 = is_8bit ? '=' : alphabet[index3];

output.append(out0);
output.append(out1);
Expand Down
4 changes: 2 additions & 2 deletions AK/BitStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class InputBitStream final : public InputStream {
}

if (m_next_byte.has_value()) {
const auto bit = (m_next_byte.value() >> m_bit_offset) & 1;
auto const bit = (m_next_byte.value() >> m_bit_offset) & 1;
result |= bit << nread;
++nread;

Expand Down Expand Up @@ -109,7 +109,7 @@ class InputBitStream final : public InputStream {
nread += 8;
m_next_byte.clear();
} else {
const auto bit = (m_next_byte.value() >> (7 - m_bit_offset)) & 1;
auto const bit = (m_next_byte.value() >> (7 - m_bit_offset)) & 1;
result <<= 1;
result |= bit;
++nread;
Expand Down
34 changes: 17 additions & 17 deletions AK/BitmapView.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class BitmapView {
return 0;

size_t count;
const u8* first = &m_data[start / 8];
const u8* last = &m_data[(start + len) / 8];
u8 const* first = &m_data[start / 8];
u8 const* last = &m_data[(start + len) / 8];
u8 byte = *first;
byte &= bitmask_first_byte[start % 8];
if (first == last) {
Expand All @@ -64,19 +64,19 @@ class BitmapView {
count += popcount(byte);
}
if (++first < last) {
const size_t* ptr_large = (const size_t*)(((FlatPtr)first + sizeof(size_t) - 1) & ~(sizeof(size_t) - 1));
if ((const u8*)ptr_large > last)
ptr_large = (const size_t*)last;
while (first < (const u8*)ptr_large) {
size_t const* ptr_large = (size_t const*)(((FlatPtr)first + sizeof(size_t) - 1) & ~(sizeof(size_t) - 1));
if ((u8 const*)ptr_large > last)
ptr_large = (size_t const*)last;
while (first < (u8 const*)ptr_large) {
count += popcount(*first);
first++;
}
const size_t* last_large = (const size_t*)((FlatPtr)last & ~(sizeof(size_t) - 1));
size_t const* last_large = (size_t const*)((FlatPtr)last & ~(sizeof(size_t) - 1));
while (ptr_large < last_large) {
count += popcount(*ptr_large);
ptr_large++;
}
for (first = (const u8*)ptr_large; first < last; first++)
for (first = (u8 const*)ptr_large; first < last; first++)
count += popcount(*first);
}
}
Expand All @@ -88,24 +88,24 @@ class BitmapView {

[[nodiscard]] bool is_null() const { return m_data == nullptr; }

[[nodiscard]] const u8* data() const { return m_data; }
[[nodiscard]] u8 const* data() const { return m_data; }

template<bool VALUE>
Optional<size_t> find_one_anywhere(size_t hint = 0) const
{
VERIFY(hint < m_size);
const u8* end = &m_data[m_size / 8];
u8 const* end = &m_data[m_size / 8];

for (;;) {
// We will use hint as what it is: a hint. Because we try to
// scan over entire 32 bit words, we may start searching before
// the hint!
const size_t* ptr_large = (const size_t*)((FlatPtr)&m_data[hint / 8] & ~(sizeof(size_t) - 1));
if ((const u8*)ptr_large < &m_data[0]) {
size_t const* ptr_large = (size_t const*)((FlatPtr)&m_data[hint / 8] & ~(sizeof(size_t) - 1));
if ((u8 const*)ptr_large < &m_data[0]) {
ptr_large++;

// m_data isn't aligned, check first bytes
size_t start_ptr_large = (const u8*)ptr_large - &m_data[0];
size_t start_ptr_large = (u8 const*)ptr_large - &m_data[0];
size_t i = 0;
u8 byte = VALUE ? 0x00 : 0xff;
while (i < start_ptr_large && m_data[i] == byte)
Expand All @@ -120,14 +120,14 @@ class BitmapView {
}

size_t val_large = VALUE ? 0x0 : NumericLimits<size_t>::max();
const size_t* end_large = (const size_t*)((FlatPtr)end & ~(sizeof(size_t) - 1));
size_t const* end_large = (size_t const*)((FlatPtr)end & ~(sizeof(size_t) - 1));
while (ptr_large < end_large && *ptr_large == val_large)
ptr_large++;

if (ptr_large == end_large) {
// We didn't find anything, check the remaining few bytes (if any)
u8 byte = VALUE ? 0x00 : 0xff;
size_t i = (const u8*)ptr_large - &m_data[0];
size_t i = (u8 const*)ptr_large - &m_data[0];
size_t byte_count = m_size / 8;
VERIFY(i <= byte_count);
while (i < byte_count && m_data[i] == byte)
Expand All @@ -137,7 +137,7 @@ class BitmapView {
return {}; // We already checked from the beginning

// Try scanning before the hint
end = (const u8*)((FlatPtr)&m_data[hint / 8] & ~(sizeof(size_t) - 1));
end = (u8 const*)((FlatPtr)&m_data[hint / 8] & ~(sizeof(size_t) - 1));
hint = 0;
continue;
}
Expand All @@ -154,7 +154,7 @@ class BitmapView {
if constexpr (!VALUE)
val_large = ~val_large;
VERIFY(val_large != 0);
return ((const u8*)ptr_large - &m_data[0]) * 8 + bit_scan_forward(val_large) - 1;
return ((u8 const*)ptr_large - &m_data[0]) * 8 + bit_scan_forward(val_large) - 1;
}
}

Expand Down
10 changes: 5 additions & 5 deletions AK/ByteReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,34 @@ struct ByteReader {
__builtin_memcpy(addr, &value, sizeof(T));
}
template<typename T>
requires(IsTriviallyConstructible<T>) static void load(const u8* addr, T& value)
requires(IsTriviallyConstructible<T>) static void load(u8 const* addr, T& value)
{
__builtin_memcpy(&value, addr, sizeof(T));
}

template<typename T>
static T* load_pointer(const u8* address)
static T* load_pointer(u8 const* address)
{
FlatPtr value;
load<FlatPtr>(address, value);
return reinterpret_cast<T*>(value);
}

static u16 load16(const u8* address)
static u16 load16(u8 const* address)
{
u16 value;
load(address, value);
return value;
}

static u32 load32(const u8* address)
static u32 load32(u8 const* address)
{
u32 value;
load(address, value);
return value;
}

static u64 load64(const u8* address)
static u64 load64(u8 const* address)
{
u64 value;
load(address, value);
Expand Down
44 changes: 22 additions & 22 deletions AK/Checked.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class Checked {
m_value = value;
}

constexpr Checked(const Checked&) = default;
constexpr Checked(Checked const&) = default;

constexpr Checked(Checked&& other)
: m_value(exchange(other.m_value, 0))
Expand All @@ -142,7 +142,7 @@ class Checked {
return *this;
}

constexpr Checked& operator=(const Checked& other) = default;
constexpr Checked& operator=(Checked const& other) = default;

constexpr Checked& operator=(Checked&& other)
{
Expand Down Expand Up @@ -199,7 +199,7 @@ class Checked {
m_value /= other;
}

constexpr Checked& operator+=(const Checked& other)
constexpr Checked& operator+=(Checked const& other)
{
m_overflow |= other.m_overflow;
add(other.value());
Expand All @@ -212,7 +212,7 @@ class Checked {
return *this;
}

constexpr Checked& operator-=(const Checked& other)
constexpr Checked& operator-=(Checked const& other)
{
m_overflow |= other.m_overflow;
sub(other.value());
Expand All @@ -225,7 +225,7 @@ class Checked {
return *this;
}

constexpr Checked& operator*=(const Checked& other)
constexpr Checked& operator*=(Checked const& other)
{
m_overflow |= other.m_overflow;
mul(other.value());
Expand All @@ -238,7 +238,7 @@ class Checked {
return *this;
}

constexpr Checked& operator/=(const Checked& other)
constexpr Checked& operator/=(Checked const& other)
{
m_overflow |= other.m_overflow;
div(other.value());
Expand Down Expand Up @@ -319,105 +319,105 @@ class Checked {
};

template<typename T>
constexpr Checked<T> operator+(const Checked<T>& a, const Checked<T>& b)
constexpr Checked<T> operator+(Checked<T> const& a, Checked<T> const& b)
{
Checked<T> c { a };
c.add(b.value());
return c;
}

template<typename T>
constexpr Checked<T> operator-(const Checked<T>& a, const Checked<T>& b)
constexpr Checked<T> operator-(Checked<T> const& a, Checked<T> const& b)
{
Checked<T> c { a };
c.sub(b.value());
return c;
}

template<typename T>
constexpr Checked<T> operator*(const Checked<T>& a, const Checked<T>& b)
constexpr Checked<T> operator*(Checked<T> const& a, Checked<T> const& b)
{
Checked<T> c { a };
c.mul(b.value());
return c;
}

template<typename T>
constexpr Checked<T> operator/(const Checked<T>& a, const Checked<T>& b)
constexpr Checked<T> operator/(Checked<T> const& a, Checked<T> const& b)
{
Checked<T> c { a };
c.div(b.value());
return c;
}

template<typename T>
constexpr bool operator<(const Checked<T>& a, T b)
constexpr bool operator<(Checked<T> const& a, T b)
{
return a.value() < b;
}

template<typename T>
constexpr bool operator>(const Checked<T>& a, T b)
constexpr bool operator>(Checked<T> const& a, T b)
{
return a.value() > b;
}

template<typename T>
constexpr bool operator>=(const Checked<T>& a, T b)
constexpr bool operator>=(Checked<T> const& a, T b)
{
return a.value() >= b;
}

template<typename T>
constexpr bool operator<=(const Checked<T>& a, T b)
constexpr bool operator<=(Checked<T> const& a, T b)
{
return a.value() <= b;
}

template<typename T>
constexpr bool operator==(const Checked<T>& a, T b)
constexpr bool operator==(Checked<T> const& a, T b)
{
return a.value() == b;
}

template<typename T>
constexpr bool operator!=(const Checked<T>& a, T b)
constexpr bool operator!=(Checked<T> const& a, T b)
{
return a.value() != b;
}

template<typename T>
constexpr bool operator<(T a, const Checked<T>& b)
constexpr bool operator<(T a, Checked<T> const& b)
{
return a < b.value();
}

template<typename T>
constexpr bool operator>(T a, const Checked<T>& b)
constexpr bool operator>(T a, Checked<T> const& b)
{
return a > b.value();
}

template<typename T>
constexpr bool operator>=(T a, const Checked<T>& b)
constexpr bool operator>=(T a, Checked<T> const& b)
{
return a >= b.value();
}

template<typename T>
constexpr bool operator<=(T a, const Checked<T>& b)
constexpr bool operator<=(T a, Checked<T> const& b)
{
return a <= b.value();
}

template<typename T>
constexpr bool operator==(T a, const Checked<T>& b)
constexpr bool operator==(T a, Checked<T> const& b)
{
return a == b.value();
}

template<typename T>
constexpr bool operator!=(T a, const Checked<T>& b)
constexpr bool operator!=(T a, Checked<T> const& b)
{
return a != b.value();
}
Expand Down
Loading

0 comments on commit 0869692

Please sign in to comment.