Skip to content

Commit

Permalink
Apply clang-format 18
Browse files Browse the repository at this point in the history
Summary: Previously this code conformed from clang-format 12.

Reviewed By: igorsugak

Differential Revision: D56065247

fbshipit-source-id: f5a985dd8f8b84f2f9e1818b3719b43c5a1b05b3
  • Loading branch information
zertosh authored and facebook-github-bot committed Apr 14, 2024
1 parent cc51e69 commit d3a569d
Show file tree
Hide file tree
Showing 160 changed files with 1,233 additions and 797 deletions.
3 changes: 2 additions & 1 deletion folly/AtomicHashMap-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ AtomicHashMap<
// Alloc a new map and shove it in. We can change whatever
// we want because other threads are waiting on us...
size_t numCellsAllocated =
(size_t)(primarySubMap->capacity_ * std::pow(1.0 + kGrowthFrac_, nextMapIdx - 1));
(size_t)(primarySubMap->capacity_ *
std::pow(1.0 + kGrowthFrac_, nextMapIdx - 1));
size_t newSize = size_t(numCellsAllocated * kGrowthFrac_);
DCHECK(
subMaps_[nextMapIdx].load(std::memory_order_relaxed) ==
Expand Down
8 changes: 6 additions & 2 deletions folly/AtomicUnorderedMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,14 @@ struct AtomicUnorderedInsertMap {
// else in this function can throw an exception. In the event of an
// exception, deallocate as if the KV was beaten in a concurrent addition.
const auto idx = allocateNear(slot);
SCOPE_FAIL { slots_[idx].stateUpdate(CONSTRUCTING, EMPTY); };
SCOPE_FAIL {
slots_[idx].stateUpdate(CONSTRUCTING, EMPTY);
};
Key* addr = &slots_[idx].keyValue().first;
new (addr) Key(key);
SCOPE_FAIL { addr->~Key(); };
SCOPE_FAIL {
addr->~Key();
};
func(static_cast<void*>(&slots_[idx].keyValue().second));

while (true) {
Expand Down
4 changes: 3 additions & 1 deletion folly/Benchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ struct BenchmarkSuspender : BenchmarkSuspenderBase {

template <class F>
auto dismissing(F f) -> invoke_result_t<F> {
SCOPE_EXIT { rehire(); };
SCOPE_EXIT {
rehire();
};
dismiss();
return f();
}
Expand Down
30 changes: 17 additions & 13 deletions folly/Expected.h
Original file line number Diff line number Diff line change
Expand Up @@ -660,10 +660,11 @@ struct ExpectedHelper {
class... Fns,
class E = ExpectedErrorType<This>,
class T = ExpectedHelper>
static auto then_(This&& ex, Fn&& fn, Fns&&... fns) -> decltype(T::then_(
T::template return_<E>(
(std::declval<Fn>()(std::declval<This>().value()), unit)),
std::declval<Fns>()...)) {
static auto then_(This&& ex, Fn&& fn, Fns&&... fns)
-> decltype(T::then_(
T::template return_<E>(
(std::declval<Fn>()(std::declval<This>().value()), unit)),
std::declval<Fns>()...)) {
if (FOLLY_LIKELY(ex.which_ == expected_detail::Which::eValue)) {
return T::then_(
T::template return_<E>(
Expand Down Expand Up @@ -1122,7 +1123,8 @@ class Expected final : expected_detail::ExpectedStorage<Value, Error> {
* swap
*/
void swap(Expected& that) noexcept(
std::is_nothrow_swappable_v<Value>&& std::is_nothrow_swappable_v<Error>) {
std::is_nothrow_swappable_v<Value> &&
std::is_nothrow_swappable_v<Error>) {
if (this->uninitializedByException() || that.uninitializedByException()) {
throw_exception<BadExpectedAccess<void>>();
}
Expand Down Expand Up @@ -1249,7 +1251,7 @@ class Expected final : expected_detail::ExpectedStorage<Value, Error> {
template <class... Fns FOLLY_REQUIRES_TRAILING(sizeof...(Fns) >= 1)>
auto then(Fns&&... fns)
const& -> decltype(expected_detail::ExpectedHelper::then_(
std::declval<const Base&>(), std::declval<Fns>()...)) {
std::declval<const Base&>(), std::declval<Fns>()...)) {
if (this->uninitializedByException()) {
throw_exception<BadExpectedAccess<void>>();
}
Expand All @@ -1259,7 +1261,8 @@ class Expected final : expected_detail::ExpectedStorage<Value, Error> {

template <class... Fns FOLLY_REQUIRES_TRAILING(sizeof...(Fns) >= 1)>
auto then(Fns&&... fns) & -> decltype(expected_detail::ExpectedHelper::then_(
std::declval<Base&>(), std::declval<Fns>()...)) {
std::declval<Base&>(),
std::declval<Fns>()...)) {
if (this->uninitializedByException()) {
throw_exception<BadExpectedAccess<void>>();
}
Expand All @@ -1269,7 +1272,8 @@ class Expected final : expected_detail::ExpectedStorage<Value, Error> {

template <class... Fns FOLLY_REQUIRES_TRAILING(sizeof...(Fns) >= 1)>
auto then(Fns&&... fns) && -> decltype(expected_detail::ExpectedHelper::then_(
std::declval<Base&&>(), std::declval<Fns>()...)) {
std::declval<Base&&>(),
std::declval<Fns>()...)) {
if (this->uninitializedByException()) {
throw_exception<BadExpectedAccess<void>>();
}
Expand All @@ -1284,7 +1288,7 @@ class Expected final : expected_detail::ExpectedStorage<Value, Error> {
template <class... Fns FOLLY_REQUIRES_TRAILING(sizeof...(Fns) >= 1)>
auto orElse(Fns&&... fns)
const& -> decltype(expected_detail::ExpectedHelper::orElse_(
std::declval<const Base&>(), std::declval<Fns>()...)) {
std::declval<const Base&>(), std::declval<Fns>()...)) {
if (this->uninitializedByException()) {
throw_exception<BadExpectedAccess<void>>();
}
Expand All @@ -1295,7 +1299,7 @@ class Expected final : expected_detail::ExpectedStorage<Value, Error> {
template <class... Fns FOLLY_REQUIRES_TRAILING(sizeof...(Fns) >= 1)>
auto
orElse(Fns&&... fns) & -> decltype(expected_detail::ExpectedHelper::orElse_(
std::declval<Base&>(), std::declval<Fns>()...)) {
std::declval<Base&>(), std::declval<Fns>()...)) {
if (this->uninitializedByException()) {
throw_exception<BadExpectedAccess<void>>();
}
Expand All @@ -1306,7 +1310,7 @@ class Expected final : expected_detail::ExpectedStorage<Value, Error> {
template <class... Fns FOLLY_REQUIRES_TRAILING(sizeof...(Fns) >= 1)>
auto
orElse(Fns&&... fns) && -> decltype(expected_detail::ExpectedHelper::orElse_(
std::declval<Base&&>(), std::declval<Fns>()...)) {
std::declval<Base&&>(), std::declval<Fns>()...)) {
if (this->uninitializedByException()) {
throw_exception<BadExpectedAccess<void>>();
}
Expand All @@ -1330,7 +1334,7 @@ class Expected final : expected_detail::ExpectedStorage<Value, Error> {

template <class Yes, class No = MakeBadExpectedAccess>
auto thenOrThrow(Yes&& yes, No&& no = No{}) & -> decltype(std::declval<Yes>()(
std::declval<Value&>())) {
std::declval<Value&>())) {
using Ret = decltype(std::declval<Yes>()(std::declval<Value&>()));
if (this->uninitializedByException()) {
throw_exception<BadExpectedAccess<void>>();
Expand Down Expand Up @@ -1459,7 +1463,7 @@ inline bool operator>=(
*/
template <class Value, class Error>
void swap(Expected<Value, Error>& lhs, Expected<Value, Error>& rhs) noexcept(
std::is_nothrow_swappable_v<Value>&& std::is_nothrow_swappable_v<Error>) {
std::is_nothrow_swappable_v<Value> && std::is_nothrow_swappable_v<Error>) {
lhs.swap(rhs);
}

Expand Down
4 changes: 3 additions & 1 deletion folly/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ File::~File() {
// make a temp file with tmpfile(), dup the fd, then return it in a File.
FILE* tmpFile = tmpfile();
checkFopenError(tmpFile, "tmpfile() failed");
SCOPE_EXIT { fclose(tmpFile); };
SCOPE_EXIT {
fclose(tmpFile);
};

// TODO(nga): consider setting close-on-exec for the resulting FD
int fd = ::dup(fileno(tmpFile));
Expand Down
2 changes: 1 addition & 1 deletion folly/Function.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ constexpr bool isEmptyFunction(T const& t) {
}

template <typename F, typename... Args>
using CallableResult = decltype(FOLLY_DECLVAL(F &&)(FOLLY_DECLVAL(Args &&)...));
using CallableResult = decltype(FOLLY_DECLVAL(F&&)(FOLLY_DECLVAL(Args&&)...));

template <typename F, typename... Args>
constexpr bool CallableNoexcept =
Expand Down
4 changes: 3 additions & 1 deletion folly/IPAddressV6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ Expected<IPAddressV6, IPAddressFormatError> IPAddressV6::tryFromString(
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_NUMERICHOST;
if (::getaddrinfo(ipBuffer.data(), nullptr, &hints, &result) == 0) {
SCOPE_EXIT { ::freeaddrinfo(result); };
SCOPE_EXIT {
::freeaddrinfo(result);
};
const struct sockaddr_in6* sa =
reinterpret_cast<struct sockaddr_in6*>(result->ai_addr);
return IPAddressV6(*sa);
Expand Down
2 changes: 1 addition & 1 deletion folly/Indestructible.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class Indestructible final {
T const* operator->() const noexcept { return get(); }

/* implicit */ operator T&() noexcept { return *get(); }
/* implicit */ operator T const &() const noexcept { return *get(); }
/* implicit */ operator T const&() const noexcept { return *get(); }

private:
struct Storage {
Expand Down
16 changes: 8 additions & 8 deletions folly/Overload.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct FunctionClassType<Return (*)(Args...)
/* implicit */ constexpr type(Ptr function) noexcept
: function_(function) {}
constexpr auto operator()(Args... args) const
FOLLY_DETAIL_NOEXCEPT_SPECIFICATION -> Return {
FOLLY_DETAIL_NOEXCEPT_SPECIFICATION->Return {
return function_(std::forward<Args>(args)...);
}

Expand All @@ -90,11 +90,11 @@ struct FunctionClassType<Return (Self::*)(Args...)
/* implicit */ constexpr type(Ptr memberPointer) noexcept
: memberPointer_(memberPointer) {}
constexpr auto operator()(Self& self, Args... args) const
FOLLY_DETAIL_NOEXCEPT_SPECIFICATION -> Return {
FOLLY_DETAIL_NOEXCEPT_SPECIFICATION->Return {
return (self.*memberPointer_)(std::forward<Args>(args)...);
}
constexpr auto operator()(Self&& self, Args... args) const
FOLLY_DETAIL_NOEXCEPT_SPECIFICATION -> Return {
FOLLY_DETAIL_NOEXCEPT_SPECIFICATION->Return {
return (self.*memberPointer_)(std::forward<Args>(args)...);
}

Expand All @@ -115,7 +115,7 @@ struct FunctionClassType<Return (Self::*)(Args...)
/* implicit */ constexpr type(Ptr memberPointer) noexcept
: memberPointer_(memberPointer) {}
constexpr auto operator()(const Self& self, Args... args) const
FOLLY_DETAIL_NOEXCEPT_SPECIFICATION -> Return {
FOLLY_DETAIL_NOEXCEPT_SPECIFICATION->Return {
return (self.*memberPointer_)(std::forward<Args>(args)...);
}

Expand All @@ -135,7 +135,7 @@ struct FunctionClassType<
/* implicit */ constexpr type(Ptr memberPointer) noexcept
: memberPointer_(memberPointer) {}
constexpr auto operator()(Self& self, Args&&... args) const
FOLLY_DETAIL_NOEXCEPT_SPECIFICATION -> Return {
FOLLY_DETAIL_NOEXCEPT_SPECIFICATION->Return {
return (self.*memberPointer_)(std::forward<Args>(args)...);
}

Expand All @@ -156,7 +156,7 @@ struct FunctionClassType<
/* implicit */ constexpr type(Ptr memberPointer) noexcept
: memberPointer_(memberPointer) {}
constexpr auto operator()(const Self& self, Args... args) const
FOLLY_DETAIL_NOEXCEPT_SPECIFICATION -> Return {
FOLLY_DETAIL_NOEXCEPT_SPECIFICATION->Return {
return (self.*memberPointer_)(std::forward<Args>(args)...);
}

Expand All @@ -176,7 +176,7 @@ struct FunctionClassType<
/* implicit */ constexpr type(Ptr memberPointer) noexcept
: memberPointer_(memberPointer) {}
constexpr auto operator()(Self&& self, Args... args) const
FOLLY_DETAIL_NOEXCEPT_SPECIFICATION -> Return {
FOLLY_DETAIL_NOEXCEPT_SPECIFICATION->Return {
return (std::move(self).*memberPointer_)(std::forward<Args>(args)...);
}

Expand All @@ -197,7 +197,7 @@ struct FunctionClassType<
/* implicit */ constexpr type(Ptr memberPointer) noexcept
: memberPointer_(memberPointer) {}
constexpr auto operator()(const Self&& self, Args... args) const
FOLLY_DETAIL_NOEXCEPT_SPECIFICATION -> Return {
FOLLY_DETAIL_NOEXCEPT_SPECIFICATION->Return {
return (std::move(self).*memberPointer_)(std::forward<Args>(args)...);
}

Expand Down
3 changes: 2 additions & 1 deletion folly/Poly.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ template <
typename... As,
std::enable_if_t<detail::IsPoly<Poly>::value, int> = 0>
auto poly_call(Poly&& _this, As&&... as) -> decltype(poly_call<N, I>(
static_cast<Poly&&>(_this).get(), static_cast<As&&>(as)...)) {
static_cast<Poly&&>(_this).get(),
static_cast<As&&>(as)...)) {
return poly_call<N, I>(
static_cast<Poly&&>(_this).get(), static_cast<As&&>(as)...);
}
Expand Down
8 changes: 4 additions & 4 deletions folly/Replaceable.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ struct move_assignment_mixin<T, true> {
move_assignment_mixin(move_assignment_mixin const&) = default;
inline move_assignment_mixin&
operator=(move_assignment_mixin&& other) noexcept(
std::is_nothrow_destructible<T>::value&&
std::is_nothrow_move_constructible<T>::value) {
std::is_nothrow_destructible<T>::value &&
std::is_nothrow_move_constructible<T>::value) {
T* destruct_ptr = std::launder(reinterpret_cast<T*>(
reinterpret_cast<Replaceable<T>*>(this)->storage_));
destruct_ptr->~T();
Expand Down Expand Up @@ -344,8 +344,8 @@ struct copy_assignment_mixin<T, true> {
copy_assignment_mixin& operator=(copy_assignment_mixin&&) = default;
inline copy_assignment_mixin&
operator=(copy_assignment_mixin const& other) noexcept(
std::is_nothrow_destructible<T>::value&&
std::is_nothrow_copy_constructible<T>::value) {
std::is_nothrow_destructible<T>::value &&
std::is_nothrow_copy_constructible<T>::value) {
T* destruct_ptr = std::launder(reinterpret_cast<T*>(
reinterpret_cast<Replaceable<T>*>(this)->storage_));
destruct_ptr->~T();
Expand Down
12 changes: 9 additions & 3 deletions folly/String.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ void stringAppendfImpl(std::string& output, const char* format, va_list args) {
std::string stringPrintf(const char* format, ...) {
va_list ap;
va_start(ap, format);
SCOPE_EXIT { va_end(ap); };
SCOPE_EXIT {
va_end(ap);
};
return stringVPrintf(format, ap);
}

Expand All @@ -235,7 +237,9 @@ std::string stringVPrintf(const char* format, va_list ap) {
std::string& stringAppendf(std::string* output, const char* format, ...) {
va_list ap;
va_start(ap, format);
SCOPE_EXIT { va_end(ap); };
SCOPE_EXIT {
va_end(ap);
};
return stringVAppendf(output, format, ap);
}

Expand All @@ -248,7 +252,9 @@ std::string& stringVAppendf(
void stringPrintf(std::string* output, const char* format, ...) {
va_list ap;
va_start(ap, format);
SCOPE_EXIT { va_end(ap); };
SCOPE_EXIT {
va_end(ap);
};
return stringVPrintf(output, format, ap);
}

Expand Down
3 changes: 1 addition & 2 deletions folly/Subprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ SubprocessSpawnError::SubprocessSpawnError(
namespace {

// Copy pointers to the given strings in a format suitable for posix_spawn
std::unique_ptr<const char* []> cloneStrings(
const std::vector<std::string>& s) {
std::unique_ptr<const char*[]> cloneStrings(const std::vector<std::string>& s) {
std::unique_ptr<const char*[]> d(new const char*[s.size() + 1]);
for (size_t i = 0; i < s.size(); i++) {
d[i] = s[i].c_str();
Expand Down
5 changes: 3 additions & 2 deletions folly/Synchronized.h
Original file line number Diff line number Diff line change
Expand Up @@ -1738,8 +1738,9 @@ void swap(Synchronized<T, M>& lhs, Synchronized<T, M>& rhs) {

namespace detail {
struct [[deprecated(
"use explicit lock(), wlock(), or rlock() instead")]] SYNCHRONIZED_macro_is_deprecated{};
}
"use explicit lock(), wlock(), or rlock() instead")]] SYNCHRONIZED_macro_is_deprecated {
};
} // namespace detail

/**
* NOTE: This API is deprecated. Use lock(), wlock(), rlock() or the withLock
Expand Down
6 changes: 3 additions & 3 deletions folly/Utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ template <typename T>
T* decay_1_(T*);

template <typename T>
auto decay_0_(int) -> decltype(detail::decay_1_(FOLLY_DECLVAL(T &&)));
auto decay_0_(int) -> decltype(detail::decay_1_(FOLLY_DECLVAL(T&&)));
template <typename T>
auto decay_0_(short) -> void;

Expand Down Expand Up @@ -277,8 +277,8 @@ struct inheritable_contain_ {
: v(static_cast<A&&>(a)...) {}
FOLLY_ERASE operator T&() & noexcept { return v; }
FOLLY_ERASE operator T&&() && noexcept { return static_cast<T&&>(v); }
FOLLY_ERASE operator T const &() const& noexcept { return v; }
FOLLY_ERASE operator T const &&() const&& noexcept {
FOLLY_ERASE operator T const&() const& noexcept { return v; }
FOLLY_ERASE operator T const&&() const&& noexcept {
return static_cast<T const&&>(v);
}
};
Expand Down
4 changes: 2 additions & 2 deletions folly/concurrency/ThreadCachedSynchronized.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ class thread_cached_synchronized {
using tlp_cache_state = ThreadLocalPtr<cache_state>;

template <typename... A>
static constexpr bool nx = noexcept(truth_state{
std::in_place, FOLLY_DECLVAL(A)...});
static constexpr bool nx =
noexcept(truth_state{std::in_place, FOLLY_DECLVAL(A)...});

template <bool C>
using if_ = std::enable_if_t<C, int>;
Expand Down
3 changes: 1 addition & 2 deletions folly/concurrency/test/ConcurrentHashMapBench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ void benches() {
<< std::endl;
for (int nthr : {1, 10}) {
std::cout << "========================= " << std::setw(2) << nthr
<< " threads"
<< " =========================" << std::endl;
<< " threads" << " =========================" << std::endl;
bench_ctor_dtor(nthr, 0, "CHM ctor/dtor -- empty ");
bench_ctor_dtor(nthr, 1, "CHM ctor/dtor -- 1 item ");
dottedLine();
Expand Down
4 changes: 2 additions & 2 deletions folly/container/Access.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ inline constexpr empty_fn empty{};
// mimic: std::data, C++17
struct data_fn {
template <typename C>
FOLLY_ERASE constexpr auto operator()(C& c) const noexcept(noexcept(c.data()))
-> decltype(c.data()) {
FOLLY_ERASE constexpr auto operator()(C& c) const
noexcept(noexcept(c.data())) -> decltype(c.data()) {
return c.data();
}
template <typename C>
Expand Down
Loading

0 comments on commit d3a569d

Please sign in to comment.