diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-12-10 16:19:40 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-12-10 16:01:50 +0000 |
commit | 51f6c2793adab2d864b3d2b360000ef8db1d3e92 (patch) | |
tree | 835b3b4446b012c75e80177cef9fbe6972cc7dbe /chromium/third_party/abseil-cpp | |
parent | 6036726eb981b6c4b42047513b9d3f4ac865daac (diff) | |
download | qtwebengine-chromium-51f6c2793adab2d864b3d2b360000ef8db1d3e92.tar.gz |
BASELINE: Update Chromium to 71.0.3578.93
Change-Id: I6a32086c33670e1b033f8b10e6bf1fd4da1d105d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/third_party/abseil-cpp')
96 files changed, 1126 insertions, 543 deletions
diff --git a/chromium/third_party/abseil-cpp/CMakeLists.txt b/chromium/third_party/abseil-cpp/CMakeLists.txt index 89a3386f7e2..9a7e1031b23 100644 --- a/chromium/third_party/abseil-cpp/CMakeLists.txt +++ b/chromium/third_party/abseil-cpp/CMakeLists.txt @@ -32,7 +32,7 @@ if (MSVC) # /wd4244 conversion from 'type1' to 'type2' # /wd4267 conversion from 'size_t' to 'type2' # /wd4800 force value to bool 'true' or 'false' (performance warning) - add_compile_options(/W3 /WX /wd4005 /wd4068 /wd4244 /wd4267 /wd4800) + add_compile_options(/W3 /wd4005 /wd4068 /wd4244 /wd4267 /wd4800) add_definitions(/DNOMINMAX /DWIN32_LEAN_AND_MEAN=1 /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS) else() set(ABSL_STD_CXX_FLAG "-std=c++11" CACHE STRING "c++ std flag (default: c++11)") diff --git a/chromium/third_party/abseil-cpp/README.chromium b/chromium/third_party/abseil-cpp/README.chromium index 91d6d381a47..6026a2f4e20 100644 --- a/chromium/third_party/abseil-cpp/README.chromium +++ b/chromium/third_party/abseil-cpp/README.chromium @@ -4,7 +4,7 @@ URL: https://github.com/abseil/abseil-cpp License: Apache 2.0 License File: LICENSE Version: 0 -Revision: bea85b52733022294eef108a2e42d77b616ddca2 +Revision: fb462224c058487763f263b7995d70efd0242c17 Security Critical: yes Description: diff --git a/chromium/third_party/abseil-cpp/absl/base/BUILD.bazel b/chromium/third_party/abseil-cpp/absl/base/BUILD.bazel index 06d092ebdfa..83d48f6b20a 100644 --- a/chromium/third_party/abseil-cpp/absl/base/BUILD.bazel +++ b/chromium/third_party/abseil-cpp/absl/base/BUILD.bazel @@ -19,6 +19,7 @@ load( "ABSL_DEFAULT_COPTS", "ABSL_TEST_COPTS", "ABSL_EXCEPTIONS_FLAG", + "ABSL_EXCEPTIONS_FLAG_LINKOPTS", ) package(default_visibility = ["//visibility:public"]) @@ -29,6 +30,7 @@ cc_library( name = "spinlock_wait", srcs = [ "internal/spinlock_akaros.inc", + "internal/spinlock_linux.inc", "internal/spinlock_posix.inc", "internal/spinlock_wait.cc", "internal/spinlock_win32.inc", @@ -179,6 +181,7 @@ cc_library( srcs = ["internal/throw_delegate.cc"], hdrs = ["internal/throw_delegate.h"], copts = ABSL_DEFAULT_COPTS + ABSL_EXCEPTIONS_FLAG, + linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS, visibility = [ "//absl:__subpackages__", ], @@ -193,6 +196,7 @@ cc_test( name = "throw_delegate_test", srcs = ["throw_delegate_test.cc"], copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, + linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS, deps = [ ":throw_delegate", "@com_google_googletest//:gtest_main", @@ -225,6 +229,7 @@ cc_library( srcs = ["internal/exception_safety_testing.cc"], hdrs = ["internal/exception_safety_testing.h"], copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, + linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS, deps = [ ":base", ":config", @@ -241,6 +246,7 @@ cc_test( name = "exception_safety_testing_test", srcs = ["exception_safety_testing_test.cc"], copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, + linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS, deps = [ ":exception_safety_testing", "//absl/memory", @@ -421,3 +427,23 @@ cc_test( "@com_github_google_benchmark//:benchmark_main", ], ) + +cc_library( + name = "bits", + hdrs = ["internal/bits.h"], + visibility = [ + "//absl:__subpackages__", + ], + deps = [":core_headers"], +) + +cc_test( + name = "bits_test", + size = "small", + srcs = ["internal/bits_test.cc"], + copts = ABSL_TEST_COPTS, + deps = [ + ":bits", + "@com_google_googletest//:gtest_main", + ], +) diff --git a/chromium/third_party/abseil-cpp/absl/base/BUILD.gn b/chromium/third_party/abseil-cpp/absl/base/BUILD.gn index a7146564622..6c540f3b2bb 100644 --- a/chromium/third_party/abseil-cpp/absl/base/BUILD.gn +++ b/chromium/third_party/abseil-cpp/absl/base/BUILD.gn @@ -23,6 +23,7 @@ source_set("spinlock_wait") { public_configs = [ "//third_party/abseil-cpp:absl_include_config" ] sources = [ "internal/spinlock_akaros.inc", + "internal/spinlock_linux.inc", "internal/spinlock_posix.inc", "internal/spinlock_wait.cc", "internal/spinlock_win32.inc", @@ -71,6 +72,7 @@ source_set("dynamic_annotations") { public = [ "dynamic_annotations.h", ] + # Abseil's dynamic annotations are only visible inside Abseil because # their usage is deprecated in Chromium (see README.chromium for more info). visibility = [] @@ -296,3 +298,19 @@ source_set("endian") { ":core_headers", ] } + +source_set("bits") { + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ + "//build/config/compiler:no_chromium_code", + "//third_party/abseil-cpp:absl_default_cflags_cc", + ] + public = [ + "internal/bits.h", + ] + deps = [ + ":core_headers", + ] + visibility = [] + visibility += [ "../*" ] +} diff --git a/chromium/third_party/abseil-cpp/absl/base/CMakeLists.txt b/chromium/third_party/abseil-cpp/absl/base/CMakeLists.txt index 01d2af085f5..04a6eb31955 100644 --- a/chromium/third_party/abseil-cpp/absl/base/CMakeLists.txt +++ b/chromium/third_party/abseil-cpp/absl/base/CMakeLists.txt @@ -31,6 +31,7 @@ list(APPEND BASE_PUBLIC_HEADERS list(APPEND BASE_INTERNAL_HEADERS "internal/atomic_hook.h" + "internal/bits.h" "internal/cycleclock.h" "internal/direct_mmap.h" "internal/endian.h" diff --git a/chromium/third_party/abseil-cpp/absl/base/attributes.h b/chromium/third_party/abseil-cpp/absl/base/attributes.h index b1883b6d752..cc933bbaaee 100644 --- a/chromium/third_party/abseil-cpp/absl/base/attributes.h +++ b/chromium/third_party/abseil-cpp/absl/base/attributes.h @@ -100,7 +100,7 @@ // ABSL_PRINTF_ATTRIBUTE // ABSL_SCANF_ATTRIBUTE // -// Tells the compiler to perform `printf` format std::string checking if the +// Tells the compiler to perform `printf` format string checking if the // compiler supports it; see the 'format' attribute in // <http://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Function-Attributes.html>. // @@ -494,6 +494,20 @@ #define ABSL_XRAY_LOG_ARGS(N) #endif +// ABSL_ATTRIBUTE_REINITIALIZES +// +// Indicates that a member function reinitializes the entire object to a known +// state, independent of the previous state of the object. +// +// The clang-tidy check bugprone-use-after-move allows member functions marked +// with this attribute to be called on objects that have been moved from; +// without the attribute, this would result in a use-after-move warning. +#if ABSL_HAVE_CPP_ATTRIBUTE(clang::reinitializes) +#define ABSL_ATTRIBUTE_REINITIALIZES [[clang::reinitializes]] +#else +#define ABSL_ATTRIBUTE_REINITIALIZES +#endif + // ----------------------------------------------------------------------------- // Variable Attributes // ----------------------------------------------------------------------------- diff --git a/chromium/third_party/abseil-cpp/absl/base/config.h b/chromium/third_party/abseil-cpp/absl/base/config.h index 6890e313bf2..d4eb7d0cbd7 100644 --- a/chromium/third_party/abseil-cpp/absl/base/config.h +++ b/chromium/third_party/abseil-cpp/absl/base/config.h @@ -199,7 +199,7 @@ #define ABSL_HAVE_INTRINSIC_INT128 1 #elif defined(__CUDACC__) // __CUDACC_VER__ is a full version number before CUDA 9, and is defined to a -// std::string explaining that it has been removed starting with CUDA 9. We use +// string explaining that it has been removed starting with CUDA 9. We use // nested #ifs because there is no short-circuiting in the preprocessor. // NOTE: `__CUDACC__` could be undefined while `__CUDACC_VER__` is defined. #if __CUDACC_VER__ >= 70000 @@ -414,14 +414,13 @@ // <string_view>, <variant> is implemented) or higher. Also, `__cplusplus` is // not correctly set by MSVC, so we use `_MSVC_LANG` to check the language // version. -// TODO(zhangxy): fix tests before enabling aliasing for `std::any`, -// `std::string_view`. +// TODO(zhangxy): fix tests before enabling aliasing for `std::any`. #if defined(_MSC_VER) && _MSC_VER >= 1910 && \ ((defined(_MSVC_LANG) && _MSVC_LANG > 201402) || __cplusplus > 201402) // #define ABSL_HAVE_STD_ANY 1 #define ABSL_HAVE_STD_OPTIONAL 1 #define ABSL_HAVE_STD_VARIANT 1 -// #define ABSL_HAVE_STD_STRING_VIEW 1 +#define ABSL_HAVE_STD_STRING_VIEW 1 #endif #endif // ABSL_BASE_CONFIG_H_ diff --git a/chromium/third_party/abseil-cpp/absl/base/exception_safety_testing_test.cc b/chromium/third_party/abseil-cpp/absl/base/exception_safety_testing_test.cc index 97c8d6f8318..c2922f33c66 100644 --- a/chromium/third_party/abseil-cpp/absl/base/exception_safety_testing_test.cc +++ b/chromium/third_party/abseil-cpp/absl/base/exception_safety_testing_test.cc @@ -179,7 +179,7 @@ TEST(ThrowingValueTest, ThrowingStreamOps) { } // Tests the operator<< of ThrowingValue by forcing ConstructorTracker to emit -// a nonfatal failure that contains the std::string representation of the Thrower +// a nonfatal failure that contains the string representation of the Thrower TEST(ThrowingValueTest, StreamOpsOutput) { using ::testing::TypeSpec; exceptions_internal::ConstructorTracker ct(exceptions_internal::countdown); @@ -931,8 +931,8 @@ TEST(ThrowingValueTraitsTest, RelationalOperators) { } TEST(ThrowingAllocatorTraitsTest, Assignablility) { - EXPECT_TRUE(std::is_move_assignable<ThrowingAllocator<int>>::value); - EXPECT_TRUE(std::is_copy_assignable<ThrowingAllocator<int>>::value); + EXPECT_TRUE(absl::is_move_assignable<ThrowingAllocator<int>>::value); + EXPECT_TRUE(absl::is_copy_assignable<ThrowingAllocator<int>>::value); EXPECT_TRUE(std::is_nothrow_move_assignable<ThrowingAllocator<int>>::value); EXPECT_TRUE(std::is_nothrow_copy_assignable<ThrowingAllocator<int>>::value); } diff --git a/chromium/third_party/abseil-cpp/absl/base/internal/bits.h b/chromium/third_party/abseil-cpp/absl/base/internal/bits.h new file mode 100644 index 00000000000..bc7faaee3b2 --- /dev/null +++ b/chromium/third_party/abseil-cpp/absl/base/internal/bits.h @@ -0,0 +1,193 @@ +// Copyright 2018 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ABSL_BASE_INTERNAL_BITS_H_ +#define ABSL_BASE_INTERNAL_BITS_H_ + +// This file contains bitwise ops which are implementation details of various +// absl libraries. + +#include <cstdint> + +// Clang on Windows has __builtin_clzll; otherwise we need to use the +// windows intrinsic functions. +#if defined(_MSC_VER) +#include <intrin.h> +#if defined(_M_X64) +#pragma intrinsic(_BitScanReverse64) +#pragma intrinsic(_BitScanForward64) +#endif +#pragma intrinsic(_BitScanReverse) +#pragma intrinsic(_BitScanForward) +#endif + +#include "absl/base/attributes.h" + +#if defined(_MSC_VER) +// We can achieve something similar to attribute((always_inline)) with MSVC by +// using the __forceinline keyword, however this is not perfect. MSVC is +// much less aggressive about inlining, and even with the __forceinline keyword. +#define ABSL_BASE_INTERNAL_FORCEINLINE __forceinline +#else +// Use default attribute inline. +#define ABSL_BASE_INTERNAL_FORCEINLINE inline ABSL_ATTRIBUTE_ALWAYS_INLINE +#endif + + +namespace absl { +namespace base_internal { + +ABSL_BASE_INTERNAL_FORCEINLINE int CountLeadingZeros64Slow(uint64_t n) { + int zeroes = 60; + if (n >> 32) zeroes -= 32, n >>= 32; + if (n >> 16) zeroes -= 16, n >>= 16; + if (n >> 8) zeroes -= 8, n >>= 8; + if (n >> 4) zeroes -= 4, n >>= 4; + return "\4\3\2\2\1\1\1\1\0\0\0\0\0\0\0"[n] + zeroes; +} + +ABSL_BASE_INTERNAL_FORCEINLINE int CountLeadingZeros64(uint64_t n) { +#if defined(_MSC_VER) && defined(_M_X64) + // MSVC does not have __buitin_clzll. Use _BitScanReverse64. + unsigned long result = 0; // NOLINT(runtime/int) + if (_BitScanReverse64(&result, n)) { + return 63 - result; + } + return 64; +#elif defined(_MSC_VER) + // MSVC does not have __buitin_clzll. Compose two calls to _BitScanReverse + unsigned long result = 0; // NOLINT(runtime/int) + if ((n >> 32) && _BitScanReverse(&result, n >> 32)) { + return 31 - result; + } + if (_BitScanReverse(&result, n)) { + return 63 - result; + } + return 64; +#elif defined(__GNUC__) + // Use __builtin_clzll, which uses the following instructions: + // x86: bsr + // ARM64: clz + // PPC: cntlzd + static_assert(sizeof(unsigned long long) == sizeof(n), // NOLINT(runtime/int) + "__builtin_clzll does not take 64-bit arg"); + + // Handle 0 as a special case because __builtin_clzll(0) is undefined. + if (n == 0) { + return 64; + } + return __builtin_clzll(n); +#else + return CountLeadingZeros64Slow(n); +#endif +} + +ABSL_BASE_INTERNAL_FORCEINLINE int CountLeadingZeros32Slow(uint64_t n) { + int zeroes = 28; + if (n >> 16) zeroes -= 16, n >>= 16; + if (n >> 8) zeroes -= 8, n >>= 8; + if (n >> 4) zeroes -= 4, n >>= 4; + return "\4\3\2\2\1\1\1\1\0\0\0\0\0\0\0"[n] + zeroes; +} + +ABSL_BASE_INTERNAL_FORCEINLINE int CountLeadingZeros32(uint32_t n) { +#if defined(_MSC_VER) + unsigned long result = 0; // NOLINT(runtime/int) + if (_BitScanReverse(&result, n)) { + return 31 - result; + } + return 32; +#elif defined(__GNUC__) + // Use __builtin_clz, which uses the following instructions: + // x86: bsr + // ARM64: clz + // PPC: cntlzd + static_assert(sizeof(int) == sizeof(n), + "__builtin_clz does not take 32-bit arg"); + + // Handle 0 as a special case because __builtin_clz(0) is undefined. + if (n == 0) { + return 32; + } + return __builtin_clz(n); +#else + return CountLeadingZeros32Slow(n); +#endif +} + +ABSL_BASE_INTERNAL_FORCEINLINE int CountTrailingZerosNonZero64Slow(uint64_t n) { + int c = 63; + n &= ~n + 1; + if (n & 0x00000000FFFFFFFF) c -= 32; + if (n & 0x0000FFFF0000FFFF) c -= 16; + if (n & 0x00FF00FF00FF00FF) c -= 8; + if (n & 0x0F0F0F0F0F0F0F0F) c -= 4; + if (n & 0x3333333333333333) c -= 2; + if (n & 0x5555555555555555) c -= 1; + return c; +} + +ABSL_BASE_INTERNAL_FORCEINLINE int CountTrailingZerosNonZero64(uint64_t n) { +#if defined(_MSC_VER) && defined(_M_X64) + unsigned long result = 0; // NOLINT(runtime/int) + _BitScanForward64(&result, n); + return result; +#elif defined(_MSC_VER) + unsigned long result = 0; // NOLINT(runtime/int) + if (static_cast<uint32_t>(n) == 0) { + _BitScanForward(&result, n >> 32); + return result + 32; + } + _BitScanForward(&result, n); + return result; +#elif defined(__GNUC__) + static_assert(sizeof(unsigned long long) == sizeof(n), // NOLINT(runtime/int) + "__builtin_ctzll does not take 64-bit arg"); + return __builtin_ctzll(n); +#else + return CountTrailingZerosNonZero64Slow(n); +#endif +} + +ABSL_BASE_INTERNAL_FORCEINLINE int CountTrailingZerosNonZero32Slow(uint32_t n) { + int c = 31; + n &= ~n + 1; + if (n & 0x0000FFFF) c -= 16; + if (n & 0x00FF00FF) c -= 8; + if (n & 0x0F0F0F0F) c -= 4; + if (n & 0x33333333) c -= 2; + if (n & 0x55555555) c -= 1; + return c; +} + +ABSL_BASE_INTERNAL_FORCEINLINE int CountTrailingZerosNonZero32(uint32_t n) { +#if defined(_MSC_VER) + unsigned long result = 0; // NOLINT(runtime/int) + _BitScanForward(&result, n); + return result; +#elif defined(__GNUC__) + static_assert(sizeof(int) == sizeof(n), + "__builtin_ctz does not take 32-bit arg"); + return __builtin_ctz(n); +#else + return CountTrailingZerosNonZero32Slow(n); +#endif +} + +#undef ABSL_BASE_INTERNAL_FORCEINLINE + +} // namespace base_internal +} // namespace absl + +#endif // ABSL_BASE_INTERNAL_BITS_H_ diff --git a/chromium/third_party/abseil-cpp/absl/base/internal/bits_test.cc b/chromium/third_party/abseil-cpp/absl/base/internal/bits_test.cc new file mode 100644 index 00000000000..e5d991d6725 --- /dev/null +++ b/chromium/third_party/abseil-cpp/absl/base/internal/bits_test.cc @@ -0,0 +1,97 @@ +// Copyright 2018 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "absl/base/internal/bits.h" + +#include "gtest/gtest.h" + +namespace { + +int CLZ64(uint64_t n) { + int fast = absl::base_internal::CountLeadingZeros64(n); + int slow = absl::base_internal::CountLeadingZeros64Slow(n); + EXPECT_EQ(fast, slow) << n; + return fast; +} + +TEST(BitsTest, CountLeadingZeros64) { + EXPECT_EQ(64, CLZ64(uint64_t{})); + EXPECT_EQ(0, CLZ64(~uint64_t{})); + + for (int index = 0; index < 64; index++) { + uint64_t x = static_cast<uint64_t>(1) << index; + const auto cnt = 63 - index; + ASSERT_EQ(cnt, CLZ64(x)) << index; + ASSERT_EQ(cnt, CLZ64(x + x - 1)) << index; + } +} + +int CLZ32(uint32_t n) { + int fast = absl::base_internal::CountLeadingZeros32(n); + int slow = absl::base_internal::CountLeadingZeros32Slow(n); + EXPECT_EQ(fast, slow) << n; + return fast; +} + +TEST(BitsTest, CountLeadingZeros32) { + EXPECT_EQ(32, CLZ32(uint32_t{})); + EXPECT_EQ(0, CLZ32(~uint32_t{})); + + for (int index = 0; index < 32; index++) { + uint32_t x = static_cast<uint32_t>(1) << index; + const auto cnt = 31 - index; + ASSERT_EQ(cnt, CLZ32(x)) << index; + ASSERT_EQ(cnt, CLZ32(x + x - 1)) << index; + ASSERT_EQ(CLZ64(x), CLZ32(x) + 32); + } +} + +int CTZ64(uint64_t n) { + int fast = absl::base_internal::CountTrailingZerosNonZero64(n); + int slow = absl::base_internal::CountTrailingZerosNonZero64Slow(n); + EXPECT_EQ(fast, slow) << n; + return fast; +} + +TEST(BitsTest, CountTrailingZerosNonZero64) { + EXPECT_EQ(0, CTZ64(~uint64_t{})); + + for (int index = 0; index < 64; index++) { + uint64_t x = static_cast<uint64_t>(1) << index; + const auto cnt = index; + ASSERT_EQ(cnt, CTZ64(x)) << index; + ASSERT_EQ(cnt, CTZ64(~(x - 1))) << index; + } +} + +int CTZ32(uint32_t n) { + int fast = absl::base_internal::CountTrailingZerosNonZero32(n); + int slow = absl::base_internal::CountTrailingZerosNonZero32Slow(n); + EXPECT_EQ(fast, slow) << n; + return fast; +} + +TEST(BitsTest, CountTrailingZerosNonZero32) { + EXPECT_EQ(0, CTZ32(~uint32_t{})); + + for (int index = 0; index < 32; index++) { + uint32_t x = static_cast<uint32_t>(1) << index; + const auto cnt = index; + ASSERT_EQ(cnt, CTZ32(x)) << index; + ASSERT_EQ(cnt, CTZ32(~(x - 1))) << index; + } +} + + +} // namespace diff --git a/chromium/third_party/abseil-cpp/absl/base/internal/raw_logging.h b/chromium/third_party/abseil-cpp/absl/base/internal/raw_logging.h index 67abfd30798..79a7bb9b2f7 100644 --- a/chromium/third_party/abseil-cpp/absl/base/internal/raw_logging.h +++ b/chromium/third_party/abseil-cpp/absl/base/internal/raw_logging.h @@ -114,7 +114,7 @@ void SafeWriteToStderr(const char *s, size_t len); // compile-time function to get the "base" filename, that is, the part of // a filename after the last "/" or "\" path separator. The search starts at -// the end of the std::string; the second parameter is the length of the std::string. +// the end of the string; the second parameter is the length of the string. constexpr const char* Basename(const char* fname, int offset) { return offset == 0 || fname[offset - 1] == '/' || fname[offset - 1] == '\\' ? fname + offset diff --git a/chromium/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc b/chromium/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc new file mode 100644 index 00000000000..94c861dc6ca --- /dev/null +++ b/chromium/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc @@ -0,0 +1,72 @@ +// Copyright 2018 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// This file is a Linux-specific part of spinlock_wait.cc + +#include <linux/futex.h> +#include <sys/syscall.h> +#include <unistd.h> + +#include <atomic> +#include <cerrno> +#include <climits> +#include <cstdint> +#include <ctime> + +#include "absl/base/attributes.h" + +// The SpinLock lockword is `std::atomic<uint32_t>`. Here we assert that +// `std::atomic<uint32_t>` is bitwise equivalent of the `int` expected +// by SYS_futex. We also assume that reads/writes done to the lockword +// by SYS_futex have rational semantics with regard to the +// std::atomic<> API. C++ provides no guarantees of these assumptions, +// but they are believed to hold in practice. +static_assert(sizeof(std::atomic<uint32_t>) == sizeof(int), + "SpinLock lockword has the wrong size for a futex"); + +// Some Android headers are missing these definitions even though they +// support these futex operations. +#ifdef __BIONIC__ +#ifndef SYS_futex +#define SYS_futex __NR_futex +#endif +#ifndef FUTEX_PRIVATE_FLAG +#define FUTEX_PRIVATE_FLAG 128 +#endif +#endif + +extern "C" { + +ABSL_ATTRIBUTE_WEAK void AbslInternalSpinLockDelay( + std::atomic<uint32_t> *w, uint32_t value, int loop, + absl::base_internal::SchedulingMode) { + if (loop != 0) { + int save_errno = errno; + struct timespec tm; + tm.tv_sec = 0; + // Increase the delay; we expect (but do not rely on) explicit wakeups. + // We don't rely on explicit wakeups because we intentionally allow for + // a race on the kSpinLockSleeper bit. + tm.tv_nsec = 16 * absl::base_internal::SpinLockSuggestedDelayNS(loop); + syscall(SYS_futex, w, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, value, &tm); + errno = save_errno; + } +} + +ABSL_ATTRIBUTE_WEAK void AbslInternalSpinLockWake(std::atomic<uint32_t> *w, + bool all) { + syscall(SYS_futex, w, FUTEX_WAKE | FUTEX_PRIVATE_FLAG, all ? INT_MAX : 1, 0); +} + +} // extern "C" diff --git a/chromium/third_party/abseil-cpp/absl/base/internal/spinlock_wait.cc b/chromium/third_party/abseil-cpp/absl/base/internal/spinlock_wait.cc index 9f6e9911e10..0fde9c04b73 100644 --- a/chromium/third_party/abseil-cpp/absl/base/internal/spinlock_wait.cc +++ b/chromium/third_party/abseil-cpp/absl/base/internal/spinlock_wait.cc @@ -13,7 +13,7 @@ // limitations under the License. // The OS-specific header included below must provide two calls: -// base::subtle::SpinLockDelay() and base::subtle::SpinLockWake(). +// AbslInternalSpinLockDelay() and AbslInternalSpinLockWake(). // See spinlock_wait.h for the specs. #include <atomic> @@ -23,6 +23,8 @@ #if defined(_WIN32) #include "absl/base/internal/spinlock_win32.inc" +#elif defined(__linux__) +#include "absl/base/internal/spinlock_linux.inc" #elif defined(__akaros__) #include "absl/base/internal/spinlock_akaros.inc" #else diff --git a/chromium/third_party/abseil-cpp/absl/base/log_severity.h b/chromium/third_party/abseil-cpp/absl/base/log_severity.h index e2931c34d1d..5770d3629e7 100644 --- a/chromium/third_party/abseil-cpp/absl/base/log_severity.h +++ b/chromium/third_party/abseil-cpp/absl/base/log_severity.h @@ -39,7 +39,7 @@ constexpr std::array<absl::LogSeverity, 4> LogSeverities() { absl::LogSeverity::kError, absl::LogSeverity::kFatal}}; } -// Returns the all-caps std::string representation (e.g. "INFO") of the specified +// Returns the all-caps string representation (e.g. "INFO") of the specified // severity level if it is one of the normal levels and "UNKNOWN" otherwise. constexpr const char* LogSeverityName(absl::LogSeverity s) { return s == absl::LogSeverity::kInfo diff --git a/chromium/third_party/abseil-cpp/absl/base/raw_logging_test.cc b/chromium/third_party/abseil-cpp/absl/base/raw_logging_test.cc index ebbc5db9067..b21cf651758 100644 --- a/chromium/third_party/abseil-cpp/absl/base/raw_logging_test.cc +++ b/chromium/third_party/abseil-cpp/absl/base/raw_logging_test.cc @@ -40,7 +40,7 @@ TEST(RawLoggingCompilationTest, PassingCheck) { } // Not all platforms support output from raw log, so we don't verify any -// particular output for RAW check failures (expecting the empty std::string +// particular output for RAW check failures (expecting the empty string // accomplishes this). This test is primarily a compilation test, but we // are verifying process death when EXPECT_DEATH works for a platform. const char kExpectedDeathOutput[] = ""; diff --git a/chromium/third_party/abseil-cpp/absl/container/BUILD.bazel b/chromium/third_party/abseil-cpp/absl/container/BUILD.bazel index 6d5c958f382..7b5f52bc059 100644 --- a/chromium/third_party/abseil-cpp/absl/container/BUILD.bazel +++ b/chromium/third_party/abseil-cpp/absl/container/BUILD.bazel @@ -19,6 +19,7 @@ load( "ABSL_DEFAULT_COPTS", "ABSL_TEST_COPTS", "ABSL_EXCEPTIONS_FLAG", + "ABSL_EXCEPTIONS_FLAG_LINKOPTS", ) package(default_visibility = ["//visibility:public"]) @@ -62,6 +63,7 @@ cc_test( name = "fixed_array_test", srcs = ["fixed_array_test.cc"], copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, + linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS, deps = [ ":fixed_array", "//absl/base:exception_testing", @@ -86,6 +88,7 @@ cc_test( name = "fixed_array_exception_safety_test", srcs = ["fixed_array_exception_safety_test.cc"], copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, + linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS, deps = [ ":fixed_array", "//absl/base:exception_safety_testing", @@ -120,6 +123,7 @@ cc_test( name = "inlined_vector_test", srcs = ["inlined_vector_test.cc"], copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, + linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS, deps = [ ":inlined_vector", ":test_instance_tracker", diff --git a/chromium/third_party/abseil-cpp/absl/container/fixed_array.h b/chromium/third_party/abseil-cpp/absl/container/fixed_array.h index 182258f623e..cfc48de8eac 100644 --- a/chromium/third_party/abseil-cpp/absl/container/fixed_array.h +++ b/chromium/third_party/abseil-cpp/absl/container/fixed_array.h @@ -138,8 +138,8 @@ class FixedArray { explicit FixedArray(size_type n, const allocator_type& a = allocator_type()) : storage_(n, a) { if (DefaultConstructorIsNonTrivial()) { - memory_internal::ConstructStorage(storage_.alloc(), storage_.begin(), - storage_.end()); + memory_internal::ConstructRange(storage_.alloc(), storage_.begin(), + storage_.end()); } } @@ -147,8 +147,8 @@ class FixedArray { FixedArray(size_type n, const value_type& val, const allocator_type& a = allocator_type()) : storage_(n, a) { - memory_internal::ConstructStorage(storage_.alloc(), storage_.begin(), - storage_.end(), val); + memory_internal::ConstructRange(storage_.alloc(), storage_.begin(), + storage_.end(), val); } // Creates an array initialized with the size and contents of `init_list`. @@ -163,13 +163,12 @@ class FixedArray { FixedArray(Iterator first, Iterator last, const allocator_type& a = allocator_type()) : storage_(std::distance(first, last), a) { - memory_internal::CopyToStorageFromRange(storage_.alloc(), storage_.begin(), - first, last); + memory_internal::CopyRange(storage_.alloc(), storage_.begin(), first, last); } ~FixedArray() noexcept { for (auto* cur = storage_.begin(); cur != storage_.end(); ++cur) { - AllocatorTraits::destroy(*storage_.alloc(), cur); + AllocatorTraits::destroy(storage_.alloc(), cur); } } @@ -446,15 +445,15 @@ class FixedArray { if (UsingInlinedStorage(size())) { InlinedStorage::AnnotateDestruct(size()); } else { - AllocatorTraits::deallocate(*alloc(), AsValueType(begin()), size()); + AllocatorTraits::deallocate(alloc(), AsValueType(begin()), size()); } } size_type size() const { return size_alloc_.template get<0>(); } StorageElement* begin() const { return data_; } StorageElement* end() const { return begin() + size(); } - allocator_type* alloc() { - return std::addressof(size_alloc_.template get<1>()); + allocator_type& alloc() { + return size_alloc_.template get<1>(); } private: @@ -468,7 +467,7 @@ class FixedArray { return InlinedStorage::data(); } else { return reinterpret_cast<StorageElement*>( - AllocatorTraits::allocate(*alloc(), size())); + AllocatorTraits::allocate(alloc(), size())); } } diff --git a/chromium/third_party/abseil-cpp/absl/container/inlined_vector_benchmark.cc b/chromium/third_party/abseil-cpp/absl/container/inlined_vector_benchmark.cc index 24f2174928a..a3ad0f8ae4f 100644 --- a/chromium/third_party/abseil-cpp/absl/container/inlined_vector_benchmark.cc +++ b/chromium/third_party/abseil-cpp/absl/container/inlined_vector_benchmark.cc @@ -66,7 +66,7 @@ BENCHMARK(BM_StdVectorFill)->Range(0, 1024); // The purpose of the next two benchmarks is to verify that // absl::InlinedVector is efficient when moving is more efficent than // copying. To do so, we use strings that are larger than the short -// std::string optimization. +// string optimization. bool StringRepresentedInline(std::string s) { const char* chars = s.data(); std::string s1 = std::move(s); diff --git a/chromium/third_party/abseil-cpp/absl/container/internal/test_instance_tracker.cc b/chromium/third_party/abseil-cpp/absl/container/internal/test_instance_tracker.cc index fe00aca8fb9..b18e0bb7a1e 100644 --- a/chromium/third_party/abseil-cpp/absl/container/internal/test_instance_tracker.cc +++ b/chromium/third_party/abseil-cpp/absl/container/internal/test_instance_tracker.cc @@ -21,6 +21,7 @@ int BaseCountedInstance::num_live_instances_ = 0; int BaseCountedInstance::num_moves_ = 0; int BaseCountedInstance::num_copies_ = 0; int BaseCountedInstance::num_swaps_ = 0; +int BaseCountedInstance::num_comparisons_ = 0; } // namespace test_internal } // namespace absl diff --git a/chromium/third_party/abseil-cpp/absl/container/internal/test_instance_tracker.h b/chromium/third_party/abseil-cpp/absl/container/internal/test_instance_tracker.h index cf8f3a531e6..ec45f574037 100644 --- a/chromium/third_party/abseil-cpp/absl/container/internal/test_instance_tracker.h +++ b/chromium/third_party/abseil-cpp/absl/container/internal/test_instance_tracker.h @@ -22,8 +22,8 @@ namespace absl { namespace test_internal { // A type that counts number of occurences of the type, the live occurrences of -// the type, as well as the number of copies, moves, and swaps that have -// occurred on the type. This is used as a base class for the copyable, +// the type, as well as the number of copies, moves, swaps, and comparisons that +// have occurred on the type. This is used as a base class for the copyable, // copyable+movable, and movable types below that are used in actual tests. Use // InstanceTracker in tests to track the number of instances. class BaseCountedInstance { @@ -66,6 +66,36 @@ class BaseCountedInstance { return *this; } + bool operator==(const BaseCountedInstance& x) const { + ++num_comparisons_; + return value_ == x.value_; + } + + bool operator!=(const BaseCountedInstance& x) const { + ++num_comparisons_; + return value_ != x.value_; + } + + bool operator<(const BaseCountedInstance& x) const { + ++num_comparisons_; + return value_ < x.value_; + } + + bool operator>(const BaseCountedInstance& x) const { + ++num_comparisons_; + return value_ > x.value_; + } + + bool operator<=(const BaseCountedInstance& x) const { + ++num_comparisons_; + return value_ <= x.value_; + } + + bool operator>=(const BaseCountedInstance& x) const { + ++num_comparisons_; + return value_ >= x.value_; + } + int value() const { if (!is_live_) std::abort(); return value_; @@ -108,6 +138,9 @@ class BaseCountedInstance { // Number of times that BaseCountedInstance objects were swapped. static int num_swaps_; + + // Number of times that BaseCountedInstance objects were compared. + static int num_comparisons_; }; // Helper to track the BaseCountedInstance instance counters. Expects that the @@ -152,13 +185,21 @@ class InstanceTracker { // construction or the last call to ResetCopiesMovesSwaps(). int swaps() const { return BaseCountedInstance::num_swaps_ - start_swaps_; } - // Resets the base values for moves, copies and swaps to the current values, - // so that subsequent Get*() calls for moves, copies and swaps will compare to - // the situation at the point of this call. + // Returns the number of comparisons on BaseCountedInstance objects since + // construction or the last call to ResetCopiesMovesSwaps(). + int comparisons() const { + return BaseCountedInstance::num_comparisons_ - start_comparisons_; + } + + // Resets the base values for moves, copies, comparisons, and swaps to the + // current values, so that subsequent Get*() calls for moves, copies, + // comparisons, and swaps will compare to the situation at the point of this + // call. void ResetCopiesMovesSwaps() { start_moves_ = BaseCountedInstance::num_moves_; start_copies_ = BaseCountedInstance::num_copies_; start_swaps_ = BaseCountedInstance::num_swaps_; + start_comparisons_ = BaseCountedInstance::num_comparisons_; } private: @@ -167,6 +208,7 @@ class InstanceTracker { int start_moves_; int start_copies_; int start_swaps_; + int start_comparisons_; }; // Copyable, not movable. diff --git a/chromium/third_party/abseil-cpp/absl/container/internal/test_instance_tracker_test.cc b/chromium/third_party/abseil-cpp/absl/container/internal/test_instance_tracker_test.cc index 9efb6771cf0..0ae57636df2 100644 --- a/chromium/third_party/abseil-cpp/absl/container/internal/test_instance_tracker_test.cc +++ b/chromium/third_party/abseil-cpp/absl/container/internal/test_instance_tracker_test.cc @@ -157,4 +157,26 @@ TEST(TestInstanceTracker, ExistingInstances) { EXPECT_EQ(1, tracker.moves()); } +TEST(TestInstanceTracker, Comparisons) { + InstanceTracker tracker; + MovableOnlyInstance one(1), two(2); + + EXPECT_EQ(0, tracker.comparisons()); + EXPECT_FALSE(one == two); + EXPECT_EQ(1, tracker.comparisons()); + EXPECT_TRUE(one != two); + EXPECT_EQ(2, tracker.comparisons()); + EXPECT_TRUE(one < two); + EXPECT_EQ(3, tracker.comparisons()); + EXPECT_FALSE(one > two); + EXPECT_EQ(4, tracker.comparisons()); + EXPECT_TRUE(one <= two); + EXPECT_EQ(5, tracker.comparisons()); + EXPECT_FALSE(one >= two); + EXPECT_EQ(6, tracker.comparisons()); + + tracker.ResetCopiesMovesSwaps(); + EXPECT_EQ(0, tracker.comparisons()); +} + } // namespace diff --git a/chromium/third_party/abseil-cpp/absl/copts.bzl b/chromium/third_party/abseil-cpp/absl/copts.bzl index 0168ac5abdd..e4b425b08e7 100644 --- a/chromium/third_party/abseil-cpp/absl/copts.bzl +++ b/chromium/third_party/abseil-cpp/absl/copts.bzl @@ -35,7 +35,6 @@ GCC_TEST_FLAGS = [ # Docs on groups of flags is preceded by ###. LLVM_FLAGS = [ - # All warnings are treated as errors by implicit -Werror flag "-Wall", "-Wextra", "-Weverything", @@ -116,7 +115,6 @@ LLVM_TEST_FLAGS = [ MSVC_FLAGS = [ "/W3", - "/WX", "/wd4005", # macro-redefinition "/wd4068", # unknown pragma "/wd4244", # conversion from 'type1' to 'type2', possible loss of data @@ -152,3 +150,7 @@ ABSL_EXCEPTIONS_FLAG = select({ "//absl:windows": ["/U_HAS_EXCEPTIONS", "/D_HAS_EXCEPTIONS=1", "/EHsc"], "//conditions:default": ["-fexceptions"], }) + +ABSL_EXCEPTIONS_FLAG_LINKOPTS = select({ + "//conditions:default": [], +}) diff --git a/chromium/third_party/abseil-cpp/absl/debugging/internal/demangle.cc b/chromium/third_party/abseil-cpp/absl/debugging/internal/demangle.cc index c9ca2f3bdb1..48354459bc8 100644 --- a/chromium/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +++ b/chromium/third_party/abseil-cpp/absl/debugging/internal/demangle.cc @@ -340,7 +340,7 @@ static bool ZeroOrMore(ParseFunc parse_func, State *state) { } // Append "str" at "out_cur_idx". If there is an overflow, out_cur_idx is -// set to out_end_idx+1. The output std::string is ensured to +// set to out_end_idx+1. The output string is ensured to // always terminate with '\0' as long as there is no overflow. static void Append(State *state, const char *const str, const int length) { for (int i = 0; i < length; ++i) { @@ -840,7 +840,7 @@ static bool ParseNumber(State *state, int *number_out) { } // Floating-point literals are encoded using a fixed-length lowercase -// hexadecimal std::string. +// hexadecimal string. static bool ParseFloatNumber(State *state) { ComplexityGuard guard(state); if (guard.IsTooComplex()) return false; diff --git a/chromium/third_party/abseil-cpp/absl/debugging/symbolize_test.cc b/chromium/third_party/abseil-cpp/absl/debugging/symbolize_test.cc index 5f2af47ee45..8029fbe9d2e 100644 --- a/chromium/third_party/abseil-cpp/absl/debugging/symbolize_test.cc +++ b/chromium/third_party/abseil-cpp/absl/debugging/symbolize_test.cc @@ -321,7 +321,7 @@ TEST(Symbolize, SymbolizeWithMultipleMaps) { } } -// Appends std::string(*args->arg) to args->symbol_buf. +// Appends string(*args->arg) to args->symbol_buf. static void DummySymbolDecorator( const absl::debugging_internal::SymbolDecoratorArgs *args) { std::string *message = static_cast<std::string *>(args->arg); diff --git a/chromium/third_party/abseil-cpp/absl/memory/BUILD.bazel b/chromium/third_party/abseil-cpp/absl/memory/BUILD.bazel index 46f47b12bb2..89a312eac4b 100644 --- a/chromium/third_party/abseil-cpp/absl/memory/BUILD.bazel +++ b/chromium/third_party/abseil-cpp/absl/memory/BUILD.bazel @@ -19,6 +19,7 @@ load( "ABSL_DEFAULT_COPTS", "ABSL_TEST_COPTS", "ABSL_EXCEPTIONS_FLAG", + "ABSL_EXCEPTIONS_FLAG_LINKOPTS", ) package(default_visibility = ["//visibility:public"]) @@ -53,6 +54,7 @@ cc_test( "memory_exception_safety_test.cc", ], copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, + linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS, deps = [ ":memory", "//absl/base:exception_safety_testing", diff --git a/chromium/third_party/abseil-cpp/absl/memory/memory.h b/chromium/third_party/abseil-cpp/absl/memory/memory.h index c7caf8b94dc..a80aab0af64 100644 --- a/chromium/third_party/abseil-cpp/absl/memory/memory.h +++ b/chromium/third_party/abseil-cpp/absl/memory/memory.h @@ -641,55 +641,59 @@ struct default_allocator_is_nothrow : std::false_type {}; #endif namespace memory_internal { -#ifdef ABSL_HAVE_EXCEPTIONS -template <typename Allocator, typename StorageElement, typename... Args> -void ConstructStorage(Allocator* alloc, StorageElement* first, - StorageElement* last, const Args&... args) { - for (StorageElement* cur = first; cur != last; ++cur) { +#ifdef ABSL_HAVE_EXCEPTIONS // ConstructRange +template <typename Allocator, typename Iterator, typename... Args> +void ConstructRange(Allocator& alloc, Iterator first, Iterator last, + const Args&... args) { + for (Iterator cur = first; cur != last; ++cur) { try { - std::allocator_traits<Allocator>::construct(*alloc, cur, args...); + std::allocator_traits<Allocator>::construct(alloc, cur, args...); } catch (...) { while (cur != first) { --cur; - std::allocator_traits<Allocator>::destroy(*alloc, cur); + std::allocator_traits<Allocator>::destroy(alloc, cur); } throw; } } } -template <typename Allocator, typename StorageElement, typename Iterator> -void CopyToStorageFromRange(Allocator* alloc, StorageElement* destination, - Iterator first, Iterator last) { - for (StorageElement* cur = destination; first != last; +#else // ABSL_HAVE_EXCEPTIONS // ConstructRange +template <typename Allocator, typename Iterator, typename... Args> +void ConstructRange(Allocator& alloc, Iterator first, Iterator last, + const Args&... args) { + for (; first != last; ++first) { + std::allocator_traits<Allocator>::construct(alloc, first, args...); + } +} +#endif // ABSL_HAVE_EXCEPTIONS // ConstructRange + +#ifdef ABSL_HAVE_EXCEPTIONS // CopyRange +template <typename Allocator, typename Iterator, typename InputIterator> +void CopyRange(Allocator& alloc, Iterator destination, InputIterator first, + InputIterator last) { + for (Iterator cur = destination; first != last; static_cast<void>(++cur), static_cast<void>(++first)) { try { - std::allocator_traits<Allocator>::construct(*alloc, cur, *first); + std::allocator_traits<Allocator>::construct(alloc, cur, *first); } catch (...) { while (cur != destination) { --cur; - std::allocator_traits<Allocator>::destroy(*alloc, cur); + std::allocator_traits<Allocator>::destroy(alloc, cur); } throw; } } } -#else // ABSL_HAVE_EXCEPTIONS -template <typename Allocator, typename StorageElement, typename... Args> -void ConstructStorage(Allocator* alloc, StorageElement* first, - StorageElement* last, const Args&... args) { - for (; first != last; ++first) { - std::allocator_traits<Allocator>::construct(*alloc, first, args...); - } -} -template <typename Allocator, typename StorageElement, typename Iterator> -void CopyToStorageFromRange(Allocator* alloc, StorageElement* destination, - Iterator first, Iterator last) { +#else // ABSL_HAVE_EXCEPTIONS // CopyRange +template <typename Allocator, typename Iterator, typename InputIterator> +void CopyRange(Allocator& alloc, Iterator destination, InputIterator first, + InputIterator last) { for (; first != last; static_cast<void>(++destination), static_cast<void>(++first)) { - std::allocator_traits<Allocator>::construct(*alloc, destination, *first); + std::allocator_traits<Allocator>::construct(alloc, destination, *first); } } -#endif // ABSL_HAVE_EXCEPTIONS +#endif // ABSL_HAVE_EXCEPTIONS // CopyRange } // namespace memory_internal } // namespace absl diff --git a/chromium/third_party/abseil-cpp/absl/meta/type_traits.h b/chromium/third_party/abseil-cpp/absl/meta/type_traits.h index 457b890841a..23ebd6ed099 100644 --- a/chromium/third_party/abseil-cpp/absl/meta/type_traits.h +++ b/chromium/third_party/abseil-cpp/absl/meta/type_traits.h @@ -105,8 +105,25 @@ template <class To, template <class...> class Op, class... Args> struct is_detected_convertible : is_detected_convertible_impl<void, To, Op, Args...>::type {}; +template <typename T> +using IsCopyAssignableImpl = + decltype(std::declval<T&>() = std::declval<const T&>()); + +template <typename T> +using IsMoveAssignableImpl = decltype(std::declval<T&>() = std::declval<T&&>()); + } // namespace type_traits_internal +template <typename T> +struct is_copy_assignable : type_traits_internal::is_detected< + type_traits_internal::IsCopyAssignableImpl, T> { +}; + +template <typename T> +struct is_move_assignable : type_traits_internal::is_detected< + type_traits_internal::IsMoveAssignableImpl, T> { +}; + // void_t() // // Ignores the type of any its arguments and returns `void`. In general, this @@ -309,7 +326,7 @@ template <typename T> struct is_trivially_copy_assignable : std::integral_constant< bool, __has_trivial_assign(typename std::remove_reference<T>::type) && - std::is_copy_assignable<T>::value> { + absl::is_copy_assignable<T>::value> { #ifdef ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE private: static constexpr bool compliant = @@ -409,11 +426,11 @@ struct IsHashEnabled : absl::conjunction<std::is_default_constructible<std::hash<Key>>, std::is_copy_constructible<std::hash<Key>>, std::is_destructible<std::hash<Key>>, - std::is_copy_assignable<std::hash<Key>>, + absl::is_copy_assignable<std::hash<Key>>, IsHashable<Key>> {}; + } // namespace type_traits_internal } // namespace absl - #endif // ABSL_META_TYPE_TRAITS_H_ diff --git a/chromium/third_party/abseil-cpp/absl/meta/type_traits_test.cc b/chromium/third_party/abseil-cpp/absl/meta/type_traits_test.cc index 81b4bd32397..f51f5dedee4 100644 --- a/chromium/third_party/abseil-cpp/absl/meta/type_traits_test.cc +++ b/chromium/third_party/abseil-cpp/absl/meta/type_traits_test.cc @@ -877,4 +877,80 @@ TEST(TypeTraitsTest, TestResultOf) { EXPECT_EQ(TypeEnum::D, GetTypeExt(Wrap<TypeD>())); } +template <typename T> +bool TestCopyAssign() { + return absl::is_copy_assignable<T>::value == + std::is_copy_assignable<T>::value; +} + +TEST(TypeTraitsTest, IsCopyAssignable) { + EXPECT_TRUE(TestCopyAssign<int>()); + EXPECT_TRUE(TestCopyAssign<int&>()); + EXPECT_TRUE(TestCopyAssign<int&&>()); + + struct S {}; + EXPECT_TRUE(TestCopyAssign<S>()); + EXPECT_TRUE(TestCopyAssign<S&>()); + EXPECT_TRUE(TestCopyAssign<S&&>()); + + class C { + public: + explicit C(C* c) : c_(c) {} + ~C() { delete c_; } + + private: + C* c_; + }; + EXPECT_TRUE(TestCopyAssign<C>()); + EXPECT_TRUE(TestCopyAssign<C&>()); + EXPECT_TRUE(TestCopyAssign<C&&>()); + + // Reason for ifndef: add_lvalue_reference<T> in libc++ breaks for these cases +#ifndef _LIBCPP_VERSION + EXPECT_TRUE(TestCopyAssign<int()>()); + EXPECT_TRUE(TestCopyAssign<int(int) const>()); + EXPECT_TRUE(TestCopyAssign<int(...) volatile&>()); + EXPECT_TRUE(TestCopyAssign<int(int, ...) const volatile&&>()); +#endif // _LIBCPP_VERSION +} + +template <typename T> +bool TestMoveAssign() { + return absl::is_move_assignable<T>::value == + std::is_move_assignable<T>::value; +} + +TEST(TypeTraitsTest, IsMoveAssignable) { + EXPECT_TRUE(TestMoveAssign<int>()); + EXPECT_TRUE(TestMoveAssign<int&>()); + EXPECT_TRUE(TestMoveAssign<int&&>()); + + struct S {}; + EXPECT_TRUE(TestMoveAssign<S>()); + EXPECT_TRUE(TestMoveAssign<S&>()); + EXPECT_TRUE(TestMoveAssign<S&&>()); + + class C { + public: + explicit C(C* c) : c_(c) {} + ~C() { delete c_; } + void operator=(const C&) = delete; + void operator=(C&&) = delete; + + private: + C* c_; + }; + EXPECT_TRUE(TestMoveAssign<C>()); + EXPECT_TRUE(TestMoveAssign<C&>()); + EXPECT_TRUE(TestMoveAssign<C&&>()); + + // Reason for ifndef: add_lvalue_reference<T> in libc++ breaks for these cases +#ifndef _LIBCPP_VERSION + EXPECT_TRUE(TestMoveAssign<int()>()); + EXPECT_TRUE(TestMoveAssign<int(int) const>()); + EXPECT_TRUE(TestMoveAssign<int(...) volatile&>()); + EXPECT_TRUE(TestMoveAssign<int(int, ...) const volatile&&>()); +#endif // _LIBCPP_VERSION +} + } // namespace diff --git a/chromium/third_party/abseil-cpp/absl/strings/BUILD.bazel b/chromium/third_party/abseil-cpp/absl/strings/BUILD.bazel index 3a5f1332cda..6d7c2619a53 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/BUILD.bazel +++ b/chromium/third_party/abseil-cpp/absl/strings/BUILD.bazel @@ -19,6 +19,7 @@ load( "ABSL_DEFAULT_COPTS", "ABSL_TEST_COPTS", "ABSL_EXCEPTIONS_FLAG", + "ABSL_EXCEPTIONS_FLAG_LINKOPTS", ) package( @@ -69,6 +70,7 @@ cc_library( deps = [ ":internal", "//absl/base", + "//absl/base:bits", "//absl/base:config", "//absl/base:core_headers", "//absl/base:endian", @@ -86,7 +88,6 @@ cc_library( "internal/utf8.cc", ], hdrs = [ - "internal/bits.h", "internal/char_map.h", "internal/ostringstream.h", "internal/resize_uninitialized.h", @@ -212,7 +213,6 @@ cc_test( visibility = ["//visibility:private"], deps = [ ":internal", - ":strings", "//absl/base:core_headers", "@com_google_googletest//:gtest_main", ], @@ -237,6 +237,7 @@ cc_test( size = "small", srcs = ["string_view_test.cc"], copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, + linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS, visibility = ["//visibility:private"], deps = [ ":strings", @@ -373,7 +374,6 @@ cc_test( visibility = ["//visibility:private"], deps = [ ":strings", - "//absl/memory", "@com_github_google_benchmark//:benchmark_main", ], ) diff --git a/chromium/third_party/abseil-cpp/absl/strings/BUILD.gn b/chromium/third_party/abseil-cpp/absl/strings/BUILD.gn index 9a8a10d0e71..20af83c0e51 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/BUILD.gn +++ b/chromium/third_party/abseil-cpp/absl/strings/BUILD.gn @@ -59,6 +59,7 @@ source_set("strings") { deps = [ ":internal", "../base", + "../base:bits", "../base:config", "../base:core_headers", "../base:endian", @@ -81,7 +82,6 @@ source_set("internal") { "internal/utf8.cc", ] public = [ - "internal/bits.h", "internal/char_map.h", "internal/ostringstream.h", "internal/resize_uninitialized.h", diff --git a/chromium/third_party/abseil-cpp/absl/strings/CMakeLists.txt b/chromium/third_party/abseil-cpp/absl/strings/CMakeLists.txt index cd122134729..f3e4162387f 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/CMakeLists.txt +++ b/chromium/third_party/abseil-cpp/absl/strings/CMakeLists.txt @@ -32,7 +32,6 @@ list(APPEND STRINGS_PUBLIC_HEADERS list(APPEND STRINGS_INTERNAL_HEADERS - "internal/bits.h" "internal/char_map.h" "internal/charconv_bigint.h" "internal/charconv_parse.h" diff --git a/chromium/third_party/abseil-cpp/absl/strings/ascii.h b/chromium/third_party/abseil-cpp/absl/strings/ascii.h index 96a64541c32..48a9da22e76 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/ascii.h +++ b/chromium/third_party/abseil-cpp/absl/strings/ascii.h @@ -165,7 +165,7 @@ inline char ascii_tolower(unsigned char c) { // Converts the characters in `s` to lowercase, changing the contents of `s`. void AsciiStrToLower(std::string* s); -// Creates a lowercase std::string from a given absl::string_view. +// Creates a lowercase string from a given absl::string_view. ABSL_MUST_USE_RESULT inline std::string AsciiStrToLower(absl::string_view s) { std::string result(s); absl::AsciiStrToLower(&result); @@ -183,7 +183,7 @@ inline char ascii_toupper(unsigned char c) { // Converts the characters in `s` to uppercase, changing the contents of `s`. void AsciiStrToUpper(std::string* s); -// Creates an uppercase std::string from a given absl::string_view. +// Creates an uppercase string from a given absl::string_view. ABSL_MUST_USE_RESULT inline std::string AsciiStrToUpper(absl::string_view s) { std::string result(s); absl::AsciiStrToUpper(&result); @@ -195,10 +195,10 @@ 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 absl::string_view(it, str.end() - it); + return str.substr(it - str.begin()); } -// Strips in place whitespace from the beginning of the given std::string. +// Strips in place whitespace from the beginning of the given string. inline void StripLeadingAsciiWhitespace(std::string* str) { auto it = std::find_if_not(str->begin(), str->end(), absl::ascii_isspace); str->erase(str->begin(), it); @@ -209,10 +209,10 @@ 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 absl::string_view(str.begin(), str.rend() - it); + return str.substr(0, str.rend() - it); } -// Strips in place whitespace from the end of the given std::string +// 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); @@ -225,7 +225,7 @@ ABSL_MUST_USE_RESULT inline absl::string_view StripAsciiWhitespace( return StripTrailingAsciiWhitespace(StripLeadingAsciiWhitespace(str)); } -// Strips in place whitespace from both ends of the given std::string +// Strips in place whitespace from both ends of the given string inline void StripAsciiWhitespace(std::string* str) { StripTrailingAsciiWhitespace(str); StripLeadingAsciiWhitespace(str); diff --git a/chromium/third_party/abseil-cpp/absl/strings/charconv.cc b/chromium/third_party/abseil-cpp/absl/strings/charconv.cc index 08c3947eccd..c7b8c98b1b4 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/charconv.cc +++ b/chromium/third_party/abseil-cpp/absl/strings/charconv.cc @@ -20,8 +20,8 @@ #include <cstring> #include "absl/base/casts.h" +#include "absl/base/internal/bits.h" #include "absl/numeric/int128.h" -#include "absl/strings/internal/bits.h" #include "absl/strings/internal/charconv_bigint.h" #include "absl/strings/internal/charconv_parse.h" @@ -243,9 +243,9 @@ struct CalculatedFloat { // minus the number of leading zero bits.) int BitWidth(uint128 value) { if (Uint128High64(value) == 0) { - return 64 - strings_internal::CountLeadingZeros64(Uint128Low64(value)); + return 64 - base_internal::CountLeadingZeros64(Uint128Low64(value)); } - return 128 - strings_internal::CountLeadingZeros64(Uint128High64(value)); + return 128 - base_internal::CountLeadingZeros64(Uint128High64(value)); } // Calculates how far to the right a mantissa needs to be shifted to create a @@ -518,7 +518,7 @@ CalculatedFloat CalculateFromParsedHexadecimal( const strings_internal::ParsedFloat& parsed_hex) { uint64_t mantissa = parsed_hex.mantissa; int exponent = parsed_hex.exponent; - int mantissa_width = 64 - strings_internal::CountLeadingZeros64(mantissa); + int mantissa_width = 64 - base_internal::CountLeadingZeros64(mantissa); const int shift = NormalizedShiftSize<FloatType>(mantissa_width, exponent); bool result_exact; exponent += shift; diff --git a/chromium/third_party/abseil-cpp/absl/strings/charconv.h b/chromium/third_party/abseil-cpp/absl/strings/charconv.h index 3e313679c96..07353829623 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/charconv.h +++ b/chromium/third_party/abseil-cpp/absl/strings/charconv.h @@ -22,7 +22,7 @@ namespace absl { // Workalike compatibilty version of std::chars_format from C++17. // // This is an bitfield enumerator which can be passed to absl::from_chars to -// configure the std::string-to-float conversion. +// configure the string-to-float conversion. enum class chars_format { scientific = 1, fixed = 2, @@ -30,7 +30,7 @@ enum class chars_format { general = fixed | scientific, }; -// The return result of a std::string-to-number conversion. +// The return result of a string-to-number conversion. // // `ec` will be set to `invalid_argument` if a well-formed number was not found // at the start of the input range, `result_out_of_range` if a well-formed @@ -67,7 +67,7 @@ struct from_chars_result { // If `fmt` is set, it must be one of the enumerator values of the chars_format. // (This is despite the fact that chars_format is a bitmask type.) If set to // `scientific`, a matching number must contain an exponent. If set to `fixed`, -// then an exponent will never match. (For example, the std::string "1e5" will be +// then an exponent will never match. (For example, the string "1e5" will be // parsed as "1".) If set to `hex`, then a hexadecimal float is parsed in the // format that strtod() accepts, except that a "0x" prefix is NOT matched. // (In particular, in `hex` mode, the input "0xff" results in the largest diff --git a/chromium/third_party/abseil-cpp/absl/strings/charconv_test.cc b/chromium/third_party/abseil-cpp/absl/strings/charconv_test.cc index f8d71cc6c44..89418fe948f 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/charconv_test.cc +++ b/chromium/third_party/abseil-cpp/absl/strings/charconv_test.cc @@ -33,7 +33,7 @@ namespace { #if ABSL_COMPILER_DOES_EXACT_ROUNDING -// Tests that the given std::string is accepted by absl::from_chars, and that it +// Tests that the given string is accepted by absl::from_chars, and that it // converts exactly equal to the given number. void TestDoubleParse(absl::string_view str, double expected_number) { SCOPED_TRACE(str); @@ -250,7 +250,7 @@ TEST(FromChars, NearRoundingCasesExplicit) { EXPECT_EQ(ToFloat("459926601011.e15"), ldexpf(12466336, 65)); } -// Common test logic for converting a std::string which lies exactly halfway between +// Common test logic for converting a string which lies exactly halfway between // two target floats. // // mantissa and exponent represent the precise value between two floating point @@ -655,7 +655,7 @@ int NextStep(int step) { // is correct for in-bounds values, and that overflow and underflow are done // correctly for out-of-bounds values. // -// input_generator maps from an integer index to a std::string to test. +// input_generator maps from an integer index to a string to test. // expected_generator maps from an integer index to an expected Float value. // from_chars conversion of input_generator(i) should result in // expected_generator(i). diff --git a/chromium/third_party/abseil-cpp/absl/strings/escaping.cc b/chromium/third_party/abseil-cpp/absl/strings/escaping.cc index fbc9f756315..8d8b00b2001 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/escaping.cc +++ b/chromium/third_party/abseil-cpp/absl/strings/escaping.cc @@ -89,7 +89,7 @@ inline bool IsSurrogate(char32_t c, absl::string_view src, std::string* error) { // // Unescapes C escape sequences and is the reverse of CEscape(). // -// If 'source' is valid, stores the unescaped std::string and its size in +// If 'source' is valid, stores the unescaped string and its size in // 'dest' and 'dest_len' respectively, and returns true. Otherwise // returns false and optionally stores the error description in // 'error'. Set 'error' to nullptr to disable error reporting. @@ -104,7 +104,7 @@ bool CUnescapeInternal(absl::string_view source, bool leave_nulls_escaped, char* dest, ptrdiff_t* dest_len, std::string* error) { char* d = dest; const char* p = source.data(); - const char* end = source.end(); + const char* end = p + source.size(); const char* last_byte = end - 1; // Small optimization for case where source = dest and there's no escaping @@ -294,7 +294,7 @@ bool CUnescapeInternal(absl::string_view source, bool leave_nulls_escaped, // ---------------------------------------------------------------------- // CUnescapeInternal() // -// Same as above but uses a C++ std::string for output. 'source' and 'dest' +// Same as above but uses a C++ string for output. 'source' and 'dest' // may be the same. // ---------------------------------------------------------------------- bool CUnescapeInternal(absl::string_view source, bool leave_nulls_escaped, @@ -304,7 +304,7 @@ bool CUnescapeInternal(absl::string_view source, bool leave_nulls_escaped, ptrdiff_t dest_size; if (!CUnescapeInternal(source, leave_nulls_escaped, - const_cast<char*>(dest->data()), + &(*dest)[0], &dest_size, error)) { return false; @@ -684,7 +684,7 @@ bool Base64UnescapeInternal(const char* src_param, size_t szsrc, char* dest, // The arrays below were generated by the following code // #include <sys/time.h> // #include <stdlib.h> -// #include <std::string.h> +// #include <string.h> // main() // { // static const char Base64[] = @@ -939,7 +939,8 @@ constexpr char kBase64Chars[] = constexpr char kWebSafeBase64Chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; -void Base64EscapeInternal(const unsigned char* src, size_t szsrc, std::string* dest, +template <typename String> +void Base64EscapeInternal(const unsigned char* src, size_t szsrc, String* dest, bool do_padding, const char* base64_chars) { const size_t calc_escaped_size = CalculateBase64EscapedLenInternal(szsrc, do_padding); @@ -951,7 +952,8 @@ void Base64EscapeInternal(const unsigned char* src, size_t szsrc, std::string* d dest->erase(escaped_len); } -bool Base64UnescapeInternal(const char* src, size_t slen, std::string* dest, +template <typename String> +bool Base64UnescapeInternal(const char* src, size_t slen, String* dest, const signed char* unbase64) { // Determine the size of the output std::string. Base64 encodes every 3 bytes into // 4 characters. any leftover chars are added directly for good measure. @@ -999,7 +1001,7 @@ constexpr char kHexValue[256] = { /* clang-format on */ // This is a templated function so that T can be either a char* -// or a std::string. This works because we use the [] operator to access +// or a string. This works because we use the [] operator to access // individual characters at a time. template <typename T> void HexStringToBytesInternal(const char* from, T to, ptrdiff_t num) { @@ -1009,7 +1011,7 @@ void HexStringToBytesInternal(const char* from, T to, ptrdiff_t num) { } } -// This is a templated function so that T can be either a char* or a std::string. +// This is a templated function so that T can be either a char* or a string. template <typename T> void BytesToHexStringInternal(const unsigned char* src, T dest, ptrdiff_t num) { auto dest_ptr = &dest[0]; diff --git a/chromium/third_party/abseil-cpp/absl/strings/escaping.h b/chromium/third_party/abseil-cpp/absl/strings/escaping.h index 7f1ab96d8ff..296597304e6 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/escaping.h +++ b/chromium/third_party/abseil-cpp/absl/strings/escaping.h @@ -17,7 +17,7 @@ // File: escaping.h // ----------------------------------------------------------------------------- // -// This header file contains std::string utilities involved in escaping and +// This header file contains string utilities involved in escaping and // unescaping strings in various ways. // @@ -37,7 +37,7 @@ namespace absl { // CUnescape() // -// Unescapes a `source` std::string and copies it into `dest`, rewriting C-style +// Unescapes a `source` string and copies it into `dest`, rewriting C-style // escape sequences (http://en.cppreference.com/w/cpp/language/escape) into // their proper code point equivalents, returning `true` if successful. // @@ -57,9 +57,10 @@ namespace absl { // 0x99). // // -// If any errors are encountered, this function returns `false` and stores the -// first encountered error in `error`. To disable error reporting, set `error` -// to `nullptr` or use the overload with no error reporting below. +// If any errors are encountered, this function returns `false`, leaving the +// `dest` output parameter in an unspecified state, and stores the first +// encountered error in `error`. To disable error reporting, set `error` to +// `nullptr` or use the overload with no error reporting below. // // Example: // @@ -78,7 +79,7 @@ inline bool CUnescape(absl::string_view source, std::string* dest) { // CEscape() // -// Escapes a 'src' std::string using C-style escapes sequences +// Escapes a 'src' string using C-style escapes sequences // (http://en.cppreference.com/w/cpp/language/escape), escaping other // non-printable/non-whitespace bytes as octal sequences (e.g. "\377"). // @@ -91,7 +92,7 @@ std::string CEscape(absl::string_view src); // CHexEscape() // -// Escapes a 'src' std::string using C-style escape sequences, escaping +// Escapes a 'src' string using C-style escape sequences, escaping // other non-printable/non-whitespace bytes as hexadecimal sequences (e.g. // "\xFF"). // @@ -104,7 +105,7 @@ std::string CHexEscape(absl::string_view src); // Utf8SafeCEscape() // -// Escapes a 'src' std::string using C-style escape sequences, escaping bytes as +// Escapes a 'src' string using C-style escape sequences, escaping bytes as // octal sequences, and passing through UTF-8 characters without conversion. // I.e., when encountering any bytes with their high bit set, this function // will not escape those values, whether or not they are valid UTF-8. @@ -112,47 +113,47 @@ std::string Utf8SafeCEscape(absl::string_view src); // Utf8SafeCHexEscape() // -// Escapes a 'src' std::string using C-style escape sequences, escaping bytes as +// Escapes a 'src' string using C-style escape sequences, escaping bytes as // hexadecimal sequences, and passing through UTF-8 characters without // conversion. std::string Utf8SafeCHexEscape(absl::string_view src); // Base64Unescape() // -// Converts a `src` std::string encoded in Base64 to its binary equivalent, writing +// Converts a `src` string encoded in Base64 to its binary equivalent, writing // it to a `dest` buffer, returning `true` on success. If `src` contains invalid // characters, `dest` is cleared and returns `false`. bool Base64Unescape(absl::string_view src, std::string* dest); -// WebSafeBase64Unescape(absl::string_view, std::string*) +// WebSafeBase64Unescape() // -// Converts a `src` std::string encoded in Base64 to its binary equivalent, writing +// Converts a `src` string encoded in Base64 to its binary equivalent, writing // it to a `dest` buffer, but using '-' instead of '+', and '_' instead of '/'. // If `src` contains invalid characters, `dest` is cleared and returns `false`. bool WebSafeBase64Unescape(absl::string_view src, std::string* dest); // Base64Escape() // -// Encodes a `src` std::string into a `dest` buffer using base64 encoding, with +// Encodes a `src` string into a `dest` buffer using base64 encoding, with // padding characters. This function conforms with RFC 4648 section 4 (base64). void Base64Escape(absl::string_view src, std::string* dest); // WebSafeBase64Escape() // -// Encodes a `src` std::string into a `dest` buffer using '-' instead of '+' and +// Encodes a `src` string into a `dest` buffer using '-' instead of '+' and // '_' instead of '/', and without padding. This function conforms with RFC 4648 // section 5 (base64url). void WebSafeBase64Escape(absl::string_view src, std::string* dest); // HexStringToBytes() // -// Converts an ASCII hex std::string into bytes, returning binary data of length +// Converts an ASCII hex string into bytes, returning binary data of length // `from.size()/2`. std::string HexStringToBytes(absl::string_view from); // BytesToHexString() // -// Converts binary data into an ASCII text std::string, returning a std::string of size +// Converts binary data into an ASCII text string, returning a string of size // `2*from.size()`. std::string BytesToHexString(absl::string_view from); diff --git a/chromium/third_party/abseil-cpp/absl/strings/escaping_test.cc b/chromium/third_party/abseil-cpp/absl/strings/escaping_test.cc index 3f65ec107f4..9dc27f3f8fa 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/escaping_test.cc +++ b/chromium/third_party/abseil-cpp/absl/strings/escaping_test.cc @@ -543,18 +543,19 @@ static struct { {"abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo="}, }; -TEST(Base64, EscapeAndUnescape) { +template <typename StringType> +void TestEscapeAndUnescape() { // Check the short strings; this tests the math (and boundaries) for (const auto& tc : base64_tests) { - std::string encoded("this junk should be ignored"); + StringType encoded("this junk should be ignored"); absl::Base64Escape(tc.plaintext, &encoded); EXPECT_EQ(encoded, tc.cyphertext); - std::string decoded("this junk should be ignored"); + StringType decoded("this junk should be ignored"); EXPECT_TRUE(absl::Base64Unescape(encoded, &decoded)); EXPECT_EQ(decoded, tc.plaintext); - std::string websafe(tc.cyphertext); + StringType websafe(tc.cyphertext); for (int c = 0; c < websafe.size(); ++c) { if ('+' == websafe[c]) websafe[c] = '-'; if ('/' == websafe[c]) websafe[c] = '_'; @@ -576,7 +577,7 @@ TEST(Base64, EscapeAndUnescape) { // Now try the long strings, this tests the streaming for (const auto& tc : absl::strings_internal::base64_strings()) { - std::string buffer; + StringType buffer; absl::WebSafeBase64Escape(tc.plaintext, &buffer); EXPECT_EQ(tc.cyphertext, buffer); } @@ -586,7 +587,7 @@ TEST(Base64, EscapeAndUnescape) { absl::string_view data_set[] = {"ab-/", absl::string_view("\0bcd", 4), absl::string_view("abc.\0", 5)}; for (absl::string_view bad_data : data_set) { - std::string buf; + StringType buf; EXPECT_FALSE(absl::Base64Unescape(bad_data, &buf)); EXPECT_FALSE(absl::WebSafeBase64Unescape(bad_data, &buf)); EXPECT_TRUE(buf.empty()); @@ -594,6 +595,10 @@ TEST(Base64, EscapeAndUnescape) { } } +TEST(Base64, EscapeAndUnescape) { + TestEscapeAndUnescape<std::string>(); +} + TEST(Base64, DISABLED_HugeData) { const size_t kSize = size_t(3) * 1000 * 1000 * 1000; static_assert(kSize % 3 == 0, "kSize must be divisible by 3"); diff --git a/chromium/third_party/abseil-cpp/absl/strings/internal/bits.h b/chromium/third_party/abseil-cpp/absl/strings/internal/bits.h deleted file mode 100644 index 901082ccddf..00000000000 --- a/chromium/third_party/abseil-cpp/absl/strings/internal/bits.h +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2018 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef ABSL_STRINGS_INTERNAL_BITS_H_ -#define ABSL_STRINGS_INTERNAL_BITS_H_ - -#include <cstdint> - -#if defined(_MSC_VER) && defined(_M_X64) -#include <intrin.h> -#pragma intrinsic(_BitScanReverse64) -#endif - -namespace absl { -namespace strings_internal { - -// Returns the number of leading 0 bits in a 64-bit value. -inline int CountLeadingZeros64(uint64_t n) { -#if defined(__GNUC__) - static_assert(sizeof(unsigned long long) == sizeof(n), // NOLINT(runtime/int) - "__builtin_clzll does not take 64bit arg"); - return n == 0 ? 64 : __builtin_clzll(n); -#elif defined(_MSC_VER) && defined(_M_X64) - unsigned long result; // NOLINT(runtime/int) - if (_BitScanReverse64(&result, n)) { - return 63 - result; - } - return 64; -#else - int zeroes = 60; - if (n >> 32) zeroes -= 32, n >>= 32; - if (n >> 16) zeroes -= 16, n >>= 16; - if (n >> 8) zeroes -= 8, n >>= 8; - if (n >> 4) zeroes -= 4, n >>= 4; - return "\4\3\2\2\1\1\1\1\0\0\0\0\0\0\0\0"[n] + zeroes; -#endif -} - -} // namespace strings_internal -} // namespace absl - -#endif // ABSL_STRINGS_INTERNAL_BITS_H_ diff --git a/chromium/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc b/chromium/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc index a04cc67669a..7e4dabc2262 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc +++ b/chromium/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc @@ -91,7 +91,7 @@ static_assert(std::numeric_limits<int>::digits10 >= kDecimalExponentDigitsMax, // To avoid incredibly large inputs causing integer overflow for our exponent, // we impose an arbitrary but very large limit on the number of significant -// digits we will accept. The implementation refuses to match a std::string with +// digits we will accept. The implementation refuses to match a string with // more consecutive significant mantissa digits than this. constexpr int kDecimalDigitLimit = 50000000; diff --git a/chromium/third_party/abseil-cpp/absl/strings/internal/charconv_parse_test.cc b/chromium/third_party/abseil-cpp/absl/strings/internal/charconv_parse_test.cc index 1ff86004973..f48b9aee1a5 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/internal/charconv_parse_test.cc +++ b/chromium/third_party/abseil-cpp/absl/strings/internal/charconv_parse_test.cc @@ -29,16 +29,16 @@ using absl::strings_internal::ParseFloat; namespace { -// Check that a given std::string input is parsed to the expected mantissa and +// Check that a given string input is parsed to the expected mantissa and // exponent. // -// Input std::string `s` must contain a '$' character. It marks the end of the +// Input string `s` must contain a '$' character. It marks the end of the // characters that should be consumed by the match. It is stripped from the // input to ParseFloat. // -// If input std::string `s` contains '[' and ']' characters, these mark the region +// If input string `s` contains '[' and ']' characters, these mark the region // of characters that should be marked as the "subrange". For NaNs, this is -// the location of the extended NaN std::string. For numbers, this is the location +// the location of the extended NaN string. For numbers, this is the location // of the full, over-large mantissa. template <int base> void ExpectParsedFloat(std::string s, absl::chars_format format_flags, @@ -92,10 +92,10 @@ void ExpectParsedFloat(std::string s, absl::chars_format format_flags, EXPECT_EQ(characters_matched, expected_characters_matched); } -// Check that a given std::string input is parsed to the expected mantissa and +// Check that a given string input is parsed to the expected mantissa and // exponent. // -// Input std::string `s` must contain a '$' character. It marks the end of the +// Input string `s` must contain a '$' character. It marks the end of the // characters that were consumed by the match. template <int base> void ExpectNumber(std::string s, absl::chars_format format_flags, @@ -106,7 +106,7 @@ void ExpectNumber(std::string s, absl::chars_format format_flags, expected_literal_exponent); } -// Check that a given std::string input is parsed to the given special value. +// Check that a given string input is parsed to the given special value. // // This tests against both number bases, since infinities and NaNs have // identical representations in both modes. @@ -116,7 +116,7 @@ void ExpectSpecial(const std::string& s, absl::chars_format format_flags, ExpectParsedFloat<16>(s, format_flags, type, 0, 0); } -// Check that a given input std::string is not matched by Float. +// Check that a given input string is not matched by Float. template <int base> void ExpectFailedParse(absl::string_view s, absl::chars_format format_flags) { ParsedFloat parsed = diff --git a/chromium/third_party/abseil-cpp/absl/strings/internal/memutil.h b/chromium/third_party/abseil-cpp/absl/strings/internal/memutil.h index a6f1c69138e..7de383b19ec 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/internal/memutil.h +++ b/chromium/third_party/abseil-cpp/absl/strings/internal/memutil.h @@ -14,7 +14,7 @@ // limitations under the License. // -// These routines provide mem versions of standard C std::string routines, +// These routines provide mem versions of standard C string routines, // such as strpbrk. They function exactly the same as the str versions, // so if you wonder what they are, replace the word "mem" by // "str" and check out the man page. I could return void*, as the @@ -22,14 +22,14 @@ // since this is by far the most common way these functions are called. // // The difference between the mem and str versions is the mem version -// takes a pointer and a length, rather than a '\0'-terminated std::string. +// takes a pointer and a length, rather than a '\0'-terminated string. // The memcase* routines defined here assume the locale is "C" // (they use absl::ascii_tolower instead of tolower). // // These routines are based on the BSD library. // -// Here's a list of routines from std::string.h, and their mem analogues. -// Functions in lowercase are defined in std::string.h; those in UPPERCASE +// Here's a list of routines from string.h, and their mem analogues. +// Functions in lowercase are defined in string.h; those in UPPERCASE // are defined here: // // strlen -- diff --git a/chromium/third_party/abseil-cpp/absl/strings/internal/ostringstream.h b/chromium/third_party/abseil-cpp/absl/strings/internal/ostringstream.h index 6e1325b9140..e81a89affea 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/internal/ostringstream.h +++ b/chromium/third_party/abseil-cpp/absl/strings/internal/ostringstream.h @@ -25,18 +25,18 @@ namespace absl { namespace strings_internal { -// The same as std::ostringstream but appends to a user-specified std::string, +// The same as std::ostringstream but appends to a user-specified string, // and is faster. It is ~70% faster to create, ~50% faster to write to, and -// completely free to extract the result std::string. +// completely free to extract the result string. // -// std::string s; +// string s; // OStringStream strm(&s); // strm << 42 << ' ' << 3.14; // appends to `s` // // The stream object doesn't have to be named. Starting from C++11 operator<< // works with rvalues of std::ostream. // -// std::string s; +// string s; // OStringStream(&s) << 42 << ' ' << 3.14; // appends to `s` // // OStringStream is faster to create than std::ostringstream but it's still @@ -45,14 +45,14 @@ namespace strings_internal { // // Creates unnecessary instances of OStringStream: slow. // -// std::string s; +// string s; // OStringStream(&s) << 42; // OStringStream(&s) << ' '; // OStringStream(&s) << 3.14; // // Creates a single instance of OStringStream and reuses it: fast. // -// std::string s; +// string s; // OStringStream strm(&s); // strm << 42; // strm << ' '; diff --git a/chromium/third_party/abseil-cpp/absl/strings/internal/resize_uninitialized.h b/chromium/third_party/abseil-cpp/absl/strings/internal/resize_uninitialized.h index 0157ca0245f..a94e0547b50 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/internal/resize_uninitialized.h +++ b/chromium/third_party/abseil-cpp/absl/strings/internal/resize_uninitialized.h @@ -44,8 +44,8 @@ void ResizeUninit(string_type* s, size_t new_size, std::false_type) { s->resize(new_size); } -// Returns true if the std::string implementation supports a resize where -// the new characters added to the std::string are left untouched. +// Returns true if the string implementation supports a resize where +// the new characters added to the string are left untouched. // // (A better name might be "STLStringSupportsUninitializedResize", alluding to // the previous function.) @@ -57,7 +57,7 @@ inline constexpr bool STLStringSupportsNontrashingResize(string_type*) { // Like str->resize(new_size), except any new characters added to "*str" as a // result of resizing may be left uninitialized, rather than being filled with // '0' bytes. Typically used when code is then going to overwrite the backing -// store of the std::string with known data. Uses a Google extension to std::string. +// store of the string with known data. Uses a Google extension to ::string. template <typename string_type, typename = void> inline void STLStringResizeUninitialized(string_type* s, size_t new_size) { ResizeUninit(s, new_size, HasResizeUninitialized<string_type>()); diff --git a/chromium/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h b/chromium/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h index 4008611211c..9d3d67c6347 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h +++ b/chromium/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h @@ -168,7 +168,7 @@ int FprintF(std::FILE* output, const UntypedFormatSpecImpl& format, int SnprintF(char* output, size_t size, const UntypedFormatSpecImpl& format, absl::Span<const FormatArgImpl> args); -// Returned by Streamed(v). Converts via '%s' to the std::string created +// Returned by Streamed(v). Converts via '%s' to the string created // by std::ostream << v. template <typename T> class StreamedWrapper { diff --git a/chromium/third_party/abseil-cpp/absl/strings/internal/str_format/extension.h b/chromium/third_party/abseil-cpp/absl/strings/internal/str_format/extension.h index 810330b9d71..f43195c127b 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/internal/str_format/extension.h +++ b/chromium/third_party/abseil-cpp/absl/strings/internal/str_format/extension.h @@ -57,7 +57,7 @@ class FormatRawSinkImpl { void (*write_)(void*, string_view); }; -// An abstraction to which conversions write their std::string data. +// An abstraction to which conversions write their string data. class FormatSinkImpl { public: explicit FormatSinkImpl(FormatRawSinkImpl raw) : raw_(raw) {} diff --git a/chromium/third_party/abseil-cpp/absl/strings/internal/str_format/output.h b/chromium/third_party/abseil-cpp/absl/strings/internal/str_format/output.h index 3b0aa5e7157..12ecd99e680 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/internal/str_format/output.h +++ b/chromium/third_party/abseil-cpp/absl/strings/internal/str_format/output.h @@ -69,10 +69,10 @@ class FILERawSink { // Provide RawSink integration with common types from the STL. inline void AbslFormatFlush(std::string* out, string_view s) { - out->append(s.begin(), s.size()); + out->append(s.data(), s.size()); } inline void AbslFormatFlush(std::ostream* out, string_view s) { - out->write(s.begin(), s.size()); + out->write(s.data(), s.size()); } template <class AbslCord, typename = typename std::enable_if< diff --git a/chromium/third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc b/chromium/third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc index 10114f489c0..c3e16fceb15 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc +++ b/chromium/third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc @@ -81,8 +81,8 @@ static constexpr std::int8_t kIds[] = { template <bool is_positional> bool ConsumeConversion(string_view *src, UnboundConversion *conv, int *next_arg) { - const char *pos = src->begin(); - const char *const end = src->end(); + const char *pos = src->data(); + const char *const end = pos + src->size(); char c; // Read the next char into `c` and update `pos`. Reads '\0' if at end. const auto get_char = [&] { c = pos == end ? '\0' : *pos++; }; diff --git a/chromium/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h b/chromium/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h index 5bebc95540e..1022f06297a 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h +++ b/chromium/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h @@ -75,14 +75,14 @@ struct UnboundConversion { bool ConsumeUnboundConversion(string_view* src, UnboundConversion* conv, int* next_arg); -// Parse the format std::string provided in 'src' and pass the identified items into +// Parse the format string provided in 'src' and pass the identified items into // 'consumer'. // Text runs will be passed by calling // Consumer::Append(string_view); // ConversionItems will be passed by calling // Consumer::ConvertOne(UnboundConversion, string_view); // In the case of ConvertOne, the string_view that is passed is the -// portion of the format std::string corresponding to the conversion, not including +// portion of the format string corresponding to the conversion, not including // the leading %. On success, it returns true. On failure, it stops and returns // false. template <typename Consumer> @@ -90,7 +90,7 @@ bool ParseFormatString(string_view src, Consumer consumer) { int next_arg = 0; while (!src.empty()) { const char* percent = - static_cast<const char*>(memchr(src.begin(), '%', src.size())); + static_cast<const char*>(memchr(src.data(), '%', src.size())); if (!percent) { // We found the last substring. return consumer.Append(src); @@ -98,7 +98,7 @@ bool ParseFormatString(string_view src, Consumer consumer) { // We found a percent, so push the text run then process the percent. size_t percent_loc = percent - src.data(); if (!consumer.Append(string_view(src.data(), percent_loc))) return false; - if (percent + 1 >= src.end()) return false; + if (percent + 1 >= src.data() + src.size()) return false; UnboundConversion conv; @@ -178,7 +178,8 @@ class ParsedFormatBase { const char* const base = data_.get(); string_view text(base, 0); for (const auto& item : items_) { - text = string_view(text.end(), (base + item.text_end) - text.end()); + const char* const end = text.data() + text.size(); + text = string_view(end, (base + item.text_end) - end); if (item.is_conversion) { if (!consumer.ConvertOne(item.conv, text)) return false; } else { @@ -237,7 +238,7 @@ class ParsedFormatBase { // This class also supports runtime format checking with the ::New() and // ::NewAllowIgnored() factory functions. // This is the only API that allows the user to pass a runtime specified format -// std::string. These factory functions will return NULL if the format does not match +// string. These factory functions will return NULL if the format does not match // the conversions requested by the user. template <str_format_internal::Conv... C> class ExtendedParsedFormat : public str_format_internal::ParsedFormatBase { diff --git a/chromium/third_party/abseil-cpp/absl/strings/internal/str_format/parser_test.cc b/chromium/third_party/abseil-cpp/absl/strings/internal/str_format/parser_test.cc index e698020b1ab..ac6886d04d9 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/internal/str_format/parser_test.cc +++ b/chromium/third_party/abseil-cpp/absl/strings/internal/str_format/parser_test.cc @@ -66,10 +66,10 @@ class ConsumeUnboundConversionTest : public ::testing::Test { typedef UnboundConversion Props; string_view Consume(string_view* src) { int next = 0; - const char* prev_begin = src->begin(); + const char* prev_begin = src->data(); o = UnboundConversion(); // refresh ConsumeUnboundConversion(src, &o, &next); - return {prev_begin, static_cast<size_t>(src->begin() - prev_begin)}; + return {prev_begin, static_cast<size_t>(src->data() - prev_begin)}; } bool Run(const char *fmt, bool force_positional = false) { diff --git a/chromium/third_party/abseil-cpp/absl/strings/internal/str_join_internal.h b/chromium/third_party/abseil-cpp/absl/strings/internal/str_join_internal.h index a734758c21e..0058fc8aa4d 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/internal/str_join_internal.h +++ b/chromium/third_party/abseil-cpp/absl/strings/internal/str_join_internal.h @@ -189,7 +189,7 @@ struct DefaultFormatter<std::unique_ptr<ValueType>> // // The main joining algorithm. This simply joins the elements in the given -// iterator range, each separated by the given separator, into an output std::string, +// iterator range, each separated by the given separator, into an output string, // and formats each element using the provided Formatter object. template <typename Iterator, typename Formatter> std::string JoinAlgorithm(Iterator start, Iterator end, absl::string_view s, @@ -205,20 +205,20 @@ std::string JoinAlgorithm(Iterator start, Iterator end, absl::string_view s, } // A joining algorithm that's optimized for a forward iterator range of -// std::string-like objects that do not need any additional formatting. This is to -// optimize the common case of joining, say, a std::vector<std::string> or a +// string-like objects that do not need any additional formatting. This is to +// optimize the common case of joining, say, a std::vector<string> or a // std::vector<absl::string_view>. // // This is an overload of the previous JoinAlgorithm() function. Here the // Formatter argument is of type NoFormatter. Since NoFormatter is an internal // type, this overload is only invoked when strings::Join() is called with a -// range of std::string-like objects (e.g., std::string, absl::string_view), and an +// range of string-like objects (e.g., string, absl::string_view), and an // explicit Formatter argument was NOT specified. // // The optimization is that the needed space will be reserved in the output -// std::string to avoid the need to resize while appending. To do this, the iterator +// string to avoid the need to resize while appending. To do this, the iterator // range will be traversed twice: once to calculate the total needed size, and -// then again to copy the elements and delimiters to the output std::string. +// then again to copy the elements and delimiters to the output string. template <typename Iterator, typename = typename std::enable_if<std::is_convertible< typename std::iterator_traits<Iterator>::iterator_category, diff --git a/chromium/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h b/chromium/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h index 9cf0833f490..81e8d555446 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +++ b/chromium/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h @@ -51,7 +51,7 @@ namespace strings_internal { // This class is implicitly constructible from everything that absl::string_view // is implicitly constructible from. If it's constructed from a temporary -// std::string, the data is moved into a data member so its lifetime matches that of +// string, the data is moved into a data member so its lifetime matches that of // the ConvertibleToStringView instance. class ConvertibleToStringView { public: @@ -102,7 +102,7 @@ ConvertibleToStringView(std::string&& s) // NOLINT(runtime/explicit) absl::string_view value_; }; -// An iterator that enumerates the parts of a std::string from a Splitter. The text +// An iterator that enumerates the parts of a string from a Splitter. The text // to be split, the Delimiter, and the Predicate are all taken from the given // Splitter object. Iterators may only be compared if they refer to the same // Splitter instance. @@ -159,7 +159,7 @@ class SplitIterator { } const absl::string_view text = splitter_->text(); const absl::string_view d = delimiter_.Find(text, pos_); - if (d.data() == text.end()) state_ = kLastState; + if (d.data() == text.data() + text.size()) state_ = kLastState; curr_ = text.substr(pos_, d.data() - (text.data() + pos_)); pos_ += curr_.size() + d.size(); } while (!predicate_(curr_)); diff --git a/chromium/third_party/abseil-cpp/absl/strings/match.h b/chromium/third_party/abseil-cpp/absl/strings/match.h index 108b6048b04..942a196b885 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/match.h +++ b/chromium/third_party/abseil-cpp/absl/strings/match.h @@ -17,7 +17,7 @@ // File: match.h // ----------------------------------------------------------------------------- // -// This file contains simple utilities for performing std::string matching checks. +// This file contains simple utilities for performing string matching checks. // All of these function parameters are specified as `absl::string_view`, // meaning that these functions can accept `std::string`, `absl::string_view` or // nul-terminated C-style strings. @@ -41,14 +41,14 @@ namespace absl { // StrContains() // -// Returns whether a given std::string `haystack` contains the substring `needle`. +// Returns whether a given string `haystack` contains the substring `needle`. inline bool StrContains(absl::string_view haystack, absl::string_view needle) { return haystack.find(needle, 0) != haystack.npos; } // StartsWith() // -// Returns whether a given std::string `text` begins with `prefix`. +// Returns whether a given string `text` begins with `prefix`. inline bool StartsWith(absl::string_view text, absl::string_view prefix) { return prefix.empty() || (text.size() >= prefix.size() && @@ -57,7 +57,7 @@ inline bool StartsWith(absl::string_view text, absl::string_view prefix) { // EndsWith() // -// Returns whether a given std::string `text` ends with `suffix`. +// Returns whether a given string `text` ends with `suffix`. inline bool EndsWith(absl::string_view text, absl::string_view suffix) { return suffix.empty() || (text.size() >= suffix.size() && @@ -68,13 +68,13 @@ inline bool EndsWith(absl::string_view text, absl::string_view suffix) { // StartsWithIgnoreCase() // -// Returns whether a given std::string `text` starts with `starts_with`, ignoring +// Returns whether a given string `text` starts with `starts_with`, ignoring // case in the comparison. bool StartsWithIgnoreCase(absl::string_view text, absl::string_view prefix); // EndsWithIgnoreCase() // -// Returns whether a given std::string `text` ends with `ends_with`, ignoring case +// Returns whether a given string `text` ends with `ends_with`, ignoring case // in the comparison. bool EndsWithIgnoreCase(absl::string_view text, absl::string_view suffix); diff --git a/chromium/third_party/abseil-cpp/absl/strings/numbers.cc b/chromium/third_party/abseil-cpp/absl/strings/numbers.cc index f842ed85e9f..9309f9da9dc 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/numbers.cc +++ b/chromium/third_party/abseil-cpp/absl/strings/numbers.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// This file contains std::string processing functions related to +// This file contains string processing functions related to // numeric values. #include "absl/strings/numbers.h" @@ -30,10 +30,10 @@ #include <memory> #include <utility> +#include "absl/base/internal/bits.h" #include "absl/base/internal/raw_logging.h" #include "absl/strings/ascii.h" #include "absl/strings/charconv.h" -#include "absl/strings/internal/bits.h" #include "absl/strings/internal/memutil.h" #include "absl/strings/str_cat.h" @@ -161,8 +161,8 @@ bool SimpleAtob(absl::string_view str, bool* value) { // their output to the beginning of the buffer. The caller is responsible // for ensuring that the buffer has enough space to hold the output. // -// Returns a pointer to the end of the std::string (i.e. the null character -// terminating the std::string). +// Returns a pointer to the end of the string (i.e. the null character +// terminating the string). // ---------------------------------------------------------------------- namespace { @@ -344,7 +344,7 @@ static std::pair<uint64_t, uint64_t> Mul32(std::pair<uint64_t, uint64_t> num, uint64_t bits128_up = (bits96_127 >> 32) + (bits64_127 < bits64_95); if (bits128_up == 0) return {bits64_127, bits0_63}; - int shift = 64 - strings_internal::CountLeadingZeros64(bits128_up); + int shift = 64 - base_internal::CountLeadingZeros64(bits128_up); uint64_t lo = (bits0_63 >> shift) + (bits64_127 << (64 - shift)); uint64_t hi = (bits64_127 >> shift) + (bits128_up << (64 - shift)); return {hi, lo}; @@ -375,7 +375,7 @@ static std::pair<uint64_t, uint64_t> PowFive(uint64_t num, int expfive) { 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5}; result = Mul32(result, powers_of_five[expfive & 15]); - int shift = strings_internal::CountLeadingZeros64(result.first); + int shift = base_internal::CountLeadingZeros64(result.first); if (shift != 0) { result.first = (result.first << shift) + (result.second >> (64 - shift)); result.second = (result.second << shift); diff --git a/chromium/third_party/abseil-cpp/absl/strings/numbers.h b/chromium/third_party/abseil-cpp/absl/strings/numbers.h index cf3c597266c..f9b2ccef94d 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/numbers.h +++ b/chromium/third_party/abseil-cpp/absl/strings/numbers.h @@ -41,32 +41,32 @@ namespace absl { // SimpleAtoi() // -// Converts the given std::string into an integer value, returning `true` if -// successful. The std::string must reflect a base-10 integer (optionally followed or +// Converts the given string into an integer value, returning `true` if +// successful. The string must reflect a base-10 integer (optionally followed or // preceded by ASCII whitespace) whose value falls within the range of the -// integer type, +// integer type. template <typename int_type> ABSL_MUST_USE_RESULT bool SimpleAtoi(absl::string_view s, int_type* out); // SimpleAtof() // -// Converts the given std::string (optionally followed or preceded by ASCII +// Converts the given string (optionally followed or preceded by ASCII // whitespace) into a float, which may be rounded on overflow or underflow. -// See http://en.cppreference.com/w/c/std::string/byte/strtof for details about the +// See http://en.cppreference.com/w/c/string/byte/strtof for details about the // allowed formats for `str`. ABSL_MUST_USE_RESULT bool SimpleAtof(absl::string_view str, float* value); // SimpleAtod() // -// Converts the given std::string (optionally followed or preceded by ASCII +// Converts the given string (optionally followed or preceded by ASCII // whitespace) into a double, which may be rounded on overflow or underflow. -// See http://en.cppreference.com/w/c/std::string/byte/strtof for details about the +// See http://en.cppreference.com/w/c/string/byte/strtof for details about the // allowed formats for `str`. ABSL_MUST_USE_RESULT bool SimpleAtod(absl::string_view str, double* value); // SimpleAtob() // -// Converts the given std::string into a boolean, returning `true` if successful. +// Converts the given string into a boolean, returning `true` if successful. // The following case-insensitive strings are interpreted as boolean `true`: // "true", "t", "yes", "y", "1". The following case-insensitive strings // are interpreted as boolean `false`: "false", "f", "no", "n", "0". @@ -169,9 +169,9 @@ ABSL_MUST_USE_RESULT bool safe_strtoi_base(absl::string_view s, int_type* out, // SimpleAtoi() // -// Converts a std::string to an integer, using `safe_strto?()` functions for actual +// Converts a string to an integer, using `safe_strto?()` functions for actual // parsing, returning `true` if successful. The `safe_strto?()` functions apply -// strict checking; the std::string must be a base-10 integer, optionally followed or +// strict checking; the string must be a base-10 integer, optionally followed or // preceded by ASCII whitespace, with a value in the range of the corresponding // integer type. template <typename int_type> diff --git a/chromium/third_party/abseil-cpp/absl/strings/numbers_benchmark.cc b/chromium/third_party/abseil-cpp/absl/strings/numbers_benchmark.cc index 8ef650b9a3e..0570b758633 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/numbers_benchmark.cc +++ b/chromium/third_party/abseil-cpp/absl/strings/numbers_benchmark.cc @@ -158,7 +158,7 @@ BENCHMARK(BM_safe_strtou64_string) ->ArgPair(16, 10) ->ArgPair(16, 16); -// Returns a vector of `num_strings` strings. Each std::string represents a +// Returns a vector of `num_strings` strings. Each string represents a // floating point number with `num_digits` digits before the decimal point and // another `num_digits` digits after. std::vector<std::string> MakeFloatStrings(int num_strings, int num_digits) { diff --git a/chromium/third_party/abseil-cpp/absl/strings/numbers_test.cc b/chromium/third_party/abseil-cpp/absl/strings/numbers_test.cc index 27cc0479e34..36fc0d64fd5 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/numbers_test.cc +++ b/chromium/third_party/abseil-cpp/absl/strings/numbers_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// This file tests std::string processing functions related to numeric values. +// This file tests string processing functions related to numeric values. #include "absl/strings/numbers.h" diff --git a/chromium/third_party/abseil-cpp/absl/strings/str_cat.cc b/chromium/third_party/abseil-cpp/absl/strings/str_cat.cc index 3fe8c95eca9..efa4fd73dba 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/str_cat.cc +++ b/chromium/third_party/abseil-cpp/absl/strings/str_cat.cc @@ -79,7 +79,7 @@ AlphaNum::AlphaNum(Dec dec) { // ---------------------------------------------------------------------- // StrCat() // This merges the given strings or integers, with no delimiter. This -// is designed to be the fastest possible way to construct a std::string out +// is designed to be the fastest possible way to construct a string out // of a mix of raw C strings, StringPieces, strings, and integer values. // ---------------------------------------------------------------------- @@ -154,10 +154,10 @@ std::string CatPieces(std::initializer_list<absl::string_view> pieces) { } // It's possible to call StrAppend with an absl::string_view that is itself a -// fragment of the std::string we're appending to. However the results of this are +// fragment of the string we're appending to. However the results of this are // random. Therefore, check for this in debug mode. Use unsigned math so we // only have to do one comparison. Note, there's an exception case: appending an -// empty std::string is always allowed. +// empty string is always allowed. #define ASSERT_NO_OVERLAP(dest, src) \ assert(((src).size() == 0) || \ (uintptr_t((src).data() - (dest).data()) > uintptr_t((dest).size()))) diff --git a/chromium/third_party/abseil-cpp/absl/strings/str_cat.h b/chromium/third_party/abseil-cpp/absl/strings/str_cat.h index e5501a5012e..da9ed9a269e 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/str_cat.h +++ b/chromium/third_party/abseil-cpp/absl/strings/str_cat.h @@ -23,7 +23,7 @@ // designed to be used as a parameter type that efficiently manages conversion // to strings and avoids copies in the above operations. // -// Any routine accepting either a std::string or a number may accept `AlphaNum`. +// Any routine accepting either a string or a number may accept `AlphaNum`. // The basic idea is that by accepting a `const AlphaNum &` as an argument // to your function, your callers will automagically convert bools, integers, // and floating point values to strings for you. @@ -65,7 +65,7 @@ namespace absl { namespace strings_internal { -// AlphaNumBuffer allows a way to pass a std::string to StrCat without having to do +// AlphaNumBuffer allows a way to pass a string to StrCat without having to do // memory allocation. It is simply a pair of a fixed-size character array, and // a size. Please don't use outside of absl, yet. template <size_t max_size> @@ -119,8 +119,8 @@ enum PadSpec : uint8_t { // Hex // ----------------------------------------------------------------------------- // -// `Hex` stores a set of hexadecimal std::string conversion parameters for use -// within `AlphaNum` std::string conversions. +// `Hex` stores a set of hexadecimal string conversion parameters for use +// within `AlphaNum` string conversions. struct Hex { uint64_t value; uint8_t width; @@ -168,8 +168,8 @@ struct Hex { // Dec // ----------------------------------------------------------------------------- // -// `Dec` stores a set of decimal std::string conversion parameters for use -// within `AlphaNum` std::string conversions. Dec is slower than the default +// `Dec` stores a set of decimal string conversion parameters for use +// within `AlphaNum` string conversions. Dec is slower than the default // integer conversion, so use it only if you need padding. struct Dec { uint64_t value; @@ -271,7 +271,7 @@ class AlphaNum { // // Merges given strings or numbers, using no delimiter(s). // -// `StrCat()` is designed to be the fastest possible way to construct a std::string +// `StrCat()` is designed to be the fastest possible way to construct a string // out of a mix of raw C strings, string_views, strings, bool values, // and numeric values. // @@ -279,7 +279,7 @@ class AlphaNum { // works poorly on strings built up out of fragments. // // For clarity and performance, don't use `StrCat()` when appending to a -// std::string. Use `StrAppend()` instead. In particular, avoid using any of these +// string. Use `StrAppend()` instead. In particular, avoid using any of these // (anti-)patterns: // // str.append(StrCat(...)) @@ -328,26 +328,26 @@ ABSL_MUST_USE_RESULT inline std::string StrCat(const AlphaNum& a, const AlphaNum // StrAppend() // ----------------------------------------------------------------------------- // -// Appends a std::string or set of strings to an existing std::string, in a similar +// Appends a string or set of strings to an existing string, in a similar // fashion to `StrCat()`. // // WARNING: `StrAppend(&str, a, b, c, ...)` requires that none of the // a, b, c, parameters be a reference into str. For speed, `StrAppend()` does // not try to check each of its input arguments to be sure that they are not -// a subset of the std::string being appended to. That is, while this will work: +// a subset of the string being appended to. That is, while this will work: // -// std::string s = "foo"; +// string s = "foo"; // s += s; // // This output is undefined: // -// std::string s = "foo"; +// string s = "foo"; // StrAppend(&s, s); // // This output is undefined as well, since `absl::string_view` does not own its // data: // -// std::string s = "foobar"; +// string s = "foobar"; // absl::string_view p = s; // StrAppend(&s, p); diff --git a/chromium/third_party/abseil-cpp/absl/strings/str_cat_test.cc b/chromium/third_party/abseil-cpp/absl/strings/str_cat_test.cc index e9d67690638..555d8db3eb8 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/str_cat_test.cc +++ b/chromium/third_party/abseil-cpp/absl/strings/str_cat_test.cc @@ -28,7 +28,8 @@ #define ABSL_EXPECT_DEBUG_DEATH(statement, regex) \ EXPECT_DEBUG_DEATH(statement, ".*") #else -#define ABSL_EXPECT_DEBUG_DEATH EXPECT_DEBUG_DEATH +#define ABSL_EXPECT_DEBUG_DEATH(statement, regex) \ + EXPECT_DEBUG_DEATH(statement, regex) #endif namespace { diff --git a/chromium/third_party/abseil-cpp/absl/strings/str_format.h b/chromium/third_party/abseil-cpp/absl/strings/str_format.h index 70a811b75e2..2d07725de21 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/str_format.h +++ b/chromium/third_party/abseil-cpp/absl/strings/str_format.h @@ -18,20 +18,20 @@ // ----------------------------------------------------------------------------- // // The `str_format` library is a typesafe replacement for the family of -// `printf()` std::string formatting routines within the `<cstdio>` standard library +// `printf()` string formatting routines within the `<cstdio>` standard library // header. Like the `printf` family, the `str_format` uses a "format string" to // perform argument substitutions based on types. // // Example: // -// std::string s = absl::StrFormat("%s %s You have $%d!", "Hello", name, dollars); +// string s = absl::StrFormat("%s %s You have $%d!", "Hello", name, dollars); // // The library consists of the following basic utilities: // // * `absl::StrFormat()`, a type-safe replacement for `std::sprintf()`, to -// write a format std::string to a `string` value. -// * `absl::StrAppendFormat()` to append a format std::string to a `string` -// * `absl::StreamFormat()` to more efficiently write a format std::string to a +// write a format string to a `string` value. +// * `absl::StrAppendFormat()` to append a format string to a `string` +// * `absl::StreamFormat()` to more efficiently write a format string to a // stream, such as`std::cout`. // * `absl::PrintF()`, `absl::FPrintF()` and `absl::SNPrintF()` as // replacements for `std::printf()`, `std::fprintf()` and `std::snprintf()`. @@ -39,15 +39,15 @@ // Note: a version of `std::sprintf()` is not supported as it is // generally unsafe due to buffer overflows. // -// Additionally, you can provide a format std::string (and its associated arguments) +// Additionally, you can provide a format string (and its associated arguments) // using one of the following abstractions: // -// * A `FormatSpec` class template fully encapsulates a format std::string and its +// * A `FormatSpec` class template fully encapsulates a format string and its // type arguments and is usually provided to `str_format` functions as a // variadic argument of type `FormatSpec<Arg...>`. The `FormatSpec<Args...>` // template is evaluated at compile-time, providing type safety. // * A `ParsedFormat` instance, which encapsulates a specific, pre-compiled -// format std::string for a specific set of type(s), and which can be passed +// format string for a specific set of type(s), and which can be passed // between API boundaries. (The `FormatSpec` type should not be used // directly.) // @@ -60,7 +60,7 @@ // // * A `FormatUntyped()` function that is similar to `Format()` except it is // loosely typed. `FormatUntyped()` is not a template and does not perform -// any compile-time checking of the format std::string; instead, it returns a +// any compile-time checking of the format string; instead, it returns a // boolean from a runtime check. // // In addition, the `str_format` library provides extension points for @@ -89,7 +89,7 @@ namespace absl { // Example: // // absl::UntypedFormatSpec format("%d"); -// std::string out; +// string out; // CHECK(absl::FormatUntyped(&out, format, {absl::FormatArg(1)})); class UntypedFormatSpec { public: @@ -135,7 +135,7 @@ str_format_internal::StreamedWrapper<T> FormatStreamed(const T& v) { // Example: // // int n = 0; -// std::string s = absl::StrFormat("%s%d%n", "hello", 123, +// string s = absl::StrFormat("%s%d%n", "hello", 123, // absl::FormatCountCapture(&n)); // EXPECT_EQ(8, n); class FormatCountCapture { @@ -155,10 +155,10 @@ class FormatCountCapture { // FormatSpec // -// The `FormatSpec` type defines the makeup of a format std::string within the +// The `FormatSpec` type defines the makeup of a format string within the // `str_format` library. You should not need to use or manipulate this type // directly. A `FormatSpec` is a variadic class template that is evaluated at -// compile-time, according to the format std::string and arguments that are passed +// compile-time, according to the format string and arguments that are passed // to it. // // For a `FormatSpec` to be valid at compile-time, it must be provided as @@ -166,12 +166,12 @@ class FormatCountCapture { // // * A `constexpr` literal or `absl::string_view`, which is how it most often // used. -// * A `ParsedFormat` instantiation, which ensures the format std::string is +// * A `ParsedFormat` instantiation, which ensures the format string is // valid before use. (See below.) // // Example: // -// // Provided as a std::string literal. +// // Provided as a string literal. // absl::StrFormat("Welcome to %s, Number %d!", "The Village", 6); // // // Provided as a constexpr absl::string_view. @@ -183,7 +183,7 @@ class FormatCountCapture { // absl::ParsedFormat<'s', 'd'> formatString("Welcome to %s, Number %d!"); // absl::StrFormat(formatString, "TheVillage", 6); // -// A format std::string generally follows the POSIX syntax as used within the POSIX +// A format string generally follows the POSIX syntax as used within the POSIX // `printf` specification. // // (See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/printf.html.) @@ -223,7 +223,7 @@ class FormatCountCapture { // "%p", *int -> "0x7ffdeb6ad2a4" // // int n = 0; -// std::string s = absl::StrFormat( +// string s = absl::StrFormat( // "%s%d%n", "hello", 123, absl::FormatCountCapture(&n)); // EXPECT_EQ(8, n); // @@ -236,7 +236,7 @@ class FormatCountCapture { // // However, in the `str_format` library, a format conversion specifies a broader // C++ conceptual category instead of an exact type. For example, `%s` binds to -// any std::string-like argument, so `std::string`, `absl::string_view`, and +// any string-like argument, so `std::string`, `absl::string_view`, and // `const char*` are all accepted. Likewise, `%d` accepts any integer-like // argument, etc. @@ -248,7 +248,7 @@ using FormatSpec = // // A `ParsedFormat` is a class template representing a preparsed `FormatSpec`, // with template arguments specifying the conversion characters used within the -// format std::string. Such characters must be valid format type specifiers, and +// format string. Such characters must be valid format type specifiers, and // these type specifiers are checked at compile-time. // // Instances of `ParsedFormat` can be created, copied, and reused to speed up @@ -275,26 +275,26 @@ using ParsedFormat = str_format_internal::ExtendedParsedFormat< // StrFormat() // -// Returns a `string` given a `printf()`-style format std::string and zero or more +// Returns a `string` given a `printf()`-style format string and zero or more // additional arguments. Use it as you would `sprintf()`. `StrFormat()` is the // primary formatting function within the `str_format` library, and should be // used in most cases where you need type-safe conversion of types into // formatted strings. // -// The format std::string generally consists of ordinary character data along with +// The format string generally consists of ordinary character data along with // one or more format conversion specifiers (denoted by the `%` character). -// Ordinary character data is returned unchanged into the result std::string, while +// Ordinary character data is returned unchanged into the result string, while // each conversion specification performs a type substitution from // `StrFormat()`'s other arguments. See the comments for `FormatSpec` for full -// information on the makeup of this format std::string. +// information on the makeup of this format string. // // Example: // -// std::string s = absl::StrFormat( +// string s = absl::StrFormat( // "Welcome to %s, Number %d!", "The Village", 6); // EXPECT_EQ("Welcome to The Village, Number 6!", s); // -// Returns an empty std::string in case of error. +// Returns an empty string in case of error. template <typename... Args> ABSL_MUST_USE_RESULT std::string StrFormat(const FormatSpec<Args...>& format, const Args&... args) { @@ -305,13 +305,13 @@ ABSL_MUST_USE_RESULT std::string StrFormat(const FormatSpec<Args...>& format, // StrAppendFormat() // -// Appends to a `dst` std::string given a format std::string, and zero or more additional +// Appends to a `dst` string given a format string, and zero or more additional // arguments, returning `*dst` as a convenience for chaining purposes. Appends // nothing in case of error (but possibly alters its capacity). // // Example: // -// std::string orig("For example PI is approximately "); +// string orig("For example PI is approximately "); // std::cout << StrAppendFormat(&orig, "%12.6f", 3.14); template <typename... Args> std::string& StrAppendFormat(std::string* dst, const FormatSpec<Args...>& format, @@ -323,7 +323,7 @@ std::string& StrAppendFormat(std::string* dst, const FormatSpec<Args...>& format // StreamFormat() // -// Writes to an output stream given a format std::string and zero or more arguments, +// Writes to an output stream given a format string and zero or more arguments, // generally in a manner that is more efficient than streaming the result of // `absl:: StrFormat()`. The returned object must be streamed before the full // expression ends. @@ -341,7 +341,7 @@ ABSL_MUST_USE_RESULT str_format_internal::Streamable StreamFormat( // PrintF() // -// Writes to stdout given a format std::string and zero or more arguments. This +// Writes to stdout given a format string and zero or more arguments. This // function is functionally equivalent to `std::printf()` (and type-safe); // prefer `absl::PrintF()` over `std::printf()`. // @@ -361,14 +361,14 @@ int PrintF(const FormatSpec<Args...>& format, const Args&... args) { // FPrintF() // -// Writes to a file given a format std::string and zero or more arguments. This +// Writes to a file given a format string and zero or more arguments. This // function is functionally equivalent to `std::fprintf()` (and type-safe); // prefer `absl::FPrintF()` over `std::fprintf()`. // // Example: // // std::string_view s = "Ulaanbaatar"; -// absl::FPrintF("The capital of Mongolia is %s", s); +// absl::FPrintF(stdout, "The capital of Mongolia is %s", s); // // Outputs: "The capital of Mongolia is Ulaanbaatar" // @@ -382,7 +382,7 @@ int FPrintF(std::FILE* output, const FormatSpec<Args...>& format, // SNPrintF() // -// Writes to a sized buffer given a format std::string and zero or more arguments. +// Writes to a sized buffer given a format string and zero or more arguments. // This function is functionally equivalent to `std::snprintf()` (and // type-safe); prefer `absl::SNPrintF()` over `std::snprintf()`. // @@ -430,14 +430,14 @@ class FormatRawSink { // Format() // -// Writes a formatted std::string to an arbitrary sink object (implementing the -// `absl::FormatRawSink` interface), using a format std::string and zero or more +// Writes a formatted string to an arbitrary sink object (implementing the +// `absl::FormatRawSink` interface), using a format string and zero or more // additional arguments. // // By default, `string` and `std::ostream` are supported as destination objects. // // `absl::Format()` is a generic version of `absl::StrFormat(), for custom -// sinks. The format std::string, like format strings for `StrFormat()`, is checked +// sinks. The format string, like format strings for `StrFormat()`, is checked // at compile-time. // // On failure, this function returns `false` and the state of the sink is @@ -463,13 +463,13 @@ using FormatArg = str_format_internal::FormatArgImpl; // FormatUntyped() // -// Writes a formatted std::string to an arbitrary sink object (implementing the +// Writes a formatted string to an arbitrary sink object (implementing the // `absl::FormatRawSink` interface), using an `UntypedFormatSpec` and zero or // more additional arguments. // // This function acts as the most generic formatting function in the // `str_format` library. The caller provides a raw sink, an unchecked format -// std::string, and (usually) a runtime specified list of arguments; no compile-time +// string, and (usually) a runtime specified list of arguments; no compile-time // checking of formatting is performed within this function. As a result, a // caller should check the return value to verify that no error occurred. // On failure, this function returns `false` and the state of the sink is @@ -483,9 +483,9 @@ using FormatArg = str_format_internal::FormatArgImpl; // // Example: // -// std::optional<std::string> FormatDynamic(const std::string& in_format, -// const vector<std::string>& in_args) { -// std::string out; +// std::optional<string> FormatDynamic(const string& in_format, +// const vector<string>& in_args) { +// string out; // std::vector<absl::FormatArg> args; // for (const auto& v : in_args) { // // It is important that 'v' is a reference to the objects in in_args. diff --git a/chromium/third_party/abseil-cpp/absl/strings/str_format_test.cc b/chromium/third_party/abseil-cpp/absl/strings/str_format_test.cc index fed75fafb5c..9a6576dc825 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/str_format_test.cc +++ b/chromium/third_party/abseil-cpp/absl/strings/str_format_test.cc @@ -391,7 +391,7 @@ TEST(StrFormat, BehavesAsDocumented) { #endif // Other conversion - int64_t value = 0x7ffdeb6; + int64_t value = 0x7ffdeb4; auto ptr_value = static_cast<uintptr_t>(value); const int& something = *reinterpret_cast<const int*>(ptr_value); EXPECT_EQ(StrFormat("%p", &something), StrFormat("0x%x", ptr_value)); diff --git a/chromium/third_party/abseil-cpp/absl/strings/str_join.h b/chromium/third_party/abseil-cpp/absl/strings/str_join.h index bd4d0e1d932..f9611ad3b47 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/str_join.h +++ b/chromium/third_party/abseil-cpp/absl/strings/str_join.h @@ -18,10 +18,10 @@ // ----------------------------------------------------------------------------- // // This header file contains functions for joining a range of elements and -// returning the result as a std::string. StrJoin operations are specified by passing -// a range, a separator std::string to use between the elements joined, and an +// returning the result as a string. StrJoin operations are specified by passing +// a range, a separator string to use between the elements joined, and an // optional Formatter responsible for converting each argument in the range to a -// std::string. If omitted, a default `AlphaNumFormatter()` is called on the elements +// string. If omitted, a default `AlphaNumFormatter()` is called on the elements // to be joined, using the same formatting that `absl::StrCat()` uses. This // package defines a number of default formatters, and you can define your own // implementations. @@ -29,7 +29,7 @@ // Ranges are specified by passing a container with `std::begin()` and // `std::end()` iterators, container-specific `begin()` and `end()` iterators, a // brace-initialized `std::initializer_list`, or a `std::tuple` of heterogeneous -// objects. The separator std::string is specified as an `absl::string_view`. +// objects. The separator string is specified as an `absl::string_view`. // // Because the default formatter uses the `absl::AlphaNum` class, // `absl::StrJoin()`, like `absl::StrCat()`, will work out-of-the-box on @@ -37,8 +37,8 @@ // // Example: // -// std::vector<std::string> v = {"foo", "bar", "baz"}; -// std::string s = absl::StrJoin(v, "-"); +// std::vector<string> v = {"foo", "bar", "baz"}; +// string s = absl::StrJoin(v, "-"); // EXPECT_EQ("foo-bar-baz", s); // // See comments on the `absl::StrJoin()` function for more examples. @@ -52,6 +52,7 @@ #include <iterator> #include <string> #include <tuple> +#include <type_traits> #include <utility> #include "absl/base/macros.h" @@ -65,16 +66,16 @@ namespace absl { // ----------------------------------------------------------------------------- // // A Formatter is a function object that is responsible for formatting its -// argument as a std::string and appending it to a given output std::string. Formatters +// argument as a string and appending it to a given output string. Formatters // may be implemented as function objects, lambdas, or normal functions. You may // provide your own Formatter to enable `absl::StrJoin()` to work with arbitrary // types. // // The following is an example of a custom Formatter that simply uses -// `std::to_string()` to format an integer as a std::string. +// `std::to_string()` to format an integer as a string. // // struct MyFormatter { -// void operator()(std::string* out, int i) const { +// void operator()(string* out, int i) const { // out->append(std::to_string(i)); // } // }; @@ -83,7 +84,7 @@ namespace absl { // argument to `absl::StrJoin()`: // // std::vector<int> v = {1, 2, 3, 4}; -// std::string s = absl::StrJoin(v, "-", MyFormatter()); +// string s = absl::StrJoin(v, "-", MyFormatter()); // EXPECT_EQ("1-2-3-4", s); // // The following standard formatters are provided within this file: @@ -155,10 +156,10 @@ DereferenceFormatter() { // StrJoin() // ----------------------------------------------------------------------------- // -// Joins a range of elements and returns the result as a std::string. -// `absl::StrJoin()` takes a range, a separator std::string to use between the +// Joins a range of elements and returns the result as a string. +// `absl::StrJoin()` takes a range, a separator string to use between the // elements joined, and an optional Formatter responsible for converting each -// argument in the range to a std::string. +// argument in the range to a string. // // If omitted, the default `AlphaNumFormatter()` is called on the elements to be // joined. @@ -166,22 +167,22 @@ DereferenceFormatter() { // Example 1: // // Joins a collection of strings. This pattern also works with a collection // // of `absl::string_view` or even `const char*`. -// std::vector<std::string> v = {"foo", "bar", "baz"}; -// std::string s = absl::StrJoin(v, "-"); +// std::vector<string> v = {"foo", "bar", "baz"}; +// string s = absl::StrJoin(v, "-"); // EXPECT_EQ("foo-bar-baz", s); // // Example 2: // // Joins the values in the given `std::initializer_list<>` specified using // // brace initialization. This pattern also works with an initializer_list // // of ints or `absl::string_view` -- any `AlphaNum`-compatible type. -// std::string s = absl::StrJoin({"foo", "bar", "baz"}, "-"); +// string s = absl::StrJoin({"foo", "bar", "baz"}, "-"); // EXPECT_EQ("foo-bar-baz", s); // // Example 3: // // Joins a collection of ints. This pattern also works with floats, // // doubles, int64s -- any `StrCat()`-compatible type. // std::vector<int> v = {1, 2, 3, -4}; -// std::string s = absl::StrJoin(v, "-"); +// string s = absl::StrJoin(v, "-"); // EXPECT_EQ("1-2-3--4", s); // // Example 4: @@ -192,7 +193,7 @@ DereferenceFormatter() { // // `std::vector<int*>`. // int x = 1, y = 2, z = 3; // std::vector<int*> v = {&x, &y, &z}; -// std::string s = absl::StrJoin(v, "-"); +// string s = absl::StrJoin(v, "-"); // EXPECT_EQ("1-2-3", s); // // Example 5: @@ -201,42 +202,42 @@ DereferenceFormatter() { // v.emplace_back(new int(1)); // v.emplace_back(new int(2)); // v.emplace_back(new int(3)); -// std::string s = absl::StrJoin(v, "-"); +// string s = absl::StrJoin(v, "-"); // EXPECT_EQ("1-2-3", s); // // Example 6: // // Joins a `std::map`, with each key-value pair separated by an equals // // sign. This pattern would also work with, say, a // // `std::vector<std::pair<>>`. -// std::map<std::string, int> m = { +// std::map<string, int> m = { // std::make_pair("a", 1), // std::make_pair("b", 2), // std::make_pair("c", 3)}; -// std::string s = absl::StrJoin(m, ",", absl::PairFormatter("=")); +// string s = absl::StrJoin(m, ",", absl::PairFormatter("=")); // EXPECT_EQ("a=1,b=2,c=3", s); // // Example 7: // // These examples show how `absl::StrJoin()` handles a few common edge // // cases: -// std::vector<std::string> v_empty; +// std::vector<string> v_empty; // EXPECT_EQ("", absl::StrJoin(v_empty, "-")); // -// std::vector<std::string> v_one_item = {"foo"}; +// std::vector<string> v_one_item = {"foo"}; // EXPECT_EQ("foo", absl::StrJoin(v_one_item, "-")); // -// std::vector<std::string> v_empty_string = {""}; +// std::vector<string> v_empty_string = {""}; // EXPECT_EQ("", absl::StrJoin(v_empty_string, "-")); // -// std::vector<std::string> v_one_item_empty_string = {"a", ""}; +// std::vector<string> v_one_item_empty_string = {"a", ""}; // EXPECT_EQ("a-", absl::StrJoin(v_one_item_empty_string, "-")); // -// std::vector<std::string> v_two_empty_string = {"", ""}; +// std::vector<string> v_two_empty_string = {"", ""}; // EXPECT_EQ("-", absl::StrJoin(v_two_empty_string, "-")); // // Example 8: // // Joins a `std::tuple<T...>` of heterogeneous types, converting each to -// // a std::string using the `absl::AlphaNum` class. -// std::string s = absl::StrJoin(std::make_tuple(123, "abc", 0.456), "-"); +// // a string using the `absl::AlphaNum` class. +// string s = absl::StrJoin(std::make_tuple(123, "abc", 0.456), "-"); // EXPECT_EQ("123-abc-0.456", s); template <typename Iterator, typename Formatter> diff --git a/chromium/third_party/abseil-cpp/absl/strings/str_replace.h b/chromium/third_party/abseil-cpp/absl/strings/str_replace.h index f4d9bb9545d..3bfe4c61ebd 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/str_replace.h +++ b/chromium/third_party/abseil-cpp/absl/strings/str_replace.h @@ -17,19 +17,19 @@ // File: str_replace.h // ----------------------------------------------------------------------------- // -// This file defines `absl::StrReplaceAll()`, a general-purpose std::string +// This file defines `absl::StrReplaceAll()`, a general-purpose string // replacement function designed for large, arbitrary text substitutions, // especially on strings which you are receiving from some other system for // further processing (e.g. processing regular expressions, escaping HTML -// entities, etc. `StrReplaceAll` is designed to be efficient even when only +// entities, etc.). `StrReplaceAll` is designed to be efficient even when only // one substitution is being performed, or when substitution is rare. // -// If the std::string being modified is known at compile-time, and the substitutions +// If the string being modified is known at compile-time, and the substitutions // vary, `absl::Substitute()` may be a better choice. // // Example: // -// std::string html_escaped = absl::StrReplaceAll(user_input, { +// string html_escaped = absl::StrReplaceAll(user_input, { // {"&", "&"}, // {"<", "<"}, // {">", ">"}, @@ -49,16 +49,16 @@ namespace absl { // StrReplaceAll() // -// Replaces character sequences within a given std::string with replacements provided +// Replaces character sequences within a given string with replacements provided // within an initializer list of key/value pairs. Candidate replacements are -// considered in order as they occur within the std::string, with earlier matches +// considered in order as they occur within the string, with earlier matches // taking precedence, and longer matches taking precedence for candidates -// starting at the same position in the std::string. Once a substitution is made, the +// starting at the same position in the string. Once a substitution is made, the // replaced text is not considered for any further substitutions. // // Example: // -// std::string s = absl::StrReplaceAll("$who bought $count #Noun. Thanks $who!", +// string s = absl::StrReplaceAll("$who bought $count #Noun. Thanks $who!", // {{"$count", absl::StrCat(5)}, // {"$who", "Bob"}, // {"#Noun", "Apples"}}); @@ -78,28 +78,28 @@ ABSL_MUST_USE_RESULT std::string StrReplaceAll( // replacements["$who"] = "Bob"; // replacements["$count"] = "5"; // replacements["#Noun"] = "Apples"; -// std::string s = absl::StrReplaceAll("$who bought $count #Noun. Thanks $who!", +// string s = absl::StrReplaceAll("$who bought $count #Noun. Thanks $who!", // replacements); // EXPECT_EQ("Bob bought 5 Apples. Thanks Bob!", s); // // // A std::vector of std::pair elements can be more efficient. -// std::vector<std::pair<const absl::string_view, std::string>> replacements; +// std::vector<std::pair<const absl::string_view, string>> replacements; // replacements.push_back({"&", "&"}); // replacements.push_back({"<", "<"}); // replacements.push_back({">", ">"}); -// std::string s = absl::StrReplaceAll("if (ptr < &foo)", +// string s = absl::StrReplaceAll("if (ptr < &foo)", // replacements); // EXPECT_EQ("if (ptr < &foo)", s); template <typename StrToStrMapping> std::string StrReplaceAll(absl::string_view s, const StrToStrMapping& replacements); // Overload of `StrReplaceAll()` to replace character sequences within a given -// output std::string *in place* with replacements provided within an initializer +// output string *in place* with replacements provided within an initializer // list of key/value pairs, returning the number of substitutions that occurred. // // Example: // -// std::string s = std::string("$who bought $count #Noun. Thanks $who!"); +// string s = std::string("$who bought $count #Noun. Thanks $who!"); // int count; // count = absl::StrReplaceAll({{"$count", absl::StrCat(5)}, // {"$who", "Bob"}, @@ -112,12 +112,12 @@ int StrReplaceAll( std::string* target); // Overload of `StrReplaceAll()` to replace patterns within a given output -// std::string *in place* with replacements provided within a container of key/value +// string *in place* with replacements provided within a container of key/value // pairs. // // Example: // -// std::string s = std::string("if (ptr < &foo)"); +// string s = std::string("if (ptr < &foo)"); // int count = absl::StrReplaceAll({{"&", "&"}, // {"<", "<"}, // {">", ">"}}, &s); diff --git a/chromium/third_party/abseil-cpp/absl/strings/str_replace_benchmark.cc b/chromium/third_party/abseil-cpp/absl/strings/str_replace_benchmark.cc index e608de8d19e..8386f2e6bf1 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/str_replace_benchmark.cc +++ b/chromium/third_party/abseil-cpp/absl/strings/str_replace_benchmark.cc @@ -38,16 +38,16 @@ struct Replacement { {"liquor", "shakes"}, // }; -// Here, we set up a std::string for use in global-replace benchmarks. +// Here, we set up a string for use in global-replace benchmarks. // We started with a million blanks, and then deterministically insert -// 10,000 copies each of two pangrams. The result is a std::string that is +// 10,000 copies each of two pangrams. The result is a string that is // 40% blank space and 60% these words. 'the' occurs 18,247 times and // all the substitutions together occur 49,004 times. // -// We then create "after_replacing_the" to be a std::string that is a result of +// We then create "after_replacing_the" to be a string that is a result of // replacing "the" with "box" in big_string. // -// And then we create "after_replacing_many" to be a std::string that is result +// And then we create "after_replacing_many" to be a string that is result // of preferring several substitutions. void SetUpStrings() { if (big_string == nullptr) { diff --git a/chromium/third_party/abseil-cpp/absl/strings/str_split.cc b/chromium/third_party/abseil-cpp/absl/strings/str_split.cc index 0207213c26b..0a68c52d14f 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/str_split.cc +++ b/chromium/third_party/abseil-cpp/absl/strings/str_split.cc @@ -43,10 +43,11 @@ absl::string_view GenericFind(absl::string_view text, if (delimiter.empty() && text.length() > 0) { // Special case for empty std::string delimiters: always return a zero-length // absl::string_view referring to the item at position 1 past pos. - return absl::string_view(text.begin() + pos + 1, 0); + return absl::string_view(text.data() + pos + 1, 0); } size_t found_pos = absl::string_view::npos; - absl::string_view found(text.end(), 0); // By default, not found + absl::string_view found(text.data() + text.size(), + 0); // By default, not found found_pos = find_policy.Find(text, delimiter, pos); if (found_pos != absl::string_view::npos) { found = absl::string_view(text.data() + found_pos, @@ -87,7 +88,7 @@ absl::string_view ByString::Find(absl::string_view text, size_t pos) const { // absl::string_view. size_t found_pos = text.find(delimiter_[0], pos); if (found_pos == absl::string_view::npos) - return absl::string_view(text.end(), 0); + return absl::string_view(text.data() + text.size(), 0); return text.substr(found_pos, 1); } return GenericFind(text, delimiter_, pos, LiteralPolicy()); @@ -100,7 +101,7 @@ absl::string_view ByString::Find(absl::string_view text, size_t pos) const { absl::string_view ByChar::Find(absl::string_view text, size_t pos) const { size_t found_pos = text.find(c_, pos); if (found_pos == absl::string_view::npos) - return absl::string_view(text.end(), 0); + return absl::string_view(text.data() + text.size(), 0); return text.substr(found_pos, 1); } @@ -128,9 +129,9 @@ absl::string_view ByLength::Find(absl::string_view text, // If the std::string is shorter than the chunk size we say we // "can't find the delimiter" so this will be the last chunk. if (substr.length() <= static_cast<size_t>(length_)) - return absl::string_view(text.end(), 0); + return absl::string_view(text.data() + text.size(), 0); - return absl::string_view(substr.begin() + length_, 0); + return absl::string_view(substr.data() + length_, 0); } } // namespace absl diff --git a/chromium/third_party/abseil-cpp/absl/strings/str_split.h b/chromium/third_party/abseil-cpp/absl/strings/str_split.h index 9a7be2b0534..c7eb280c411 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/str_split.h +++ b/chromium/third_party/abseil-cpp/absl/strings/str_split.h @@ -19,13 +19,13 @@ // // This file contains functions for splitting strings. It defines the main // `StrSplit()` function, several delimiters for determining the boundaries on -// which to split the std::string, and predicates for filtering delimited results. +// which to split the string, and predicates for filtering delimited results. // `StrSplit()` adapts the returned collection to the type specified by the // caller. // // Example: // -// // Splits the given std::string on commas. Returns the results in a +// // Splits the given string on commas. Returns the results in a // // vector of strings. // std::vector<std::string> v = absl::StrSplit("a,b,c", ','); // // Can also use "," @@ -55,7 +55,7 @@ namespace absl { //------------------------------------------------------------------------------ // // `StrSplit()` uses delimiters to define the boundaries between elements in the -// provided input. Several `Delimiter` types are defined below. If a std::string +// provided input. Several `Delimiter` types are defined below. If a string // (`const char*`, `std::string`, or `absl::string_view`) is passed in place of // an explicit `Delimiter` object, `StrSplit()` treats it the same way as if it // were passed a `ByString` delimiter. @@ -65,7 +65,7 @@ namespace absl { // // The following `Delimiter` types are available for use within `StrSplit()`: // -// - `ByString` (default for std::string arguments) +// - `ByString` (default for string arguments) // - `ByChar` (default for a char argument) // - `ByAnyChar` // - `ByLength` @@ -76,15 +76,15 @@ namespace absl { // be split and the position to begin searching for the next delimiter in the // input text. The returned absl::string_view should refer to the next // occurrence (after pos) of the represented delimiter; this returned -// absl::string_view represents the next location where the input std::string should +// absl::string_view represents the next location where the input string should // be broken. The returned absl::string_view may be zero-length if the Delimiter -// does not represent a part of the std::string (e.g., a fixed-length delimiter). If +// does not represent a part of the string (e.g., a fixed-length delimiter). If // no delimiter is found in the given text, a zero-length absl::string_view // referring to text.end() should be returned (e.g., // absl::string_view(text.end(), 0)). It is important that the returned // absl::string_view always be within the bounds of input text given as an -// argument--it must not refer to a std::string that is physically located outside of -// the given std::string. +// argument--it must not refer to a string that is physically located outside of +// the given string. // // The following example is a simple Delimiter object that is created with a // single char and will look for that char in the text passed to the Find() @@ -104,13 +104,13 @@ namespace absl { // ByString // -// A sub-std::string delimiter. If `StrSplit()` is passed a std::string in place of a -// `Delimiter` object, the std::string will be implicitly converted into a +// A sub-string delimiter. If `StrSplit()` is passed a string in place of a +// `Delimiter` object, the string will be implicitly converted into a // `ByString` delimiter. // // Example: // -// // Because a std::string literal is converted to an `absl::ByString`, +// // Because a string literal is converted to an `absl::ByString`, // // the following two splits are equivalent. // // std::vector<std::string> v1 = absl::StrSplit("a, b, c", ", "); @@ -131,7 +131,7 @@ class ByString { // ByChar // // A single character delimiter. `ByChar` is functionally equivalent to a -// 1-char std::string within a `ByString` delimiter, but slightly more +// 1-char string within a `ByString` delimiter, but slightly more // efficient. // // Example: @@ -164,9 +164,9 @@ class ByChar { // ByAnyChar // // A delimiter that will match any of the given byte-sized characters within -// its provided std::string. +// its provided string. // -// Note: this delimiter works with single-byte std::string data, but does not work +// Note: this delimiter works with single-byte string data, but does not work // with variable-width encodings, such as UTF-8. // // Example: @@ -175,8 +175,8 @@ class ByChar { // std::vector<std::string> v = absl::StrSplit("a,b=c", ByAnyChar(",=")); // // v[0] == "a", v[1] == "b", v[2] == "c" // -// If `ByAnyChar` is given the empty std::string, it behaves exactly like -// `ByString` and matches each individual character in the input std::string. +// If `ByAnyChar` is given the empty string, it behaves exactly like +// `ByString` and matches each individual character in the input string. // class ByAnyChar { public: @@ -192,7 +192,7 @@ class ByAnyChar { // A delimiter for splitting into equal-length strings. The length argument to // the constructor must be greater than 0. // -// Note: this delimiter works with single-byte std::string data, but does not work +// Note: this delimiter works with single-byte string data, but does not work // with variable-width encodings, such as UTF-8. // // Example: @@ -202,7 +202,7 @@ class ByAnyChar { // // v[0] == "123", v[1] == "456", v[2] == "789" // -// Note that the std::string does not have to be a multiple of the fixed split +// Note that the string does not have to be a multiple of the fixed split // length. In such a case, the last substring will be shorter. // // using absl::ByLength; @@ -223,9 +223,9 @@ namespace strings_internal { // A traits-like metafunction for selecting the default Delimiter object type // for a particular Delimiter type. The base case simply exposes type Delimiter // itself as the delimiter's Type. However, there are specializations for -// std::string-like objects that map them to the ByString delimiter object. +// string-like objects that map them to the ByString delimiter object. // This allows functions like absl::StrSplit() and absl::MaxSplits() to accept -// std::string-like objects (e.g., ',') as delimiter arguments but they will be +// string-like objects (e.g., ',') as delimiter arguments but they will be // treated as if a ByString delimiter was given. template <typename Delimiter> struct SelectDelimiter { @@ -261,7 +261,8 @@ class MaxSplitsImpl { : delimiter_(delimiter), limit_(limit), count_(0) {} absl::string_view Find(absl::string_view text, size_t pos) { if (count_++ == limit_) { - return absl::string_view(text.end(), 0); // No more matches. + return absl::string_view(text.data() + text.size(), + 0); // No more matches. } return delimiter_.Find(text, pos); } @@ -331,7 +332,7 @@ struct AllowEmpty { // SkipEmpty() // // Returns `false` if the given `absl::string_view` is empty, indicating that -// `StrSplit()` should omit the empty std::string. +// `StrSplit()` should omit the empty string. // // Example: // @@ -339,7 +340,7 @@ struct AllowEmpty { // // // v[0] == "a", v[1] == "b" // -// Note: `SkipEmpty()` does not consider a std::string containing only whitespace +// Note: `SkipEmpty()` does not consider a string containing only whitespace // to be empty. To skip such whitespace as well, use the `SkipWhitespace()` // predicate. struct SkipEmpty { @@ -349,7 +350,7 @@ struct SkipEmpty { // SkipWhitespace() // // Returns `false` if the given `absl::string_view` is empty *or* contains only -// whitespace, indicating that `StrSplit()` should omit the std::string. +// whitespace, indicating that `StrSplit()` should omit the string. // // Example: // @@ -373,7 +374,7 @@ struct SkipWhitespace { // StrSplit() // -// Splits a given std::string based on the provided `Delimiter` object, returning the +// Splits a given string based on the provided `Delimiter` object, returning the // elements within the type specified by the caller. Optionally, you may pass a // `Predicate` to `StrSplit()` indicating whether to include or exclude the // resulting element within the final result set. (See the overviews for @@ -412,7 +413,7 @@ struct SkipWhitespace { // // The `StrSplit()` function adapts the returned collection to the collection // specified by the caller (e.g. `std::vector` above). The returned collections -// may contain `string`, `absl::string_view` (in which case the original std::string +// may contain `string`, `absl::string_view` (in which case the original string // being split must ensure that it outlives the collection), or any object that // can be explicitly created from an `absl::string_view`. This behavior works // for: @@ -424,7 +425,7 @@ struct SkipWhitespace { // Example: // // // The results are returned as `absl::string_view` objects. Note that we -// // have to ensure that the input std::string outlives any results. +// // have to ensure that the input string outlives any results. // std::vector<absl::string_view> v = absl::StrSplit("a,b,c", ','); // // // Stores results in a std::set<std::string>, which also performs @@ -444,7 +445,7 @@ struct SkipWhitespace { // // is provided as a series of key/value pairs. For example, the 0th element // // resulting from the split will be stored as a key to the 1st element. If // // an odd number of elements are resolved, the last element is paired with -// // a default-constructed value (e.g., empty std::string). +// // a default-constructed value (e.g., empty string). // std::map<std::string, std::string> m = absl::StrSplit("a,b,c", ','); // // m["a"] == "b", m["c"] == "" // last component value equals "" // @@ -452,14 +453,14 @@ struct SkipWhitespace { // elements and is not a collection type. When splitting to a `std::pair` the // first two split strings become the `std::pair` `.first` and `.second` // members, respectively. The remaining split substrings are discarded. If there -// are less than two split substrings, the empty std::string is used for the +// are less than two split substrings, the empty string is used for the // corresponding // `std::pair` member. // // Example: // // // Stores first two split strings as the members in a std::pair. -// std::pair<std::string, std::string> p = absl::StrSplit("a,b,c", ','); +// std::pair<string, string> p = absl::StrSplit("a,b,c", ','); // // p.first == "a", p.second == "b" // "c" is omitted. // // The `StrSplit()` function can be used multiple times to perform more @@ -467,9 +468,9 @@ struct SkipWhitespace { // // Example: // -// // The input std::string "a=b=c,d=e,f=,g" becomes +// // The input string "a=b=c,d=e,f=,g" becomes // // { "a" => "b=c", "d" => "e", "f" => "", "g" => "" } -// std::map<std::string, std::string> m; +// std::map<string, string> m; // for (absl::string_view sp : absl::StrSplit("a=b=c,d=e,f=,g", ',')) { // m.insert(absl::StrSplit(sp, absl::MaxSplits('=', 1))); // } diff --git a/chromium/third_party/abseil-cpp/absl/strings/str_split_test.cc b/chromium/third_party/abseil-cpp/absl/strings/str_split_test.cc index 29a68047c99..413ad318bf9 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/str_split_test.cc +++ b/chromium/third_party/abseil-cpp/absl/strings/str_split_test.cc @@ -276,7 +276,7 @@ TEST(SplitIterator, Basics) { EXPECT_EQ(it, end); } -// Simple Predicate to skip a particular std::string. +// Simple Predicate to skip a particular string. class Skip { public: explicit Skip(const std::string& s) : s_(s) {} @@ -763,12 +763,12 @@ template <typename Delimiter> static bool IsFoundAtStartingPos(absl::string_view text, Delimiter d, size_t starting_pos, int expected_pos) { absl::string_view found = d.Find(text, starting_pos); - return found.data() != text.end() && + return found.data() != text.data() + text.size() && expected_pos == found.data() - text.data(); } // Helper function for testing Delimiter objects. Returns true if the given -// Delimiter is found in the given std::string at the given position. This function +// Delimiter is found in the given string at the given position. This function // tests two cases: // 1. The actual text given, staring at position 0 // 2. The text given with leading padding that should be ignored diff --git a/chromium/third_party/abseil-cpp/absl/strings/string_view.h b/chromium/third_party/abseil-cpp/absl/strings/string_view.h index a7f9199240a..9c03108b443 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/string_view.h +++ b/chromium/third_party/abseil-cpp/absl/strings/string_view.h @@ -19,7 +19,7 @@ // // This file contains the definition of the `absl::string_view` class. A // `string_view` points to a contiguous span of characters, often part or all of -// another `std::string`, double-quoted std::string literal, character array, or even +// another `std::string`, double-quoted string literal, character array, or even // another `string_view`. // // This `absl::string_view` abstraction is designed to be a drop-in @@ -56,15 +56,15 @@ namespace absl { // absl::string_view // -// A `string_view` provides a lightweight view into the std::string data provided by -// a `std::string`, double-quoted std::string literal, character array, or even -// another `string_view`. A `string_view` does *not* own the std::string to which it +// A `string_view` provides a lightweight view into the string data provided by +// a `std::string`, double-quoted string literal, character array, or even +// another `string_view`. A `string_view` does *not* own the string to which it // points, and that data cannot be modified through the view. // // You can use `string_view` as a function or method parameter anywhere a -// parameter can receive a double-quoted std::string literal, `const char*`, +// parameter can receive a double-quoted string literal, `const char*`, // `std::string`, or another `absl::string_view` argument with no need to copy -// the std::string data. Systematic use of `string_view` within function arguments +// the string data. Systematic use of `string_view` within function arguments // reduces data copies and `strlen()` calls. // // Because of its small size, prefer passing `string_view` by value: @@ -97,8 +97,8 @@ namespace absl { // `string_view` this way, it is your responsibility to ensure that the object // pointed to by the `string_view` outlives the `string_view`. // -// A `string_view` may represent a whole std::string or just part of a std::string. For -// example, when splitting a std::string, `std::vector<absl::string_view>` is a +// A `string_view` may represent a whole string or just part of a string. For +// example, when splitting a string, `std::vector<absl::string_view>` is a // natural data type for the output. // // @@ -141,7 +141,7 @@ namespace absl { // All empty `string_view` objects whether null or not, are equal: // // absl::string_view() == absl::string_view("", 0) -// absl::string_view(nullptr, 0) == absl:: string_view("abcdef"+6, 0) +// absl::string_view(nullptr, 0) == absl::string_view("abcdef"+6, 0) class string_view { public: using traits_type = std::char_traits<char>; @@ -340,7 +340,7 @@ class string_view { // // Returns a "substring" of the `string_view` (at offset `pos` and length // `n`) as another string_view. This function throws `std::out_of_bounds` if - // `pos > size'. + // `pos > size`. string_view substr(size_type pos, size_type n = npos) const { if (ABSL_PREDICT_FALSE(pos > length_)) base_internal::ThrowStdOutOfRange("absl::string_view::substr"); @@ -351,7 +351,7 @@ class string_view { // string_view::compare() // // Performs a lexicographical comparison between the `string_view` and - // another `absl::string_view), returning -1 if `this` is less than, 0 if + // another `absl::string_view`, returning -1 if `this` is less than, 0 if // `this` is equal to, and 1 if `this` is greater than the passed std::string // view. Note that in the case of data equality, a further comparison is made // on the respective sizes of the two `string_view`s to determine which is diff --git a/chromium/third_party/abseil-cpp/absl/strings/string_view_test.cc b/chromium/third_party/abseil-cpp/absl/strings/string_view_test.cc index b19d07c7fd6..a94e82254ee 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/string_view_test.cc +++ b/chromium/third_party/abseil-cpp/absl/strings/string_view_test.cc @@ -35,7 +35,8 @@ #define ABSL_EXPECT_DEATH_IF_SUPPORTED(statement, regex) \ EXPECT_DEATH_IF_SUPPORTED(statement, ".*") #else -#define ABSL_EXPECT_DEATH_IF_SUPPORTED EXPECT_DEATH_IF_SUPPORTED +#define ABSL_EXPECT_DEATH_IF_SUPPORTED(statement, regex) \ + EXPECT_DEATH_IF_SUPPORTED(statement, regex) #endif namespace { @@ -283,7 +284,7 @@ TEST(StringViewTest, ComparisonOperatorsByCharacterPosition) { } #undef COMPARE -// Sadly, our users often confuse std::string::npos with absl::string_view::npos; +// Sadly, our users often confuse string::npos with absl::string_view::npos; // So much so that we test here that they are the same. They need to // both be unsigned, and both be the maximum-valued integer of their type. @@ -811,15 +812,18 @@ TEST(StringViewTest, FrontBackSingleChar) { } // `std::string_view::string_view(const char*)` calls -// `std::char_traits<char>::length(const char*)` to get the std::string length. In +// `std::char_traits<char>::length(const char*)` to get the string length. In // libc++, it doesn't allow `nullptr` in the constexpr context, with the error // "read of dereferenced null pointer is not allowed in a constant expression". // At run time, the behavior of `std::char_traits::length()` on `nullptr` is -// undefined by the standard and usually results in crash with libc++. This -// conforms to the standard, but `absl::string_view` implements a different +// undefined by the standard and usually results in crash with libc++. +// In MSVC, creating a constexpr string_view from nullptr also triggers an +// "unevaluable pointer value" error. This compiler implementation conforms +// to the standard, but `absl::string_view` implements a different // behavior for historical reasons. We work around tests that construct // `string_view` from `nullptr` when using libc++. -#if !defined(ABSL_HAVE_STD_STRING_VIEW) || !defined(_LIBCPP_VERSION) +#if !defined(ABSL_HAVE_STD_STRING_VIEW) || \ + (!defined(_LIBCPP_VERSION) && !defined(_MSC_VER)) #define ABSL_HAVE_STRING_VIEW_FROM_NULLPTR 1 #endif // !defined(ABSL_HAVE_STD_STRING_VIEW) || !defined(_LIBCPP_VERSION) diff --git a/chromium/third_party/abseil-cpp/absl/strings/strip.h b/chromium/third_party/abseil-cpp/absl/strings/strip.h index 2f8d21f7deb..8d0d7c6bfc1 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/strip.h +++ b/chromium/third_party/abseil-cpp/absl/strings/strip.h @@ -17,7 +17,7 @@ // File: strip.h // ----------------------------------------------------------------------------- // -// This file contains various functions for stripping substrings from a std::string. +// This file contains various functions for stripping substrings from a string. #ifndef ABSL_STRINGS_STRIP_H_ #define ABSL_STRINGS_STRIP_H_ @@ -33,7 +33,7 @@ namespace absl { // ConsumePrefix() // -// Strips the `expected` prefix from the start of the given std::string, returning +// Strips the `expected` prefix from the start of the given string, returning // `true` if the strip operation succeeded or false otherwise. // // Example: @@ -48,7 +48,7 @@ inline bool ConsumePrefix(absl::string_view* str, absl::string_view expected) { } // ConsumeSuffix() // -// Strips the `expected` suffix from the end of the given std::string, returning +// Strips the `expected` suffix from the end of the given string, returning // `true` if the strip operation succeeded or false otherwise. // // Example: @@ -64,9 +64,9 @@ inline bool ConsumeSuffix(absl::string_view* str, absl::string_view expected) { // StripPrefix() // -// Returns a view into the input std::string 'str' with the given 'prefix' removed, -// but leaving the original std::string intact. If the prefix does not match at the -// start of the std::string, returns the original std::string instead. +// Returns a view into the input string 'str' with the given 'prefix' removed, +// but leaving the original string intact. If the prefix does not match at the +// start of the string, returns the original string instead. ABSL_MUST_USE_RESULT inline absl::string_view StripPrefix( absl::string_view str, absl::string_view prefix) { if (absl::StartsWith(str, prefix)) str.remove_prefix(prefix.size()); @@ -75,9 +75,9 @@ ABSL_MUST_USE_RESULT inline absl::string_view StripPrefix( // StripSuffix() // -// Returns a view into the input std::string 'str' with the given 'suffix' removed, -// but leaving the original std::string intact. If the suffix does not match at the -// end of the std::string, returns the original std::string instead. +// Returns a view into the input string 'str' with the given 'suffix' removed, +// but leaving the original string intact. If the suffix does not match at the +// end of the string, returns the original string instead. ABSL_MUST_USE_RESULT inline absl::string_view StripSuffix( absl::string_view str, absl::string_view suffix) { if (absl::EndsWith(str, suffix)) str.remove_suffix(suffix.size()); diff --git a/chromium/third_party/abseil-cpp/absl/strings/strip_test.cc b/chromium/third_party/abseil-cpp/absl/strings/strip_test.cc index 205c160c192..40c4c607121 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/strip_test.cc +++ b/chromium/third_party/abseil-cpp/absl/strings/strip_test.cc @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -// This file contains functions that remove a defined part from the std::string, -// i.e., strip the std::string. +// This file contains functions that remove a defined part from the string, +// i.e., strip the string. #include "absl/strings/strip.h" diff --git a/chromium/third_party/abseil-cpp/absl/strings/substitute.h b/chromium/third_party/abseil-cpp/absl/strings/substitute.h index c4b25ba7095..4de7b4e75ff 100644 --- a/chromium/third_party/abseil-cpp/absl/strings/substitute.h +++ b/chromium/third_party/abseil-cpp/absl/strings/substitute.h @@ -17,46 +17,46 @@ // File: substitute.h // ----------------------------------------------------------------------------- // -// This package contains functions for efficiently performing std::string -// substitutions using a format std::string with positional notation: +// This package contains functions for efficiently performing string +// substitutions using a format string with positional notation: // `Substitute()` and `SubstituteAndAppend()`. // // Unlike printf-style format specifiers, `Substitute()` functions do not need // to specify the type of the substitution arguments. Supported arguments -// following the format std::string, such as strings, string_views, ints, +// following the format string, such as strings, string_views, ints, // floats, and bools, are automatically converted to strings during the // substitution process. (See below for a full list of supported types.) // // `Substitute()` does not allow you to specify *how* to format a value, beyond -// the default conversion to std::string. For example, you cannot format an integer +// the default conversion to string. For example, you cannot format an integer // in hex. // -// The format std::string uses positional identifiers indicated by a dollar sign ($) +// The format string uses positional identifiers indicated by a dollar sign ($) // and single digit positional ids to indicate which substitution arguments to -// use at that location within the format std::string. +// use at that location within the format string. // // Example 1: -// std::string s = Substitute("$1 purchased $0 $2. Thanks $1!", +// string s = Substitute("$1 purchased $0 $2. Thanks $1!", // 5, "Bob", "Apples"); // EXPECT_EQ("Bob purchased 5 Apples. Thanks Bob!", s); // // Example 2: -// std::string s = "Hi. "; +// string s = "Hi. "; // SubstituteAndAppend(&s, "My name is $0 and I am $1 years old.", "Bob", 5); // EXPECT_EQ("Hi. My name is Bob and I am 5 years old.", s); // // // Supported types: -// * absl::string_view, std::string, const char* (null is equivalent to "") +// * absl::string_view, string, const char* (null is equivalent to "") // * int32_t, int64_t, uint32_t, uint64 // * float, double // * bool (Printed as "true" or "false") -// * pointer types other than char* (Printed as "0x<lower case hex std::string>", +// * pointer types other than char* (Printed as "0x<lower case hex string>", // except that null is printed as "NULL") // -// If an invalid format std::string is provided, Substitute returns an empty std::string -// and SubstituteAndAppend does not change the provided output std::string. -// A format std::string is invalid if it: +// If an invalid format string is provided, Substitute returns an empty string +// and SubstituteAndAppend does not change the provided output string. +// A format string is invalid if it: // * ends in an unescaped $ character, // e.g. "Hello $", or // * calls for a position argument which is not provided, @@ -88,7 +88,7 @@ namespace substitute_internal { // // This class provides an argument type for `absl::Substitute()` and // `absl::SubstituteAndAppend()`. `Arg` handles implicit conversion of various -// types to a std::string. (`Arg` is very similar to the `AlphaNum` class in +// types to a string. (`Arg` is very similar to the `AlphaNum` class in // `StrCat()`.) // // This class has implicit constructors. @@ -197,8 +197,8 @@ constexpr int PlaceholderBitmask(const char* format) { // SubstituteAndAppend() // -// Substitutes variables into a given format std::string and appends to a given -// output std::string. See file comments above for usage. +// Substitutes variables into a given format string and appends to a given +// output string. See file comments above for usage. // // The declarations of `SubstituteAndAppend()` below consist of overloads // for passing 0 to 10 arguments, respectively. @@ -444,7 +444,7 @@ void SubstituteAndAppend( // Substitute() // -// Substitutes variables into a given format std::string. See file comments above +// Substitutes variables into a given format string. See file comments above // for usage. // // The declarations of `Substitute()` below consist of overloads for passing 0 @@ -456,7 +456,7 @@ void SubstituteAndAppend( // Example: // template <typename... Args> // void VarMsg(absl::string_view format, const Args&... args) { -// std::string s = absl::Substitute(format, args...); +// string s = absl::Substitute(format, args...); ABSL_MUST_USE_RESULT inline std::string Substitute(absl::string_view format) { std::string result; diff --git a/chromium/third_party/abseil-cpp/absl/synchronization/BUILD.bazel b/chromium/third_party/abseil-cpp/absl/synchronization/BUILD.bazel index 8d302e01223..4f6a70740c2 100644 --- a/chromium/third_party/abseil-cpp/absl/synchronization/BUILD.bazel +++ b/chromium/third_party/abseil-cpp/absl/synchronization/BUILD.bazel @@ -138,6 +138,9 @@ cc_library( name = "thread_pool", testonly = 1, hdrs = ["internal/thread_pool.h"], + visibility = [ + "//absl:__subpackages__", + ], deps = [ ":synchronization", "//absl/base:core_headers", @@ -149,6 +152,7 @@ cc_test( size = "large", srcs = ["mutex_test.cc"], copts = ABSL_TEST_COPTS, + shard_count = 25, deps = [ ":synchronization", ":thread_pool", diff --git a/chromium/third_party/abseil-cpp/absl/synchronization/BUILD.gn b/chromium/third_party/abseil-cpp/absl/synchronization/BUILD.gn index 3664aa13274..e6f763a060b 100644 --- a/chromium/third_party/abseil-cpp/absl/synchronization/BUILD.gn +++ b/chromium/third_party/abseil-cpp/absl/synchronization/BUILD.gn @@ -50,8 +50,8 @@ source_set("synchronization") { "internal/create_thread_identity.cc", "internal/per_thread_sem.cc", "internal/waiter.cc", + "mutex.cc", "notification.cc", - "mutex.cc" ] public = [ "barrier.h", @@ -93,6 +93,8 @@ source_set("thread_pool") { ":synchronization", "../base:core_headers", ] + visibility = [] + visibility += [ "../*" ] } source_set("per_thread_sem_test_common") { diff --git a/chromium/third_party/abseil-cpp/absl/synchronization/mutex.cc b/chromium/third_party/abseil-cpp/absl/synchronization/mutex.cc index 80f34f035fc..47b7b4a870b 100644 --- a/chromium/third_party/abseil-cpp/absl/synchronization/mutex.cc +++ b/chromium/third_party/abseil-cpp/absl/synchronization/mutex.cc @@ -298,7 +298,7 @@ static struct SynchEvent { // this is a trivial hash table for the events // set "bits" in the word there (waiting until lockbit is clear before doing // so), and return a refcounted reference that will remain valid until // UnrefSynchEvent() is called. If a new SynchEvent is allocated, -// the std::string name is copied into it. +// the string name is copied into it. // When used with a mutex, the caller should also ensure that kMuEvent // is set in the mutex word, and similarly for condition variables and kCVEvent. static SynchEvent *EnsureSynchEvent(std::atomic<intptr_t> *addr, @@ -1827,8 +1827,8 @@ bool Mutex::LockSlowWithDeadline(MuHow how, const Condition *cond, cond == nullptr || EvalConditionAnnotated(cond, this, true, how); } -// RAW_CHECK_FMT() takes a condition, a printf-style format std::string, and -// the printf-style argument list. The format std::string must be a literal. +// RAW_CHECK_FMT() takes a condition, a printf-style format string, and +// the printf-style argument list. The format string must be a literal. // Arguments after the first are not evaluated unless the condition is true. #define RAW_CHECK_FMT(cond, ...) \ do { \ diff --git a/chromium/third_party/abseil-cpp/absl/synchronization/mutex.h b/chromium/third_party/abseil-cpp/absl/synchronization/mutex.h index 83c214867ac..a378190538e 100644 --- a/chromium/third_party/abseil-cpp/absl/synchronization/mutex.h +++ b/chromium/third_party/abseil-cpp/absl/synchronization/mutex.h @@ -962,7 +962,7 @@ void RegisterMutexTracer(void (*fn)(const char *msg, const void *obj, // // The function pointer registered here will be called here on various CondVar // events. The callback is given an opaque handle to the CondVar object and -// a std::string identifying the event. This is thread-safe, but only a single +// a string identifying the event. This is thread-safe, but only a single // tracer can be registered. // // Events that can be sent are "Wait", "Unwait", "Signal wakeup", and diff --git a/chromium/third_party/abseil-cpp/absl/time/duration.cc b/chromium/third_party/abseil-cpp/absl/time/duration.cc index f402137b0a6..2950c7cdc63 100644 --- a/chromium/third_party/abseil-cpp/absl/time/duration.cc +++ b/chromium/third_party/abseil-cpp/absl/time/duration.cc @@ -666,7 +666,7 @@ std::chrono::hours ToChronoHours(Duration d) { } // -// To/From std::string formatting. +// To/From string formatting. // namespace { @@ -744,7 +744,7 @@ void AppendNumberUnit(std::string* out, double n, DisplayUnit unit) { } // namespace // From Go's doc at http://golang.org/pkg/time/#Duration.String -// [FormatDuration] returns a std::string representing the duration in the +// [FormatDuration] returns a string representing the duration in the // form "72h3m0.5s". Leading zero units are omitted. As a special // case, durations less than one second format use a smaller unit // (milli-, micro-, or nanoseconds) to ensure that the leading digit @@ -787,8 +787,8 @@ std::string FormatDuration(Duration d) { namespace { // A helper for ParseDuration() that parses a leading number from the given -// std::string and stores the result in *int_part/*frac_part/*frac_scale. The -// given std::string pointer is modified to point to the first unconsumed char. +// string and stores the result in *int_part/*frac_part/*frac_scale. The +// given string pointer is modified to point to the first unconsumed char. bool ConsumeDurationNumber(const char** dpp, int64_t* int_part, int64_t* frac_part, int64_t* frac_scale) { *int_part = 0; @@ -816,8 +816,8 @@ bool ConsumeDurationNumber(const char** dpp, int64_t* int_part, } // A helper for ParseDuration() that parses a leading unit designator (e.g., -// ns, us, ms, s, m, h) from the given std::string and stores the resulting unit -// in "*unit". The given std::string pointer is modified to point to the first +// ns, us, ms, s, m, h) from the given string and stores the resulting unit +// in "*unit". The given string pointer is modified to point to the first // unconsumed char. bool ConsumeDurationUnit(const char** start, Duration* unit) { const char *s = *start; @@ -850,7 +850,7 @@ bool ConsumeDurationUnit(const char** start, Duration* unit) { } // namespace // From Go's doc at http://golang.org/pkg/time/#ParseDuration -// [ParseDuration] parses a duration std::string. A duration std::string is +// [ParseDuration] parses a duration string. A duration string is // a possibly signed sequence of decimal numbers, each with optional // fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". // Valid time units are "ns", "us" "ms", "s", "m", "h". diff --git a/chromium/third_party/abseil-cpp/absl/time/format.cc b/chromium/third_party/abseil-cpp/absl/time/format.cc index e98e60a372b..ee597e407a9 100644 --- a/chromium/third_party/abseil-cpp/absl/time/format.cc +++ b/chromium/third_party/abseil-cpp/absl/time/format.cc @@ -88,7 +88,7 @@ bool ParseTime(const std::string& format, const std::string& input, absl::Time* return absl::ParseTime(format, input, absl::UTCTimeZone(), time, err); } -// If the input std::string does not contain an explicit UTC offset, interpret +// If the input string does not contain an explicit UTC offset, interpret // the fields with respect to the given TimeZone. bool ParseTime(const std::string& format, const std::string& input, absl::TimeZone tz, absl::Time* time, std::string* err) { diff --git a/chromium/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time.h b/chromium/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time.h index 898222b4c7a..0842fa4a468 100644 --- a/chromium/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time.h +++ b/chromium/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time.h @@ -59,7 +59,7 @@ namespace cctz { // inferior fields to their minimum valid value (as described above). The // following are examples of how each of the six types would align the fields // representing November 22, 2015 at 12:34:56 in the afternoon. (Note: the -// std::string format used here is not important; it's just a shorthand way of +// string format used here is not important; it's just a shorthand way of // showing the six YMDHMS fields.) // // civil_second 2015-11-22 12:34:56 diff --git a/chromium/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h b/chromium/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h index 2362a4f4fbc..5fe0967f5b2 100644 --- a/chromium/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h +++ b/chromium/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h @@ -355,11 +355,11 @@ class civil_time { : civil_time(ct.f_) {} // Factories for the maximum/minimum representable civil_time. - static civil_time max() { + static CONSTEXPR_F civil_time max() { const auto max_year = std::numeric_limits<std::int_least64_t>::max(); return civil_time(max_year, 12, 31, 23, 59, 59); } - static civil_time min() { + static CONSTEXPR_F civil_time min() { const auto min_year = std::numeric_limits<std::int_least64_t>::min(); return civil_time(min_year, 1, 1, 0, 0, 0); } @@ -508,12 +508,8 @@ CONSTEXPR_F weekday get_weekday(const civil_day& cd) noexcept { CONSTEXPR_D int k_weekday_offsets[1 + 12] = { -1, 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4, }; - year_t wd = cd.year() - (cd.month() < 3); - if (wd >= 0) { - wd += wd / 4 - wd / 100 + wd / 400; - } else { - wd += (wd - 3) / 4 - (wd - 99) / 100 + (wd - 399) / 400; - } + year_t wd = 2400 + (cd.year() % 400) - (cd.month() < 3); + wd += wd / 4 - wd / 100 + wd / 400; wd += k_weekday_offsets[cd.month()] + cd.day(); return k_weekday_by_sun_off[(wd % 7 + 7) % 7]; } diff --git a/chromium/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h b/chromium/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h index 0b9764ea72a..c86a555250e 100644 --- a/chromium/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h +++ b/chromium/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h @@ -279,7 +279,7 @@ bool parse(const std::string&, const std::string&, const time_zone&, } // namespace detail // Formats the given time_point in the given cctz::time_zone according to -// the provided format std::string. Uses strftime()-like formatting options, +// the provided format string. Uses strftime()-like formatting options, // with the following extensions: // // - %Ez - RFC3339-compatible numeric UTC offset (+hh:mm or -hh:mm) @@ -298,7 +298,7 @@ bool parse(const std::string&, const std::string&, const time_zone&, // more than four characters, just like %Y. // // Tip: Format strings should include the UTC offset (e.g., %z, %Ez, or %E*z) -// so that the resulting std::string uniquely identifies an absolute time. +// so that the resulting string uniquely identifies an absolute time. // // Example: // cctz::time_zone lax; @@ -314,7 +314,7 @@ inline std::string format(const std::string& fmt, const time_point<D>& tp, return detail::format(fmt, p.first, n, tz); } -// Parses an input std::string according to the provided format std::string and +// Parses an input string according to the provided format string and // returns the corresponding time_point. Uses strftime()-like formatting // options, with the same extensions as cctz::format(), but with the // exceptions that %E#S is interpreted as %E*S, and %E#f as %E*f. %Ez @@ -328,7 +328,7 @@ inline std::string format(const std::string& fmt, const time_point<D>& tp, // // "1970-01-01 00:00:00.0 +0000" // -// For example, parsing a std::string of "15:45" (%H:%M) will return a time_point +// For example, parsing a string of "15:45" (%H:%M) will return a time_point // that represents "1970-01-01 15:45:00.0 +0000". // // Note that parse() returns time instants, so it makes most sense to parse diff --git a/chromium/third_party/abseil-cpp/absl/time/internal/cctz/src/cctz_benchmark.cc b/chromium/third_party/abseil-cpp/absl/time/internal/cctz/src/cctz_benchmark.cc index c97df78c09c..4498d7d0b6b 100644 --- a/chromium/third_party/abseil-cpp/absl/time/internal/cctz/src/cctz_benchmark.cc +++ b/chromium/third_party/abseil-cpp/absl/time/internal/cctz/src/cctz_benchmark.cc @@ -778,13 +778,13 @@ void BM_Zone_UTCTimeZone(benchmark::State& state) { } BENCHMARK(BM_Zone_UTCTimeZone); -// In each "ToDateTime" benchmark we switch between two instants -// separated by at least one transition in order to defeat any -// internal caching of previous results (e.g., see local_time_hint_). +// In each "ToCivil" benchmark we switch between two instants separated +// by at least one transition in order to defeat any internal caching of +// previous results (e.g., see local_time_hint_). // // The "UTC" variants use UTC instead of the Google/local time zone. -void BM_Time_ToDateTime_CCTZ(benchmark::State& state) { +void BM_Time_ToCivil_CCTZ(benchmark::State& state) { const cctz::time_zone tz = TestTimeZone(); std::chrono::system_clock::time_point tp = std::chrono::system_clock::from_time_t(1384569027); @@ -796,9 +796,9 @@ void BM_Time_ToDateTime_CCTZ(benchmark::State& state) { benchmark::DoNotOptimize(cctz::convert(tp, tz)); } } -BENCHMARK(BM_Time_ToDateTime_CCTZ); +BENCHMARK(BM_Time_ToCivil_CCTZ); -void BM_Time_ToDateTime_Libc(benchmark::State& state) { +void BM_Time_ToCivil_Libc(benchmark::State& state) { // No timezone support, so just use localtime. time_t t = 1384569027; time_t t2 = 1418962578; @@ -813,9 +813,9 @@ void BM_Time_ToDateTime_Libc(benchmark::State& state) { #endif } } -BENCHMARK(BM_Time_ToDateTime_Libc); +BENCHMARK(BM_Time_ToCivil_Libc); -void BM_Time_ToDateTimeUTC_CCTZ(benchmark::State& state) { +void BM_Time_ToCivilUTC_CCTZ(benchmark::State& state) { const cctz::time_zone tz = cctz::utc_time_zone(); std::chrono::system_clock::time_point tp = std::chrono::system_clock::from_time_t(1384569027); @@ -824,9 +824,9 @@ void BM_Time_ToDateTimeUTC_CCTZ(benchmark::State& state) { benchmark::DoNotOptimize(cctz::convert(tp, tz)); } } -BENCHMARK(BM_Time_ToDateTimeUTC_CCTZ); +BENCHMARK(BM_Time_ToCivilUTC_CCTZ); -void BM_Time_ToDateTimeUTC_Libc(benchmark::State& state) { +void BM_Time_ToCivilUTC_Libc(benchmark::State& state) { time_t t = 1384569027; struct tm tm; while (state.KeepRunning()) { @@ -838,16 +838,16 @@ void BM_Time_ToDateTimeUTC_Libc(benchmark::State& state) { #endif } } -BENCHMARK(BM_Time_ToDateTimeUTC_Libc); +BENCHMARK(BM_Time_ToCivilUTC_Libc); -// In each "FromDateTime" benchmark we switch between two YMDhms -// values separated by at least one transition in order to defeat any -// internal caching of previous results (e.g., see time_local_hint_). +// In each "FromCivil" benchmark we switch between two YMDhms values +// separated by at least one transition in order to defeat any internal +// caching of previous results (e.g., see time_local_hint_). // // The "UTC" variants use UTC instead of the Google/local time zone. // The "Day0" variants require normalization of the day of month. -void BM_Time_FromDateTime_CCTZ(benchmark::State& state) { +void BM_Time_FromCivil_CCTZ(benchmark::State& state) { const cctz::time_zone tz = TestTimeZone(); int i = 0; while (state.KeepRunning()) { @@ -860,9 +860,9 @@ void BM_Time_FromDateTime_CCTZ(benchmark::State& state) { } } } -BENCHMARK(BM_Time_FromDateTime_CCTZ); +BENCHMARK(BM_Time_FromCivil_CCTZ); -void BM_Time_FromDateTime_Libc(benchmark::State& state) { +void BM_Time_FromCivil_Libc(benchmark::State& state) { // No timezone support, so just use localtime. int i = 0; while (state.KeepRunning()) { @@ -886,20 +886,20 @@ void BM_Time_FromDateTime_Libc(benchmark::State& state) { benchmark::DoNotOptimize(mktime(&tm)); } } -BENCHMARK(BM_Time_FromDateTime_Libc); +BENCHMARK(BM_Time_FromCivil_Libc); -void BM_Time_FromDateTimeUTC_CCTZ(benchmark::State& state) { +void BM_Time_FromCivilUTC_CCTZ(benchmark::State& state) { const cctz::time_zone tz = cctz::utc_time_zone(); while (state.KeepRunning()) { benchmark::DoNotOptimize( cctz::convert(cctz::civil_second(2014, 12, 18, 20, 16, 18), tz)); } } -BENCHMARK(BM_Time_FromDateTimeUTC_CCTZ); +BENCHMARK(BM_Time_FromCivilUTC_CCTZ); -// There is no BM_Time_FromDateTimeUTC_Libc. +// There is no BM_Time_FromCivilUTC_Libc. -void BM_Time_FromDateTimeDay0_CCTZ(benchmark::State& state) { +void BM_Time_FromCivilDay0_CCTZ(benchmark::State& state) { const cctz::time_zone tz = TestTimeZone(); int i = 0; while (state.KeepRunning()) { @@ -912,9 +912,9 @@ void BM_Time_FromDateTimeDay0_CCTZ(benchmark::State& state) { } } } -BENCHMARK(BM_Time_FromDateTimeDay0_CCTZ); +BENCHMARK(BM_Time_FromCivilDay0_CCTZ); -void BM_Time_FromDateTimeDay0_Libc(benchmark::State& state) { +void BM_Time_FromCivilDay0_Libc(benchmark::State& state) { // No timezone support, so just use localtime. int i = 0; while (state.KeepRunning()) { @@ -938,7 +938,7 @@ void BM_Time_FromDateTimeDay0_Libc(benchmark::State& state) { benchmark::DoNotOptimize(mktime(&tm)); } } -BENCHMARK(BM_Time_FromDateTimeDay0_Libc); +BENCHMARK(BM_Time_FromCivilDay0_Libc); const char* const kFormats[] = { RFC1123_full, // 0 diff --git a/chromium/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc b/chromium/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc index 1b023848efa..a02b1e341ac 100644 --- a/chromium/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc +++ b/chromium/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc @@ -533,7 +533,7 @@ const char* ParseSubSeconds(const char* dp, detail::femtoseconds* subseconds) { return dp; } -// Parses a std::string into a std::tm using strptime(3). +// Parses a string into a std::tm using strptime(3). const char* ParseTM(const char* dp, const char* fmt, std::tm* tm) { if (dp != nullptr) { dp = strptime(dp, fmt, tm); @@ -743,7 +743,7 @@ bool parse(const std::string& format, const std::string& input, data = ParseTM(data, spec.c_str(), &tm); // If we successfully parsed %p we need to remember whether the result - // was AM or PM so that we can adjust tm_hour before ConvertDateTime(). + // was AM or PM so that we can adjust tm_hour before time_zone::lookup(). // So reparse the input with a known AM hour, and check if it is shifted // to a PM hour. if (spec == "%p" && data != nullptr) { diff --git a/chromium/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format_test.cc b/chromium/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format_test.cc index a90dda7603a..6b9928ed32f 100644 --- a/chromium/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format_test.cc +++ b/chromium/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format_test.cc @@ -669,13 +669,13 @@ TEST(Parse, WithTimeZone) { utc_time_zone(), &tp)); ExpectTime(tp, tz, 2013, 6, 28, 19 - 8 - 7, 8, 9, -7 * 60 * 60, true, "PDT"); - // Check a skipped time (a Spring DST transition). parse() returns - // the preferred-offset result, as defined for ConvertDateTime(). + // Check a skipped time (a Spring DST transition). parse() uses the + // pre-transition offset. EXPECT_TRUE(parse("%Y-%m-%d %H:%M:%S", "2011-03-13 02:15:00", tz, &tp)); ExpectTime(tp, tz, 2011, 3, 13, 3, 15, 0, -7 * 60 * 60, true, "PDT"); - // Check a repeated time (a Fall DST transition). parse() returns - // the preferred-offset result, as defined for ConvertDateTime(). + // Check a repeated time (a Fall DST transition). parse() uses the + // pre-transition offset. EXPECT_TRUE(parse("%Y-%m-%d %H:%M:%S", "2011-11-06 01:15:00", tz, &tp)); ExpectTime(tp, tz, 2011, 11, 6, 1, 15, 0, -7 * 60 * 60, true, "PDT"); } diff --git a/chromium/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc b/chromium/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc index bf73635d4c6..2cb358d048e 100644 --- a/chromium/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc +++ b/chromium/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc @@ -286,7 +286,7 @@ bool TimeZoneInfo::EquivTransitions(std::uint_fast8_t tt1_index, return true; } -// Use the POSIX-TZ-environment-variable-style std::string to handle times +// Use the POSIX-TZ-environment-variable-style string to handle times // in years after the last transition stored in the zoneinfo data. void TimeZoneInfo::ExtendTransitions(const std::string& name, const Header& hdr) { diff --git a/chromium/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.h b/chromium/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.h index 6619f27edcf..9ccd4a8b68b 100644 --- a/chromium/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.h +++ b/chromium/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.h @@ -89,7 +89,7 @@ struct PosixTransition { } time; }; -// The entirety of a POSIX-std::string specified time-zone rule. The standard +// The entirety of a POSIX-string specified time-zone rule. The standard // abbreviation and offset are always given. If the time zone includes // daylight saving, then the daylight abbrevation is non-empty and the // remaining fields are also valid. Note that the start/end transitions diff --git a/chromium/third_party/abseil-cpp/absl/time/time.h b/chromium/third_party/abseil-cpp/absl/time/time.h index c41cb89c5ef..36e10b91ce7 100644 --- a/chromium/third_party/abseil-cpp/absl/time/time.h +++ b/chromium/third_party/abseil-cpp/absl/time/time.h @@ -25,11 +25,12 @@ // * `absl::TimeZone` defines geopolitical time zone regions (as collected // within the IANA Time Zone database (https://www.iana.org/time-zones)). // +// // Example: // // absl::TimeZone nyc; // -// // LoadTimeZone may fail so it's always better to check for success. +// // LoadTimeZone() may fail so it's always better to check for success. // if (!absl::LoadTimeZone("America/New_York", &nyc)) { // // handle error case // } @@ -481,7 +482,7 @@ std::chrono::hours ToChronoHours(Duration d); // FormatDuration() // -// Returns a std::string representing the duration in the form "72h3m0.5s". +// Returns a string representing the duration in the form "72h3m0.5s". // Returns "inf" or "-inf" for +/- `InfiniteDuration()`. std::string FormatDuration(Duration d); @@ -492,11 +493,11 @@ inline std::ostream& operator<<(std::ostream& os, Duration d) { // ParseDuration() // -// Parses a duration std::string consisting of a possibly signed sequence of +// Parses a duration string consisting of a possibly signed sequence of // decimal numbers, each with an optional fractional part and a unit // suffix. The valid suffixes are "ns", "us" "ms", "s", "m", and "h". // Simple examples include "300ms", "-1.5h", and "2h45m". Parses "0" as -// `ZeroDuration()`. Parses "inf" and "-inf" as +/- `InfiniteDuration()`. +// `ZeroDuration()`. Parses "inf" and "-inf" as +/- `InfiniteDuration()`. bool ParseDuration(const std::string& dur_string, Duration* d); // Support for flag values of type Duration. Duration flags must be specified @@ -689,7 +690,9 @@ constexpr Time InfinitePast() { // Examples: // // absl::TimeZone lax; -// if (!absl::LoadTimeZone("America/Los_Angeles", &lax)) { ... } +// if (!absl::LoadTimeZone("America/Los_Angeles", &lax)) { +// // handle error case +// } // // // A unique civil time // absl::TimeConversion jan01 = @@ -759,7 +762,9 @@ TimeConversion ConvertDateTime(int64_t year, int mon, int day, int hour, // Example: // // absl::TimeZone seattle; -// if (!absl::LoadTimeZone("America/Los_Angeles", &seattle)) { ... } +// if (!absl::LoadTimeZone("America/Los_Angeles", &seattle)) { +// // handle error case +// } // absl::Time t = absl::FromDateTime(2017, 9, 26, 9, 30, 0, seattle); Time FromDateTime(int64_t year, int mon, int day, int hour, int min, int sec, TimeZone tz); @@ -871,8 +876,10 @@ std::chrono::system_clock::time_point ToChronoTime(Time); // FormatTime()/ParseTime() format specifiers for RFC3339 date/time strings, // with trailing zeros trimmed or with fractional seconds omitted altogether. // -// Note that RFC3339_sec[] matches an ISO 8601 extended format for date -// and time with UTC offset. +// Note that RFC3339_sec[] matches an ISO 8601 extended format for date and +// time with UTC offset. Also note the use of "%Y": RFC3339 mandates that +// years have exactly four digits, but we allow them to take their natural +// width. extern const char RFC3339_full[]; // %Y-%m-%dT%H:%M:%E*S%Ez extern const char RFC3339_sec[]; // %Y-%m-%dT%H:%M:%S%Ez @@ -886,7 +893,7 @@ extern const char RFC1123_no_wday[]; // %d %b %E4Y %H:%M:%S %z // FormatTime() // // Formats the given `absl::Time` in the `absl::TimeZone` according to the -// provided format std::string. Uses strftime()-like formatting options, with +// provided format string. Uses strftime()-like formatting options, with // the following extensions: // // - %Ez - RFC3339-compatible numeric UTC offset (+hh:mm or -hh:mm) @@ -910,16 +917,18 @@ extern const char RFC1123_no_wday[]; // %d %b %E4Y %H:%M:%S %z // Example: // // absl::TimeZone lax; -// if (!absl::LoadTimeZone("America/Los_Angeles", &lax)) { ... } +// if (!absl::LoadTimeZone("America/Los_Angeles", &lax)) { +// // handle error case +// } // absl::Time t = absl::FromDateTime(2013, 1, 2, 3, 4, 5, lax); // -// std::string f = absl::FormatTime("%H:%M:%S", t, lax); // "03:04:05" +// string f = absl::FormatTime("%H:%M:%S", t, lax); // "03:04:05" // f = absl::FormatTime("%H:%M:%E3S", t, lax); // "03:04:05.000" // // Note: If the given `absl::Time` is `absl::InfiniteFuture()`, the returned -// std::string will be exactly "infinite-future". If the given `absl::Time` is -// `absl::InfinitePast()`, the returned std::string will be exactly "infinite-past". -// In both cases the given format std::string and `absl::TimeZone` are ignored. +// string will be exactly "infinite-future". If the given `absl::Time` is +// `absl::InfinitePast()`, the returned string will be exactly "infinite-past". +// In both cases the given format string and `absl::TimeZone` are ignored. // std::string FormatTime(const std::string& format, Time t, TimeZone tz); @@ -936,7 +945,7 @@ inline std::ostream& operator<<(std::ostream& os, Time t) { // ParseTime() // -// Parses an input std::string according to the provided format std::string and +// Parses an input string according to the provided format string and // returns the corresponding `absl::Time`. Uses strftime()-like formatting // options, with the same extensions as FormatTime(), but with the // exceptions that %E#S is interpreted as %E*S, and %E#f as %E*f. %Ez @@ -950,7 +959,7 @@ inline std::ostream& operator<<(std::ostream& os, Time t) { // // "1970-01-01 00:00:00.0 +0000" // -// For example, parsing a std::string of "15:45" (%H:%M) will return an absl::Time +// For example, parsing a string of "15:45" (%H:%M) will return an absl::Time // that represents "1970-01-01 15:45:00.0 +0000". // // Note that since ParseTime() returns time instants, it makes the most sense @@ -977,15 +986,15 @@ inline std::ostream& operator<<(std::ostream& os, Time t) { // Errors are indicated by returning false and assigning an error message // to the "err" out param if it is non-null. // -// Note: If the input std::string is exactly "infinite-future", the returned +// Note: If the input string is exactly "infinite-future", the returned // `absl::Time` will be `absl::InfiniteFuture()` and `true` will be returned. -// If the input std::string is "infinite-past", the returned `absl::Time` will be +// If the input string is "infinite-past", the returned `absl::Time` will be // `absl::InfinitePast()` and `true` will be returned. // bool ParseTime(const std::string& format, const std::string& input, Time* time, std::string* err); -// Like ParseTime() above, but if the format std::string does not contain a UTC +// Like ParseTime() above, but if the format string does not contain a UTC // offset specification (%z/%Ez/%E*z) then the input is interpreted in the // given TimeZone. This means that the input, by itself, does not identify a // unique instant. Being time-zone dependent, it also admits the possibility @@ -1028,7 +1037,9 @@ std::string UnparseFlag(Time t); // absl::TimeZone pst = absl::FixedTimeZone(-8 * 60 * 60); // absl::TimeZone loc = absl::LocalTimeZone(); // absl::TimeZone lax; -// if (!absl::LoadTimeZone("America/Los_Angeles", &lax)) { ... } +// if (!absl::LoadTimeZone("America/Los_Angeles", &lax)) { +// // handle error case +// } // // See also: // - https://github.com/google/cctz diff --git a/chromium/third_party/abseil-cpp/absl/types/BUILD.bazel b/chromium/third_party/abseil-cpp/absl/types/BUILD.bazel index 096c119e638..7841a97d985 100644 --- a/chromium/third_party/abseil-cpp/absl/types/BUILD.bazel +++ b/chromium/third_party/abseil-cpp/absl/types/BUILD.bazel @@ -19,6 +19,7 @@ load( "ABSL_DEFAULT_COPTS", "ABSL_TEST_COPTS", "ABSL_EXCEPTIONS_FLAG", + "ABSL_EXCEPTIONS_FLAG_LINKOPTS", ) package(default_visibility = ["//visibility:public"]) @@ -55,6 +56,7 @@ cc_library( "bad_any_cast.h", ], copts = ABSL_EXCEPTIONS_FLAG + ABSL_DEFAULT_COPTS, + linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS, visibility = ["//visibility:private"], deps = [ "//absl/base", @@ -69,6 +71,7 @@ cc_test( "any_test.cc", ], copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, + linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS, deps = [ ":any", "//absl/base", @@ -100,6 +103,7 @@ cc_test( name = "any_exception_safety_test", srcs = ["any_exception_safety_test.cc"], copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, + linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS, deps = [ ":any", "//absl/base:exception_safety_testing", @@ -124,6 +128,7 @@ cc_test( size = "small", srcs = ["span_test.cc"], copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, + linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS, deps = [ ":span", "//absl/base:config", @@ -172,6 +177,7 @@ cc_library( srcs = ["bad_optional_access.cc"], hdrs = ["bad_optional_access.h"], copts = ABSL_DEFAULT_COPTS + ABSL_EXCEPTIONS_FLAG, + linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS, deps = [ "//absl/base", "//absl/base:config", @@ -183,6 +189,7 @@ cc_library( srcs = ["bad_variant_access.cc"], hdrs = ["bad_variant_access.h"], copts = ABSL_EXCEPTIONS_FLAG + ABSL_DEFAULT_COPTS, + linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS, deps = [ "//absl/base", "//absl/base:config", @@ -196,6 +203,7 @@ cc_test( "optional_test.cc", ], copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, + linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS, deps = [ ":optional", "//absl/base", @@ -212,6 +220,7 @@ cc_test( "optional_exception_safety_test.cc", ], copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, + linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS, deps = [ ":optional", "//absl/base:exception_safety_testing", @@ -239,6 +248,7 @@ cc_test( size = "small", srcs = ["variant_test.cc"], copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, + linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS, deps = [ ":variant", "//absl/base:config", @@ -271,6 +281,7 @@ cc_test( "variant_exception_safety_test.cc", ], copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, + linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS, deps = [ ":variant", "//absl/base:exception_safety_testing", diff --git a/chromium/third_party/abseil-cpp/absl/types/internal/variant.h b/chromium/third_party/abseil-cpp/absl/types/internal/variant.h index 7708e67cb14..f220afd0441 100644 --- a/chromium/third_party/abseil-cpp/absl/types/internal/variant.h +++ b/chromium/third_party/abseil-cpp/absl/types/internal/variant.h @@ -37,6 +37,8 @@ #include "absl/types/bad_variant_access.h" #include "absl/utility/utility.h" +#if !defined(ABSL_HAVE_STD_VARIANT) + namespace absl { template <class... Types> @@ -1227,23 +1229,23 @@ using VariantCopyBase = absl::conditional_t< // Base that is dependent on whether or not the move-assign can be trivial. template <class... T> using VariantMoveAssignBase = absl::conditional_t< - absl::disjunction<absl::conjunction<std::is_move_assignable<Union<T...>>, + absl::disjunction<absl::conjunction<absl::is_move_assignable<Union<T...>>, std::is_move_constructible<Union<T...>>, std::is_destructible<Union<T...>>>, absl::negation<absl::conjunction< std::is_move_constructible<T>..., - std::is_move_assignable<T>...>>>::value, + absl::is_move_assignable<T>...>>>::value, VariantCopyBase<T...>, VariantMoveAssignBaseNontrivial<T...>>; // Base that is dependent on whether or not the copy-assign can be trivial. template <class... T> using VariantCopyAssignBase = absl::conditional_t< - absl::disjunction<absl::conjunction<std::is_copy_assignable<Union<T...>>, + absl::disjunction<absl::conjunction<absl::is_copy_assignable<Union<T...>>, std::is_copy_constructible<Union<T...>>, std::is_destructible<Union<T...>>>, absl::negation<absl::conjunction< std::is_copy_constructible<T>..., - std::is_copy_assignable<T>...>>>::value, + absl::is_copy_assignable<T>...>>>::value, VariantMoveAssignBase<T...>, VariantCopyAssignBaseNontrivial<T...>>; template <class... T> @@ -1612,4 +1614,5 @@ struct VariantHashBase<Variant, } // namespace variant_internal } // namespace absl +#endif // !defined(ABSL_HAVE_STD_VARIANT) #endif // ABSL_TYPES_variant_internal_H_ diff --git a/chromium/third_party/abseil-cpp/absl/types/optional.h b/chromium/third_party/abseil-cpp/absl/types/optional.h index c837cddeef4..14210018815 100644 --- a/chromium/third_party/abseil-cpp/absl/types/optional.h +++ b/chromium/third_party/abseil-cpp/absl/types/optional.h @@ -59,6 +59,7 @@ using std::nullopt; #include <type_traits> #include <utility> +#include "absl/base/attributes.h" #include "absl/memory/memory.h" #include "absl/meta/type_traits.h" #include "absl/types/bad_optional_access.h" @@ -411,10 +412,10 @@ constexpr copy_traits get_ctor_copy_traits() { template <typename T> constexpr copy_traits get_assign_copy_traits() { - return std::is_copy_assignable<T>::value && + return absl::is_copy_assignable<T>::value && std::is_copy_constructible<T>::value ? copy_traits::copyable - : std::is_move_assignable<T>::value && + : absl::is_move_assignable<T>::value && std::is_move_constructible<T>::value ? copy_traits::movable : copy_traits::non_movable; @@ -700,7 +701,7 @@ class optional : private optional_internal::optional_data<T>, // optional::reset() // // Destroys the inner `T` value of an `absl::optional` if one is present. - void reset() noexcept { this->destruct(); } + ABSL_ATTRIBUTE_REINITIALIZES void reset() noexcept { this->destruct(); } // optional::emplace() // diff --git a/chromium/third_party/abseil-cpp/absl/types/optional_test.cc b/chromium/third_party/abseil-cpp/absl/types/optional_test.cc index 179bfd66d2f..d90db9f821b 100644 --- a/chromium/third_party/abseil-cpp/absl/types/optional_test.cc +++ b/chromium/third_party/abseil-cpp/absl/types/optional_test.cc @@ -607,11 +607,12 @@ TEST(optionalTest, CopyAssignment) { opt2_to_empty = empty; EXPECT_FALSE(opt2_to_empty); - EXPECT_FALSE(std::is_copy_assignable<absl::optional<const int>>::value); - EXPECT_TRUE(std::is_copy_assignable<absl::optional<Copyable>>::value); - EXPECT_FALSE(std::is_copy_assignable<absl::optional<MoveableThrow>>::value); - EXPECT_FALSE(std::is_copy_assignable<absl::optional<MoveableNoThrow>>::value); - EXPECT_FALSE(std::is_copy_assignable<absl::optional<NonMovable>>::value); + EXPECT_FALSE(absl::is_copy_assignable<absl::optional<const int>>::value); + EXPECT_TRUE(absl::is_copy_assignable<absl::optional<Copyable>>::value); + EXPECT_FALSE(absl::is_copy_assignable<absl::optional<MoveableThrow>>::value); + EXPECT_FALSE( + absl::is_copy_assignable<absl::optional<MoveableNoThrow>>::value); + EXPECT_FALSE(absl::is_copy_assignable<absl::optional<NonMovable>>::value); EXPECT_TRUE(absl::is_trivially_copy_assignable<int>::value); EXPECT_TRUE(absl::is_trivially_copy_assignable<volatile int>::value); @@ -625,9 +626,9 @@ TEST(optionalTest, CopyAssignment) { }; EXPECT_TRUE(absl::is_trivially_copy_assignable<Trivial>::value); - EXPECT_FALSE(std::is_copy_assignable<const Trivial>::value); - EXPECT_FALSE(std::is_copy_assignable<volatile Trivial>::value); - EXPECT_TRUE(std::is_copy_assignable<NonTrivial>::value); + EXPECT_FALSE(absl::is_copy_assignable<const Trivial>::value); + EXPECT_FALSE(absl::is_copy_assignable<volatile Trivial>::value); + EXPECT_TRUE(absl::is_copy_assignable<NonTrivial>::value); EXPECT_FALSE(absl::is_trivially_copy_assignable<NonTrivial>::value); // std::optional doesn't support volatile nontrivial types. @@ -695,11 +696,11 @@ TEST(optionalTest, MoveAssignment) { EXPECT_EQ(1, listener.volatile_move_assign); } #endif // ABSL_HAVE_STD_OPTIONAL - EXPECT_FALSE(std::is_move_assignable<absl::optional<const int>>::value); - EXPECT_TRUE(std::is_move_assignable<absl::optional<Copyable>>::value); - EXPECT_TRUE(std::is_move_assignable<absl::optional<MoveableThrow>>::value); - EXPECT_TRUE(std::is_move_assignable<absl::optional<MoveableNoThrow>>::value); - EXPECT_FALSE(std::is_move_assignable<absl::optional<NonMovable>>::value); + EXPECT_FALSE(absl::is_move_assignable<absl::optional<const int>>::value); + EXPECT_TRUE(absl::is_move_assignable<absl::optional<Copyable>>::value); + EXPECT_TRUE(absl::is_move_assignable<absl::optional<MoveableThrow>>::value); + EXPECT_TRUE(absl::is_move_assignable<absl::optional<MoveableNoThrow>>::value); + EXPECT_FALSE(absl::is_move_assignable<absl::optional<NonMovable>>::value); EXPECT_FALSE( std::is_nothrow_move_assignable<absl::optional<MoveableThrow>>::value); @@ -1619,7 +1620,7 @@ TEST(optionalTest, AssignmentConstraints) { EXPECT_TRUE( (std::is_assignable<absl::optional<AnyLike>&, const AnyLike&>::value)); EXPECT_TRUE(std::is_move_assignable<absl::optional<AnyLike>>::value); - EXPECT_TRUE(std::is_copy_assignable<absl::optional<AnyLike>>::value); + EXPECT_TRUE(absl::is_copy_assignable<absl::optional<AnyLike>>::value); } } // namespace diff --git a/chromium/third_party/abseil-cpp/absl/types/span.h b/chromium/third_party/abseil-cpp/absl/types/span.h index 76be819ecca..5387e8e027d 100644 --- a/chromium/third_party/abseil-cpp/absl/types/span.h +++ b/chromium/third_party/abseil-cpp/absl/types/span.h @@ -87,7 +87,7 @@ constexpr auto GetDataImpl(C& c, char) noexcept // NOLINT(runtime/references) return c.data(); } -// Before C++17, std::string::data returns a const char* in all cases. +// Before C++17, string::data returns a const char* in all cases. inline char* GetDataImpl(std::string& s, // NOLINT(runtime/references) int) noexcept { return &s[0]; diff --git a/chromium/third_party/abseil-cpp/absl/types/variant.h b/chromium/third_party/abseil-cpp/absl/types/variant.h index 17e0634de03..2f78722f8b7 100644 --- a/chromium/third_party/abseil-cpp/absl/types/variant.h +++ b/chromium/third_party/abseil-cpp/absl/types/variant.h @@ -414,9 +414,9 @@ constexpr absl::add_pointer_t<const T> get_if( // }; // // // Declare our variant, and call `absl::visit()` on it. -// std::variant<int, std::string> foo = std::string("foo"); +// absl::variant<int, std::string> foo = std::string("foo"); // GetVariant visitor; -// std::visit(visitor, foo); // Prints `The variant's value is: foo' +// absl::visit(visitor, foo); // Prints `The variant's value is: foo' template <typename Visitor, typename... Variants> variant_internal::VisitResult<Visitor, Variants...> visit(Visitor&& vis, Variants&&... vars) { diff --git a/chromium/third_party/abseil-cpp/absl/types/variant_test.cc b/chromium/third_party/abseil-cpp/absl/types/variant_test.cc index 262bd9446c1..bfb8bd7a022 100644 --- a/chromium/third_party/abseil-cpp/absl/types/variant_test.cc +++ b/chromium/third_party/abseil-cpp/absl/types/variant_test.cc @@ -403,7 +403,7 @@ struct is_trivially_move_constructible template <class T> struct is_trivially_move_assignable - : std::is_move_assignable<SingleUnion<T>>::type {}; + : absl::is_move_assignable<SingleUnion<T>>::type {}; TEST(VariantTest, NothrowMoveConstructible) { // Verify that variant is nothrow move constructible iff its template @@ -2439,14 +2439,14 @@ TEST(VariantTest, TestMoveConversionViaConvertVariantTo) { TEST(VariantTest, TestCopyAndMoveTypeTraits) { EXPECT_TRUE(std::is_copy_constructible<variant<std::string>>::value); - EXPECT_TRUE(std::is_copy_assignable<variant<std::string>>::value); + EXPECT_TRUE(absl::is_copy_assignable<variant<std::string>>::value); EXPECT_TRUE(std::is_move_constructible<variant<std::string>>::value); - EXPECT_TRUE(std::is_move_assignable<variant<std::string>>::value); + EXPECT_TRUE(absl::is_move_assignable<variant<std::string>>::value); EXPECT_TRUE(std::is_move_constructible<variant<std::unique_ptr<int>>>::value); - EXPECT_TRUE(std::is_move_assignable<variant<std::unique_ptr<int>>>::value); + EXPECT_TRUE(absl::is_move_assignable<variant<std::unique_ptr<int>>>::value); EXPECT_FALSE( std::is_copy_constructible<variant<std::unique_ptr<int>>>::value); - EXPECT_FALSE(std::is_copy_assignable<variant<std::unique_ptr<int>>>::value); + EXPECT_FALSE(absl::is_copy_assignable<variant<std::unique_ptr<int>>>::value); EXPECT_FALSE( absl::is_trivially_copy_constructible<variant<std::string>>::value); diff --git a/chromium/third_party/abseil-cpp/absl/utility/utility.h b/chromium/third_party/abseil-cpp/absl/utility/utility.h index d73602c47d3..aef4baa02dc 100644 --- a/chromium/third_party/abseil-cpp/absl/utility/utility.h +++ b/chromium/third_party/abseil-cpp/absl/utility/utility.h @@ -235,13 +235,13 @@ auto apply_helper(Functor&& functor, Tuple&& t, index_sequence<Indexes...>) // Example: // // class Foo{void Bar(int);}; -// void user_function(int, std::string); +// void user_function(int, string); // void user_function(std::unique_ptr<Foo>); // // int main() // { -// std::tuple<int, std::string> tuple1(42, "bar"); -// // Invokes the user function overload on int, std::string. +// std::tuple<int, string> tuple1(42, "bar"); +// // Invokes the user function overload on int, string. // absl::apply(&user_function, tuple1); // // auto foo = absl::make_unique<Foo>(); |