1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:18:11 +00:00

Everywhere: Run clang-format

The following command was used to clang-format these files:

    clang-format-16 -i $(find . \
        -not \( -path "./\.*" -prune \) \
        -not \( -path "./Base/*" -prune \) \
        -not \( -path "./Build/*" -prune \) \
        -not \( -path "./Toolchain/*" -prune \) \
        -not \( -path "./Ports/*" -prune \) \
        -type f -name "*.cpp" -o -name "*.h")
This commit is contained in:
Timothy Flynn 2023-07-07 22:44:33 -04:00 committed by Linus Groh
parent 388d455575
commit aff81d318b
17 changed files with 49 additions and 54 deletions

View file

@ -40,14 +40,15 @@ namespace Detail {
template<typename T, typename Out, typename... Args> template<typename T, typename Out, typename... Args>
inline constexpr bool IsCallableWithArguments = requires(T t) { inline constexpr bool IsCallableWithArguments = requires(T t) {
{ {
t(declval<Args>()...) t(declval<Args>()...)
} -> ConvertibleTo<Out>; } -> ConvertibleTo<Out>;
} || requires(T t) { } || requires(T t) {
{ {
t(declval<Args>()...) t(declval<Args>()...)
} -> SameAs<Out>; } -> SameAs<Out>;
}; };
} }
using Detail::IsCallableWithArguments; using Detail::IsCallableWithArguments;

View file

@ -32,9 +32,9 @@ namespace AK {
// Concept to detect types which look like timespec without requiring the type. // Concept to detect types which look like timespec without requiring the type.
template<typename T> template<typename T>
concept TimeSpecType = requires(T t) { concept TimeSpecType = requires(T t) {
t.tv_sec; t.tv_sec;
t.tv_nsec; t.tv_nsec;
}; };
constexpr bool is_leap_year(int year) constexpr bool is_leap_year(int year)
{ {

View file

@ -220,8 +220,7 @@ struct Empty {
}; };
template<typename T> template<typename T>
concept NotLvalueReference = ! concept NotLvalueReference = !IsLvalueReference<T>;
IsLvalueReference<T>;
template<NotLvalueReference... Ts> template<NotLvalueReference... Ts>
struct Variant struct Variant

View file

@ -31,13 +31,13 @@ struct CanBePlacedInsideVectorHelper;
template<typename StorageType> template<typename StorageType>
struct CanBePlacedInsideVectorHelper<StorageType, true> { struct CanBePlacedInsideVectorHelper<StorageType, true> {
template<typename U> template<typename U>
static constexpr bool value = requires(U && u) { StorageType { &u }; }; static constexpr bool value = requires(U&& u) { StorageType { &u }; };
}; };
template<typename StorageType> template<typename StorageType>
struct CanBePlacedInsideVectorHelper<StorageType, false> { struct CanBePlacedInsideVectorHelper<StorageType, false> {
template<typename U> template<typename U>
static constexpr bool value = requires(U && u) { StorageType(forward<U>(u)); }; static constexpr bool value = requires(U&& u) { StorageType(forward<U>(u)); };
}; };
} }

View file

@ -31,8 +31,7 @@ enum class InterruptsState;
// FIXME This needs to go behind some sort of platform abstraction // FIXME This needs to go behind some sort of platform abstraction
// it is used between Thread and Processor. // it is used between Thread and Processor.
struct [[gnu::aligned(16)]] FPUState struct [[gnu::aligned(16)]] FPUState {
{
u8 buffer[512]; u8 buffer[512];
}; };

View file

@ -45,8 +45,7 @@ extern "C" void thread_context_first_enter(void);
extern "C" void exit_kernel_thread(void); extern "C" void exit_kernel_thread(void);
extern "C" void do_assume_context(Thread* thread, u32 flags); extern "C" void do_assume_context(Thread* thread, u32 flags);
struct [[gnu::aligned(64), gnu::packed]] FPUState struct [[gnu::aligned(64), gnu::packed]] FPUState {
{
SIMD::LegacyRegion legacy_region; SIMD::LegacyRegion legacy_region;
SIMD::Header xsave_header; SIMD::Header xsave_header;

View file

@ -71,7 +71,7 @@ protected:
{ {
VERIFY(b.blocker_type() == Thread::Blocker::Type::Routing); VERIFY(b.blocker_type() == Thread::Blocker::Type::Routing);
auto& blocker = static_cast<ARPTableBlocker&>(b); auto& blocker = static_cast<ARPTableBlocker&>(b);
auto maybe_mac_address = arp_table().with([&](auto const& table) -> auto{ auto maybe_mac_address = arp_table().with([&](auto const& table) -> auto {
return table.get(blocker.ip_address()); return table.get(blocker.ip_address());
}); });
if (!maybe_mac_address.has_value()) if (!maybe_mac_address.has_value())
@ -95,7 +95,7 @@ bool ARPTableBlocker::setup_blocker()
void ARPTableBlocker::will_unblock_immediately_without_blocking(UnblockImmediatelyReason) void ARPTableBlocker::will_unblock_immediately_without_blocking(UnblockImmediatelyReason)
{ {
auto addr = arp_table().with([&](auto const& table) -> auto{ auto addr = arp_table().with([&](auto const& table) -> auto {
return table.get(ip_address()); return table.get(ip_address());
}); });
@ -297,11 +297,11 @@ RoutingDecision route_to(IPv4Address const& target, IPv4Address const& source, R
if (adapter == NetworkingManagement::the().loopback_adapter()) if (adapter == NetworkingManagement::the().loopback_adapter())
return { adapter, adapter->mac_address() }; return { adapter, adapter->mac_address() };
if ((target_addr & IPv4Address { 240, 0, 0, 0 }.to_u32()) == IPv4Address { 224, 0, 0, 0 }.to_u32()) if ((target_addr & (IPv4Address { 240, 0, 0, 0 }.to_u32())) == IPv4Address { 224, 0, 0, 0 }.to_u32())
return { adapter, multicast_ethernet_address(target) }; return { adapter, multicast_ethernet_address(target) };
{ {
auto addr = arp_table().with([&](auto const& table) -> auto{ auto addr = arp_table().with([&](auto const& table) -> auto {
return table.get(next_hop_ip); return table.get(next_hop_ip);
}); });
if (addr.has_value()) { if (addr.has_value()) {

View file

@ -20,8 +20,8 @@ namespace Kernel {
namespace Syscall { namespace Syscall {
using Handler = auto(Process::*)(FlatPtr, FlatPtr, FlatPtr, FlatPtr) -> ErrorOr<FlatPtr>; using Handler = auto (Process::*)(FlatPtr, FlatPtr, FlatPtr, FlatPtr) -> ErrorOr<FlatPtr>;
using HandlerWithRegisterState = auto(Process::*)(RegisterState&) -> ErrorOr<FlatPtr>; using HandlerWithRegisterState = auto (Process::*)(RegisterState&) -> ErrorOr<FlatPtr>;
struct HandlerMetadata { struct HandlerMetadata {
Handler handler; Handler handler;

View file

@ -771,7 +771,7 @@ void ArgsParser::autocomplete(FILE* file, StringView program_name, ReadonlySpan<
// Look for a long option // Look for a long option
auto option_pattern = argument.substring_view(2); auto option_pattern = argument.substring_view(2);
auto it = m_options.find_if([&](auto& option) { return option.hide_mode != OptionHideMode::None && StringView { option.long_name, strlen(option.long_name) } == option_pattern; }); auto it = m_options.find_if([&](auto& option) { return (option.hide_mode != OptionHideMode::None) && StringView { option.long_name, strlen(option.long_name) } == option_pattern; });
if (it.is_end()) if (it.is_end())
continue; continue;

View file

@ -43,7 +43,7 @@ void CRC32::update(ReadonlyBytes span)
} }
}; };
// FIXME: On Intel, use _mm_crc32_u8 / _mm_crc32_u64 if available (SSE 4.2). // FIXME: On Intel, use _mm_crc32_u8 / _mm_crc32_u64 if available (SSE 4.2).
#else #else

View file

@ -17,8 +17,8 @@ public:
template<typename PRF> template<typename PRF>
static ErrorOr<ByteBuffer> derive_key(ReadonlyBytes password, ReadonlyBytes salt, u32 iterations, u32 key_length_bytes) static ErrorOr<ByteBuffer> derive_key(ReadonlyBytes password, ReadonlyBytes salt, u32 iterations, u32 key_length_bytes)
requires requires(PRF t) { requires requires(PRF t) {
t.digest_size(); t.digest_size();
} }
{ {
PRF prf(password); PRF prf(password);

View file

@ -17,10 +17,10 @@ template<typename T, typename Container = Vector<T>, typename ColumnNameListType
class ItemListModel : public Model { class ItemListModel : public Model {
public: public:
static constexpr auto IsTwoDimensional = requires(Container data) { static constexpr auto IsTwoDimensional = requires(Container data) {
requires !IsVoid<ColumnNameListType>; requires !IsVoid<ColumnNameListType>;
data.at(0).at(0); data.at(0).at(0);
data.at(0).size(); data.at(0).size();
}; };
// Substitute 'void' for a dummy u8. // Substitute 'void' for a dummy u8.
using ColumnNamesT = Conditional<IsVoid<ColumnNameListType>, u8, ColumnNameListType>; using ColumnNamesT = Conditional<IsVoid<ColumnNameListType>, u8, ColumnNameListType>;

View file

@ -241,11 +241,11 @@ private:
template<typename Func, typename... Args> template<typename Func, typename... Args>
concept ThrowCompletionOrVoidFunction = requires(Func func, Args... args) { concept ThrowCompletionOrVoidFunction = requires(Func func, Args... args) {
{ {
func(args...) func(args...)
} }
-> SameAs<ThrowCompletionOr<void>>; -> SameAs<ThrowCompletionOr<void>>;
}; };
template<typename... Args> template<typename... Args>
class ThrowCompletionOrVoidCallback : public Function<ThrowCompletionOr<void>(Args...)> { class ThrowCompletionOrVoidCallback : public Function<ThrowCompletionOr<void>(Args...)> {

View file

@ -560,7 +560,7 @@ void Editor::initialize()
m_configuration.set(Configuration::NonInteractive); m_configuration.set(Configuration::NonInteractive);
} else { } else {
auto* term = getenv("TERM"); auto* term = getenv("TERM");
if (term != NULL && StringView { term, strlen(term) }.starts_with("xterm"sv)) if ((term != NULL) && StringView { term, strlen(term) }.starts_with("xterm"sv))
m_configuration.set(Configuration::Full); m_configuration.set(Configuration::Full);
else else
m_configuration.set(Configuration::NoEscapeSequences); m_configuration.set(Configuration::NoEscapeSequences);

View file

@ -402,15 +402,16 @@ void Printer::print(Wasm::ImportSection::Import const& import)
{ {
TemporaryChange change { m_indent, m_indent + 1 }; TemporaryChange change { m_indent, m_indent + 1 };
import.description().visit( import.description().visit(
[this](auto const& type) { print(type); [this](auto const& type) {
}, print(type);
},
[this](TypeIndex const& index) { [this](TypeIndex const& index) {
print_indent(); print_indent();
print("(type index {})\n", index.value()); print("(type index {})\n", index.value());
}); });
} }
print_indent(); print_indent();
print(")\n"); print(")\n");
} }
void Printer::print(Wasm::Instruction const& instruction) void Printer::print(Wasm::Instruction const& instruction)

View file

@ -930,11 +930,9 @@ struct InvocationOf<impl> {
return HostFunction( return HostFunction(
[&self, function_name](Configuration& configuration, Vector<Value>& arguments) -> Wasm::Result { [&self, function_name](Configuration& configuration, Vector<Value>& arguments) -> Wasm::Result {
Tuple args = [&]<typename... Ts, auto... Is>(IndexSequence<Is...>) Tuple args = [&]<typename... Ts, auto... Is>(IndexSequence<Is...>) {
{
return Tuple { ABI::deserialize(ABI::to_compatible_value<Ts>(arguments[Is]))... }; return Tuple { ABI::deserialize(ABI::to_compatible_value<Ts>(arguments[Is]))... };
} }.template operator()<Args...>(MakeIndexSequence<sizeof...(Args)>());
.template operator()<Args...>(MakeIndexSequence<sizeof...(Args)>());
auto result = args.apply_as_args([&](auto&&... impl_args) { return (self.*impl)(configuration, impl_args...); }); auto result = args.apply_as_args([&](auto&&... impl_args) { return (self.*impl)(configuration, impl_args...); });
dbgln_if(WASI_DEBUG, "WASI: {}({}) = {}", function_name, arguments, result); dbgln_if(WASI_DEBUG, "WASI: {}({}) = {}", function_name, arguments, result);
@ -948,8 +946,7 @@ struct InvocationOf<impl> {
if constexpr (!IsVoid<R>) { if constexpr (!IsVoid<R>) {
// Return values are passed as pointers, after the arguments // Return values are passed as pointers, after the arguments
if constexpr (requires { &R::serialize_into; }) { if constexpr (requires { &R::serialize_into; }) {
constexpr auto ResultCount = []<auto N>(void(R::*)(Array<Bytes, N>) const) { return N; } constexpr auto ResultCount = []<auto N>(void (R::*)(Array<Bytes, N>) const) { return N; }(&R::serialize_into);
(&R::serialize_into);
ABI::serialize(*value.result(), address_spans<ResultCount>(arguments.span().slice(sizeof...(Args)), configuration)); ABI::serialize(*value.result(), address_spans<ResultCount>(arguments.span().slice(sizeof...(Args)), configuration));
} else { } else {
ABI::serialize(*value.result(), address_spans<1>(arguments.span().slice(sizeof...(Args)), configuration)); ABI::serialize(*value.result(), address_spans<1>(arguments.span().slice(sizeof...(Args)), configuration));

View file

@ -6246,8 +6246,7 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_filter_value_list_value(Vector<Compone
} else if (filter_token == FilterToken::DropShadow) { } else if (filter_token == FilterToken::DropShadow) {
if (!tokens.has_next_token()) if (!tokens.has_next_token())
return {}; return {};
auto next_token = [&]() -> auto& auto next_token = [&]() -> auto& {
{
auto& token = tokens.next_token(); auto& token = tokens.next_token();
tokens.skip_whitespace(); tokens.skip_whitespace();
return token; return token;