Commit 65109ecd by Patrick Xia Committed by Copybara-Service

trivial: format some files using clang-format

PiperOrigin-RevId: 527598377
Change-Id: I0ae1505db595b7f3a420f2f608c6e02f8800f138
parent 8518869e
...@@ -411,7 +411,7 @@ AbslHashValue(H hash_state, LongDouble value) { ...@@ -411,7 +411,7 @@ AbslHashValue(H hash_state, LongDouble value) {
// AbslHashValue() for hashing pointers // AbslHashValue() for hashing pointers
template <typename H, typename T> template <typename H, typename T>
H AbslHashValue(H hash_state, T* ptr) { H AbslHashValue(H hash_state, T* ptr) {
auto v = reinterpret_cast<uintptr_t>(ptr); auto v = reinterpret_cast<uintptr_t>(ptr);
// Due to alignment, pointers tend to have low bits as zero, and the next few // Due to alignment, pointers tend to have low bits as zero, and the next few
// bits follow a pattern since they are also multiples of some base value. // bits follow a pattern since they are also multiples of some base value.
...@@ -428,7 +428,7 @@ H AbslHashValue(H hash_state, std::nullptr_t) { ...@@ -428,7 +428,7 @@ H AbslHashValue(H hash_state, std::nullptr_t) {
// AbslHashValue() for hashing pointers-to-member // AbslHashValue() for hashing pointers-to-member
template <typename H, typename T, typename C> template <typename H, typename T, typename C>
H AbslHashValue(H hash_state, T C::* ptr) { H AbslHashValue(H hash_state, T C::*ptr) {
auto salient_ptm_size = [](std::size_t n) -> std::size_t { auto salient_ptm_size = [](std::size_t n) -> std::size_t {
#if defined(_MSC_VER) #if defined(_MSC_VER)
// Pointers-to-member-function on MSVC consist of one pointer plus 0, 1, 2, // Pointers-to-member-function on MSVC consist of one pointer plus 0, 1, 2,
...@@ -446,8 +446,8 @@ H AbslHashValue(H hash_state, T C::* ptr) { ...@@ -446,8 +446,8 @@ H AbslHashValue(H hash_state, T C::* ptr) {
return n == 24 ? 20 : n == 16 ? 12 : n; return n == 24 ? 20 : n == 16 ? 12 : n;
} }
#else #else
// On other platforms, we assume that pointers-to-members do not have // On other platforms, we assume that pointers-to-members do not have
// padding. // padding.
#ifdef __cpp_lib_has_unique_object_representations #ifdef __cpp_lib_has_unique_object_representations
static_assert(std::has_unique_object_representations<T C::*>::value); static_assert(std::has_unique_object_representations<T C::*>::value);
#endif // __cpp_lib_has_unique_object_representations #endif // __cpp_lib_has_unique_object_representations
...@@ -955,8 +955,8 @@ class ABSL_DLL MixingHashState : public HashStateBase<MixingHashState> { ...@@ -955,8 +955,8 @@ class ABSL_DLL MixingHashState : public HashStateBase<MixingHashState> {
#endif // ABSL_HAVE_INTRINSIC_INT128 #endif // ABSL_HAVE_INTRINSIC_INT128
static constexpr uint64_t kMul = static constexpr uint64_t kMul =
sizeof(size_t) == 4 ? uint64_t{0xcc9e2d51} sizeof(size_t) == 4 ? uint64_t{0xcc9e2d51}
: uint64_t{0x9ddfea08eb382d69}; : uint64_t{0x9ddfea08eb382d69};
template <typename T> template <typename T>
using IntegralFastPath = using IntegralFastPath =
......
...@@ -119,8 +119,8 @@ class ...@@ -119,8 +119,8 @@ class
#ifdef ABSL_HAVE_INTRINSIC_INT128 #ifdef ABSL_HAVE_INTRINSIC_INT128
constexpr uint128(__int128 v); // NOLINT(runtime/explicit) constexpr uint128(__int128 v); // NOLINT(runtime/explicit)
constexpr uint128(unsigned __int128 v); // NOLINT(runtime/explicit) constexpr uint128(unsigned __int128 v); // NOLINT(runtime/explicit)
#endif // ABSL_HAVE_INTRINSIC_INT128 #endif // ABSL_HAVE_INTRINSIC_INT128
constexpr uint128(int128 v); // NOLINT(runtime/explicit) constexpr uint128(int128 v); // NOLINT(runtime/explicit)
explicit uint128(float v); explicit uint128(float v);
explicit uint128(double v); explicit uint128(double v);
explicit uint128(long double v); explicit uint128(long double v);
...@@ -286,9 +286,9 @@ class numeric_limits<absl::uint128> { ...@@ -286,9 +286,9 @@ class numeric_limits<absl::uint128> {
#endif // ABSL_HAVE_INTRINSIC_INT128 #endif // ABSL_HAVE_INTRINSIC_INT128
static constexpr bool tinyness_before = false; static constexpr bool tinyness_before = false;
static constexpr absl::uint128 (min)() { return 0; } static constexpr absl::uint128(min)() { return 0; }
static constexpr absl::uint128 lowest() { return 0; } static constexpr absl::uint128 lowest() { return 0; }
static constexpr absl::uint128 (max)() { return absl::Uint128Max(); } static constexpr absl::uint128(max)() { return absl::Uint128Max(); }
static constexpr absl::uint128 epsilon() { return 0; } static constexpr absl::uint128 epsilon() { return 0; }
static constexpr absl::uint128 round_error() { return 0; } static constexpr absl::uint128 round_error() { return 0; }
static constexpr absl::uint128 infinity() { return 0; } static constexpr absl::uint128 infinity() { return 0; }
...@@ -521,9 +521,9 @@ class numeric_limits<absl::int128> { ...@@ -521,9 +521,9 @@ class numeric_limits<absl::int128> {
#endif // ABSL_HAVE_INTRINSIC_INT128 #endif // ABSL_HAVE_INTRINSIC_INT128
static constexpr bool tinyness_before = false; static constexpr bool tinyness_before = false;
static constexpr absl::int128 (min)() { return absl::Int128Min(); } static constexpr absl::int128(min)() { return absl::Int128Min(); }
static constexpr absl::int128 lowest() { return absl::Int128Min(); } static constexpr absl::int128 lowest() { return absl::Int128Min(); }
static constexpr absl::int128 (max)() { return absl::Int128Max(); } static constexpr absl::int128(max)() { return absl::Int128Max(); }
static constexpr absl::int128 epsilon() { return 0; } static constexpr absl::int128 epsilon() { return 0; }
static constexpr absl::int128 round_error() { return 0; } static constexpr absl::int128 round_error() { return 0; }
static constexpr absl::int128 infinity() { return 0; } static constexpr absl::int128 infinity() { return 0; }
...@@ -561,9 +561,7 @@ inline uint128& uint128::operator=(unsigned long v) { ...@@ -561,9 +561,7 @@ inline uint128& uint128::operator=(unsigned long v) {
} }
// NOLINTNEXTLINE(runtime/int) // NOLINTNEXTLINE(runtime/int)
inline uint128& uint128::operator=(long long v) { inline uint128& uint128::operator=(long long v) { return *this = uint128(v); }
return *this = uint128(v);
}
// NOLINTNEXTLINE(runtime/int) // NOLINTNEXTLINE(runtime/int)
inline uint128& uint128::operator=(unsigned long long v) { inline uint128& uint128::operator=(unsigned long long v) {
...@@ -571,18 +569,14 @@ inline uint128& uint128::operator=(unsigned long long v) { ...@@ -571,18 +569,14 @@ inline uint128& uint128::operator=(unsigned long long v) {
} }
#ifdef ABSL_HAVE_INTRINSIC_INT128 #ifdef ABSL_HAVE_INTRINSIC_INT128
inline uint128& uint128::operator=(__int128 v) { inline uint128& uint128::operator=(__int128 v) { return *this = uint128(v); }
return *this = uint128(v);
}
inline uint128& uint128::operator=(unsigned __int128 v) { inline uint128& uint128::operator=(unsigned __int128 v) {
return *this = uint128(v); return *this = uint128(v);
} }
#endif // ABSL_HAVE_INTRINSIC_INT128 #endif // ABSL_HAVE_INTRINSIC_INT128
inline uint128& uint128::operator=(int128 v) { inline uint128& uint128::operator=(int128 v) { return *this = uint128(v); }
return *this = uint128(v);
}
// Arithmetic operators. // Arithmetic operators.
...@@ -637,8 +631,7 @@ constexpr uint64_t Uint128High64(uint128 v) { return v.hi_; } ...@@ -637,8 +631,7 @@ constexpr uint64_t Uint128High64(uint128 v) { return v.hi_; }
#if defined(ABSL_IS_LITTLE_ENDIAN) #if defined(ABSL_IS_LITTLE_ENDIAN)
constexpr uint128::uint128(uint64_t high, uint64_t low) constexpr uint128::uint128(uint64_t high, uint64_t low) : lo_{low}, hi_{high} {}
: lo_{low}, hi_{high} {}
constexpr uint128::uint128(int v) constexpr uint128::uint128(int v)
: lo_{static_cast<uint64_t>(v)}, : lo_{static_cast<uint64_t>(v)},
...@@ -670,8 +663,7 @@ constexpr uint128::uint128(int128 v) ...@@ -670,8 +663,7 @@ constexpr uint128::uint128(int128 v)
#elif defined(ABSL_IS_BIG_ENDIAN) #elif defined(ABSL_IS_BIG_ENDIAN)
constexpr uint128::uint128(uint64_t high, uint64_t low) constexpr uint128::uint128(uint64_t high, uint64_t low) : hi_{high}, lo_{low} {}
: hi_{high}, lo_{low} {}
constexpr uint128::uint128(int v) constexpr uint128::uint128(int v)
: hi_{v < 0 ? (std::numeric_limits<uint64_t>::max)() : 0}, : hi_{v < 0 ? (std::numeric_limits<uint64_t>::max)() : 0},
...@@ -817,13 +809,9 @@ constexpr bool operator>=(uint128 lhs, uint128 rhs) { return !(lhs < rhs); } ...@@ -817,13 +809,9 @@ constexpr bool operator>=(uint128 lhs, uint128 rhs) { return !(lhs < rhs); }
// Unary operators. // Unary operators.
constexpr inline uint128 operator+(uint128 val) { constexpr inline uint128 operator+(uint128 val) { return val; }
return val;
}
constexpr inline int128 operator+(int128 val) { constexpr inline int128 operator+(int128 val) { return val; }
return val;
}
constexpr uint128 operator-(uint128 val) { constexpr uint128 operator-(uint128 val) {
#if defined(ABSL_HAVE_INTRINSIC_INT128) #if defined(ABSL_HAVE_INTRINSIC_INT128)
...@@ -906,7 +894,7 @@ constexpr uint128 operator<<(uint128 lhs, int amount) { ...@@ -906,7 +894,7 @@ constexpr uint128 operator<<(uint128 lhs, int amount) {
#else #else
// uint64_t shifts of >= 64 are undefined, so we will need some // uint64_t shifts of >= 64 are undefined, so we will need some
// special-casing. // special-casing.
return amount >= 64 ? MakeUint128(Uint128Low64(lhs) << (amount - 64), 0) return amount >= 64 ? MakeUint128(Uint128Low64(lhs) << (amount - 64), 0)
: amount == 0 ? lhs : amount == 0 ? lhs
: MakeUint128((Uint128High64(lhs) << amount) | : MakeUint128((Uint128High64(lhs) << amount) |
(Uint128Low64(lhs) >> (64 - amount)), (Uint128Low64(lhs) >> (64 - amount)),
...@@ -920,7 +908,7 @@ constexpr uint128 operator>>(uint128 lhs, int amount) { ...@@ -920,7 +908,7 @@ constexpr uint128 operator>>(uint128 lhs, int amount) {
#else #else
// uint64_t shifts of >= 64 are undefined, so we will need some // uint64_t shifts of >= 64 are undefined, so we will need some
// special-casing. // special-casing.
return amount >= 64 ? MakeUint128(0, Uint128High64(lhs) >> (amount - 64)) return amount >= 64 ? MakeUint128(0, Uint128High64(lhs) >> (amount - 64))
: amount == 0 ? lhs : amount == 0 ? lhs
: MakeUint128(Uint128High64(lhs) >> amount, : MakeUint128(Uint128High64(lhs) >> amount,
(Uint128Low64(lhs) >> amount) | (Uint128Low64(lhs) >> amount) |
...@@ -1042,27 +1030,19 @@ constexpr int128 MakeInt128(int64_t high, uint64_t low) { ...@@ -1042,27 +1030,19 @@ constexpr int128 MakeInt128(int64_t high, uint64_t low) {
} }
// Assignment from integer types. // Assignment from integer types.
inline int128& int128::operator=(int v) { inline int128& int128::operator=(int v) { return *this = int128(v); }
return *this = int128(v);
}
inline int128& int128::operator=(unsigned int v) { inline int128& int128::operator=(unsigned int v) { return *this = int128(v); }
return *this = int128(v);
}
inline int128& int128::operator=(long v) { // NOLINT(runtime/int) inline int128& int128::operator=(long v) { // NOLINT(runtime/int)
return *this = int128(v); return *this = int128(v);
} }
// NOLINTNEXTLINE(runtime/int) // NOLINTNEXTLINE(runtime/int)
inline int128& int128::operator=(unsigned long v) { inline int128& int128::operator=(unsigned long v) { return *this = int128(v); }
return *this = int128(v);
}
// NOLINTNEXTLINE(runtime/int) // NOLINTNEXTLINE(runtime/int)
inline int128& int128::operator=(long long v) { inline int128& int128::operator=(long long v) { return *this = int128(v); }
return *this = int128(v);
}
// NOLINTNEXTLINE(runtime/int) // NOLINTNEXTLINE(runtime/int)
inline int128& int128::operator=(unsigned long long v) { inline int128& int128::operator=(unsigned long long v) {
......
...@@ -80,10 +80,8 @@ std::ostream& operator<<(std::ostream& os, StatusCode code) { ...@@ -80,10 +80,8 @@ std::ostream& operator<<(std::ostream& os, StatusCode code) {
namespace status_internal { namespace status_internal {
static absl::optional<size_t> FindPayloadIndexByUrl( static absl::optional<size_t> FindPayloadIndexByUrl(
const Payloads* payloads, const Payloads* payloads, absl::string_view type_url) {
absl::string_view type_url) { if (payloads == nullptr) return absl::nullopt;
if (payloads == nullptr)
return absl::nullopt;
for (size_t i = 0; i < payloads->size(); ++i) { for (size_t i = 0; i < payloads->size(); ++i) {
if ((*payloads)[i].type_url == type_url) return i; if ((*payloads)[i].type_url == type_url) return i;
...@@ -125,8 +123,7 @@ absl::optional<absl::Cord> Status::GetPayload( ...@@ -125,8 +123,7 @@ absl::optional<absl::Cord> Status::GetPayload(
const auto* payloads = GetPayloads(); const auto* payloads = GetPayloads();
absl::optional<size_t> index = absl::optional<size_t> index =
status_internal::FindPayloadIndexByUrl(payloads, type_url); status_internal::FindPayloadIndexByUrl(payloads, type_url);
if (index.has_value()) if (index.has_value()) return (*payloads)[index.value()].payload;
return (*payloads)[index.value()].payload;
return absl::nullopt; return absl::nullopt;
} }
...@@ -303,7 +300,7 @@ std::string Status::ToStringSlow(StatusToStringMode mode) const { ...@@ -303,7 +300,7 @@ std::string Status::ToStringSlow(StatusToStringMode mode) const {
absl::StrAppend(&text, absl::StatusCodeToString(code()), ": ", message()); absl::StrAppend(&text, absl::StatusCodeToString(code()), ": ", message());
const bool with_payload = (mode & StatusToStringMode::kWithPayload) == const bool with_payload = (mode & StatusToStringMode::kWithPayload) ==
StatusToStringMode::kWithPayload; StatusToStringMode::kWithPayload;
if (with_payload) { if (with_payload) {
status_internal::StatusPayloadPrinter printer = status_internal::StatusPayloadPrinter printer =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment