From 628a2825f8dc0219964886e7cc3f7f519e3bd950 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Tue, 4 Jan 2022 18:04:19 -0800 Subject: [PATCH] Export of internal Abseil changes -- 04e8fdf6a37d31f9364ca0f70bf663ee972481c6 by Abseil Team : Another implicit sign conversion found and removed. PiperOrigin-RevId: 419718762 -- dbb6bca7d3cfa9ce79e70d0ed3d0354a4e3a0983 by Abseil Team : Fix sign conversions so that absl/status/status.h can compile with -Wconversion -Wsign-compare PiperOrigin-RevId: 419658075 GitOrigin-RevId: 04e8fdf6a37d31f9364ca0f70bf663ee972481c6 Change-Id: I18441488cc84f573c2818ee241c387e1953d5105 --- absl/container/inlined_vector.h | 4 ++-- absl/container/internal/inlined_vector.h | 4 ++-- absl/container/internal/raw_hash_set.h | 2 +- absl/numeric/bits.h | 3 ++- absl/random/internal/pcg_engine.h | 2 +- absl/strings/ascii.h | 6 ++--- absl/strings/internal/cord_internal.h | 9 +++---- absl/strings/numbers.h | 2 +- absl/strings/str_cat.h | 30 ++++++++++++++---------- absl/types/span.h | 3 ++- 10 files changed, 37 insertions(+), 28 deletions(-) diff --git a/absl/container/inlined_vector.h b/absl/container/inlined_vector.h index 5597d43e..711b29c1 100644 --- a/absl/container/inlined_vector.h +++ b/absl/container/inlined_vector.h @@ -151,7 +151,7 @@ class InlinedVector { const allocator_type& allocator = allocator_type()) : storage_(allocator) { storage_.Initialize(IteratorValueAdapter(first), - std::distance(first, last)); + static_cast(std::distance(first, last))); } // Creates an inlined vector with elements constructed from the provided input @@ -522,7 +522,7 @@ class InlinedVector { EnableIfAtLeastForwardIterator = 0> void assign(ForwardIterator first, ForwardIterator last) { storage_.Assign(IteratorValueAdapter(first), - std::distance(first, last)); + static_cast(std::distance(first, last))); } // Overload of `InlinedVector::assign(...)` to replace the contents of the diff --git a/absl/container/internal/inlined_vector.h b/absl/container/internal/inlined_vector.h index 98c26afc..cd34a413 100644 --- a/absl/container/internal/inlined_vector.h +++ b/absl/container/internal/inlined_vector.h @@ -311,10 +311,10 @@ class Storage { // Storage Constructors and Destructor // --------------------------------------------------------------------------- - Storage() : metadata_(A(), /* size and is_allocated */ 0) {} + Storage() : metadata_(A(), /* size and is_allocated */ 0u) {} explicit Storage(const A& allocator) - : metadata_(allocator, /* size and is_allocated */ 0) {} + : metadata_(allocator, /* size and is_allocated */ 0u) {} ~Storage() { if (GetSizeAndIsAllocated() == 0) { diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h index ad12f41c..1157d25a 100644 --- a/absl/container/internal/raw_hash_set.h +++ b/absl/container/internal/raw_hash_set.h @@ -1953,7 +1953,7 @@ class raw_hash_set { absl::container_internal::CompressedTuple - settings_{0, HashtablezInfoHandle{}, hasher{}, key_equal{}, + settings_{0u, HashtablezInfoHandle{}, hasher{}, key_equal{}, allocator_type{}}; }; diff --git a/absl/numeric/bits.h b/absl/numeric/bits.h index 52013ad4..628cdf50 100644 --- a/absl/numeric/bits.h +++ b/absl/numeric/bits.h @@ -133,7 +133,8 @@ template ABSL_INTERNAL_CONSTEXPR_CLZ inline typename std::enable_if::value, T>::type bit_width(T x) noexcept { - return std::numeric_limits::digits - countl_zero(x); + return std::numeric_limits::digits - + static_cast(countl_zero(x)); } // Returns: If x == 0, 0; otherwise the maximal value y such that diff --git a/absl/random/internal/pcg_engine.h b/absl/random/internal/pcg_engine.h index 8efaf2e0..4ab44c94 100644 --- a/absl/random/internal/pcg_engine.h +++ b/absl/random/internal/pcg_engine.h @@ -262,7 +262,7 @@ struct pcg_xsl_rr_128_64 { uint64_t rotate = h >> 58u; uint64_t s = Uint128Low64(state) ^ h; #endif - return rotr(s, rotate); + return rotr(s, static_cast(rotate)); } }; diff --git a/absl/strings/ascii.h b/absl/strings/ascii.h index 9b8e5d1a..42eadaea 100644 --- a/absl/strings/ascii.h +++ b/absl/strings/ascii.h @@ -197,7 +197,7 @@ ABSL_MUST_USE_RESULT inline std::string AsciiStrToUpper(absl::string_view s) { ABSL_MUST_USE_RESULT inline absl::string_view StripLeadingAsciiWhitespace( absl::string_view str) { auto it = std::find_if_not(str.begin(), str.end(), absl::ascii_isspace); - return str.substr(it - str.begin()); + return str.substr(static_cast(it - str.begin())); } // Strips in place whitespace from the beginning of the given string. @@ -211,13 +211,13 @@ inline void StripLeadingAsciiWhitespace(std::string* str) { ABSL_MUST_USE_RESULT inline absl::string_view StripTrailingAsciiWhitespace( absl::string_view str) { auto it = std::find_if_not(str.rbegin(), str.rend(), absl::ascii_isspace); - return str.substr(0, str.rend() - it); + return str.substr(0, static_cast(str.rend() - it)); } // Strips in place whitespace from the end of the given string inline void StripTrailingAsciiWhitespace(std::string* str) { auto it = std::find_if_not(str->rbegin(), str->rend(), absl::ascii_isspace); - str->erase(str->rend() - it); + str->erase(static_cast(str->rend() - it)); } // Returns absl::string_view with whitespace stripped from both ends of the diff --git a/absl/strings/internal/cord_internal.h b/absl/strings/internal/cord_internal.h index b16c8fa5..776d1c40 100644 --- a/absl/strings/internal/cord_internal.h +++ b/absl/strings/internal/cord_internal.h @@ -462,8 +462,8 @@ class InlineData { // Requires the current instance to hold a tree value. CordzInfo* cordz_info() const { assert(is_tree()); - intptr_t info = - static_cast(absl::big_endian::ToHost64(as_tree_.cordz_info)); + intptr_t info = static_cast( + absl::big_endian::ToHost64(static_cast(as_tree_.cordz_info))); assert(info & 1); return reinterpret_cast(info - 1); } @@ -473,8 +473,9 @@ class InlineData { // Requires the current instance to hold a tree value. void set_cordz_info(CordzInfo* cordz_info) { assert(is_tree()); - intptr_t info = reinterpret_cast(cordz_info) | 1; - as_tree_.cordz_info = absl::big_endian::FromHost64(info); + uintptr_t info = reinterpret_cast(cordz_info) | 1; + as_tree_.cordz_info = + static_cast(absl::big_endian::FromHost64(info)); } // Resets the current cordz_info to null / empty. diff --git a/absl/strings/numbers.h b/absl/strings/numbers.h index e977fc67..3ed24669 100644 --- a/absl/strings/numbers.h +++ b/absl/strings/numbers.h @@ -265,7 +265,7 @@ inline size_t FastHexToBufferZeroPad16(uint64_t val, char* out) { } #endif // | 0x1 so that even 0 has 1 digit. - return 16 - countl_zero(val | 0x1) / 4; + return 16 - static_cast(countl_zero(val | 0x1) / 4); } } // namespace numbers_internal diff --git a/absl/strings/str_cat.h b/absl/strings/str_cat.h index a8a85c73..4d228b09 100644 --- a/absl/strings/str_cat.h +++ b/absl/strings/str_cat.h @@ -214,23 +214,29 @@ class AlphaNum { // A bool ctor would also convert incoming pointers (bletch). AlphaNum(int x) // NOLINT(runtime/explicit) - : piece_(digits_, - numbers_internal::FastIntToBuffer(x, digits_) - &digits_[0]) {} + : piece_(digits_, static_cast( + numbers_internal::FastIntToBuffer(x, digits_) - + &digits_[0])) {} AlphaNum(unsigned int x) // NOLINT(runtime/explicit) - : piece_(digits_, - numbers_internal::FastIntToBuffer(x, digits_) - &digits_[0]) {} + : piece_(digits_, static_cast( + numbers_internal::FastIntToBuffer(x, digits_) - + &digits_[0])) {} AlphaNum(long x) // NOLINT(*) - : piece_(digits_, - numbers_internal::FastIntToBuffer(x, digits_) - &digits_[0]) {} + : piece_(digits_, static_cast( + numbers_internal::FastIntToBuffer(x, digits_) - + &digits_[0])) {} AlphaNum(unsigned long x) // NOLINT(*) - : piece_(digits_, - numbers_internal::FastIntToBuffer(x, digits_) - &digits_[0]) {} + : piece_(digits_, static_cast( + numbers_internal::FastIntToBuffer(x, digits_) - + &digits_[0])) {} AlphaNum(long long x) // NOLINT(*) - : piece_(digits_, - numbers_internal::FastIntToBuffer(x, digits_) - &digits_[0]) {} + : piece_(digits_, static_cast( + numbers_internal::FastIntToBuffer(x, digits_) - + &digits_[0])) {} AlphaNum(unsigned long long x) // NOLINT(*) - : piece_(digits_, - numbers_internal::FastIntToBuffer(x, digits_) - &digits_[0]) {} + : piece_(digits_, static_cast( + numbers_internal::FastIntToBuffer(x, digits_) - + &digits_[0])) {} AlphaNum(float f) // NOLINT(runtime/explicit) : piece_(digits_, numbers_internal::SixDigitsToBuffer(f, digits_)) {} diff --git a/absl/types/span.h b/absl/types/span.h index 6272bb7a..fdfbd77c 100644 --- a/absl/types/span.h +++ b/absl/types/span.h @@ -664,7 +664,8 @@ constexpr Span MakeSpan(T* ptr, size_t size) noexcept { template Span MakeSpan(T* begin, T* end) noexcept { - return ABSL_HARDENING_ASSERT(begin <= end), Span(begin, end - begin); + return ABSL_HARDENING_ASSERT(begin <= end), + Span(begin, static_cast(end - begin)); } template