Merge "Revert "Upgrade ABSL to LTS version 20250127.0."" into main
diff --git a/CMake/AbseilDll.cmake b/CMake/AbseilDll.cmake
index 1b89569..32cc28f 100644
--- a/CMake/AbseilDll.cmake
+++ b/CMake/AbseilDll.cmake
@@ -49,8 +49,6 @@
"base/internal/thread_identity.h"
"base/internal/throw_delegate.cc"
"base/internal/throw_delegate.h"
- "base/internal/tracing.cc"
- "base/internal/tracing.h"
"base/internal/tsan_mutex_interface.h"
"base/internal/unaligned_access.h"
"base/internal/unscaledcycleclock.cc"
@@ -193,8 +191,6 @@
"log/internal/proto.cc"
"log/internal/strip.h"
"log/internal/structured.h"
- "log/internal/structured_proto.cc"
- "log/internal/structured_proto.h"
"log/internal/vlog_config.cc"
"log/internal/vlog_config.h"
"log/internal/voidify.h"
@@ -838,7 +834,6 @@
PRIVATE
${_dll_libs}
${ABSL_DEFAULT_LINKOPTS}
- $<$<BOOL:${ANDROID}>:-llog>
)
set_target_properties(${_dll} PROPERTIES
LINKER_LANGUAGE "CXX"
diff --git a/CMake/AbseilHelpers.cmake b/CMake/AbseilHelpers.cmake
index d8fb9fe..b177e59 100644
--- a/CMake/AbseilHelpers.cmake
+++ b/CMake/AbseilHelpers.cmake
@@ -186,16 +186,16 @@
endif()
endif()
endforeach()
+ set(skip_next_cflag OFF)
foreach(cflag ${ABSL_CC_LIB_COPTS})
- # Strip out the CMake-specific `SHELL:` prefix, which is used to construct
- # a group of space-separated options.
- # https://cmake.org/cmake/help/v3.30/command/target_compile_options.html#option-de-duplication
- string(REGEX REPLACE "^SHELL:" "" cflag "${cflag}")
- if(${cflag} MATCHES "^-Xarch_")
+ if(skip_next_cflag)
+ set(skip_next_cflag OFF)
+ elseif(${cflag} MATCHES "^-Xarch_")
# An -Xarch_ flag implies that its successor only applies to the
- # specified platform. Such option groups are each specified in a single
- # `SHELL:`-prefixed string in the COPTS list, which we simply ignore.
- elseif(${cflag} MATCHES "^(-Wno-|/wd)")
+ # specified platform. Filter both of them out before the successor
+ # reaches the "^-m" filter.
+ set(skip_next_cflag ON)
+ elseif(${cflag} MATCHES "^(-Wno|/wd)")
# These flags are needed to suppress warnings that might fire in our headers.
set(PC_CFLAGS "${PC_CFLAGS} ${cflag}")
elseif(${cflag} MATCHES "^(-W|/w[1234eo])")
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5b21ee7..7c82b3a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,8 +23,8 @@
cmake_policy(SET CMP0141 NEW)
endif (POLICY CMP0141)
-project(absl LANGUAGES CXX VERSION 20250127)
-set(ABSL_SOVERSION "2501.0.0")
+project(absl LANGUAGES CXX VERSION 20240722)
+set(ABSL_SOVERSION "2407.0.0")
include(CTest)
# Output directory is correct by default for most build setups. However, when
@@ -47,7 +47,10 @@
option(ABSL_PROPAGATE_CXX_STD
"Use CMake C++ standard meta features (e.g. cxx_std_14) that propagate to targets that link to Abseil"
- ON)
+ OFF) # TODO: Default to ON for CMake 3.8 and greater.
+if(NOT ABSL_PROPAGATE_CXX_STD)
+ message(WARNING "A future Abseil release will default ABSL_PROPAGATE_CXX_STD to ON for CMake 3.8 and up. We recommend enabling this option to ensure your project still builds correctly.")
+endif()
option(ABSL_USE_SYSTEM_INCLUDES
"Silence warnings in Abseil headers by marking them as SYSTEM includes"
@@ -201,13 +204,11 @@
)
endif() # absl_VERSION
- # Install the headers except for "options.h" which is installed separately.
install(DIRECTORY absl
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING
PATTERN "*.inc"
PATTERN "*.h"
- PATTERN "options.h" EXCLUDE
PATTERN "copts" EXCLUDE
PATTERN "testdata" EXCLUDE
)
@@ -247,21 +248,7 @@
ABSL_INTERNAL_OPTIONS_H_PINNED
"${ABSL_INTERNAL_OPTIONS_H_CONTENTS}")
- # If the file already exists, check if it matches the new contents.
- # This avoids writing the file if it is already up-to-date when the CMake
- # generation is triggered and triggering unnecessary rebuilds.
- set(ABSL_INTERNAL_OPTIONS_H_PINNED_NEEDS_UPDATE TRUE)
- if (EXISTS "${CMAKE_BINARY_DIR}/options-pinned.h")
- file(READ "${CMAKE_BINARY_DIR}/options-pinned.h" ABSL_INTERNAL_OPTIONS_PINNED_H_CONTENTS)
- if ("${ABSL_INTERNAL_OPTIONS_H_PINNED}" STREQUAL "${ABSL_INTERNAL_OPTIONS_PINNED_H_CONTENTS}")
- set(ABSL_INTERNAL_OPTIONS_H_PINNED_NEEDS_UPDATE FALSE)
- endif()
- endif()
-
- # If the file needs an update, generate it.
- if (ABSL_INTERNAL_OPTIONS_H_PINNED_NEEDS_UPDATE)
- file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/options-pinned.h" CONTENT "${ABSL_INTERNAL_OPTIONS_H_PINNED}")
- endif()
+ file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/options-pinned.h" CONTENT "${ABSL_INTERNAL_OPTIONS_H_PINNED}")
install(FILES "${CMAKE_BINARY_DIR}/options-pinned.h"
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/absl/base
diff --git a/METADATA b/METADATA
index 90da8ab..4f42d94 100644
--- a/METADATA
+++ b/METADATA
@@ -12,7 +12,7 @@
type: GIT
value: "https://github.com/abseil/abseil-cpp"
}
- version: "20250127.0"
- last_upgrade_date { year: 2025 month: 3 day: 11 }
+ version: "20240722.0"
+ last_upgrade_date { year: 2024 month: 11 day: 4 }
license_type: NOTICE
}
diff --git a/MODULE.bazel b/MODULE.bazel
index 8083c11..75285b6 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -16,31 +16,27 @@
module(
name = "abseil-cpp",
- version = "20250127.0",
+ version = "20240722.0",
compatibility_level = 1,
)
-cc_configure = use_extension("@rules_cc//cc:extensions.bzl",
- "cc_configure_extension",
- dev_dependency = True)
+cc_configure = use_extension("@bazel_tools//tools/cpp:cc_configure.bzl", "cc_configure_extension")
use_repo(cc_configure, "local_config_cc")
# Only direct dependencies need to be listed below.
# Please keep the versions in sync with the versions in the WORKSPACE file.
-bazel_dep(name = "rules_cc", version = "0.0.17")
-bazel_dep(name = "bazel_skylib", version = "1.7.1")
-bazel_dep(name = "platforms", version = "0.0.10")
+bazel_dep(name = "bazel_skylib",
+ version = "1.5.0")
-bazel_dep(
- name = "google_benchmark",
- version = "1.8.5",
- dev_dependency = True,
-)
+bazel_dep(name = "google_benchmark",
+ version = "1.8.3",
+ repo_name = "com_github_google_benchmark",
+ dev_dependency = True)
-# Note: Googletest is NOT a dev_dependency. Some Abseil test utilities
-# intended to be used by Abseil users depend on GoogleTest.
-bazel_dep(
- name = "googletest",
- version = "1.15.2",
-)
+bazel_dep(name = "googletest",
+ version = "1.15.2",
+ repo_name = "com_google_googletest")
+
+bazel_dep(name = "platforms",
+ version = "0.0.10")
diff --git a/WORKSPACE b/WORKSPACE
index 28e17c9..dee6d05 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -14,55 +14,42 @@
# limitations under the License.
#
-workspace(name = "abseil-cpp")
+workspace(name = "com_google_absl")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# GoogleTest/GoogleMock framework. Used by most unit-tests.
http_archive(
- name = "googletest",
+ name = "com_google_googletest",
sha256 = "7b42b4d6ed48810c5362c265a17faebe90dc2373c885e5216439d37927f02926",
strip_prefix = "googletest-1.15.2",
# Keep this URL in sync with the version in ci/cmake_common.sh and
# ci/windows_msvc_cmake.bat.
urls = ["https://github.com/google/googletest/releases/download/v1.15.2/googletest-1.15.2.tar.gz"],
- # Now that Abseil is using the canonical names from the Bazel Central Registry, map
- # GoogleTest's old names to the new canonical names.
- repo_mapping = {
- "@com_google_absl": "@",
- "@com_googlesource_code_re2": "@re2",
- },
)
# RE2 (the regular expression library used by GoogleTest)
http_archive(
- name = "re2",
+ name = "com_googlesource_code_re2",
sha256 = "eb2df807c781601c14a260a507a5bb4509be1ee626024cb45acbd57cb9d4032b",
strip_prefix = "re2-2024-07-02",
urls = ["https://github.com/google/re2/releases/download/2024-07-02/re2-2024-07-02.tar.gz"],
+ repo_mapping = {"@abseil-cpp": "@com_google_absl"},
)
# Google benchmark.
http_archive(
- name = "google_benchmark",
- sha256 = "d26789a2b46d8808a48a4556ee58ccc7c497fcd4c0af9b90197674a81e04798a",
- strip_prefix = "benchmark-1.8.5",
- urls = ["https://github.com/google/benchmark/archive/refs/tags/v1.8.5.tar.gz"],
+ name = "com_github_google_benchmark",
+ sha256 = "6bc180a57d23d4d9515519f92b0c83d61b05b5bab188961f36ac7b06b0d9e9ce",
+ strip_prefix = "benchmark-1.8.3",
+ urls = ["https://github.com/google/benchmark/archive/refs/tags/v1.8.3.tar.gz"],
)
# Bazel Skylib.
http_archive(
name = "bazel_skylib",
- sha256 = "bc283cdfcd526a52c3201279cda4bc298652efa898b10b4db0837dc51652756f",
- urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz"],
-)
-
-# C++ rules for Bazel
-http_archive(
- name = "rules_cc",
- urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.1.0/rules_cc-0.1.0.tar.gz"],
- sha256 = "4b12149a041ddfb8306a8fd0e904e39d673552ce82e4296e96fac9cbf0780e59",
- strip_prefix = "rules_cc-0.1.0",
+ sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94",
+ urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz"],
)
# Bazel platform rules.
diff --git a/absl/BUILD.bazel b/absl/BUILD.bazel
index 2a25ac6..253c0ae 100644
--- a/absl/BUILD.bazel
+++ b/absl/BUILD.bazel
@@ -29,6 +29,14 @@
)
config_setting(
+ name = "gcc_compiler",
+ flag_values = {
+ "@bazel_tools//tools/cpp:compiler": "gcc",
+ },
+ visibility = [":__subpackages__"],
+)
+
+config_setting(
name = "mingw_unspecified_compiler",
flag_values = {
"@bazel_tools//tools/cpp:compiler": "mingw",
@@ -45,10 +53,91 @@
)
config_setting(
- name = "fuchsia",
+ name = "msvc_compiler",
+ flag_values = {
+ "@bazel_tools//tools/cpp:compiler": "msvc-cl",
+ },
+ visibility = [":__subpackages__"],
+)
+
+config_setting(
+ name = "clang-cl_compiler",
+ flag_values = {
+ "@bazel_tools//tools/cpp:compiler": "clang-cl",
+ },
+ visibility = [":__subpackages__"],
+)
+
+config_setting(
+ name = "osx",
constraint_values = [
- "@platforms//os:fuchsia",
+ "@platforms//os:osx",
],
+)
+
+config_setting(
+ name = "ios",
+ constraint_values = [
+ "@platforms//os:ios",
+ ],
+)
+
+config_setting(
+ name = "ppc",
+ values = {
+ "cpu": "ppc",
+ },
+ visibility = [":__subpackages__"],
+)
+
+config_setting(
+ name = "cpu_wasm",
+ values = {
+ "cpu": "wasm",
+ },
+ visibility = [":__subpackages__"],
+)
+
+config_setting(
+ name = "cpu_wasm32",
+ values = {
+ "cpu": "wasm32",
+ },
+ visibility = [":__subpackages__"],
+)
+
+config_setting(
+ name = "platforms_wasm32",
+ constraint_values = [
+ "@platforms//cpu:wasm32",
+ ],
+ visibility = [":__subpackages__"],
+)
+
+config_setting(
+ name = "platforms_wasm64",
+ constraint_values = [
+ "@platforms//cpu:wasm64",
+ ],
+ visibility = [":__subpackages__"],
+)
+
+selects.config_setting_group(
+ name = "wasm",
+ match_any = [
+ ":cpu_wasm",
+ ":cpu_wasm32",
+ ":platforms_wasm32",
+ ":platforms_wasm64",
+ ],
+ visibility = [":__subpackages__"],
+)
+
+config_setting(
+ name = "fuchsia",
+ values = {
+ "cpu": "fuchsia",
+ },
visibility = [":__subpackages__"],
)
diff --git a/absl/algorithm/BUILD.bazel b/absl/algorithm/BUILD.bazel
index 9a723e5..f20e729 100644
--- a/absl/algorithm/BUILD.bazel
+++ b/absl/algorithm/BUILD.bazel
@@ -51,8 +51,8 @@
deps = [
":algorithm",
"//absl/base:config",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -84,7 +84,7 @@
"//absl/base:core_headers",
"//absl/memory",
"//absl/types:span",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
diff --git a/absl/algorithm/algorithm.h b/absl/algorithm/algorithm.h
index 48f5950..59aeed7 100644
--- a/absl/algorithm/algorithm.h
+++ b/absl/algorithm/algorithm.h
@@ -53,8 +53,8 @@
// n = (`last` - `first`) comparisons. A linear search over short containers
// may be faster than a binary search, even when the container is sorted.
template <typename InputIterator, typename EqualityComparable>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool linear_search(
- InputIterator first, InputIterator last, const EqualityComparable& value) {
+bool linear_search(InputIterator first, InputIterator last,
+ const EqualityComparable& value) {
return std::find(first, last, value) != last;
}
diff --git a/absl/algorithm/algorithm_test.cc b/absl/algorithm/algorithm_test.cc
index 1c1a307..e6ee469 100644
--- a/absl/algorithm/algorithm_test.cc
+++ b/absl/algorithm/algorithm_test.cc
@@ -14,9 +14,11 @@
#include "absl/algorithm/algorithm.h"
-#include <array>
+#include <algorithm>
+#include <list>
#include <vector>
+#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "absl/base/config.h"
@@ -45,16 +47,4 @@
absl::linear_search(const_container->begin(), const_container->end(), 4));
}
-#if defined(ABSL_INTERNAL_CPLUSPLUS_LANG) && \
- ABSL_INTERNAL_CPLUSPLUS_LANG >= 202002L
-
-TEST_F(LinearSearchTest, Constexpr) {
- static constexpr std::array<int, 3> kArray = {1, 2, 3};
- static_assert(absl::linear_search(kArray.begin(), kArray.end(), 3));
- static_assert(!absl::linear_search(kArray.begin(), kArray.end(), 4));
-}
-
-#endif // defined(ABSL_INTERNAL_CPLUSPLUS_LANG) &&
- // ABSL_INTERNAL_CPLUSPLUS_LANG >= 202002L
-
} // namespace
diff --git a/absl/algorithm/container.h b/absl/algorithm/container.h
index 3193656..6bbe3b5 100644
--- a/absl/algorithm/container.h
+++ b/absl/algorithm/container.h
@@ -131,14 +131,11 @@
//
// Container-based version of absl::linear_search() for performing a linear
// search within a container.
-//
-// For a generalization that uses a predicate, see absl::c_any_of().
template <typename C, typename EqualityComparable>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool c_linear_search(
- const C& c, EqualityComparable&& value) {
- return absl::linear_search(container_algorithm_internal::c_begin(c),
- container_algorithm_internal::c_end(c),
- std::forward<EqualityComparable>(value));
+bool c_linear_search(const C& c, EqualityComparable&& value) {
+ return linear_search(container_algorithm_internal::c_begin(c),
+ container_algorithm_internal::c_end(c),
+ std::forward<EqualityComparable>(value));
}
//------------------------------------------------------------------------------
@@ -166,7 +163,7 @@
// Container-based version of the <algorithm> `std::all_of()` function to
// test if all elements within a container satisfy a condition.
template <typename C, typename Pred>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool c_all_of(const C& c, Pred&& pred) {
+bool c_all_of(const C& c, Pred&& pred) {
return std::all_of(container_algorithm_internal::c_begin(c),
container_algorithm_internal::c_end(c),
std::forward<Pred>(pred));
@@ -177,7 +174,7 @@
// Container-based version of the <algorithm> `std::any_of()` function to
// test if any element in a container fulfills a condition.
template <typename C, typename Pred>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool c_any_of(const C& c, Pred&& pred) {
+bool c_any_of(const C& c, Pred&& pred) {
return std::any_of(container_algorithm_internal::c_begin(c),
container_algorithm_internal::c_end(c),
std::forward<Pred>(pred));
@@ -188,7 +185,7 @@
// Container-based version of the <algorithm> `std::none_of()` function to
// test if no elements in a container fulfill a condition.
template <typename C, typename Pred>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool c_none_of(const C& c, Pred&& pred) {
+bool c_none_of(const C& c, Pred&& pred) {
return std::none_of(container_algorithm_internal::c_begin(c),
container_algorithm_internal::c_end(c),
std::forward<Pred>(pred));
@@ -199,8 +196,7 @@
// Container-based version of the <algorithm> `std::for_each()` function to
// apply a function to a container's elements.
template <typename C, typename Function>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 decay_t<Function> c_for_each(C&& c,
- Function&& f) {
+decay_t<Function> c_for_each(C&& c, Function&& f) {
return std::for_each(container_algorithm_internal::c_begin(c),
container_algorithm_internal::c_end(c),
std::forward<Function>(f));
@@ -211,9 +207,7 @@
// Container-based version of the <algorithm> `std::find()` function to find
// the first element containing the passed value within a container value.
template <typename C, typename T>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20
- container_algorithm_internal::ContainerIter<C>
- c_find(C& c, T&& value) {
+container_algorithm_internal::ContainerIter<C> c_find(C& c, T&& value) {
return std::find(container_algorithm_internal::c_begin(c),
container_algorithm_internal::c_end(c),
std::forward<T>(value));
@@ -224,8 +218,7 @@
// Container-based version of the <algorithm> `std::ranges::contains()` C++23
// function to search a container for a value.
template <typename Sequence, typename T>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool c_contains(const Sequence& sequence,
- T&& value) {
+bool c_contains(const Sequence& sequence, T&& value) {
return absl::c_find(sequence, std::forward<T>(value)) !=
container_algorithm_internal::c_end(sequence);
}
@@ -235,9 +228,7 @@
// Container-based version of the <algorithm> `std::find_if()` function to find
// the first element in a container matching the given condition.
template <typename C, typename Pred>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20
- container_algorithm_internal::ContainerIter<C>
- c_find_if(C& c, Pred&& pred) {
+container_algorithm_internal::ContainerIter<C> c_find_if(C& c, Pred&& pred) {
return std::find_if(container_algorithm_internal::c_begin(c),
container_algorithm_internal::c_end(c),
std::forward<Pred>(pred));
@@ -248,9 +239,8 @@
// Container-based version of the <algorithm> `std::find_if_not()` function to
// find the first element in a container not matching the given condition.
template <typename C, typename Pred>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20
- container_algorithm_internal::ContainerIter<C>
- c_find_if_not(C& c, Pred&& pred) {
+container_algorithm_internal::ContainerIter<C> c_find_if_not(C& c,
+ Pred&& pred) {
return std::find_if_not(container_algorithm_internal::c_begin(c),
container_algorithm_internal::c_end(c),
std::forward<Pred>(pred));
@@ -261,9 +251,8 @@
// Container-based version of the <algorithm> `std::find_end()` function to
// find the last subsequence within a container.
template <typename Sequence1, typename Sequence2>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20
- container_algorithm_internal::ContainerIter<Sequence1>
- c_find_end(Sequence1& sequence, Sequence2& subsequence) {
+container_algorithm_internal::ContainerIter<Sequence1> c_find_end(
+ Sequence1& sequence, Sequence2& subsequence) {
return std::find_end(container_algorithm_internal::c_begin(sequence),
container_algorithm_internal::c_end(sequence),
container_algorithm_internal::c_begin(subsequence),
@@ -273,10 +262,8 @@
// Overload of c_find_end() for using a predicate evaluation other than `==` as
// the function's test condition.
template <typename Sequence1, typename Sequence2, typename BinaryPredicate>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20
- container_algorithm_internal::ContainerIter<Sequence1>
- c_find_end(Sequence1& sequence, Sequence2& subsequence,
- BinaryPredicate&& pred) {
+container_algorithm_internal::ContainerIter<Sequence1> c_find_end(
+ Sequence1& sequence, Sequence2& subsequence, BinaryPredicate&& pred) {
return std::find_end(container_algorithm_internal::c_begin(sequence),
container_algorithm_internal::c_end(sequence),
container_algorithm_internal::c_begin(subsequence),
@@ -290,9 +277,8 @@
// find the first element within the container that is also within the options
// container.
template <typename C1, typename C2>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20
- container_algorithm_internal::ContainerIter<C1>
- c_find_first_of(C1& container, const C2& options) {
+container_algorithm_internal::ContainerIter<C1> c_find_first_of(C1& container,
+ C2& options) {
return std::find_first_of(container_algorithm_internal::c_begin(container),
container_algorithm_internal::c_end(container),
container_algorithm_internal::c_begin(options),
@@ -302,9 +288,8 @@
// Overload of c_find_first_of() for using a predicate evaluation other than
// `==` as the function's test condition.
template <typename C1, typename C2, typename BinaryPredicate>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20
- container_algorithm_internal::ContainerIter<C1>
- c_find_first_of(C1& container, const C2& options, BinaryPredicate&& pred) {
+container_algorithm_internal::ContainerIter<C1> c_find_first_of(
+ C1& container, C2& options, BinaryPredicate&& pred) {
return std::find_first_of(container_algorithm_internal::c_begin(container),
container_algorithm_internal::c_end(container),
container_algorithm_internal::c_begin(options),
@@ -317,9 +302,8 @@
// Container-based version of the <algorithm> `std::adjacent_find()` function to
// find equal adjacent elements within a container.
template <typename Sequence>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20
- container_algorithm_internal::ContainerIter<Sequence>
- c_adjacent_find(Sequence& sequence) {
+container_algorithm_internal::ContainerIter<Sequence> c_adjacent_find(
+ Sequence& sequence) {
return std::adjacent_find(container_algorithm_internal::c_begin(sequence),
container_algorithm_internal::c_end(sequence));
}
@@ -327,9 +311,8 @@
// Overload of c_adjacent_find() for using a predicate evaluation other than
// `==` as the function's test condition.
template <typename Sequence, typename BinaryPredicate>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20
- container_algorithm_internal::ContainerIter<Sequence>
- c_adjacent_find(Sequence& sequence, BinaryPredicate&& pred) {
+container_algorithm_internal::ContainerIter<Sequence> c_adjacent_find(
+ Sequence& sequence, BinaryPredicate&& pred) {
return std::adjacent_find(container_algorithm_internal::c_begin(sequence),
container_algorithm_internal::c_end(sequence),
std::forward<BinaryPredicate>(pred));
@@ -340,9 +323,8 @@
// Container-based version of the <algorithm> `std::count()` function to count
// values that match within a container.
template <typename C, typename T>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20
- container_algorithm_internal::ContainerDifferenceType<const C>
- c_count(const C& c, T&& value) {
+container_algorithm_internal::ContainerDifferenceType<const C> c_count(
+ const C& c, T&& value) {
return std::count(container_algorithm_internal::c_begin(c),
container_algorithm_internal::c_end(c),
std::forward<T>(value));
@@ -353,9 +335,8 @@
// Container-based version of the <algorithm> `std::count_if()` function to
// count values matching a condition within a container.
template <typename C, typename Pred>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20
- container_algorithm_internal::ContainerDifferenceType<const C>
- c_count_if(const C& c, Pred&& pred) {
+container_algorithm_internal::ContainerDifferenceType<const C> c_count_if(
+ const C& c, Pred&& pred) {
return std::count_if(container_algorithm_internal::c_begin(c),
container_algorithm_internal::c_end(c),
std::forward<Pred>(pred));
@@ -367,9 +348,8 @@
// return the first element where two ordered containers differ. Applies `==` to
// the first N elements of `c1` and `c2`, where N = min(size(c1), size(c2)).
template <typename C1, typename C2>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20
- container_algorithm_internal::ContainerIterPairType<C1, C2>
- c_mismatch(C1& c1, C2& c2) {
+container_algorithm_internal::ContainerIterPairType<C1, C2> c_mismatch(C1& c1,
+ C2& c2) {
return std::mismatch(container_algorithm_internal::c_begin(c1),
container_algorithm_internal::c_end(c1),
container_algorithm_internal::c_begin(c2),
@@ -380,9 +360,8 @@
// the function's test condition. Applies `pred`to the first N elements of `c1`
// and `c2`, where N = min(size(c1), size(c2)).
template <typename C1, typename C2, typename BinaryPredicate>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20
- container_algorithm_internal::ContainerIterPairType<C1, C2>
- c_mismatch(C1& c1, C2& c2, BinaryPredicate pred) {
+container_algorithm_internal::ContainerIterPairType<C1, C2> c_mismatch(
+ C1& c1, C2& c2, BinaryPredicate pred) {
return std::mismatch(container_algorithm_internal::c_begin(c1),
container_algorithm_internal::c_end(c1),
container_algorithm_internal::c_begin(c2),
@@ -394,7 +373,7 @@
// Container-based version of the <algorithm> `std::equal()` function to
// test whether two containers are equal.
template <typename C1, typename C2>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool c_equal(const C1& c1, const C2& c2) {
+bool c_equal(const C1& c1, const C2& c2) {
return std::equal(container_algorithm_internal::c_begin(c1),
container_algorithm_internal::c_end(c1),
container_algorithm_internal::c_begin(c2),
@@ -404,8 +383,7 @@
// Overload of c_equal() for using a predicate evaluation other than `==` as
// the function's test condition.
template <typename C1, typename C2, typename BinaryPredicate>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool c_equal(const C1& c1, const C2& c2,
- BinaryPredicate&& pred) {
+bool c_equal(const C1& c1, const C2& c2, BinaryPredicate&& pred) {
return std::equal(container_algorithm_internal::c_begin(c1),
container_algorithm_internal::c_end(c1),
container_algorithm_internal::c_begin(c2),
@@ -418,8 +396,7 @@
// Container-based version of the <algorithm> `std::is_permutation()` function
// to test whether a container is a permutation of another.
template <typename C1, typename C2>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool c_is_permutation(const C1& c1,
- const C2& c2) {
+bool c_is_permutation(const C1& c1, const C2& c2) {
return std::is_permutation(container_algorithm_internal::c_begin(c1),
container_algorithm_internal::c_end(c1),
container_algorithm_internal::c_begin(c2),
@@ -429,8 +406,7 @@
// Overload of c_is_permutation() for using a predicate evaluation other than
// `==` as the function's test condition.
template <typename C1, typename C2, typename BinaryPredicate>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool c_is_permutation(
- const C1& c1, const C2& c2, BinaryPredicate&& pred) {
+bool c_is_permutation(const C1& c1, const C2& c2, BinaryPredicate&& pred) {
return std::is_permutation(container_algorithm_internal::c_begin(c1),
container_algorithm_internal::c_end(c1),
container_algorithm_internal::c_begin(c2),
@@ -443,9 +419,8 @@
// Container-based version of the <algorithm> `std::search()` function to search
// a container for a subsequence.
template <typename Sequence1, typename Sequence2>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20
- container_algorithm_internal::ContainerIter<Sequence1>
- c_search(Sequence1& sequence, Sequence2& subsequence) {
+container_algorithm_internal::ContainerIter<Sequence1> c_search(
+ Sequence1& sequence, Sequence2& subsequence) {
return std::search(container_algorithm_internal::c_begin(sequence),
container_algorithm_internal::c_end(sequence),
container_algorithm_internal::c_begin(subsequence),
@@ -455,10 +430,8 @@
// Overload of c_search() for using a predicate evaluation other than
// `==` as the function's test condition.
template <typename Sequence1, typename Sequence2, typename BinaryPredicate>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20
- container_algorithm_internal::ContainerIter<Sequence1>
- c_search(Sequence1& sequence, Sequence2& subsequence,
- BinaryPredicate&& pred) {
+container_algorithm_internal::ContainerIter<Sequence1> c_search(
+ Sequence1& sequence, Sequence2& subsequence, BinaryPredicate&& pred) {
return std::search(container_algorithm_internal::c_begin(sequence),
container_algorithm_internal::c_end(sequence),
container_algorithm_internal::c_begin(subsequence),
@@ -471,8 +444,7 @@
// Container-based version of the <algorithm> `std::ranges::contains_subrange()`
// C++23 function to search a container for a subsequence.
template <typename Sequence1, typename Sequence2>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool c_contains_subrange(
- Sequence1& sequence, Sequence2& subsequence) {
+bool c_contains_subrange(Sequence1& sequence, Sequence2& subsequence) {
return absl::c_search(sequence, subsequence) !=
container_algorithm_internal::c_end(sequence);
}
@@ -480,8 +452,8 @@
// Overload of c_contains_subrange() for using a predicate evaluation other than
// `==` as the function's test condition.
template <typename Sequence1, typename Sequence2, typename BinaryPredicate>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool c_contains_subrange(
- Sequence1& sequence, Sequence2& subsequence, BinaryPredicate&& pred) {
+bool c_contains_subrange(Sequence1& sequence, Sequence2& subsequence,
+ BinaryPredicate&& pred) {
return absl::c_search(sequence, subsequence,
std::forward<BinaryPredicate>(pred)) !=
container_algorithm_internal::c_end(sequence);
@@ -492,9 +464,8 @@
// Container-based version of the <algorithm> `std::search_n()` function to
// search a container for the first sequence of N elements.
template <typename Sequence, typename Size, typename T>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20
- container_algorithm_internal::ContainerIter<Sequence>
- c_search_n(Sequence& sequence, Size count, T&& value) {
+container_algorithm_internal::ContainerIter<Sequence> c_search_n(
+ Sequence& sequence, Size count, T&& value) {
return std::search_n(container_algorithm_internal::c_begin(sequence),
container_algorithm_internal::c_end(sequence), count,
std::forward<T>(value));
@@ -504,10 +475,8 @@
// `==` as the function's test condition.
template <typename Sequence, typename Size, typename T,
typename BinaryPredicate>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20
- container_algorithm_internal::ContainerIter<Sequence>
- c_search_n(Sequence& sequence, Size count, T&& value,
- BinaryPredicate&& pred) {
+container_algorithm_internal::ContainerIter<Sequence> c_search_n(
+ Sequence& sequence, Size count, T&& value, BinaryPredicate&& pred) {
return std::search_n(container_algorithm_internal::c_begin(sequence),
container_algorithm_internal::c_end(sequence), count,
std::forward<T>(value),
diff --git a/absl/algorithm/container_test.cc b/absl/algorithm/container_test.cc
index 85e3b11..5012224 100644
--- a/absl/algorithm/container_test.cc
+++ b/absl/algorithm/container_test.cc
@@ -139,13 +139,11 @@
TEST_F(NonMutatingTest, FindFirstOf) {
absl::c_find_first_of(container_, sequence_);
absl::c_find_first_of(sequence_, container_);
- absl::c_find_first_of(sequence_, std::array<int, 2>{1, 2});
}
TEST_F(NonMutatingTest, FindFirstOfWithPredicate) {
absl::c_find_first_of(container_, sequence_, BinPredicate);
absl::c_find_first_of(sequence_, container_, BinPredicate);
- absl::c_find_first_of(sequence_, std::array<int, 2>{1, 2}, BinPredicate);
}
TEST_F(NonMutatingTest, AdjacentFind) { absl::c_adjacent_find(sequence_); }
@@ -1166,7 +1164,6 @@
#if defined(ABSL_INTERNAL_CPLUSPLUS_LANG) && \
ABSL_INTERNAL_CPLUSPLUS_LANG >= 201703L
-
TEST(ConstexprTest, Distance) {
// Works at compile time with constexpr containers.
static_assert(absl::c_distance(std::array<int, 3>()) == 3);
@@ -1206,216 +1203,8 @@
static_assert(*kMinMaxPair.first == 3);
static_assert(*kMinMaxPair.second == 1);
}
+
#endif // defined(ABSL_INTERNAL_CPLUSPLUS_LANG) &&
// ABSL_INTERNAL_CPLUSPLUS_LANG >= 201703L
-#if defined(ABSL_INTERNAL_CPLUSPLUS_LANG) && \
- ABSL_INTERNAL_CPLUSPLUS_LANG >= 202002L
-
-TEST(ConstexprTest, LinearSearch) {
- static constexpr std::array<int, 3> kArray = {1, 2, 3};
- static_assert(absl::c_linear_search(kArray, 3));
- static_assert(!absl::c_linear_search(kArray, 4));
-}
-
-TEST(ConstexprTest, AllOf) {
- static constexpr std::array<int, 3> kArray = {1, 2, 3};
- static_assert(!absl::c_all_of(kArray, [](int x) { return x > 1; }));
- static_assert(absl::c_all_of(kArray, [](int x) { return x > 0; }));
-}
-
-TEST(ConstexprTest, AnyOf) {
- static constexpr std::array<int, 3> kArray = {1, 2, 3};
- static_assert(absl::c_any_of(kArray, [](int x) { return x > 2; }));
- static_assert(!absl::c_any_of(kArray, [](int x) { return x > 5; }));
-}
-
-TEST(ConstexprTest, NoneOf) {
- static constexpr std::array<int, 3> kArray = {1, 2, 3};
- static_assert(!absl::c_none_of(kArray, [](int x) { return x > 2; }));
- static_assert(absl::c_none_of(kArray, [](int x) { return x > 5; }));
-}
-
-TEST(ConstexprTest, ForEach) {
- static constexpr std::array<int, 3> kArray = [] {
- std::array<int, 3> array = {1, 2, 3};
- absl::c_for_each(array, [](int& x) { x += 1; });
- return array;
- }();
- static_assert(kArray == std::array{2, 3, 4});
-}
-
-TEST(ConstexprTest, Find) {
- static constexpr std::array<int, 3> kArray = {1, 2, 3};
- static_assert(absl::c_find(kArray, 1) == kArray.begin());
- static_assert(absl::c_find(kArray, 4) == kArray.end());
-}
-
-TEST(ConstexprTest, Contains) {
- static constexpr std::array<int, 3> kArray = {1, 2, 3};
- static_assert(absl::c_contains(kArray, 1));
- static_assert(!absl::c_contains(kArray, 4));
-}
-
-TEST(ConstexprTest, FindIf) {
- static constexpr std::array<int, 3> kArray = {1, 2, 3};
- static_assert(absl::c_find_if(kArray, [](int x) { return x > 2; }) ==
- kArray.begin() + 2);
- static_assert(absl::c_find_if(kArray, [](int x) { return x > 5; }) ==
- kArray.end());
-}
-
-TEST(ConstexprTest, FindIfNot) {
- static constexpr std::array<int, 3> kArray = {1, 2, 3};
- static_assert(absl::c_find_if_not(kArray, [](int x) { return x > 1; }) ==
- kArray.begin());
- static_assert(absl::c_find_if_not(kArray, [](int x) { return x > 0; }) ==
- kArray.end());
-}
-
-TEST(ConstexprTest, FindEnd) {
- static constexpr std::array<int, 5> kHaystack = {1, 2, 3, 2, 3};
- static constexpr std::array<int, 2> kNeedle = {2, 3};
- static_assert(absl::c_find_end(kHaystack, kNeedle) == kHaystack.begin() + 3);
-}
-
-TEST(ConstexprTest, FindFirstOf) {
- static constexpr std::array<int, 3> kArray = {1, 2, 3};
- static_assert(absl::c_find_first_of(kArray, kArray) == kArray.begin());
-}
-
-TEST(ConstexprTest, AdjacentFind) {
- static constexpr std::array<int, 4> kArray = {1, 2, 2, 3};
- static_assert(absl::c_adjacent_find(kArray) == kArray.begin() + 1);
-}
-
-TEST(ConstexprTest, AdjacentFindWithPredicate) {
- static constexpr std::array<int, 3> kArray = {1, 2, 3};
- static_assert(absl::c_adjacent_find(kArray, std::less<int>()) ==
- kArray.begin());
-}
-
-TEST(ConstexprTest, Count) {
- static constexpr std::array<int, 3> kArray = {1, 2, 3};
- static_assert(absl::c_count(kArray, 1) == 1);
- static_assert(absl::c_count(kArray, 2) == 1);
- static_assert(absl::c_count(kArray, 3) == 1);
- static_assert(absl::c_count(kArray, 4) == 0);
-}
-
-TEST(ConstexprTest, CountIf) {
- static constexpr std::array<int, 3> kArray = {1, 2, 3};
- static_assert(absl::c_count_if(kArray, [](int x) { return x > 0; }) == 3);
- static_assert(absl::c_count_if(kArray, [](int x) { return x > 1; }) == 2);
-}
-
-TEST(ConstexprTest, Mismatch) {
- static constexpr std::array<int, 3> kArray1 = {1, 2, 3};
- static constexpr std::array<int, 3> kArray2 = {1, 2, 3};
- static constexpr std::array<int, 3> kArray3 = {2, 3, 4};
- static_assert(absl::c_mismatch(kArray1, kArray2) ==
- std::pair{kArray1.end(), kArray2.end()});
- static_assert(absl::c_mismatch(kArray1, kArray3) ==
- std::pair{kArray1.begin(), kArray3.begin()});
-}
-
-TEST(ConstexprTest, MismatchWithPredicate) {
- static constexpr std::array<int, 3> kArray1 = {1, 2, 3};
- static constexpr std::array<int, 3> kArray2 = {1, 2, 3};
- static constexpr std::array<int, 3> kArray3 = {2, 3, 4};
- static_assert(absl::c_mismatch(kArray1, kArray2, std::not_equal_to<int>()) ==
- std::pair{kArray1.begin(), kArray2.begin()});
- static_assert(absl::c_mismatch(kArray1, kArray3, std::not_equal_to<int>()) ==
- std::pair{kArray1.end(), kArray3.end()});
-}
-
-TEST(ConstexprTest, Equal) {
- static constexpr std::array<int, 3> kArray1 = {1, 2, 3};
- static constexpr std::array<int, 3> kArray2 = {1, 2, 3};
- static constexpr std::array<int, 3> kArray3 = {2, 3, 4};
- static_assert(absl::c_equal(kArray1, kArray2));
- static_assert(!absl::c_equal(kArray1, kArray3));
-}
-
-TEST(ConstexprTest, EqualWithPredicate) {
- static constexpr std::array<int, 3> kArray1 = {1, 2, 3};
- static constexpr std::array<int, 3> kArray2 = {1, 2, 3};
- static constexpr std::array<int, 3> kArray3 = {2, 3, 4};
- static_assert(!absl::c_equal(kArray1, kArray2, std::not_equal_to<int>()));
- static_assert(absl::c_equal(kArray1, kArray3, std::not_equal_to<int>()));
-}
-
-TEST(ConstexprTest, IsPermutation) {
- static constexpr std::array<int, 3> kArray1 = {1, 2, 3};
- static constexpr std::array<int, 3> kArray2 = {3, 2, 1};
- static constexpr std::array<int, 3> kArray3 = {2, 3, 4};
- static_assert(absl::c_is_permutation(kArray1, kArray2));
- static_assert(!absl::c_is_permutation(kArray1, kArray3));
-}
-
-TEST(ConstexprTest, IsPermutationWithPredicate) {
- static constexpr std::array<int, 3> kArray1 = {1, 2, 3};
- static constexpr std::array<int, 3> kArray2 = {3, 2, 1};
- static constexpr std::array<int, 3> kArray3 = {2, 3, 4};
- static_assert(absl::c_is_permutation(kArray1, kArray2, std::equal_to<int>()));
- static_assert(
- !absl::c_is_permutation(kArray1, kArray3, std::equal_to<int>()));
-}
-
-TEST(ConstexprTest, Search) {
- static constexpr std::array<int, 3> kArray1 = {1, 2, 3};
- static constexpr std::array<int, 3> kArray2 = {1, 2, 3};
- static constexpr std::array<int, 3> kArray3 = {2, 3, 4};
- static_assert(absl::c_search(kArray1, kArray2) == kArray1.begin());
- static_assert(absl::c_search(kArray1, kArray3) == kArray1.end());
-}
-
-TEST(ConstexprTest, SearchWithPredicate) {
- static constexpr std::array<int, 3> kArray1 = {1, 2, 3};
- static constexpr std::array<int, 3> kArray2 = {1, 2, 3};
- static constexpr std::array<int, 3> kArray3 = {2, 3, 4};
- static_assert(absl::c_search(kArray1, kArray2, std::not_equal_to<int>()) ==
- kArray1.end());
- static_assert(absl::c_search(kArray1, kArray3, std::not_equal_to<int>()) ==
- kArray1.begin());
-}
-
-TEST(ConstexprTest, ContainsSubrange) {
- static constexpr std::array<int, 3> kArray1 = {1, 2, 3};
- static constexpr std::array<int, 3> kArray2 = {1, 2, 3};
- static constexpr std::array<int, 3> kArray3 = {2, 3, 4};
- static_assert(absl::c_contains_subrange(kArray1, kArray2));
- static_assert(!absl::c_contains_subrange(kArray1, kArray3));
-}
-
-TEST(ConstexprTest, ContainsSubrangeWithPredicate) {
- static constexpr std::array<int, 3> kArray1 = {1, 2, 3};
- static constexpr std::array<int, 3> kArray2 = {1, 2, 3};
- static constexpr std::array<int, 3> kArray3 = {2, 3, 4};
- static_assert(
- !absl::c_contains_subrange(kArray1, kArray2, std::not_equal_to<>()));
- static_assert(
- absl::c_contains_subrange(kArray1, kArray3, std::not_equal_to<>()));
-}
-
-TEST(ConstexprTest, SearchN) {
- static constexpr std::array<int, 4> kArray = {1, 2, 2, 3};
- static_assert(absl::c_search_n(kArray, 1, 1) == kArray.begin());
- static_assert(absl::c_search_n(kArray, 2, 2) == kArray.begin() + 1);
- static_assert(absl::c_search_n(kArray, 1, 4) == kArray.end());
-}
-
-TEST(ConstexprTest, SearchNWithPredicate) {
- static constexpr std::array<int, 4> kArray = {1, 2, 2, 3};
- static_assert(absl::c_search_n(kArray, 1, 1, std::not_equal_to<int>()) ==
- kArray.begin() + 1);
- static_assert(absl::c_search_n(kArray, 2, 2, std::not_equal_to<int>()) ==
- kArray.end());
- static_assert(absl::c_search_n(kArray, 1, 4, std::not_equal_to<int>()) ==
- kArray.begin());
-}
-
-#endif // defined(ABSL_INTERNAL_CPLUSPLUS_LANG) &&
- // ABSL_INTERNAL_CPLUSPLUS_LANG >= 202002L
-
} // namespace
diff --git a/absl/base/BUILD.bazel b/absl/base/BUILD.bazel
index a7827db..96503c9 100644
--- a/absl/base/BUILD.bazel
+++ b/absl/base/BUILD.bazel
@@ -207,9 +207,9 @@
"//conditions:default": [],
}),
linkopts = select({
- "@rules_cc//cc/compiler:msvc-cl": [],
- "@rules_cc//cc/compiler:clang-cl": [],
- "@rules_cc//cc/compiler:emscripten": [],
+ "//absl:msvc_compiler": [],
+ "//absl:clang-cl_compiler": [],
+ "//absl:wasm": [],
"//conditions:default": ["-pthread"],
}) + ABSL_DEFAULT_LINKOPTS,
visibility = [
@@ -268,17 +268,17 @@
],
copts = ABSL_DEFAULT_COPTS,
linkopts = select({
- "@rules_cc//cc/compiler:msvc-cl": [
+ "//absl:msvc_compiler": [
"-DEFAULTLIB:advapi32.lib",
],
- "@rules_cc//cc/compiler:clang-cl": [
+ "//absl:clang-cl_compiler": [
"-DEFAULTLIB:advapi32.lib",
],
"//absl:mingw_compiler": [
"-DEFAULTLIB:advapi32.lib",
"-ladvapi32",
],
- "@rules_cc//cc/compiler:emscripten": [],
+ "//absl:wasm": [],
"//conditions:default": ["-pthread"],
}) + ABSL_DEFAULT_LINKOPTS,
deps = [
@@ -319,8 +319,8 @@
":atomic_hook",
":atomic_hook_test_helper",
":core_headers",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -335,8 +335,8 @@
deps = [
":base",
":core_headers",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -375,8 +375,8 @@
deps = [
":config",
":throw_delegate",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -389,8 +389,8 @@
deps = [
":errno_saver",
":strerror",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -405,7 +405,7 @@
],
deps = [
":config",
- "@googletest//:gtest",
+ "@com_google_googletest//:gtest",
],
)
@@ -432,7 +432,7 @@
"//absl/meta:type_traits",
"//absl/strings",
"//absl/utility",
- "@googletest//:gtest",
+ "@com_google_googletest//:gtest",
],
)
@@ -444,8 +444,8 @@
deps = [
":exception_safety_testing",
"//absl/memory",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -462,8 +462,8 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":base_internal",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -477,8 +477,8 @@
":base_internal",
"//absl/memory",
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -496,7 +496,7 @@
":config",
":core_headers",
"//absl/synchronization",
- "@googletest//:gtest",
+ "@com_google_googletest//:gtest",
],
alwayslink = 1,
)
@@ -516,8 +516,8 @@
":config",
":core_headers",
"//absl/synchronization",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -536,7 +536,7 @@
":no_destructor",
":raw_logging_internal",
"//absl/synchronization",
- "@google_benchmark//:benchmark_main",
+ "@com_github_google_benchmark//:benchmark_main",
],
alwayslink = 1,
)
@@ -576,8 +576,8 @@
deps = [
":config",
":endian",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -589,8 +589,8 @@
deps = [
":config",
"//absl/synchronization:thread_pool",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -603,8 +603,8 @@
":base",
":core_headers",
"//absl/synchronization",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -617,8 +617,8 @@
":config",
":no_destructor",
":raw_logging_internal",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -633,7 +633,7 @@
deps = [
":no_destructor",
":raw_logging_internal",
- "@google_benchmark//:benchmark_main",
+ "@com_github_google_benchmark//:benchmark_main",
],
)
@@ -643,18 +643,8 @@
deps = [
":core_headers",
":nullability",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
- ],
-)
-
-cc_test(
- name = "nullability_default_nonnull_test",
- srcs = ["nullability_default_nonnull_test.cc"],
- deps = [
- ":nullability",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -666,8 +656,8 @@
deps = [
":raw_logging_internal",
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -680,8 +670,8 @@
deps = [
":base",
"//absl/synchronization",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -714,8 +704,8 @@
":base",
":core_headers",
"//absl/synchronization",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -729,8 +719,8 @@
deps = [
":base",
"//absl/synchronization",
- "@google_benchmark//:benchmark_main",
- "@googletest//:gtest",
+ "@com_github_google_benchmark//:benchmark_main",
+ "@com_google_googletest//:gtest",
],
)
@@ -757,8 +747,8 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":scoped_set_env",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -773,8 +763,8 @@
"//absl/flags:flag_internal",
"//absl/flags:marshalling",
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -803,8 +793,8 @@
deps = [
":strerror",
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -818,7 +808,7 @@
visibility = ["//visibility:private"],
deps = [
":strerror",
- "@google_benchmark//:benchmark_main",
+ "@com_github_google_benchmark//:benchmark_main",
],
)
@@ -843,8 +833,8 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":fast_type_id",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -871,8 +861,8 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":prefetch",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -906,8 +896,8 @@
deps = [
":config",
":poison",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -921,8 +911,8 @@
deps = [
":core_headers",
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -935,48 +925,7 @@
deps = [
":core_headers",
"//absl/types:optional",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
- ],
-)
-
-cc_library(
- name = "tracing_internal",
- srcs = ["internal/tracing.cc"],
- hdrs = ["internal/tracing.h"],
- copts = ABSL_DEFAULT_COPTS,
- linkopts = ABSL_DEFAULT_LINKOPTS,
- visibility = [
- "//absl:__subpackages__",
- ],
- deps = [
- "//absl/base:config",
- "//absl/base:core_headers",
- ],
-)
-
-cc_test(
- name = "tracing_internal_weak_test",
- srcs = ["internal/tracing_weak_test.cc"],
- copts = ABSL_TEST_COPTS,
- linkopts = ABSL_DEFAULT_LINKOPTS,
- deps = [
- ":tracing_internal",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
- ],
-)
-
-cc_test(
- name = "tracing_internal_strong_test",
- srcs = ["internal/tracing_strong_test.cc"],
- copts = ABSL_TEST_COPTS,
- linkopts = ABSL_DEFAULT_LINKOPTS,
- deps = [
- ":config",
- ":core_headers",
- ":tracing_internal",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
diff --git a/absl/base/CMakeLists.txt b/absl/base/CMakeLists.txt
index ac62a04..97994fc 100644
--- a/absl/base/CMakeLists.txt
+++ b/absl/base/CMakeLists.txt
@@ -95,18 +95,6 @@
GTest::gtest_main
)
-absl_cc_test(
- NAME
- nullability_default_nonnull_test
- SRCS
- "nullability_default_nonnull_test.cc"
- COPTS
- ${ABSL_TEST_COPTS}
- DEPS
- absl::nullability
- GTest::gtest_main
-)
-
# Internal-only target, do not depend on directly.
absl_cc_library(
NAME
@@ -546,7 +534,6 @@
absl::no_destructor
absl::config
absl::raw_logging_internal
- GTest::gmock
GTest::gtest_main
)
@@ -782,42 +769,3 @@
absl::poison
GTest::gtest_main
)
-
-absl_cc_library(
- NAME
- tracing_internal
- HDRS
- "internal/tracing.h"
- SRCS
- "internal/tracing.cc"
- COPTS
- ${ABSL_DEFAULT_COPTS}
- DEPS
- absl::base
-)
-
-absl_cc_test(
- NAME
- tracing_internal_weak_test
- SRCS
- "internal/tracing_weak_test.cc"
- COPTS
- ${ABSL_TEST_COPTS}
- DEPS
- absl::base
- absl::tracing_internal
- GTest::gtest_main
-)
-
-absl_cc_test(
- NAME
- tracing_internal_strong_test
- SRCS
- "internal/tracing_strong_test.cc"
- COPTS
- ${ABSL_TEST_COPTS}
- DEPS
- absl::base
- absl::tracing_internal
- GTest::gtest_main
-)
diff --git a/absl/base/attributes.h b/absl/base/attributes.h
index 95b102e..5ea5ee3 100644
--- a/absl/base/attributes.h
+++ b/absl/base/attributes.h
@@ -31,8 +31,6 @@
// `__has_attribute()` first. If the check fails, we check if we are on GCC and
// assume the attribute exists on GCC (which is verified on GCC 4.7).
-// SKIP_ABSL_INLINE_NAMESPACE_CHECK
-
#ifndef ABSL_BASE_ATTRIBUTES_H_
#define ABSL_BASE_ATTRIBUTES_H_
@@ -135,14 +133,12 @@
// Tags a function as weak for the purposes of compilation and linking.
// Weak attributes did not work properly in LLVM's Windows backend before
// 9.0.0, so disable them there. See https://bugs.llvm.org/show_bug.cgi?id=37598
-// for further information. Weak attributes do not work across DLL boundary.
+// for further information.
// The MinGW compiler doesn't complain about the weak attribute until the link
// step, presumably because Windows doesn't use ELF binaries.
-#if (ABSL_HAVE_ATTRIBUTE(weak) || \
- (defined(__GNUC__) && !defined(__clang__))) && \
- (!defined(_WIN32) || \
- (defined(__clang__) && __clang_major__ >= 9 && \
- !defined(ABSL_BUILD_DLL) && !defined(ABSL_CONSUME_DLL))) && \
+#if (ABSL_HAVE_ATTRIBUTE(weak) || \
+ (defined(__GNUC__) && !defined(__clang__))) && \
+ (!defined(_WIN32) || (defined(__clang__) && __clang_major__ >= 9)) && \
!defined(__MINGW32__)
#undef ABSL_ATTRIBUTE_WEAK
#define ABSL_ATTRIBUTE_WEAK __attribute__((weak))
@@ -831,76 +827,30 @@
#define ABSL_ATTRIBUTE_LIFETIME_BOUND
#endif
-// Internal attribute; name and documentation TBD.
-//
-// See the upstream documentation:
-// https://clang.llvm.org/docs/AttributeReference.html#lifetime_capture_by
-#if ABSL_HAVE_CPP_ATTRIBUTE(clang::lifetime_capture_by)
-#define ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(Owner) \
- [[clang::lifetime_capture_by(Owner)]]
-#else
-#define ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(Owner)
-#endif
-
-// ABSL_ATTRIBUTE_VIEW indicates that a type is solely a "view" of data that it
-// points to, similarly to a span, string_view, or other non-owning reference
-// type.
-// This enables diagnosing certain lifetime issues similar to those enabled by
-// ABSL_ATTRIBUTE_LIFETIME_BOUND, such as:
-//
-// struct ABSL_ATTRIBUTE_VIEW StringView {
-// template<class R>
-// StringView(const R&);
-// };
-//
-// StringView f(std::string s) {
-// return s; // warning: address of stack memory returned
-// }
-//
-// We disable this on Clang versions < 13 because of the following
-// false-positive:
-//
-// absl::string_view f(absl::optional<absl::string_view> sv) { return *sv; }
+// ABSL_INTERNAL_ATTRIBUTE_VIEW indicates that a type acts like a view i.e. a
+// raw (non-owning) pointer. This enables diagnoses similar to those enabled by
+// ABSL_ATTRIBUTE_LIFETIME_BOUND.
//
// See the following links for details:
// https://reviews.llvm.org/D64448
// https://lists.llvm.org/pipermail/cfe-dev/2018-November/060355.html
-#if ABSL_HAVE_CPP_ATTRIBUTE(gsl::Pointer) && \
- (!defined(__clang_major__) || __clang_major__ >= 13)
-#define ABSL_ATTRIBUTE_VIEW [[gsl::Pointer]]
+#if ABSL_HAVE_CPP_ATTRIBUTE(gsl::Pointer)
+#define ABSL_INTERNAL_ATTRIBUTE_VIEW [[gsl::Pointer]]
#else
-#define ABSL_ATTRIBUTE_VIEW
+#define ABSL_INTERNAL_ATTRIBUTE_VIEW
#endif
-// ABSL_ATTRIBUTE_OWNER indicates that a type is a container, smart pointer, or
-// similar class that owns all the data that it points to.
-// This enables diagnosing certain lifetime issues similar to those enabled by
-// ABSL_ATTRIBUTE_LIFETIME_BOUND, such as:
-//
-// struct ABSL_ATTRIBUTE_VIEW StringView {
-// template<class R>
-// StringView(const R&);
-// };
-//
-// struct ABSL_ATTRIBUTE_OWNER String {};
-//
-// StringView f(String s) {
-// return s; // warning: address of stack memory returned
-// }
-//
-// We disable this on Clang versions < 13 because of the following
-// false-positive:
-//
-// absl::string_view f(absl::optional<absl::string_view> sv) { return *sv; }
+// ABSL_INTERNAL_ATTRIBUTE_OWNER indicates that a type acts like a smart
+// (owning) pointer. This enables diagnoses similar to those enabled by
+// ABSL_ATTRIBUTE_LIFETIME_BOUND.
//
// See the following links for details:
// https://reviews.llvm.org/D64448
// https://lists.llvm.org/pipermail/cfe-dev/2018-November/060355.html
-#if ABSL_HAVE_CPP_ATTRIBUTE(gsl::Owner) && \
- (!defined(__clang_major__) || __clang_major__ >= 13)
-#define ABSL_ATTRIBUTE_OWNER [[gsl::Owner]]
+#if ABSL_HAVE_CPP_ATTRIBUTE(gsl::Owner)
+#define ABSL_INTERNAL_ATTRIBUTE_OWNER [[gsl::Owner]]
#else
-#define ABSL_ATTRIBUTE_OWNER
+#define ABSL_INTERNAL_ATTRIBUTE_OWNER
#endif
// ABSL_ATTRIBUTE_TRIVIAL_ABI
diff --git a/absl/base/call_once.h b/absl/base/call_once.h
index b666d36..7b0e69c 100644
--- a/absl/base/call_once.h
+++ b/absl/base/call_once.h
@@ -31,8 +31,6 @@
#include <type_traits>
#include <utility>
-#include "absl/base/attributes.h"
-#include "absl/base/config.h"
#include "absl/base/internal/invoke.h"
#include "absl/base/internal/low_level_scheduling.h"
#include "absl/base/internal/raw_logging.h"
@@ -149,10 +147,10 @@
};
template <typename Callable, typename... Args>
- void
- CallOnceImpl(absl::Nonnull<std::atomic<uint32_t>*> control,
- base_internal::SchedulingMode scheduling_mode, Callable&& fn,
- Args&&... args) {
+ABSL_ATTRIBUTE_NOINLINE void CallOnceImpl(
+ absl::Nonnull<std::atomic<uint32_t>*> control,
+ base_internal::SchedulingMode scheduling_mode, Callable&& fn,
+ Args&&... args) {
#ifndef NDEBUG
{
uint32_t old_control = control->load(std::memory_order_relaxed);
@@ -211,8 +209,7 @@
} // namespace base_internal
template <typename Callable, typename... Args>
- void
- call_once(absl::once_flag& flag, Callable&& fn, Args&&... args) {
+void call_once(absl::once_flag& flag, Callable&& fn, Args&&... args) {
std::atomic<uint32_t>* once = base_internal::ControlWord(&flag);
uint32_t s = once->load(std::memory_order_acquire);
if (ABSL_PREDICT_FALSE(s != base_internal::kOnceDone)) {
diff --git a/absl/base/config.h b/absl/base/config.h
index 0b24865..0b22167 100644
--- a/absl/base/config.h
+++ b/absl/base/config.h
@@ -117,7 +117,7 @@
//
// LTS releases can be obtained from
// https://github.com/abseil/abseil-cpp/releases.
-#define ABSL_LTS_RELEASE_VERSION 20250127
+#define ABSL_LTS_RELEASE_VERSION 20240722
#define ABSL_LTS_RELEASE_PATCH_LEVEL 0
// Helper macro to convert a CPP variable to a string literal.
@@ -380,7 +380,7 @@
defined(__asmjs__) || defined(__EMSCRIPTEN__) || defined(__Fuchsia__) || \
defined(__sun) || defined(__myriad2__) || defined(__HAIKU__) || \
defined(__OpenBSD__) || defined(__NetBSD__) || defined(__QNX__) || \
- defined(__VXWORKS__) || defined(__hexagon__) || defined(__XTENSA__)
+ defined(__VXWORKS__) || defined(__hexagon__)
#define ABSL_HAVE_MMAP 1
#endif
@@ -926,7 +926,7 @@
// https://llvm.org/docs/CompileCudaWithLLVM.html#detecting-clang-vs-nvcc-from-code
#ifdef ABSL_INTERNAL_HAVE_ARM_NEON
#error ABSL_INTERNAL_HAVE_ARM_NEON cannot be directly set
-#elif defined(__ARM_NEON) && !(defined(__NVCC__) && defined(__CUDACC__))
+#elif defined(__ARM_NEON) && !defined(__CUDA_ARCH__)
#define ABSL_INTERNAL_HAVE_ARM_NEON 1
#endif
diff --git a/absl/base/internal/nullability_impl.h b/absl/base/internal/nullability_impl.h
index b601fc4..03fa243 100644
--- a/absl/base/internal/nullability_impl.h
+++ b/absl/base/internal/nullability_impl.h
@@ -26,41 +26,80 @@
ABSL_NAMESPACE_BEGIN
namespace nullability_internal {
+// `IsNullabilityCompatible` checks whether its first argument is a class
+// explicitly tagged as supporting nullability annotations. The tag is the type
+// declaration `absl_nullability_compatible`.
+template <typename, typename = void>
+struct IsNullabilityCompatible : std::false_type {};
+
template <typename T>
+struct IsNullabilityCompatible<
+ T, absl::void_t<typename T::absl_nullability_compatible>> : std::true_type {
+};
+
+template <typename T>
+constexpr bool IsSupportedType = IsNullabilityCompatible<T>::value;
+
+template <typename T>
+constexpr bool IsSupportedType<T*> = true;
+
+template <typename T, typename U>
+constexpr bool IsSupportedType<T U::*> = true;
+
+template <typename T, typename... Deleter>
+constexpr bool IsSupportedType<std::unique_ptr<T, Deleter...>> = true;
+
+template <typename T>
+constexpr bool IsSupportedType<std::shared_ptr<T>> = true;
+
+template <typename T>
+struct EnableNullable {
+ static_assert(nullability_internal::IsSupportedType<std::remove_cv_t<T>>,
+ "Template argument must be a raw or supported smart pointer "
+ "type. See absl/base/nullability.h.");
+ using type = T;
+};
+
+template <typename T>
+struct EnableNonnull {
+ static_assert(nullability_internal::IsSupportedType<std::remove_cv_t<T>>,
+ "Template argument must be a raw or supported smart pointer "
+ "type. See absl/base/nullability.h.");
+ using type = T;
+};
+
+template <typename T>
+struct EnableNullabilityUnknown {
+ static_assert(nullability_internal::IsSupportedType<std::remove_cv_t<T>>,
+ "Template argument must be a raw or supported smart pointer "
+ "type. See absl/base/nullability.h.");
+ using type = T;
+};
+
+// Note: we do not apply Clang nullability attributes (e.g. _Nullable). These
+// only support raw pointers, and conditionally enabling them only for raw
+// pointers inhibits template arg deduction. Ideally, they would support all
+// pointer-like types.
+template <typename T, typename = typename EnableNullable<T>::type>
using NullableImpl
#if ABSL_HAVE_CPP_ATTRIBUTE(clang::annotate)
[[clang::annotate("Nullable")]]
#endif
-// Don't add the _Nullable attribute in Objective-C compiles. Many Objective-C
-// projects enable the `-Wnullable-to-nonnull-conversion warning`, which is
-// liable to produce false positives.
-#if ABSL_HAVE_FEATURE(nullability_on_classes) && !defined(__OBJC__)
- = T _Nullable;
-#else
= T;
-#endif
-template <typename T>
+template <typename T, typename = typename EnableNonnull<T>::type>
using NonnullImpl
#if ABSL_HAVE_CPP_ATTRIBUTE(clang::annotate)
[[clang::annotate("Nonnull")]]
#endif
-#if ABSL_HAVE_FEATURE(nullability_on_classes) && !defined(__OBJC__)
- = T _Nonnull;
-#else
= T;
-#endif
-template <typename T>
+template <typename T, typename = typename EnableNullabilityUnknown<T>::type>
using NullabilityUnknownImpl
#if ABSL_HAVE_CPP_ATTRIBUTE(clang::annotate)
[[clang::annotate("Nullability_Unspecified")]]
#endif
-#if ABSL_HAVE_FEATURE(nullability_on_classes) && !defined(__OBJC__)
- = T _Null_unspecified;
-#else
= T;
-#endif
} // namespace nullability_internal
ABSL_NAMESPACE_END
diff --git a/absl/base/internal/raw_logging.cc b/absl/base/internal/raw_logging.cc
index 35a08f0..d32b40a 100644
--- a/absl/base/internal/raw_logging.cc
+++ b/absl/base/internal/raw_logging.cc
@@ -175,7 +175,7 @@
} else {
DoRawLog(&buf, &size, "%s", kTruncated);
}
- AsyncSignalSafeWriteError(buffer, static_cast<size_t>(buf - buffer));
+ AsyncSignalSafeWriteError(buffer, strlen(buffer));
}
#else
static_cast<void>(format);
diff --git a/absl/base/internal/sysinfo.cc b/absl/base/internal/sysinfo.cc
index 1937db3..79eaba3 100644
--- a/absl/base/internal/sysinfo.cc
+++ b/absl/base/internal/sysinfo.cc
@@ -46,10 +46,6 @@
#include <rtems.h>
#endif
-#if defined(__Fuchsia__)
-#include <zircon/process.h>
-#endif
-
#include <string.h>
#include <cassert>
@@ -465,16 +461,6 @@
return reinterpret_cast<pid_t>(thread);
}
-#elif defined(__Fuchsia__)
-
-pid_t GetTID() {
- // Use our thread handle as the TID, which should be unique within this
- // process (but may not be globally unique). The handle value was chosen over
- // a kernel object ID (KOID) because zx_handle_t (32-bits) can be cast to a
- // pid_t type without loss of precision, but a zx_koid_t (64-bits) cannot.
- return static_cast<pid_t>(zx_thread_self());
-}
-
#else
// Fallback implementation of `GetTID` using `pthread_self`.
diff --git a/absl/base/internal/thread_identity.h b/absl/base/internal/thread_identity.h
index acfc15a..b6e917c 100644
--- a/absl/base/internal/thread_identity.h
+++ b/absl/base/internal/thread_identity.h
@@ -130,11 +130,7 @@
};
// The instances of this class are allocated in NewThreadIdentity() with an
-// alignment of PerThreadSynch::kAlignment and never destroyed. Initialization
-// should happen in OneTimeInitThreadIdentity().
-//
-// Instances may be reused by new threads - fields should be reset in
-// ResetThreadIdentityBetweenReuse().
+// alignment of PerThreadSynch::kAlignment.
//
// NOTE: The layout of fields in this structure is critical, please do not
// add, remove, or modify the field placements without fully auditing the
diff --git a/absl/base/internal/tracing.cc b/absl/base/internal/tracing.cc
deleted file mode 100644
index d304e6a..0000000
--- a/absl/base/internal/tracing.cc
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2024 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
-//
-// https://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/tracing.h"
-
-#include "absl/base/attributes.h"
-#include "absl/base/config.h"
-
-namespace absl {
-ABSL_NAMESPACE_BEGIN
-namespace base_internal {
-
-extern "C" {
-
-ABSL_ATTRIBUTE_WEAK void ABSL_INTERNAL_C_SYMBOL(AbslInternalTraceWait)(
- const void*, ObjectKind) {}
-ABSL_ATTRIBUTE_WEAK void ABSL_INTERNAL_C_SYMBOL(AbslInternalTraceContinue)(
- const void*, ObjectKind) {}
-ABSL_ATTRIBUTE_WEAK void ABSL_INTERNAL_C_SYMBOL(AbslInternalTraceSignal)(
- const void*, ObjectKind) {}
-ABSL_ATTRIBUTE_WEAK void ABSL_INTERNAL_C_SYMBOL(AbslInternalTraceObserved)(
- const void*, ObjectKind) {}
-
-} // extern "C"
-
-} // namespace base_internal
-ABSL_NAMESPACE_END
-} // namespace absl
diff --git a/absl/base/internal/tracing.h b/absl/base/internal/tracing.h
deleted file mode 100644
index e7ab775..0000000
--- a/absl/base/internal/tracing.h
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright 2024 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
-//
-// https://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_TRACING_H_
-#define ABSL_BASE_INTERNAL_TRACING_H_
-
-#include "absl/base/config.h"
-
-namespace absl {
-ABSL_NAMESPACE_BEGIN
-namespace base_internal {
-
-// Well known Abseil object types that have causality.
-enum class ObjectKind { kUnknown, kBlockingCounter, kNotification };
-
-// `TraceWait` and `TraceContinue` record the start and end of a potentially
-// blocking wait operation on `object`. `object` typically represents a higher
-// level synchronization object such as `absl::Notification`.
-void TraceWait(const void* object, ObjectKind kind);
-void TraceContinue(const void* object, ObjectKind kind);
-
-// `TraceSignal` records a signal on `object`.
-void TraceSignal(const void* object, ObjectKind kind);
-
-// `TraceObserved` records the non-blocking observation of a signaled object.
-void TraceObserved(const void* object, ObjectKind kind);
-
-// ---------------------------------------------------------------------------
-// Weak implementation detail:
-//
-// We define the weak API as extern "C": in some build configurations we pass
-// `--detect-odr-violations` to the gold linker. This causes it to flag weak
-// symbol overrides as ODR violations. Because ODR only applies to C++ and not
-// C, `--detect-odr-violations` ignores symbols not mangled with C++ names.
-// By changing our extension points to be extern "C", we dodge this check.
-// ---------------------------------------------------------------------------
-extern "C" {
-
- void ABSL_INTERNAL_C_SYMBOL(AbslInternalTraceWait)(const void* object,
- ObjectKind kind);
- void ABSL_INTERNAL_C_SYMBOL(AbslInternalTraceContinue)(const void* object,
- ObjectKind kind);
- void ABSL_INTERNAL_C_SYMBOL(AbslInternalTraceSignal)(const void* object,
- ObjectKind kind);
- void ABSL_INTERNAL_C_SYMBOL(AbslInternalTraceObserved)(const void* object,
- ObjectKind kind);
-
-} // extern "C"
-
-inline void TraceWait(const void* object, ObjectKind kind) {
- ABSL_INTERNAL_C_SYMBOL(AbslInternalTraceWait)(object, kind);
-}
-
-inline void TraceContinue(const void* object, ObjectKind kind) {
- ABSL_INTERNAL_C_SYMBOL(AbslInternalTraceContinue)(object, kind);
-}
-
-inline void TraceSignal(const void* object, ObjectKind kind) {
- ABSL_INTERNAL_C_SYMBOL(AbslInternalTraceSignal)(object, kind);
-}
-
-inline void TraceObserved(const void* object, ObjectKind kind) {
- ABSL_INTERNAL_C_SYMBOL(AbslInternalTraceObserved)(object, kind);
-}
-
-} // namespace base_internal
-ABSL_NAMESPACE_END
-} // namespace absl
-
-#endif // ABSL_BASE_INTERNAL_TRACING_H_
diff --git a/absl/base/internal/tracing_strong_test.cc b/absl/base/internal/tracing_strong_test.cc
deleted file mode 100644
index 979f1c5..0000000
--- a/absl/base/internal/tracing_strong_test.cc
+++ /dev/null
@@ -1,117 +0,0 @@
-// Copyright 2024 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
-//
-// https://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 <tuple>
-#include <vector>
-
-#include "gmock/gmock.h"
-#include "gtest/gtest.h"
-#include "absl/base/attributes.h"
-#include "absl/base/config.h"
-#include "absl/base/internal/tracing.h"
-
-#if ABSL_HAVE_ATTRIBUTE_WEAK
-
-namespace {
-
-using ::testing::ElementsAre;
-
-using ::absl::base_internal::ObjectKind;
-
-enum Function { kWait, kContinue, kSignal, kObserved };
-
-using Record = std::tuple<Function, const void*, ObjectKind>;
-
-thread_local std::vector<Record>* tls_records = nullptr;
-
-} // namespace
-
-namespace absl {
-ABSL_NAMESPACE_BEGIN
-namespace base_internal {
-
-// Strong extern "C" implementation.
-extern "C" {
-
-void ABSL_INTERNAL_C_SYMBOL(AbslInternalTraceWait)(const void* object,
- ObjectKind kind) {
- if (tls_records != nullptr) {
- tls_records->push_back({kWait, object, kind});
- }
-}
-
-void ABSL_INTERNAL_C_SYMBOL(AbslInternalTraceContinue)(const void* object,
- ObjectKind kind) {
- if (tls_records != nullptr) {
- tls_records->push_back({kContinue, object, kind});
- }
-}
-
-void ABSL_INTERNAL_C_SYMBOL(AbslInternalTraceSignal)(const void* object,
- ObjectKind kind) {
- if (tls_records != nullptr) {
- tls_records->push_back({kSignal, object, kind});
- }
-}
-
-void ABSL_INTERNAL_C_SYMBOL(AbslInternalTraceObserved)(const void* object,
- ObjectKind kind) {
- if (tls_records != nullptr) {
- tls_records->push_back({kObserved, object, kind});
- }
-}
-
-} // extern "C"
-
-} // namespace base_internal
-ABSL_NAMESPACE_END
-} // namespace absl
-
-namespace {
-
-TEST(TracingInternal, InvokesStrongFunctionWithNullptr) {
- std::vector<Record> records;
- tls_records = &records;
- auto kind = absl::base_internal::ObjectKind::kUnknown;
- absl::base_internal::TraceWait(nullptr, kind);
- absl::base_internal::TraceContinue(nullptr, kind);
- absl::base_internal::TraceSignal(nullptr, kind);
- absl::base_internal::TraceObserved(nullptr, kind);
- tls_records = nullptr;
-
- EXPECT_THAT(records, ElementsAre(Record{kWait, nullptr, kind},
- Record{kContinue, nullptr, kind},
- Record{kSignal, nullptr, kind},
- Record{kObserved, nullptr, kind}));
-}
-
-TEST(TracingInternal, InvokesStrongFunctionWithObjectAddress) {
- int object = 0;
- std::vector<Record> records;
- tls_records = &records;
- auto kind = absl::base_internal::ObjectKind::kUnknown;
- absl::base_internal::TraceWait(&object, kind);
- absl::base_internal::TraceContinue(&object, kind);
- absl::base_internal::TraceSignal(&object, kind);
- absl::base_internal::TraceObserved(&object, kind);
- tls_records = nullptr;
-
- EXPECT_THAT(records, ElementsAre(Record{kWait, &object, kind},
- Record{kContinue, &object, kind},
- Record{kSignal, &object, kind},
- Record{kObserved, &object, kind}));
-}
-
-} // namespace
-
-#endif // ABSL_HAVE_ATTRIBUTE_WEAK
diff --git a/absl/base/internal/tracing_weak_test.cc b/absl/base/internal/tracing_weak_test.cc
deleted file mode 100644
index 6d7553f..0000000
--- a/absl/base/internal/tracing_weak_test.cc
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2024 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
-//
-// https://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 "gtest/gtest.h"
-#include "absl/base/internal/tracing.h"
-
-namespace {
-
-TEST(TracingInternal, HasDefaultImplementation) {
- auto kind = absl::base_internal::ObjectKind::kUnknown;
- absl::base_internal::TraceWait(nullptr, kind);
- absl::base_internal::TraceContinue(nullptr, kind);
- absl::base_internal::TraceSignal(nullptr, kind);
- absl::base_internal::TraceObserved(nullptr, kind);
-
- int object = 0;
- absl::base_internal::TraceWait(&object, kind);
- absl::base_internal::TraceContinue(&object, kind);
- absl::base_internal::TraceSignal(&object, kind);
- absl::base_internal::TraceObserved(&object, kind);
-}
-
-} // namespace
diff --git a/absl/base/internal/unscaledcycleclock.cc b/absl/base/internal/unscaledcycleclock.cc
index 68f9273..a0bf3a6 100644
--- a/absl/base/internal/unscaledcycleclock.cc
+++ b/absl/base/internal/unscaledcycleclock.cc
@@ -105,6 +105,16 @@
#elif defined(__aarch64__)
+// System timer of ARMv8 runs at a different frequency than the CPU's.
+// The frequency is fixed, typically in the range 1-50MHz. It can be
+// read at CNTFRQ special register. We assume the OS has set up
+// the virtual timer properly.
+int64_t UnscaledCycleClock::Now() {
+ int64_t virtual_timer_value;
+ asm volatile("mrs %0, cntvct_el0" : "=r"(virtual_timer_value));
+ return virtual_timer_value;
+}
+
double UnscaledCycleClock::Frequency() {
uint64_t aarch64_timer_frequency;
asm volatile("mrs %0, cntfrq_el0" : "=r"(aarch64_timer_frequency));
diff --git a/absl/base/internal/unscaledcycleclock.h b/absl/base/internal/unscaledcycleclock.h
index 965c42d..cc1276b 100644
--- a/absl/base/internal/unscaledcycleclock.h
+++ b/absl/base/internal/unscaledcycleclock.h
@@ -85,18 +85,6 @@
return static_cast<int64_t>((high << 32) | low);
}
-#elif defined(__aarch64__)
-
-// System timer of ARMv8 runs at a different frequency than the CPU's.
-// The frequency is fixed, typically in the range 1-50MHz. It can be
-// read at CNTFRQ special register. We assume the OS has set up
-// the virtual timer properly.
-inline int64_t UnscaledCycleClock::Now() {
- int64_t virtual_timer_value;
- asm volatile("mrs %0, cntvct_el0" : "=r"(virtual_timer_value));
- return virtual_timer_value;
-}
-
#endif
} // namespace base_internal
diff --git a/absl/base/macros.h b/absl/base/macros.h
index ff89944..b318f11 100644
--- a/absl/base/macros.h
+++ b/absl/base/macros.h
@@ -34,7 +34,6 @@
#include "absl/base/attributes.h"
#include "absl/base/config.h"
#include "absl/base/optimization.h"
-#include "absl/base/options.h"
#include "absl/base/port.h"
// ABSL_ARRAYSIZE()
@@ -82,9 +81,8 @@
// ABSL_ASSERT()
//
// In C++11, `assert` can't be used portably within constexpr functions.
-// `assert` also generates spurious unused-symbol warnings.
// ABSL_ASSERT functions as a runtime assert but works in C++11 constexpr
-// functions, and maintains references to symbols. Example:
+// functions. Example:
//
// constexpr double Divide(double a, double b) {
// return ABSL_ASSERT(b != 0), a / b;
@@ -93,18 +91,8 @@
// This macro is inspired by
// https://akrzemi1.wordpress.com/2017/05/18/asserts-in-constexpr-functions/
#if defined(NDEBUG)
-#if ABSL_INTERNAL_CPLUSPLUS_LANG >= 202002L
-// We use `decltype` here to avoid generating unnecessary code that the
-// optimizer then has to optimize away.
-// This not only improves compilation performance by reducing codegen bloat
-// and optimization work, but also guarantees fast run-time performance without
-// having to rely on the optimizer.
-#define ABSL_ASSERT(expr) (decltype((expr) ? void() : void())())
-#else
-// Pre-C++20, lambdas can't be inside unevaluated operands, so we're forced to
-// rely on the optimizer.
-#define ABSL_ASSERT(expr) (false ? ((expr) ? void() : void()) : void())
-#endif
+#define ABSL_ASSERT(expr) \
+ (false ? static_cast<void>(expr) : static_cast<void>(0))
#else
#define ABSL_ASSERT(expr) \
(ABSL_PREDICT_TRUE((expr)) ? static_cast<void>(0) \
@@ -132,7 +120,7 @@
//
// See `ABSL_OPTION_HARDENED` in `absl/base/options.h` for more information on
// hardened mode.
-#if (ABSL_OPTION_HARDENED == 1 || ABSL_OPTION_HARDENED == 2) && defined(NDEBUG)
+#if ABSL_OPTION_HARDENED == 1 && defined(NDEBUG)
#define ABSL_HARDENING_ASSERT(expr) \
(ABSL_PREDICT_TRUE((expr)) ? static_cast<void>(0) \
: [] { ABSL_INTERNAL_HARDENING_ABORT(); }())
@@ -140,25 +128,6 @@
#define ABSL_HARDENING_ASSERT(expr) ABSL_ASSERT(expr)
#endif
-// ABSL_HARDENING_ASSERT_SLOW()
-//
-// `ABSL_HARDENING_ASSERT()` is like `ABSL_HARDENING_ASSERT()`,
-// but specifically for assertions whose predicates are too slow
-// to be enabled in many applications.
-//
-// When `NDEBUG` is not defined, `ABSL_HARDENING_ASSERT_SLOW()` is identical to
-// `ABSL_ASSERT()`.
-//
-// See `ABSL_OPTION_HARDENED` in `absl/base/options.h` for more information on
-// hardened mode.
-#if ABSL_OPTION_HARDENED == 1 && defined(NDEBUG)
-#define ABSL_HARDENING_ASSERT_SLOW(expr) \
- (ABSL_PREDICT_TRUE((expr)) ? static_cast<void>(0) \
- : [] { ABSL_INTERNAL_HARDENING_ABORT(); }())
-#else
-#define ABSL_HARDENING_ASSERT_SLOW(expr) ABSL_ASSERT(expr)
-#endif
-
#ifdef ABSL_HAVE_EXCEPTIONS
#define ABSL_INTERNAL_TRY try
#define ABSL_INTERNAL_CATCH_ANY catch (...)
diff --git a/absl/base/nullability.h b/absl/base/nullability.h
index 241c65a..34dc083 100644
--- a/absl/base/nullability.h
+++ b/absl/base/nullability.h
@@ -135,9 +135,17 @@
// ...
// };
//
-// Note: Compilers that don't support the `nullability_on_classes` feature will
-// allow nullability annotations to be applied to any type, not just ones
-// marked with `ABSL_NULLABILITY_COMPATIBLE`.
+// Note: For the time being, nullability-compatible classes should additionally
+// be marked with an `absl_nullability_compatible` nested type (this will soon
+// be deprecated). The actual definition of this inner type is not relevant as
+// it is used merely as a marker. It is common to use a using declaration of
+// `absl_nullability_compatible` set to void.
+//
+// // Example:
+// struct MyPtr {
+// using absl_nullability_compatible = void;
+// ...
+// };
//
// DISCLAIMER:
// ===========================================================================
@@ -153,47 +161,10 @@
#include "absl/base/config.h"
#include "absl/base/internal/nullability_impl.h"
-// ABSL_POINTERS_DEFAULT_NONNULL
-//
-// This macro specifies that all unannotated pointer types within the given
-// file are designated as nonnull (instead of the default "unknown"). This macro
-// exists as a standalone statement and applies default nonnull behavior to all
-// subsequent pointers; as a result, place this macro as the first non-comment,
-// non-`#include` line in a file.
-//
-// Example:
-//
-// #include "absl/base/nullability.h"
-//
-// ABSL_POINTERS_DEFAULT_NONNULL
-//
-// void FillMessage(Message *m); // implicitly non-null
-// absl::Nullable<T*> GetNullablePtr(); // explicitly nullable
-// absl::NullabilityUnknown<T*> GetUnknownPtr(); // explicitly unknown
-//
-// The macro can be safely used in header files -- it will not affect any files
-// that include it.
-//
-// In files with the macro, plain `T*` syntax means `absl::Nonnull<T*>`, and the
-// exceptions (`Nullable` and `NullabilityUnknown`) must be marked
-// explicitly. The same holds, correspondingly, for smart pointer types.
-//
-// For comparison, without the macro, all unannotated pointers would default to
-// unknown, and otherwise require explicit annotations to change this behavior:
-//
-// #include "absl/base/nullability.h"
-//
-// void FillMessage(absl::Nonnull<Message*> m); // explicitly non-null
-// absl::Nullable<T*> GetNullablePtr(); // explicitly nullable
-// T* GetUnknownPtr(); // implicitly unknown
-//
-// No-op except for being a human readable signal.
-#define ABSL_POINTERS_DEFAULT_NONNULL
-
namespace absl {
ABSL_NAMESPACE_BEGIN
-// absl::Nonnull (default with `ABSL_POINTERS_DEFAULT_NONNULL`)
+// absl::Nonnull
//
// The indicated pointer is never null. It is the responsibility of the provider
// of this pointer across an API boundary to ensure that the pointer is never
@@ -226,7 +197,7 @@
template <typename T>
using Nullable = nullability_internal::NullableImpl<T>;
-// absl::NullabilityUnknown (default without `ABSL_POINTERS_DEFAULT_NONNULL`)
+// absl::NullabilityUnknown (default)
//
// The indicated pointer has not yet been determined to be definitively
// "non-null" or "nullable." Providers of such pointers across API boundaries
@@ -237,10 +208,9 @@
// migrated into one of the above two nullability states: `Nonnull<T>` or
// `Nullable<T>`.
//
-// NOTE: For files that do not specify `ABSL_POINTERS_DEFAULT_NONNULL`,
-// because this annotation is the global default state, unannotated pointers are
-// are assumed to have "unknown" semantics. This assumption is designed to
-// minimize churn and reduce clutter within the codebase.
+// NOTE: Because this annotation is the global default state, unannotated
+// pointers are assumed to have "unknown" semantics. This assumption is designed
+// to minimize churn and reduce clutter within the codebase.
//
// Example:
//
@@ -271,36 +241,10 @@
// struct ABSL_NULLABILITY_COMPATIBLE MyPtr {
// ...
// };
-//
-// Note: Compilers that don't support the `nullability_on_classes` feature will
-// allow nullability annotations to be applied to any type, not just ones marked
-// with `ABSL_NULLABILITY_COMPATIBLE`.
#if ABSL_HAVE_FEATURE(nullability_on_classes)
#define ABSL_NULLABILITY_COMPATIBLE _Nullable
#else
#define ABSL_NULLABILITY_COMPATIBLE
#endif
-// ABSL_NONNULL
-// ABSL_NULLABLE
-// ABSL_NULLABILITY_UNKNOWN
-//
-// These macros are analogues of the alias template nullability annotations
-// above.
-//
-// Example:
-// int* ABSL_NULLABLE foo;
-// Is equivalent to:
-// absl::Nullable<int*> foo;
-#if defined(__clang__) && !defined(__OBJC__) && \
- ABSL_HAVE_FEATURE(nullability_on_classes)
-#define ABSL_NONNULL _Nonnull
-#define ABSL_NULLABLE _Nullable
-#define ABSL_NULLABILITY_UNKNOWN _Null_unspecified
-#else
-#define ABSL_NONNULL
-#define ABSL_NULLABLE
-#define ABSL_NULLABILITY_UNKNOWN
-#endif
-
#endif // ABSL_BASE_NULLABILITY_H_
diff --git a/absl/base/nullability_default_nonnull_test.cc b/absl/base/nullability_default_nonnull_test.cc
deleted file mode 100644
index bd5b483..0000000
--- a/absl/base/nullability_default_nonnull_test.cc
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2024 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
-//
-// https://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 <cassert>
-
-#include "gtest/gtest.h"
-#include "absl/base/nullability.h"
-
-ABSL_POINTERS_DEFAULT_NONNULL
-
-namespace {
-
-void FuncWithDefaultNonnullArg(int* /*arg*/) {}
-template <typename T>
-void FuncWithDeducedDefaultNonnullArg(T* /*arg*/) {}
-
-TEST(DefaultNonnullTest, NonnullArgument) {
- int var = 0;
- FuncWithDefaultNonnullArg(&var);
- FuncWithDeducedDefaultNonnullArg<int>(&var);
-}
-
-int* FuncWithDefaultNonnullReturn() {
- static int var = 0;
- return &var;
-}
-
-TEST(DefaultNonnullTest, NonnullReturn) {
- auto var = FuncWithDefaultNonnullReturn();
- (void)var;
-}
-
-} // namespace
diff --git a/absl/base/optimization.h b/absl/base/optimization.h
index 429ea9c..3aa66e1 100644
--- a/absl/base/optimization.h
+++ b/absl/base/optimization.h
@@ -25,8 +25,6 @@
// new code that requires C compatibility or assume C compatibility will remain
// indefinitely.
-// SKIP_ABSL_INLINE_NAMESPACE_CHECK
-
#ifndef ABSL_BASE_OPTIMIZATION_H_
#define ABSL_BASE_OPTIMIZATION_H_
@@ -273,14 +271,20 @@
#elif defined(_MSC_VER)
#define ABSL_ASSUME(cond) __assume(cond)
#elif defined(__cpp_lib_unreachable) && __cpp_lib_unreachable >= 202202L
-#define ABSL_ASSUME(cond) ((cond) ? void() : std::unreachable())
+#define ABSL_ASSUME(cond) \
+ do { \
+ if (!(cond)) std::unreachable(); \
+ } while (false)
#elif defined(__GNUC__) || ABSL_HAVE_BUILTIN(__builtin_unreachable)
-#define ABSL_ASSUME(cond) ((cond) ? void() : __builtin_unreachable())
-#elif ABSL_INTERNAL_CPLUSPLUS_LANG >= 202002L
-// Unimplemented. Uses the same definition as ABSL_ASSERT in the NDEBUG case.
-#define ABSL_ASSUME(expr) (decltype((expr) ? void() : void())())
+#define ABSL_ASSUME(cond) \
+ do { \
+ if (!(cond)) __builtin_unreachable(); \
+ } while (false)
#else
-#define ABSL_ASSUME(expr) (false ? ((expr) ? void() : void()) : void())
+#define ABSL_ASSUME(cond) \
+ do { \
+ static_cast<void>(false && (cond)); \
+ } while (false)
#endif
// ABSL_INTERNAL_UNIQUE_SMALL_NAME(cond)
diff --git a/absl/base/optimization_test.cc b/absl/base/optimization_test.cc
index b47b11a..e83369f 100644
--- a/absl/base/optimization_test.cc
+++ b/absl/base/optimization_test.cc
@@ -88,9 +88,9 @@
EXPECT_FALSE(ABSL_PREDICT_FALSE(no_value));
}
-class ImplicitlyConvertibleToBool {
+class ImplictlyConvertibleToBool {
public:
- explicit ImplicitlyConvertibleToBool(bool value) : value_(value) {}
+ explicit ImplictlyConvertibleToBool(bool value) : value_(value) {}
operator bool() const { // NOLINT(google-explicit-constructor)
return value_;
}
@@ -100,17 +100,17 @@
};
TEST(PredictTest, ImplicitBoolConversion) {
- const ImplicitlyConvertibleToBool is_true(true);
- const ImplicitlyConvertibleToBool is_false(false);
+ const ImplictlyConvertibleToBool is_true(true);
+ const ImplictlyConvertibleToBool is_false(false);
if (!ABSL_PREDICT_TRUE(is_true)) ADD_FAILURE();
if (ABSL_PREDICT_TRUE(is_false)) ADD_FAILURE();
if (!ABSL_PREDICT_FALSE(is_true)) ADD_FAILURE();
if (ABSL_PREDICT_FALSE(is_false)) ADD_FAILURE();
}
-class ExplicitlyConvertibleToBool {
+class ExplictlyConvertibleToBool {
public:
- explicit ExplicitlyConvertibleToBool(bool value) : value_(value) {}
+ explicit ExplictlyConvertibleToBool(bool value) : value_(value) {}
explicit operator bool() const { return value_; }
private:
@@ -118,24 +118,12 @@
};
TEST(PredictTest, ExplicitBoolConversion) {
- const ExplicitlyConvertibleToBool is_true(true);
- const ExplicitlyConvertibleToBool is_false(false);
+ const ExplictlyConvertibleToBool is_true(true);
+ const ExplictlyConvertibleToBool is_false(false);
if (!ABSL_PREDICT_TRUE(is_true)) ADD_FAILURE();
if (ABSL_PREDICT_TRUE(is_false)) ADD_FAILURE();
if (!ABSL_PREDICT_FALSE(is_true)) ADD_FAILURE();
if (ABSL_PREDICT_FALSE(is_false)) ADD_FAILURE();
}
-// This verifies that ABSL_ASSUME compiles in a variety of contexts.
-// It does not test optimization.
-TEST(AbslAssume, Compiles) {
- int x = 0;
- ABSL_ASSUME(x >= 0);
- EXPECT_EQ(x, 0);
-
- // https://github.com/abseil/abseil-cpp/issues/1814
- ABSL_ASSUME(x >= 0), (x >= 0) ? ++x : --x;
- EXPECT_EQ(x, 1);
-}
-
} // namespace
diff --git a/absl/base/options.h b/absl/base/options.h
index cfd6d7a..3ea6045 100644
--- a/absl/base/options.h
+++ b/absl/base/options.h
@@ -226,7 +226,7 @@
// allowed.
#define ABSL_OPTION_USE_INLINE_NAMESPACE 1
-#define ABSL_OPTION_INLINE_NAMESPACE_NAME lts_20250127
+#define ABSL_OPTION_INLINE_NAMESPACE_NAME lts_20240722
// ABSL_OPTION_HARDENED
//
@@ -235,10 +235,7 @@
//
// A value of 0 means that "hardened" mode is not enabled.
//
-// A value of 1 means that "hardened" mode is enabled with all checks.
-//
-// A value of 2 means that "hardened" mode is partially enabled, with
-// only a subset of checks chosen to minimize performance impact.
+// A value of 1 means that "hardened" mode is enabled.
//
// Hardened builds have additional security checks enabled when `NDEBUG` is
// defined. Defining `NDEBUG` is normally used to turn `assert()` macro into a
diff --git a/absl/base/policy_checks.h b/absl/base/policy_checks.h
index 7538166..372e848 100644
--- a/absl/base/policy_checks.h
+++ b/absl/base/policy_checks.h
@@ -21,8 +21,6 @@
// reported with `#error`. This enforcement is best effort, so successfully
// compiling this header does not guarantee a supported configuration.
-// SKIP_ABSL_INLINE_NAMESPACE_CHECK
-
#ifndef ABSL_BASE_POLICY_CHECKS_H_
#define ABSL_BASE_POLICY_CHECKS_H_
diff --git a/absl/base/raw_logging_test.cc b/absl/base/raw_logging_test.cc
index 03a88ff..3d30bd3 100644
--- a/absl/base/raw_logging_test.cc
+++ b/absl/base/raw_logging_test.cc
@@ -35,10 +35,6 @@
ABSL_RAW_LOG(ERROR, "RAW ERROR: %d", 1);
}
-TEST(RawLoggingCompilationTest, LogWithNulls) {
- ABSL_RAW_LOG(INFO, "RAW INFO: %s%c%s", "Hello", 0, "World");
-}
-
TEST(RawLoggingCompilationTest, PassingCheck) {
ABSL_RAW_CHECK(true, "RAW CHECK");
}
diff --git a/absl/cleanup/BUILD.bazel b/absl/cleanup/BUILD.bazel
index 2c20224..984d571 100644
--- a/absl/cleanup/BUILD.bazel
+++ b/absl/cleanup/BUILD.bazel
@@ -67,7 +67,7 @@
":cleanup",
"//absl/base:config",
"//absl/utility",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
diff --git a/absl/container/BUILD.bazel b/absl/container/BUILD.bazel
index 19dc91d..b00c30f 100644
--- a/absl/container/BUILD.bazel
+++ b/absl/container/BUILD.bazel
@@ -54,8 +54,8 @@
"//absl/types:any",
"//absl/types:optional",
"//absl/utility",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -87,8 +87,8 @@
"//absl/base:exception_testing",
"//absl/hash:hash_testing",
"//absl/memory",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -101,8 +101,8 @@
":fixed_array",
"//absl/base:config",
"//absl/base:exception_safety_testing",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -115,7 +115,7 @@
tags = ["benchmark"],
deps = [
":fixed_array",
- "@google_benchmark//:benchmark_main",
+ "@com_github_google_benchmark//:benchmark_main",
],
)
@@ -175,8 +175,8 @@
"//absl/log:check",
"//absl/memory",
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -192,7 +192,7 @@
"//absl/base:core_headers",
"//absl/base:raw_logging_internal",
"//absl/strings",
- "@google_benchmark//:benchmark_main",
+ "@com_github_google_benchmark//:benchmark_main",
],
)
@@ -204,8 +204,8 @@
":inlined_vector",
"//absl/base:config",
"//absl/base:exception_safety_testing",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -229,8 +229,8 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":test_instance_tracker",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -275,8 +275,8 @@
"//absl/log:check",
"//absl/meta:type_traits",
"//absl/types:any",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -305,7 +305,6 @@
deps = [
":container_memory",
":flat_hash_set",
- ":hash_container_defaults",
":hash_generator_testing",
":test_allocator",
":unordered_set_constructor_test",
@@ -313,12 +312,11 @@
":unordered_set_members_test",
":unordered_set_modifiers_test",
"//absl/base:config",
- "//absl/hash",
"//absl/log:check",
"//absl/memory",
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -354,8 +352,8 @@
":unordered_map_members_test",
":unordered_map_modifiers_test",
"//absl/base:config",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -392,8 +390,8 @@
":unordered_set_modifiers_test",
"//absl/base:config",
"//absl/memory",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -422,8 +420,8 @@
"//absl/base:no_destructor",
"//absl/meta:type_traits",
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -471,8 +469,8 @@
"//absl/strings",
"//absl/strings:cord",
"//absl/strings:cord_test_helpers",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -511,8 +509,8 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":hash_policy_testing",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -535,8 +533,8 @@
deps = [
":container_memory",
":hash_policy_traits",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -557,8 +555,8 @@
deps = [
":common_policy_traits",
"//absl/base:config",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -622,8 +620,8 @@
"//absl/synchronization",
"//absl/synchronization:thread_pool",
"//absl/time",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -644,8 +642,8 @@
":hash_policy_traits",
":node_slot_policy",
"//absl/base:config",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -682,10 +680,8 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":common",
- ":common_policy_traits",
":compressed_tuple",
":container_memory",
- ":hash_function_defaults",
":hash_policy_traits",
":hashtable_debug_hooks",
":hashtablez_sampler",
@@ -736,9 +732,8 @@
"//absl/memory",
"//absl/meta:type_traits",
"//absl/strings",
- "//absl/types:optional",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -757,7 +752,7 @@
"//absl/base:raw_logging_internal",
"//absl/random",
"//absl/strings:str_format",
- "@google_benchmark//:benchmark_main",
+ "@com_github_google_benchmark//:benchmark_main",
],
)
@@ -796,8 +791,8 @@
":raw_hash_set",
":tracked",
"//absl/base:config",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -831,8 +826,8 @@
"//absl/log:check",
"//absl/types:span",
"//absl/utility",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -848,7 +843,7 @@
":layout",
"//absl/base:core_headers",
"//absl/base:raw_logging_internal",
- "@google_benchmark//:benchmark_main",
+ "@com_github_google_benchmark//:benchmark_main",
],
)
@@ -872,7 +867,7 @@
deps = [
":hash_generator_testing",
":hash_policy_testing",
- "@googletest//:gtest",
+ "@com_google_googletest//:gtest",
],
)
@@ -885,7 +880,7 @@
deps = [
":hash_generator_testing",
":hash_policy_testing",
- "@googletest//:gtest",
+ "@com_google_googletest//:gtest",
],
)
@@ -898,7 +893,7 @@
deps = [
":hash_generator_testing",
":hash_policy_testing",
- "@googletest//:gtest",
+ "@com_google_googletest//:gtest",
],
)
@@ -912,7 +907,7 @@
":hash_generator_testing",
":hash_policy_testing",
"//absl/meta:type_traits",
- "@googletest//:gtest",
+ "@com_google_googletest//:gtest",
],
)
@@ -924,7 +919,7 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
"//absl/meta:type_traits",
- "@googletest//:gtest",
+ "@com_google_googletest//:gtest",
],
)
@@ -936,7 +931,7 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
"//absl/meta:type_traits",
- "@googletest//:gtest",
+ "@com_google_googletest//:gtest",
],
)
@@ -949,7 +944,7 @@
deps = [
":hash_generator_testing",
":hash_policy_testing",
- "@googletest//:gtest",
+ "@com_google_googletest//:gtest",
],
)
@@ -962,7 +957,7 @@
deps = [
":hash_generator_testing",
":hash_policy_testing",
- "@googletest//:gtest",
+ "@com_google_googletest//:gtest",
],
)
@@ -977,8 +972,8 @@
":unordered_set_lookup_test",
":unordered_set_members_test",
":unordered_set_modifiers_test",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -993,8 +988,8 @@
":unordered_map_lookup_test",
":unordered_map_members_test",
":unordered_map_modifiers_test",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -1010,8 +1005,8 @@
":flat_hash_set",
":node_hash_map",
":node_hash_set",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -1092,8 +1087,8 @@
"//absl/strings",
"//absl/types:compare",
"//absl/types:optional",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -1122,7 +1117,7 @@
"//absl/strings:cord",
"//absl/strings:str_format",
"//absl/time",
- "@google_benchmark//:benchmark_main",
- "@googletest//:gtest",
+ "@com_github_google_benchmark//:benchmark_main",
+ "@com_google_googletest//:gtest",
],
)
diff --git a/absl/container/CMakeLists.txt b/absl/container/CMakeLists.txt
index 85a4ce2..25831d5 100644
--- a/absl/container/CMakeLists.txt
+++ b/absl/container/CMakeLists.txt
@@ -350,8 +350,6 @@
absl::config
absl::container_memory
absl::flat_hash_set
- absl::hash
- absl::hash_container_defaults
absl::hash_generator_testing
absl::memory
absl::strings
@@ -749,7 +747,6 @@
${ABSL_DEFAULT_COPTS}
DEPS
absl::bits
- absl::common_policy_traits
absl::compressed_tuple
absl::config
absl::container_common
@@ -758,7 +755,6 @@
absl::dynamic_annotations
absl::endian
absl::hash
- absl::hash_function_defaults
absl::hash_policy_traits
absl::hashtable_debug_hooks
absl::hashtablez_sampler
@@ -795,7 +791,6 @@
absl::log
absl::memory
absl::node_hash_set
- absl::optional
absl::prefetch
absl::raw_hash_set
absl::strings
diff --git a/absl/container/btree_map.h b/absl/container/btree_map.h
index 470de2a..b959b67 100644
--- a/absl/container/btree_map.h
+++ b/absl/container/btree_map.h
@@ -87,7 +87,7 @@
//
template <typename Key, typename Value, typename Compare = std::less<Key>,
typename Alloc = std::allocator<std::pair<const Key, Value>>>
-class ABSL_ATTRIBUTE_OWNER btree_map
+class ABSL_INTERNAL_ATTRIBUTE_OWNER btree_map
: public container_internal::btree_map_container<
container_internal::btree<container_internal::map_params<
Key, Value, Compare, Alloc, /*TargetNodeSize=*/256,
@@ -525,7 +525,7 @@
//
template <typename Key, typename Value, typename Compare = std::less<Key>,
typename Alloc = std::allocator<std::pair<const Key, Value>>>
-class ABSL_ATTRIBUTE_OWNER btree_multimap
+class ABSL_INTERNAL_ATTRIBUTE_OWNER btree_multimap
: public container_internal::btree_multimap_container<
container_internal::btree<container_internal::map_params<
Key, Value, Compare, Alloc, /*TargetNodeSize=*/256,
diff --git a/absl/container/btree_set.h b/absl/container/btree_set.h
index e57d6d9..986d27d 100644
--- a/absl/container/btree_set.h
+++ b/absl/container/btree_set.h
@@ -89,7 +89,7 @@
//
template <typename Key, typename Compare = std::less<Key>,
typename Alloc = std::allocator<Key>>
-class ABSL_ATTRIBUTE_OWNER btree_set
+class ABSL_INTERNAL_ATTRIBUTE_OWNER btree_set
: public container_internal::btree_set_container<
container_internal::btree<container_internal::set_params<
Key, Compare, Alloc, /*TargetNodeSize=*/256,
@@ -445,7 +445,7 @@
//
template <typename Key, typename Compare = std::less<Key>,
typename Alloc = std::allocator<Key>>
-class ABSL_ATTRIBUTE_OWNER btree_multiset
+class ABSL_INTERNAL_ATTRIBUTE_OWNER btree_multiset
: public container_internal::btree_multiset_container<
container_internal::btree<container_internal::set_params<
Key, Compare, Alloc, /*TargetNodeSize=*/256,
diff --git a/absl/container/btree_test.cc b/absl/container/btree_test.cc
index ef1b5bb..d7102fe 100644
--- a/absl/container/btree_test.cc
+++ b/absl/container/btree_test.cc
@@ -2949,7 +2949,6 @@
TEST(Btree, ConstructImplicitlyWithUnadaptedComparator) {
absl::btree_set<MultiKey, MultiKeyComp> set = {{}, MultiKeyComp{}};
- EXPECT_TRUE(set.empty());
}
TEST(Btree, InvalidComparatorsCaught) {
diff --git a/absl/container/fixed_array.h b/absl/container/fixed_array.h
index 95abb0a..9f1c813 100644
--- a/absl/container/fixed_array.h
+++ b/absl/container/fixed_array.h
@@ -41,7 +41,6 @@
#include <type_traits>
#include "absl/algorithm/algorithm.h"
-#include "absl/base/attributes.h"
#include "absl/base/config.h"
#include "absl/base/dynamic_annotations.h"
#include "absl/base/internal/throw_delegate.h"
@@ -75,7 +74,7 @@
// `std::vector`.
template <typename T, size_t N = kFixedArrayUseDefault,
typename A = std::allocator<T>>
-class ABSL_ATTRIBUTE_WARN_UNUSED FixedArray {
+class FixedArray {
static_assert(!std::is_array<T>::value || std::extent<T>::value > 0,
"Arrays with unknown bounds cannot be used with FixedArray.");
diff --git a/absl/container/fixed_array_test.cc b/absl/container/fixed_array_test.cc
index 331d702..2421b5f 100644
--- a/absl/container/fixed_array_test.cc
+++ b/absl/container/fixed_array_test.cc
@@ -419,7 +419,7 @@
EXPECT_THAT(stack_array, testing::ElementsAreArray({1, 1, 1, 1}));
absl::FixedArray<int, 0> heap_array(4, 1);
- EXPECT_THAT(heap_array, testing::ElementsAreArray({1, 1, 1, 1}));
+ EXPECT_THAT(stack_array, testing::ElementsAreArray({1, 1, 1, 1}));
}
TEST(FillConstructorTest, EmptyArray) {
@@ -518,10 +518,7 @@
}
};
-TEST(FixedArrayTest, UsesGlobalAlloc) {
- absl::FixedArray<PickyDelete, 0> a(5);
- EXPECT_EQ(a.size(), 5);
-}
+TEST(FixedArrayTest, UsesGlobalAlloc) { absl::FixedArray<PickyDelete, 0> a(5); }
TEST(FixedArrayTest, Data) {
static const int kInput[] = {2, 3, 5, 7, 11, 13, 17};
@@ -785,7 +782,6 @@
AllocFxdArr copy = arr;
EXPECT_EQ(allocated, len * sizeof(int) * 2);
- EXPECT_EQ(copy, arr);
}
#ifdef ABSL_HAVE_ADDRESS_SANITIZER
diff --git a/absl/container/flat_hash_map.h b/absl/container/flat_hash_map.h
index 735ee34..ebd9ed6 100644
--- a/absl/container/flat_hash_map.h
+++ b/absl/container/flat_hash_map.h
@@ -125,7 +125,7 @@
template <class K, class V, class Hash = DefaultHashContainerHash<K>,
class Eq = DefaultHashContainerEq<K>,
class Allocator = std::allocator<std::pair<const K, V>>>
-class ABSL_ATTRIBUTE_OWNER flat_hash_map
+class ABSL_INTERNAL_ATTRIBUTE_OWNER flat_hash_map
: public absl::container_internal::raw_hash_map<
absl::container_internal::FlatHashMapPolicy<K, V>, Hash, Eq,
Allocator> {
@@ -426,7 +426,8 @@
// flat_hash_map::swap(flat_hash_map& other)
//
// Exchanges the contents of this `flat_hash_map` with those of the `other`
- // flat hash map.
+ // flat hash map, avoiding invocation of any move, copy, or swap operations on
+ // individual elements.
//
// All iterators and references on the `flat_hash_map` remain valid, excepting
// for the past-the-end iterator, which is invalidated.
@@ -573,21 +574,6 @@
return container_internal::EraseIf(pred, &c);
}
-// swap(flat_hash_map<>, flat_hash_map<>)
-//
-// Swaps the contents of two `flat_hash_map` containers.
-//
-// NOTE: we need to define this function template in order for
-// `flat_hash_set::swap` to be called instead of `std::swap`. Even though we
-// have `swap(raw_hash_set&, raw_hash_set&)` defined, that function requires a
-// derived-to-base conversion, whereas `std::swap` is a function template so
-// `std::swap` will be preferred by compiler.
-template <typename K, typename V, typename H, typename E, typename A>
-void swap(flat_hash_map<K, V, H, E, A>& x,
- flat_hash_map<K, V, H, E, A>& y) noexcept(noexcept(x.swap(y))) {
- x.swap(y);
-}
-
namespace container_internal {
// c_for_each_fast(flat_hash_map<>, Function)
diff --git a/absl/container/flat_hash_set.h b/absl/container/flat_hash_set.h
index b5d0f7f..a3e36e0 100644
--- a/absl/container/flat_hash_set.h
+++ b/absl/container/flat_hash_set.h
@@ -122,7 +122,7 @@
template <class T, class Hash = DefaultHashContainerHash<T>,
class Eq = DefaultHashContainerEq<T>,
class Allocator = std::allocator<T>>
-class ABSL_ATTRIBUTE_OWNER flat_hash_set
+class ABSL_INTERNAL_ATTRIBUTE_OWNER flat_hash_set
: public absl::container_internal::raw_hash_set<
absl::container_internal::FlatHashSetPolicy<T>, Hash, Eq, Allocator> {
using Base = typename flat_hash_set::raw_hash_set;
@@ -360,7 +360,8 @@
// flat_hash_set::swap(flat_hash_set& other)
//
// Exchanges the contents of this `flat_hash_set` with those of the `other`
- // flat hash set.
+ // flat hash set, avoiding invocation of any move, copy, or swap operations on
+ // individual elements.
//
// All iterators and references on the `flat_hash_set` remain valid, excepting
// for the past-the-end iterator, which is invalidated.
@@ -477,21 +478,6 @@
return container_internal::EraseIf(pred, &c);
}
-// swap(flat_hash_set<>, flat_hash_set<>)
-//
-// Swaps the contents of two `flat_hash_set` containers.
-//
-// NOTE: we need to define this function template in order for
-// `flat_hash_set::swap` to be called instead of `std::swap`. Even though we
-// have `swap(raw_hash_set&, raw_hash_set&)` defined, that function requires a
-// derived-to-base conversion, whereas `std::swap` is a function template so
-// `std::swap` will be preferred by compiler.
-template <typename T, typename H, typename E, typename A>
-void swap(flat_hash_set<T, H, E, A>& x,
- flat_hash_set<T, H, E, A>& y) noexcept(noexcept(x.swap(y))) {
- return x.swap(y);
-}
-
namespace container_internal {
// c_for_each_fast(flat_hash_set<>, Function)
diff --git a/absl/container/flat_hash_set_test.cc b/absl/container/flat_hash_set_test.cc
index 68ea7a0..0dd4326 100644
--- a/absl/container/flat_hash_set_test.cc
+++ b/absl/container/flat_hash_set_test.cc
@@ -14,10 +14,8 @@
#include "absl/container/flat_hash_set.h"
-#include <cstddef>
#include <cstdint>
#include <memory>
-#include <string>
#include <type_traits>
#include <utility>
#include <vector>
@@ -25,7 +23,6 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "absl/base/config.h"
-#include "absl/container/hash_container_defaults.h"
#include "absl/container/internal/container_memory.h"
#include "absl/container/internal/hash_generator_testing.h"
#include "absl/container/internal/test_allocator.h"
@@ -33,7 +30,6 @@
#include "absl/container/internal/unordered_set_lookup_test.h"
#include "absl/container/internal/unordered_set_members_test.h"
#include "absl/container/internal/unordered_set_modifiers_test.h"
-#include "absl/hash/hash.h"
#include "absl/log/check.h"
#include "absl/memory/memory.h"
#include "absl/strings/string_view.h"
@@ -295,62 +291,6 @@
std::allocator<int>>(nullptr, nullptr))()));
}
-struct HashEqInvalidOnMove {
- HashEqInvalidOnMove() = default;
- HashEqInvalidOnMove(const HashEqInvalidOnMove& rhs) = default;
- HashEqInvalidOnMove(HashEqInvalidOnMove&& rhs) { rhs.moved = true; }
- HashEqInvalidOnMove& operator=(const HashEqInvalidOnMove& rhs) = default;
- HashEqInvalidOnMove& operator=(HashEqInvalidOnMove&& rhs) {
- rhs.moved = true;
- return *this;
- }
-
- size_t operator()(int x) const {
- CHECK(!moved);
- return absl::HashOf(x);
- }
-
- bool operator()(int x, int y) const {
- CHECK(!moved);
- return x == y;
- }
-
- bool moved = false;
-};
-
-TEST(FlatHashSet, MovedFromCleared_HashMustBeValid) {
- flat_hash_set<int, HashEqInvalidOnMove> s1, s2;
- // Moving the hashtable must not move the hasher because we need to support
- // this behavior.
- s2 = std::move(s1);
- s1.clear();
- s1.insert(2);
- EXPECT_THAT(s1, UnorderedElementsAre(2));
-}
-
-TEST(FlatHashSet, MovedFromCleared_EqMustBeValid) {
- flat_hash_set<int, DefaultHashContainerHash<int>, HashEqInvalidOnMove> s1, s2;
- // Moving the hashtable must not move the equality functor because we need to
- // support this behavior.
- s2 = std::move(s1);
- s1.clear();
- s1.insert(2);
- EXPECT_THAT(s1, UnorderedElementsAre(2));
-}
-
-TEST(FlatHashSet, Equality) {
- {
- flat_hash_set<int> s1 = {1, 2, 3};
- flat_hash_set<int> s2 = {1, 2, 3};
- EXPECT_EQ(s1, s2);
- }
- {
- flat_hash_set<std::string> s1 = {"a", "b", "c"};
- flat_hash_set<std::string> s2 = {"a", "b", "c"};
- EXPECT_EQ(s1, s2);
- }
-}
-
} // namespace
} // namespace container_internal
ABSL_NAMESPACE_END
diff --git a/absl/container/inlined_vector.h b/absl/container/inlined_vector.h
index cbf8bc2..974b652 100644
--- a/absl/container/inlined_vector.h
+++ b/absl/container/inlined_vector.h
@@ -46,7 +46,6 @@
#include <utility>
#include "absl/algorithm/algorithm.h"
-#include "absl/base/attributes.h"
#include "absl/base/internal/throw_delegate.h"
#include "absl/base/macros.h"
#include "absl/base/optimization.h"
@@ -68,7 +67,7 @@
// as a `std::vector`. The API of the `absl::InlinedVector` within this file is
// designed to cover the same API footprint as covered by `std::vector`.
template <typename T, size_t N, typename A = std::allocator<T>>
-class ABSL_ATTRIBUTE_WARN_UNUSED InlinedVector {
+class InlinedVector {
static_assert(N > 0, "`absl::InlinedVector` requires an inlined capacity.");
using Storage = inlined_vector_internal::Storage<T, N, A>;
diff --git a/absl/container/inlined_vector_test.cc b/absl/container/inlined_vector_test.cc
index 54cd310..6954262 100644
--- a/absl/container/inlined_vector_test.cc
+++ b/absl/container/inlined_vector_test.cc
@@ -1190,7 +1190,6 @@
tracker.ResetCopiesMovesSwaps();
{ // Copy constructor should create 'len' more instances.
InstanceVec v_copy(v);
- EXPECT_EQ(v_copy.size(), v.size());
EXPECT_EQ(tracker.instances(), len + len);
EXPECT_EQ(tracker.copies(), len);
EXPECT_EQ(tracker.moves(), 0);
@@ -1218,7 +1217,6 @@
tracker.ResetCopiesMovesSwaps();
{
InstanceVec v_copy(std::move(v));
- EXPECT_EQ(v_copy.size(), len);
if (static_cast<size_t>(len) > inlined_capacity) {
// Allocation is moved as a whole.
EXPECT_EQ(tracker.instances(), len);
@@ -1749,80 +1747,61 @@
using MyAlloc = CountingAllocator<int>;
using AllocVec = absl::InlinedVector<int, 4, MyAlloc>;
const int ia[] = {0, 1, 2, 3, 4, 5, 6, 7};
- int64_t bytes_allocated = 0;
- int64_t instance_count = 0;
- MyAlloc alloc(&bytes_allocated, &instance_count);
+ int64_t allocated = 0;
+ MyAlloc alloc(&allocated);
{
AllocVec ABSL_ATTRIBUTE_UNUSED v(ia, ia + 4, alloc);
- EXPECT_THAT(bytes_allocated, Eq(0));
- EXPECT_THAT(instance_count, Eq(4));
+ EXPECT_THAT(allocated, Eq(0));
}
- EXPECT_THAT(bytes_allocated, Eq(0));
- EXPECT_THAT(instance_count, Eq(0));
+ EXPECT_THAT(allocated, Eq(0));
{
AllocVec ABSL_ATTRIBUTE_UNUSED v(ia, ia + ABSL_ARRAYSIZE(ia), alloc);
- EXPECT_THAT(bytes_allocated,
- Eq(static_cast<int64_t>(v.size() * sizeof(int))));
- EXPECT_THAT(instance_count, Eq(static_cast<int64_t>(v.size())));
+ EXPECT_THAT(allocated, Eq(static_cast<int64_t>(v.size() * sizeof(int))));
}
- EXPECT_THAT(bytes_allocated, Eq(0));
- EXPECT_THAT(instance_count, Eq(0));
+ EXPECT_THAT(allocated, Eq(0));
{
AllocVec v(4, 1, alloc);
- EXPECT_THAT(bytes_allocated, Eq(0));
- EXPECT_THAT(instance_count, Eq(4));
+ EXPECT_THAT(allocated, Eq(0));
- int64_t bytes_allocated2 = 0;
- MyAlloc alloc2(&bytes_allocated2);
- ABSL_ATTRIBUTE_UNUSED AllocVec v2(v, alloc2);
- EXPECT_THAT(bytes_allocated2, Eq(0));
+ int64_t allocated2 = 0;
+ MyAlloc alloc2(&allocated2);
+ AllocVec v2(v, alloc2);
+ EXPECT_THAT(allocated2, Eq(0));
- int64_t bytes_allocated3 = 0;
- MyAlloc alloc3(&bytes_allocated3);
- ABSL_ATTRIBUTE_UNUSED AllocVec v3(std::move(v), alloc3);
- EXPECT_THAT(bytes_allocated3, Eq(0));
+ int64_t allocated3 = 0;
+ MyAlloc alloc3(&allocated3);
+ AllocVec v3(std::move(v), alloc3);
+ EXPECT_THAT(allocated3, Eq(0));
}
- EXPECT_THAT(bytes_allocated, Eq(0));
- EXPECT_THAT(instance_count, Eq(0));
+ EXPECT_THAT(allocated, 0);
{
AllocVec v(8, 2, alloc);
- EXPECT_THAT(bytes_allocated,
- Eq(static_cast<int64_t>(v.size() * sizeof(int))));
- EXPECT_THAT(instance_count, Eq(static_cast<int64_t>(v.size())));
+ EXPECT_THAT(allocated, Eq(static_cast<int64_t>(v.size() * sizeof(int))));
- int64_t bytes_allocated2 = 0;
- MyAlloc alloc2(&bytes_allocated2);
+ int64_t allocated2 = 0;
+ MyAlloc alloc2(&allocated2);
AllocVec v2(v, alloc2);
- EXPECT_THAT(bytes_allocated2,
- Eq(static_cast<int64_t>(v2.size() * sizeof(int))));
+ EXPECT_THAT(allocated2, Eq(static_cast<int64_t>(v2.size() * sizeof(int))));
- int64_t bytes_allocated3 = 0;
- MyAlloc alloc3(&bytes_allocated3);
+ int64_t allocated3 = 0;
+ MyAlloc alloc3(&allocated3);
AllocVec v3(std::move(v), alloc3);
- EXPECT_THAT(bytes_allocated3,
- Eq(static_cast<int64_t>(v3.size() * sizeof(int))));
+ EXPECT_THAT(allocated3, Eq(static_cast<int64_t>(v3.size() * sizeof(int))));
}
- EXPECT_EQ(bytes_allocated, 0);
- EXPECT_EQ(instance_count, 0);
+ EXPECT_EQ(allocated, 0);
{
// Test shrink_to_fit deallocations.
AllocVec v(8, 2, alloc);
- EXPECT_EQ(bytes_allocated, static_cast<int64_t>(8 * sizeof(int)));
- EXPECT_EQ(instance_count, 8);
+ EXPECT_EQ(allocated, static_cast<int64_t>(8 * sizeof(int)));
v.resize(5);
- EXPECT_EQ(bytes_allocated, static_cast<int64_t>(8 * sizeof(int)));
- EXPECT_EQ(instance_count, 5);
+ EXPECT_EQ(allocated, static_cast<int64_t>(8 * sizeof(int)));
v.shrink_to_fit();
- EXPECT_EQ(bytes_allocated, static_cast<int64_t>(5 * sizeof(int)));
- EXPECT_EQ(instance_count, 5);
+ EXPECT_EQ(allocated, static_cast<int64_t>(5 * sizeof(int)));
v.resize(4);
- EXPECT_EQ(bytes_allocated, static_cast<int64_t>(5 * sizeof(int)));
- EXPECT_EQ(instance_count, 4);
+ EXPECT_EQ(allocated, static_cast<int64_t>(5 * sizeof(int)));
v.shrink_to_fit();
- EXPECT_EQ(bytes_allocated, 0);
- EXPECT_EQ(instance_count, 4);
+ EXPECT_EQ(allocated, 0);
}
- EXPECT_EQ(instance_count, 0);
}
TEST(AllocatorSupportTest, SwapBothAllocated) {
diff --git a/absl/container/internal/common_policy_traits.h b/absl/container/internal/common_policy_traits.h
index bbf5475..c521f61 100644
--- a/absl/container/internal/common_policy_traits.h
+++ b/absl/container/internal/common_policy_traits.h
@@ -28,15 +28,6 @@
ABSL_NAMESPACE_BEGIN
namespace container_internal {
-template <class Policy, class = void>
-struct policy_trait_element_is_owner : std::false_type {};
-
-template <class Policy>
-struct policy_trait_element_is_owner<
- Policy,
- std::enable_if_t<!std::is_void<typename Policy::element_is_owner>::value>>
- : Policy::element_is_owner {};
-
// Defines how slots are initialized/destroyed/moved.
template <class Policy, class = void>
struct common_policy_traits {
diff --git a/absl/container/internal/container_memory.h b/absl/container/internal/container_memory.h
index e703179..ba8e08a 100644
--- a/absl/container/internal/container_memory.h
+++ b/absl/container/internal/container_memory.h
@@ -17,7 +17,6 @@
#include <cassert>
#include <cstddef>
-#include <cstdint>
#include <cstring>
#include <memory>
#include <new>
diff --git a/absl/container/internal/inlined_vector.h b/absl/container/internal/inlined_vector.h
index 0bd0a1c..2f24e46 100644
--- a/absl/container/internal/inlined_vector.h
+++ b/absl/container/internal/inlined_vector.h
@@ -83,10 +83,8 @@
template <typename A>
using IsSwapOk = absl::type_traits_internal::IsSwappable<ValueType<A>>;
-template <typename A,
- bool IsTriviallyDestructible =
- absl::is_trivially_destructible<ValueType<A>>::value &&
- std::is_same<A, std::allocator<ValueType<A>>>::value>
+template <typename A, bool IsTriviallyDestructible =
+ absl::is_trivially_destructible<ValueType<A>>::value>
struct DestroyAdapter;
template <typename A>
diff --git a/absl/container/internal/layout.h b/absl/container/internal/layout.h
index d56a28d..f04c717 100644
--- a/absl/container/internal/layout.h
+++ b/absl/container/internal/layout.h
@@ -305,7 +305,7 @@
template <class T>
std::string TypeName() {
std::string out;
-#ifdef ABSL_INTERNAL_HAS_RTTI
+#if ABSL_INTERNAL_HAS_RTTI
absl::StrAppend(&out, "<",
absl::debugging_internal::DemangleString(typeid(T).name()),
">");
diff --git a/absl/container/internal/raw_hash_set.cc b/absl/container/internal/raw_hash_set.cc
index 8911aa3..1cae038 100644
--- a/absl/container/internal/raw_hash_set.cc
+++ b/absl/container/internal/raw_hash_set.cc
@@ -24,12 +24,10 @@
#include "absl/base/config.h"
#include "absl/base/dynamic_annotations.h"
#include "absl/base/internal/endian.h"
-#include "absl/base/internal/raw_logging.h"
#include "absl/base/optimization.h"
#include "absl/container/internal/container_memory.h"
#include "absl/container/internal/hashtablez_sampler.h"
#include "absl/hash/hash.h"
-#include "absl/numeric/bits.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
@@ -98,16 +96,6 @@
RehashProbabilityConstant();
}
-// Find a non-deterministic hash for single group table.
-// Last two bits are used to find a position for a newly inserted element after
-// resize.
-// This function is mixing all bits of hash and control pointer to maximize
-// entropy.
-size_t SingleGroupTableH1(size_t hash, ctrl_t* control) {
- return static_cast<size_t>(absl::popcount(
- hash ^ static_cast<size_t>(reinterpret_cast<uintptr_t>(control))));
-}
-
} // namespace
GenerationType* EmptyGeneration() {
@@ -147,7 +135,7 @@
// index 1 occupied, so we need to insert either at index 0 or index 2.
assert(HashSetResizeHelper::SooSlotIndex() == 1);
PrepareInsertCommon(common);
- const size_t offset = SingleGroupTableH1(hash, common.control()) & 2;
+ const size_t offset = H1(hash, common.control()) & 2;
common.growth_info().OverwriteEmptyAsFull();
SetCtrlInSingleGroupTable(common, offset, H2(hash), slot_size);
common.infoz().RecordInsert(hash, /*distance_from_desired=*/0);
@@ -350,7 +338,7 @@
c.infoz().RecordClearedReservation();
c.infoz().RecordStorageChanged(0, soo_enabled ? SooCapacity() : 0);
(*policy.dealloc)(c, policy);
- c = soo_enabled ? CommonFields{soo_tag_t{}} : CommonFields{non_soo_tag_t{}};
+ c = soo_enabled ? CommonFields{soo_tag_t{}} : CommonFields{};
}
}
@@ -358,124 +346,124 @@
ctrl_t* __restrict new_ctrl, size_t new_capacity) const {
assert(is_single_group(new_capacity));
constexpr size_t kHalfWidth = Group::kWidth / 2;
- ABSL_ASSUME(old_capacity_ < kHalfWidth);
- ABSL_ASSUME(old_capacity_ > 0);
- static_assert(Group::kWidth == 8 || Group::kWidth == 16,
- "Group size is not supported.");
+ constexpr size_t kQuarterWidth = Group::kWidth / 4;
+ assert(old_capacity_ < kHalfWidth);
+ static_assert(sizeof(uint64_t) >= kHalfWidth,
+ "Group size is too large. The ctrl bytes for half a group must "
+ "fit into a uint64_t for this implementation.");
+ static_assert(sizeof(uint64_t) <= Group::kWidth,
+ "Group size is too small. The ctrl bytes for a group must "
+ "cover a uint64_t for this implementation.");
- // NOTE: operations are done with compile time known size = 8.
+ const size_t half_old_capacity = old_capacity_ / 2;
+
+ // NOTE: operations are done with compile time known size = kHalfWidth.
// Compiler optimizes that into single ASM operation.
- // Load the bytes from old_capacity. This contains
- // - the sentinel byte
- // - all the old control bytes
- // - the rest is filled with kEmpty bytes
- // Example:
- // old_ctrl = 012S012EEEEEEEEE...
- // copied_bytes = S012EEEE
- uint64_t copied_bytes =
- absl::little_endian::Load64(old_ctrl() + old_capacity_);
+ // Load the bytes from half_old_capacity + 1. This contains the last half of
+ // old_ctrl bytes, followed by the sentinel byte, and then the first half of
+ // the cloned bytes. This effectively shuffles the control bytes.
+ uint64_t copied_bytes = 0;
+ copied_bytes =
+ absl::little_endian::Load64(old_ctrl() + half_old_capacity + 1);
// We change the sentinel byte to kEmpty before storing to both the start of
// the new_ctrl, and past the end of the new_ctrl later for the new cloned
// bytes. Note that this is faster than setting the sentinel byte to kEmpty
// after the copy directly in new_ctrl because we are limited on store
// bandwidth.
- static constexpr uint64_t kEmptyXorSentinel =
+ constexpr uint64_t kEmptyXorSentinel =
static_cast<uint8_t>(ctrl_t::kEmpty) ^
static_cast<uint8_t>(ctrl_t::kSentinel);
+ const uint64_t mask_convert_old_sentinel_to_empty =
+ kEmptyXorSentinel << (half_old_capacity * 8);
+ copied_bytes ^= mask_convert_old_sentinel_to_empty;
- // Replace the first byte kSentinel with kEmpty.
- // Resulting bytes will be shifted by one byte old control blocks.
- // Example:
- // old_ctrl = 012S012EEEEEEEEE...
- // before = S012EEEE
- // after = E012EEEE
- copied_bytes ^= kEmptyXorSentinel;
-
- if (Group::kWidth == 8) {
- // With group size 8, we can grow with two write operations.
- assert(old_capacity_ < 8 && "old_capacity_ is too large for group size 8");
- absl::little_endian::Store64(new_ctrl, copied_bytes);
-
- static constexpr uint64_t kSentinal64 =
- static_cast<uint8_t>(ctrl_t::kSentinel);
-
- // Prepend kSentinel byte to the beginning of copied_bytes.
- // We have maximum 3 non-empty bytes at the beginning of copied_bytes for
- // group size 8.
- // Example:
- // old_ctrl = 012S012EEEE
- // before = E012EEEE
- // after = SE012EEE
- copied_bytes = (copied_bytes << 8) ^ kSentinal64;
- absl::little_endian::Store64(new_ctrl + new_capacity, copied_bytes);
- // Example for capacity 3:
- // old_ctrl = 012S012EEEE
- // After the first store:
- // >!
- // new_ctrl = E012EEEE???????
- // After the second store:
- // >!
- // new_ctrl = E012EEESE012EEE
- return;
- }
-
- assert(Group::kWidth == 16);
-
- // Fill the second half of the main control bytes with kEmpty.
- // For small capacity that may write into mirrored control bytes.
- // It is fine as we will overwrite all the bytes later.
- std::memset(new_ctrl + kHalfWidth, static_cast<int8_t>(ctrl_t::kEmpty),
- kHalfWidth);
- // Fill the second half of the mirrored control bytes with kEmpty.
- std::memset(new_ctrl + new_capacity + kHalfWidth,
- static_cast<int8_t>(ctrl_t::kEmpty), kHalfWidth);
- // Copy the first half of the non-mirrored control bytes.
+ // Copy second half of bytes to the beginning. This correctly sets the bytes
+ // [0, old_capacity]. We potentially copy more bytes in order to have compile
+ // time known size. Mirrored bytes from the old_ctrl() will also be copied. In
+ // case of old_capacity_ == 3, we will copy 1st element twice.
+ // Examples:
+ // (old capacity = 1)
+ // old_ctrl = 0S0EEEEEEE...
+ // new_ctrl = E0EEEEEE??...
+ //
+ // (old capacity = 3)
+ // old_ctrl = 012S012EEEEE...
+ // new_ctrl = 12E012EE????...
+ //
+ // (old capacity = 7)
+ // old_ctrl = 0123456S0123456EE...
+ // new_ctrl = 456E0123?????????...
absl::little_endian::Store64(new_ctrl, copied_bytes);
- new_ctrl[new_capacity] = ctrl_t::kSentinel;
- // Copy the first half of the mirrored control bytes.
+
+ // Set the space [old_capacity + 1, new_capacity] to empty as these bytes will
+ // not be written again. This is safe because
+ // NumControlBytes = new_capacity + kWidth and new_capacity >=
+ // old_capacity+1.
+ // Examples:
+ // (old_capacity = 3, new_capacity = 15)
+ // new_ctrl = 12E012EE?????????????...??
+ // *new_ctrl = 12E0EEEEEEEEEEEEEEEE?...??
+ // position / S
+ //
+ // (old_capacity = 7, new_capacity = 15)
+ // new_ctrl = 456E0123?????????????????...??
+ // *new_ctrl = 456E0123EEEEEEEEEEEEEEEE?...??
+ // position / S
+ std::memset(new_ctrl + old_capacity_ + 1, static_cast<int8_t>(ctrl_t::kEmpty),
+ Group::kWidth);
+
+ // Set the last kHalfWidth bytes to empty, to ensure the bytes all the way to
+ // the end are initialized.
+ // Examples:
+ // new_ctrl = 12E0EEEEEEEEEEEEEEEE?...???????
+ // *new_ctrl = 12E0EEEEEEEEEEEEEEEE???EEEEEEEE
+ // position S /
+ //
+ // new_ctrl = 456E0123EEEEEEEEEEEEEEEE???????
+ // *new_ctrl = 456E0123EEEEEEEEEEEEEEEEEEEEEEE
+ // position S /
+ std::memset(new_ctrl + NumControlBytes(new_capacity) - kHalfWidth,
+ static_cast<int8_t>(ctrl_t::kEmpty), kHalfWidth);
+
+ // Copy the first bytes to the end (starting at new_capacity +1) to set the
+ // cloned bytes. Note that we use the already copied bytes from old_ctrl here
+ // rather than copying from new_ctrl to avoid a Read-after-Write hazard, since
+ // new_ctrl was just written to. The first old_capacity-1 bytes are set
+ // correctly. Then there may be up to old_capacity bytes that need to be
+ // overwritten, and any remaining bytes will be correctly set to empty. This
+ // sets [new_capacity + 1, new_capacity +1 + old_capacity] correctly.
+ // Examples:
+ // new_ctrl = 12E0EEEEEEEEEEEEEEEE?...???????
+ // *new_ctrl = 12E0EEEEEEEEEEEE12E012EEEEEEEEE
+ // position S/
+ //
+ // new_ctrl = 456E0123EEEEEEEE?...???EEEEEEEE
+ // *new_ctrl = 456E0123EEEEEEEE456E0123EEEEEEE
+ // position S/
absl::little_endian::Store64(new_ctrl + new_capacity + 1, copied_bytes);
- // Example for growth capacity 1->3:
- // old_ctrl = 0S0EEEEEEEEEEEEEE
- // new_ctrl at the end = E0ESE0EEEEEEEEEEEEE
- // >!
- // new_ctrl after 1st memset = ????????EEEEEEEE???
- // >!
- // new_ctrl after 2nd memset = ????????EEEEEEEEEEE
- // >!
- // new_ctrl after 1st store = E0EEEEEEEEEEEEEEEEE
- // new_ctrl after kSentinel = E0ESEEEEEEEEEEEEEEE
- // >!
- // new_ctrl after 2nd store = E0ESE0EEEEEEEEEEEEE
+ // Set The remaining bytes at the end past the cloned bytes to empty. The
+ // incorrectly set bytes are [new_capacity + old_capacity + 2,
+ // min(new_capacity + 1 + kHalfWidth, new_capacity + old_capacity + 2 +
+ // half_old_capacity)]. Taking the difference, we need to set min(kHalfWidth -
+ // (old_capacity + 1), half_old_capacity)]. Since old_capacity < kHalfWidth,
+ // half_old_capacity < kQuarterWidth, so we set kQuarterWidth beginning at
+ // new_capacity + old_capacity + 2 to kEmpty.
+ // Examples:
+ // new_ctrl = 12E0EEEEEEEEEEEE12E012EEEEEEEEE
+ // *new_ctrl = 12E0EEEEEEEEEEEE12E0EEEEEEEEEEE
+ // position S /
+ //
+ // new_ctrl = 456E0123EEEEEEEE456E0123EEEEEEE
+ // *new_ctrl = 456E0123EEEEEEEE456E0123EEEEEEE (no change)
+ // position S /
+ std::memset(new_ctrl + new_capacity + old_capacity_ + 2,
+ static_cast<int8_t>(ctrl_t::kEmpty), kQuarterWidth);
- // Example for growth capacity 3->7:
- // old_ctrl = 012S012EEEEEEEEEEEE
- // new_ctrl at the end = E012EEESE012EEEEEEEEEEE
- // >!
- // new_ctrl after 1st memset = ????????EEEEEEEE???????
- // >!
- // new_ctrl after 2nd memset = ????????EEEEEEEEEEEEEEE
- // >!
- // new_ctrl after 1st store = E012EEEEEEEEEEEEEEEEEEE
- // new_ctrl after kSentinel = E012EEESEEEEEEEEEEEEEEE
- // >!
- // new_ctrl after 2nd store = E012EEESE012EEEEEEEEEEE
-
-
- // Example for growth capacity 7->15:
- // old_ctrl = 0123456S0123456EEEEEEEE
- // new_ctrl at the end = E0123456EEEEEEESE0123456EEEEEEE
- // >!
- // new_ctrl after 1st memset = ????????EEEEEEEE???????????????
- // >!
- // new_ctrl after 2nd memset = ????????EEEEEEEE???????EEEEEEEE
- // >!
- // new_ctrl after 1st store = E0123456EEEEEEEE???????EEEEEEEE
- // new_ctrl after kSentinel = E0123456EEEEEEES???????EEEEEEEE
- // >!
- // new_ctrl after 2nd store = E0123456EEEEEEESE0123456EEEEEEE
+ // Finally, we set the new sentinel byte.
+ new_ctrl[new_capacity] = ctrl_t::kSentinel;
}
void HashSetResizeHelper::InitControlBytesAfterSoo(ctrl_t* new_ctrl, ctrl_t h2,
@@ -492,10 +480,15 @@
void HashSetResizeHelper::GrowIntoSingleGroupShuffleTransferableSlots(
void* new_slots, size_t slot_size) const {
- ABSL_ASSUME(old_capacity_ > 0);
+ assert(old_capacity_ > 0);
+ const size_t half_old_capacity = old_capacity_ / 2;
+
SanitizerUnpoisonMemoryRegion(old_slots(), slot_size * old_capacity_);
- std::memcpy(SlotAddress(new_slots, 1, slot_size), old_slots(),
- slot_size * old_capacity_);
+ std::memcpy(new_slots,
+ SlotAddress(old_slots(), half_old_capacity + 1, slot_size),
+ slot_size * half_old_capacity);
+ std::memcpy(SlotAddress(new_slots, half_old_capacity + 1, slot_size),
+ old_slots(), slot_size * (half_old_capacity + 1));
}
void HashSetResizeHelper::GrowSizeIntoSingleGroupTransferable(
@@ -595,23 +588,6 @@
return &common;
}
-FindInfo HashSetResizeHelper::FindFirstNonFullAfterResize(const CommonFields& c,
- size_t old_capacity,
- size_t hash) {
- size_t new_capacity = c.capacity();
- if (!IsGrowingIntoSingleGroupApplicable(old_capacity, new_capacity)) {
- return find_first_non_full(c, hash);
- }
-
- // We put the new element either at the beginning or at the end of the table
- // with approximately equal probability.
- size_t offset =
- SingleGroupTableH1(hash, c.control()) & 1 ? 0 : new_capacity - 1;
-
- assert(IsEmpty(c.control()[offset]));
- return FindInfo{offset, 0};
-}
-
size_t PrepareInsertNonSoo(CommonFields& common, size_t hash, FindInfo target,
const PolicyFunctions& policy) {
// When there are no deleted slots in the table
@@ -662,10 +638,6 @@
return target.offset;
}
-void HashTableSizeOverflow() {
- ABSL_RAW_LOG(FATAL, "Hash table size overflow");
-}
-
} // namespace container_internal
ABSL_NAMESPACE_END
} // namespace absl
diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h
index 79ccb59..d4fe8f5 100644
--- a/absl/container/internal/raw_hash_set.h
+++ b/absl/container/internal/raw_hash_set.h
@@ -41,6 +41,12 @@
// When heterogeneous lookup is disabled, only the explicit `key_type` overloads
// exist.
//
+// find() also supports passing the hash explicitly:
+//
+// iterator find(const key_type& key, size_t hash);
+// template <class U>
+// iterator find(const U& key, size_t hash);
+//
// In addition the pointer to element and iterator stability guarantees are
// weaker: all iterators and pointers are invalidated after a new element is
// inserted.
@@ -184,7 +190,6 @@
#include <cstddef>
#include <cstdint>
#include <cstring>
-#include <functional>
#include <initializer_list>
#include <iterator>
#include <limits>
@@ -203,14 +208,11 @@
#include "absl/base/port.h"
#include "absl/base/prefetch.h"
#include "absl/container/internal/common.h" // IWYU pragma: export // for node_handle
-#include "absl/container/internal/common_policy_traits.h"
#include "absl/container/internal/compressed_tuple.h"
#include "absl/container/internal/container_memory.h"
-#include "absl/container/internal/hash_function_defaults.h"
#include "absl/container/internal/hash_policy_traits.h"
#include "absl/container/internal/hashtable_debug_hooks.h"
#include "absl/container/internal/hashtablez_sampler.h"
-#include "absl/hash/hash.h"
#include "absl/memory/memory.h"
#include "absl/meta/type_traits.h"
#include "absl/numeric/bits.h"
@@ -250,15 +252,6 @@
#define ABSL_SWISSTABLE_ENABLE_GENERATIONS
#endif
-#ifdef ABSL_SWISSTABLE_ASSERT
-#error ABSL_SWISSTABLE_ASSERT cannot be directly set
-#else
-// We use this macro for assertions that users may see when the table is in an
-// invalid state that sanitizers may help diagnose.
-#define ABSL_SWISSTABLE_ASSERT(CONDITION) \
- assert((CONDITION) && "Try enabling sanitizers.")
-#endif
-
// We use uint8_t so we don't need to worry about padding.
using GenerationType = uint8_t;
@@ -329,7 +322,7 @@
// sequence and `mask` (usually the capacity of the table) as the mask to
// apply to each value in the progression.
probe_seq(size_t hash, size_t mask) {
- ABSL_SWISSTABLE_ASSERT(((mask + 1) & mask) == 0 && "not a mask");
+ assert(((mask + 1) & mask) == 0 && "not a mask");
mask_ = mask;
offset_ = hash & mask_;
}
@@ -459,7 +452,7 @@
public:
explicit BitMask(T mask) : Base(mask) {
if (Shift == 3 && !NullifyBitsOnIteration) {
- ABSL_SWISSTABLE_ASSERT(this->mask_ == (this->mask_ & kMsbs8Bytes));
+ assert(this->mask_ == (this->mask_ & kMsbs8Bytes));
}
}
// BitMask is an iterator over the indices of its abstract bits.
@@ -543,18 +536,6 @@
// See definition comment for why this is size 32.
ABSL_DLL extern const ctrl_t kEmptyGroup[32];
-// We use these sentinel capacity values in debug mode to indicate different
-// classes of bugs.
-enum InvalidCapacity : size_t {
- kAboveMaxValidCapacity = ~size_t{} - 100,
- kReentrance,
- kDestroyed,
-
- // These two must be last because we use `>= kMovedFrom` to mean moved-from.
- kMovedFrom,
- kSelfMovedFrom,
-};
-
// Returns a pointer to a control byte group that can be used by empty tables.
inline ctrl_t* EmptyGroup() {
// Const must be cast away here; no uses of this function will actually write
@@ -706,8 +687,10 @@
// Returns a bitmask representing the positions of slots that match hash.
BitMask<uint16_t, kWidth> Match(h2_t hash) const {
auto match = _mm_set1_epi8(static_cast<char>(hash));
- return BitMask<uint16_t, kWidth>(
+ BitMask<uint16_t, kWidth> result = BitMask<uint16_t, kWidth>(0);
+ result = BitMask<uint16_t, kWidth>(
static_cast<uint16_t>(_mm_movemask_epi8(_mm_cmpeq_epi8(match, ctrl))));
+ return result;
}
// Returns a bitmask representing the positions of empty slots.
@@ -1122,20 +1105,19 @@
// Overwrites single empty slot with a full slot.
void OverwriteEmptyAsFull() {
- ABSL_SWISSTABLE_ASSERT(GetGrowthLeft() > 0);
+ assert(GetGrowthLeft() > 0);
--growth_left_info_;
}
// Overwrites several empty slots with full slots.
void OverwriteManyEmptyAsFull(size_t cnt) {
- ABSL_SWISSTABLE_ASSERT(GetGrowthLeft() >= cnt);
+ assert(GetGrowthLeft() >= cnt);
growth_left_info_ -= cnt;
}
// Overwrites specified control element with full slot.
void OverwriteControlAsFull(ctrl_t ctrl) {
- ABSL_SWISSTABLE_ASSERT(GetGrowthLeft() >=
- static_cast<size_t>(IsEmpty(ctrl)));
+ assert(GetGrowthLeft() >= static_cast<size_t>(IsEmpty(ctrl)));
growth_left_info_ -= static_cast<size_t>(IsEmpty(ctrl));
}
@@ -1205,7 +1187,7 @@
slot_offset_(
(generation_offset_ + NumGenerationBytes() + slot_align - 1) &
(~slot_align + 1)) {
- ABSL_SWISSTABLE_ASSERT(IsValidCapacity(capacity));
+ assert(IsValidCapacity(capacity));
}
// Returns the capacity of a table.
@@ -1226,9 +1208,6 @@
// Given the capacity of a table, computes the total size of the backing
// array.
size_t alloc_size(size_t slot_size) const {
- ABSL_SWISSTABLE_ASSERT(
- slot_size <=
- ((std::numeric_limits<size_t>::max)() - slot_offset_) / capacity_);
return slot_offset_ + capacity_ * slot_size;
}
@@ -1253,10 +1232,6 @@
struct soo_tag_t {};
// Sentinel type to indicate SOO CommonFields construction with full size.
struct full_soo_tag_t {};
-// Sentinel type to indicate non-SOO CommonFields construction.
-struct non_soo_tag_t {};
-// Sentinel value to indicate an uninitialized CommonFields for use in swapping.
-struct uninitialized_tag_t {};
// Suppress erroneous uninitialized memory errors on GCC. For example, GCC
// thinks that the call to slot_array() in find_or_prepare_insert() is reading
@@ -1338,13 +1313,10 @@
// of this state to helper functions as a single argument.
class CommonFields : public CommonFieldsGenerationInfo {
public:
+ CommonFields() : capacity_(0), size_(0), heap_or_soo_(EmptyGroup()) {}
explicit CommonFields(soo_tag_t) : capacity_(SooCapacity()), size_(0) {}
explicit CommonFields(full_soo_tag_t)
: capacity_(SooCapacity()), size_(size_t{1} << HasInfozShift()) {}
- explicit CommonFields(non_soo_tag_t)
- : capacity_(0), size_(0), heap_or_soo_(EmptyGroup()) {}
- // For use in swapping.
- explicit CommonFields(uninitialized_tag_t) {}
// Not copyable
CommonFields(const CommonFields&) = delete;
@@ -1356,8 +1328,7 @@
template <bool kSooEnabled>
static CommonFields CreateDefault() {
- return kSooEnabled ? CommonFields{soo_tag_t{}}
- : CommonFields{non_soo_tag_t{}};
+ return kSooEnabled ? CommonFields{soo_tag_t{}} : CommonFields{};
}
// The inline data for SOO is written on top of control_/slots_.
@@ -1371,8 +1342,7 @@
void set_control(ctrl_t* c) { heap_or_soo_.control() = c; }
void* backing_array_start() const {
// growth_info (and maybe infoz) is stored before control bytes.
- ABSL_SWISSTABLE_ASSERT(
- reinterpret_cast<uintptr_t>(control()) % alignof(size_t) == 0);
+ assert(reinterpret_cast<uintptr_t>(control()) % alignof(size_t) == 0);
return control() - ControlOffset(has_infoz());
}
@@ -1395,20 +1365,18 @@
size_ = size_t{1} << HasInfozShift();
}
void increment_size() {
- ABSL_SWISSTABLE_ASSERT(size() < capacity());
+ assert(size() < capacity());
size_ += size_t{1} << HasInfozShift();
}
void decrement_size() {
- ABSL_SWISSTABLE_ASSERT(size() > 0);
+ assert(size() > 0);
size_ -= size_t{1} << HasInfozShift();
}
// The total number of available slots.
size_t capacity() const { return capacity_; }
void set_capacity(size_t c) {
- // We allow setting above the max valid capacity for debugging purposes.
- ABSL_SWISSTABLE_ASSERT(c == 0 || IsValidCapacity(c) ||
- c > kAboveMaxValidCapacity);
+ assert(c == 0 || IsValidCapacity(c));
capacity_ = c;
}
@@ -1420,8 +1388,7 @@
GrowthInfo& growth_info() {
auto* gl_ptr = reinterpret_cast<GrowthInfo*>(control()) - 1;
- ABSL_SWISSTABLE_ASSERT(
- reinterpret_cast<uintptr_t>(gl_ptr) % alignof(GrowthInfo) == 0);
+ assert(reinterpret_cast<uintptr_t>(gl_ptr) % alignof(GrowthInfo) == 0);
return *gl_ptr;
}
GrowthInfo growth_info() const {
@@ -1441,7 +1408,7 @@
: HashtablezInfoHandle();
}
void set_infoz(HashtablezInfoHandle infoz) {
- ABSL_SWISSTABLE_ASSERT(has_infoz());
+ assert(has_infoz());
*reinterpret_cast<HashtablezInfoHandle*>(backing_array_start()) = infoz;
}
@@ -1477,20 +1444,6 @@
std::count(control(), control() + capacity(), ctrl_t::kDeleted));
}
- // Helper to enable sanitizer mode validation to protect against reentrant
- // calls during element constructor/destructor.
- template <typename F>
- void RunWithReentrancyGuard(F f) {
-#ifdef NDEBUG
- f();
- return;
-#endif
- const size_t cap = capacity();
- set_capacity(InvalidCapacity::kReentrance);
- f();
- set_capacity(cap);
- }
-
private:
// We store the has_infoz bit in the lowest bit of size_.
static constexpr size_t HasInfozShift() { return 1; }
@@ -1501,8 +1454,8 @@
// We can't assert that SOO is enabled because we don't have SooEnabled(), but
// we assert what we can.
void AssertInSooMode() const {
- ABSL_SWISSTABLE_ASSERT(capacity() == SooCapacity());
- ABSL_SWISSTABLE_ASSERT(!has_infoz());
+ assert(capacity() == SooCapacity());
+ assert(!has_infoz());
}
// The number of slots in the backing array. This is always 2^N-1 for an
@@ -1528,7 +1481,7 @@
// Returns the next valid capacity after `n`.
inline size_t NextCapacity(size_t n) {
- ABSL_SWISSTABLE_ASSERT(IsValidCapacity(n) || n == 0);
+ assert(IsValidCapacity(n) || n == 0);
return n * 2 + 1;
}
@@ -1547,15 +1500,6 @@
return n ? ~size_t{} >> countl_zero(n) : 1;
}
-template <size_t kSlotSize>
-size_t MaxValidCapacity() {
- return NormalizeCapacity((std::numeric_limits<size_t>::max)() / 4 /
- kSlotSize);
-}
-
-// Use a non-inlined function to avoid code bloat.
-[[noreturn]] void HashTableSizeOverflow();
-
// General notes on capacity/growth methods below:
// - We use 7/8th as maximum load factor. For 16-wide groups, that gives an
// average of two empty slots per group.
@@ -1567,7 +1511,7 @@
// Given `capacity`, applies the load factor; i.e., it returns the maximum
// number of values we should put into the table before a resizing rehash.
inline size_t CapacityToGrowth(size_t capacity) {
- ABSL_SWISSTABLE_ASSERT(IsValidCapacity(capacity));
+ assert(IsValidCapacity(capacity));
// `capacity*7/8`
if (Group::kWidth == 8 && capacity == 7) {
// x-x/8 does not work when x==7.
@@ -1759,7 +1703,7 @@
"hashtable.");
fail_if(true, "Comparing non-end() iterators from different hashtables.");
} else {
- ABSL_HARDENING_ASSERT_SLOW(
+ ABSL_HARDENING_ASSERT(
AreItersFromSameContainer(ctrl_a, ctrl_b, slot_a, slot_b) &&
"Invalid iterator comparison. The iterators may be from different "
"containers or the container might have rehashed or moved. Consider "
@@ -1825,7 +1769,7 @@
seq.index()};
}
seq.next();
- ABSL_SWISSTABLE_ASSERT(seq.index() <= common.capacity() && "full table!");
+ assert(seq.index() <= common.capacity() && "full table!");
}
}
@@ -1857,7 +1801,7 @@
// Sets sanitizer poisoning for slot corresponding to control byte being set.
inline void DoSanitizeOnSetCtrl(const CommonFields& c, size_t i, ctrl_t h,
size_t slot_size) {
- ABSL_SWISSTABLE_ASSERT(i < c.capacity());
+ assert(i < c.capacity());
auto* slot_i = static_cast<const char*>(c.slot_array()) + i * slot_size;
if (IsFull(h)) {
SanitizerUnpoisonMemoryRegion(slot_i, slot_size);
@@ -1887,7 +1831,7 @@
// setting the cloned control byte.
inline void SetCtrlInSingleGroupTable(const CommonFields& c, size_t i, ctrl_t h,
size_t slot_size) {
- ABSL_SWISSTABLE_ASSERT(is_single_group(c.capacity()));
+ assert(is_single_group(c.capacity()));
DoSanitizeOnSetCtrl(c, i, h, slot_size);
ctrl_t* ctrl = c.control();
ctrl[i] = h;
@@ -1927,8 +1871,8 @@
// Small tables capacity fits into portable group, where
// GroupPortableImpl::MaskFull is more efficient for the
// capacity <= GroupPortableImpl::kWidth.
- ABSL_SWISSTABLE_ASSERT(cap <= GroupPortableImpl::kWidth &&
- "unexpectedly large small capacity");
+ assert(cap <= GroupPortableImpl::kWidth &&
+ "unexpectedly large small capacity");
static_assert(Group::kWidth >= GroupPortableImpl::kWidth,
"unexpected group width");
// Group starts from kSentinel slot, so indices in the mask will
@@ -1945,21 +1889,19 @@
ABSL_ATTRIBUTE_UNUSED const size_t original_size_for_assert = remaining;
while (remaining != 0) {
for (uint32_t i : GroupFullEmptyOrDeleted(ctrl).MaskFull()) {
- ABSL_SWISSTABLE_ASSERT(IsFull(ctrl[i]) &&
- "hash table was modified unexpectedly");
+ assert(IsFull(ctrl[i]) && "hash table was modified unexpectedly");
cb(ctrl + i, slot + i);
--remaining;
}
ctrl += Group::kWidth;
slot += Group::kWidth;
- ABSL_SWISSTABLE_ASSERT(
- (remaining == 0 || *(ctrl - 1) != ctrl_t::kSentinel) &&
- "hash table was modified unexpectedly");
+ assert((remaining == 0 || *(ctrl - 1) != ctrl_t::kSentinel) &&
+ "hash table was modified unexpectedly");
}
// NOTE: erasure of the current element is allowed in callback for
// absl::erase_if specialization. So we use `>=`.
- ABSL_SWISSTABLE_ASSERT(original_size_for_assert >= c.size() &&
- "hash table was modified unexpectedly");
+ assert(original_size_for_assert >= c.size() &&
+ "hash table was modified unexpectedly");
}
template <typename CharAlloc>
@@ -2014,16 +1956,34 @@
// `GrowSizeIntoSingleGroup*` in case `IsGrowingIntoSingleGroupApplicable`.
// Falls back to `find_first_non_full` in case of big groups.
static FindInfo FindFirstNonFullAfterResize(const CommonFields& c,
- size_t old_capacity, size_t hash);
+ size_t old_capacity,
+ size_t hash) {
+ if (!IsGrowingIntoSingleGroupApplicable(old_capacity, c.capacity())) {
+ return find_first_non_full(c, hash);
+ }
+ // Find a location for the new element non-deterministically.
+ // Note that any position is correct.
+ // It will located at `half_old_capacity` or one of the other
+ // empty slots with approximately 50% probability each.
+ size_t offset = probe(c, hash).offset();
+
+ // Note that we intentionally use unsigned int underflow.
+ if (offset - (old_capacity + 1) >= old_capacity) {
+ // Offset fall on kSentinel or into the mostly occupied first half.
+ offset = old_capacity / 2;
+ }
+ assert(IsEmpty(c.control()[offset]));
+ return FindInfo{offset, 0};
+ }
HeapOrSoo& old_heap_or_soo() { return old_heap_or_soo_; }
void* old_soo_data() { return old_heap_or_soo_.get_soo_data(); }
ctrl_t* old_ctrl() const {
- ABSL_SWISSTABLE_ASSERT(!was_soo_);
+ assert(!was_soo_);
return old_heap_or_soo_.control();
}
void* old_slots() const {
- ABSL_SWISSTABLE_ASSERT(!was_soo_);
+ assert(!was_soo_);
return old_heap_or_soo_.slot_array().get();
}
size_t old_capacity() const { return old_capacity_; }
@@ -2074,7 +2034,7 @@
ctrl_t soo_slot_h2,
size_t key_size,
size_t value_size) {
- ABSL_SWISSTABLE_ASSERT(c.capacity());
+ assert(c.capacity());
HashtablezInfoHandle infoz =
ShouldSampleHashtablezInfo<Alloc>()
? SampleHashtablezInfo<SooEnabled>(SizeOfSlot, key_size, value_size,
@@ -2131,20 +2091,21 @@
// 1. GrowIntoSingleGroupShuffleControlBytes was already called.
template <class PolicyTraits, class Alloc>
void GrowSizeIntoSingleGroup(CommonFields& c, Alloc& alloc_ref) {
- ABSL_SWISSTABLE_ASSERT(old_capacity_ < Group::kWidth / 2);
- ABSL_SWISSTABLE_ASSERT(
- IsGrowingIntoSingleGroupApplicable(old_capacity_, c.capacity()));
+ assert(old_capacity_ < Group::kWidth / 2);
+ assert(IsGrowingIntoSingleGroupApplicable(old_capacity_, c.capacity()));
using slot_type = typename PolicyTraits::slot_type;
- ABSL_SWISSTABLE_ASSERT(is_single_group(c.capacity()));
+ assert(is_single_group(c.capacity()));
- auto* new_slots = static_cast<slot_type*>(c.slot_array()) + 1;
+ auto* new_slots = static_cast<slot_type*>(c.slot_array());
auto* old_slots_ptr = static_cast<slot_type*>(old_slots());
- auto* old_ctrl_ptr = old_ctrl();
- for (size_t i = 0; i < old_capacity_; ++i, ++new_slots) {
- if (IsFull(old_ctrl_ptr[i])) {
- SanitizerUnpoisonMemoryRegion(new_slots, sizeof(slot_type));
- PolicyTraits::transfer(&alloc_ref, new_slots, old_slots_ptr + i);
+ size_t shuffle_bit = old_capacity_ / 2 + 1;
+ for (size_t i = 0; i < old_capacity_; ++i) {
+ if (IsFull(old_ctrl()[i])) {
+ size_t new_i = i ^ shuffle_bit;
+ SanitizerUnpoisonMemoryRegion(new_slots + new_i, sizeof(slot_type));
+ PolicyTraits::transfer(&alloc_ref, new_slots + new_i,
+ old_slots_ptr + i);
}
}
PoisonSingleGroupEmptySlots(c, sizeof(slot_type));
@@ -2186,25 +2147,27 @@
// 1. new_ctrl is allocated for new_capacity,
// but not initialized.
// 2. new_capacity is a single group.
- // 3. old_capacity > 0.
//
// All elements are transferred into the first `old_capacity + 1` positions
- // of the new_ctrl. Elements are shifted by 1 in order to keep a space at the
- // beginning for the new element.
- // Position of the new added element will be based on `H1` and is not
- // deterministic.
+ // of the new_ctrl. Elements are rotated by `old_capacity_ / 2 + 1` positions
+ // in order to change an order and keep it non deterministic.
+ // Although rotation itself deterministic, position of the new added element
+ // will be based on `H1` and is not deterministic.
//
// Examples:
// S = kSentinel, E = kEmpty
//
+ // old_ctrl = SEEEEEEEE...
+ // new_ctrl = ESEEEEEEE...
+ //
// old_ctrl = 0SEEEEEEE...
// new_ctrl = E0ESE0EEE...
//
// old_ctrl = 012S012EEEEEEEEE...
- // new_ctrl = E012EEESE012EEE...
+ // new_ctrl = 2E01EEES2E01EEE...
//
// old_ctrl = 0123456S0123456EEEEEEEEEEE...
- // new_ctrl = E0123456EEEEEESE0123456EEE...
+ // new_ctrl = 456E0123EEEEEES456E0123EEE...
void GrowIntoSingleGroupShuffleControlBytes(ctrl_t* new_ctrl,
size_t new_capacity) const;
@@ -2413,10 +2376,6 @@
alignof(slot_type) <= alignof(HeapOrSoo);
}
- constexpr static size_t DefaultCapacity() {
- return SooEnabled() ? SooCapacity() : 0;
- }
-
// Whether `size` fits in the SOO capacity of this table.
bool fits_in_soo(size_t size) const {
return SooEnabled() && size <= SooCapacity();
@@ -2443,14 +2402,23 @@
static_assert(std::is_lvalue_reference<reference>::value,
"Policy::element() must return a reference");
+ template <typename T>
+ struct SameAsElementReference
+ : std::is_same<typename std::remove_cv<
+ typename std::remove_reference<reference>::type>::type,
+ typename std::remove_cv<
+ typename std::remove_reference<T>::type>::type> {};
+
// An enabler for insert(T&&): T must be convertible to init_type or be the
// same as [cv] value_type [ref].
+ // Note: we separate SameAsElementReference into its own type to avoid using
+ // reference unless we need to. MSVC doesn't seem to like it in some
+ // cases.
template <class T>
- using Insertable = absl::disjunction<
- std::is_same<absl::remove_cvref_t<reference>, absl::remove_cvref_t<T>>,
- std::is_convertible<T, init_type>>;
- template <class T>
- using IsNotBitField = std::is_pointer<T*>;
+ using RequiresInsertable = typename std::enable_if<
+ absl::disjunction<std::is_convertible<T, init_type>,
+ SameAsElementReference<T>>::value,
+ int>::type;
// RequiresNotInit is a workaround for gcc prior to 7.1.
// See https://godbolt.org/g/Y4xsUh.
@@ -2461,17 +2429,6 @@
template <class... Ts>
using IsDecomposable = IsDecomposable<void, PolicyTraits, Hash, Eq, Ts...>;
- template <class T>
- using IsDecomposableAndInsertable =
- IsDecomposable<std::enable_if_t<Insertable<T>::value, T>>;
-
- // Evaluates to true if an assignment from the given type would require the
- // source object to remain alive for the life of the element.
- template <class U>
- using IsLifetimeBoundAssignmentFrom = std::conditional_t<
- policy_trait_element_is_owner<Policy>::value, std::false_type,
- type_traits_internal::IsLifetimeBoundAssignment<init_type, U>>;
-
public:
static_assert(std::is_same<pointer, value_type*>::value,
"Allocators with custom pointer types are not supported");
@@ -2656,11 +2613,7 @@
const allocator_type& alloc = allocator_type())
: settings_(CommonFields::CreateDefault<SooEnabled()>(), hash, eq,
alloc) {
- if (bucket_count > DefaultCapacity()) {
- if (ABSL_PREDICT_FALSE(bucket_count >
- MaxValidCapacity<sizeof(slot_type)>())) {
- HashTableSizeOverflow();
- }
+ if (bucket_count > (SooEnabled() ? SooCapacity() : 0)) {
resize(NormalizeCapacity(bucket_count));
}
}
@@ -2719,8 +2672,7 @@
// absl::flat_hash_set<int> a, b{a};
//
// RequiresNotInit<T> is a workaround for gcc prior to 7.1.
- template <class T, RequiresNotInit<T> = 0,
- std::enable_if_t<Insertable<T>::value, int> = 0>
+ template <class T, RequiresNotInit<T> = 0, RequiresInsertable<T> = 0>
raw_hash_set(std::initializer_list<T> init, size_t bucket_count = 0,
const hasher& hash = hasher(), const key_equal& eq = key_equal(),
const allocator_type& alloc = allocator_type())
@@ -2731,8 +2683,7 @@
const allocator_type& alloc = allocator_type())
: raw_hash_set(init.begin(), init.end(), bucket_count, hash, eq, alloc) {}
- template <class T, RequiresNotInit<T> = 0,
- std::enable_if_t<Insertable<T>::value, int> = 0>
+ template <class T, RequiresNotInit<T> = 0, RequiresInsertable<T> = 0>
raw_hash_set(std::initializer_list<T> init, size_t bucket_count,
const hasher& hash, const allocator_type& alloc)
: raw_hash_set(init, bucket_count, hash, key_equal(), alloc) {}
@@ -2741,8 +2692,7 @@
const hasher& hash, const allocator_type& alloc)
: raw_hash_set(init, bucket_count, hash, key_equal(), alloc) {}
- template <class T, RequiresNotInit<T> = 0,
- std::enable_if_t<Insertable<T>::value, int> = 0>
+ template <class T, RequiresNotInit<T> = 0, RequiresInsertable<T> = 0>
raw_hash_set(std::initializer_list<T> init, size_t bucket_count,
const allocator_type& alloc)
: raw_hash_set(init, bucket_count, hasher(), key_equal(), alloc) {}
@@ -2751,8 +2701,7 @@
const allocator_type& alloc)
: raw_hash_set(init, bucket_count, hasher(), key_equal(), alloc) {}
- template <class T, RequiresNotInit<T> = 0,
- std::enable_if_t<Insertable<T>::value, int> = 0>
+ template <class T, RequiresNotInit<T> = 0, RequiresInsertable<T> = 0>
raw_hash_set(std::initializer_list<T> init, const allocator_type& alloc)
: raw_hash_set(init, 0, hasher(), key_equal(), alloc) {}
@@ -2767,7 +2716,6 @@
raw_hash_set(const raw_hash_set& that, const allocator_type& a)
: raw_hash_set(GrowthToLowerboundCapacity(that.size()), that.hash_ref(),
that.eq_ref(), a) {
- that.AssertNotDebugCapacity();
const size_t size = that.size();
if (size == 0) {
return;
@@ -2775,14 +2723,14 @@
// We don't use `that.is_soo()` here because `that` can have non-SOO
// capacity but have a size that fits into SOO capacity.
if (fits_in_soo(size)) {
- ABSL_SWISSTABLE_ASSERT(size == 1);
+ assert(size == 1);
common().set_full_soo();
emplace_at(soo_iterator(), *that.begin());
const HashtablezInfoHandle infoz = try_sample_soo();
if (infoz.IsSampled()) resize_with_soo_infoz(infoz);
return;
}
- ABSL_SWISSTABLE_ASSERT(!that.is_soo());
+ assert(!that.is_soo());
const size_t cap = capacity();
// Note about single group tables:
// 1. It is correct to have any order of elements.
@@ -2814,8 +2762,7 @@
offset = (offset + shift) & cap;
}
const h2_t h2 = static_cast<h2_t>(*that_ctrl);
- ABSL_SWISSTABLE_ASSERT( // We rely that hash is not changed for small
- // tables.
+ assert( // We rely that hash is not changed for small tables.
H2(PolicyTraits::apply(HashElement{hash_ref()},
PolicyTraits::element(that_slot))) == h2 &&
"hash function value changed unexpectedly during the copy");
@@ -2839,6 +2786,7 @@
: // Hash, equality and allocator are copied instead of moved because
// `that` must be left valid. If Hash is std::function<Key>, moving it
// would create a nullptr functor that cannot be called.
+ // TODO(b/296061262): move instead of copying hash/eq/alloc.
// Note: we avoid using exchange for better generated code.
settings_(PolicyTraits::transfer_uses_memcpy() || !that.is_full_soo()
? std::move(that.common())
@@ -2848,7 +2796,7 @@
transfer(soo_slot(), that.soo_slot());
}
that.common() = CommonFields::CreateDefault<SooEnabled()>();
- annotate_for_bug_detection_on_move(that);
+ maybe_increment_generation_or_rehash_on_move();
}
raw_hash_set(raw_hash_set&& that, const allocator_type& a)
@@ -2856,14 +2804,13 @@
that.eq_ref(), a) {
if (a == that.alloc_ref()) {
swap_common(that);
- annotate_for_bug_detection_on_move(that);
+ maybe_increment_generation_or_rehash_on_move();
} else {
move_elements_allocs_unequal(std::move(that));
}
}
raw_hash_set& operator=(const raw_hash_set& that) {
- that.AssertNotDebugCapacity();
if (ABSL_PREDICT_FALSE(this == &that)) return *this;
constexpr bool propagate_alloc =
AllocTraits::propagate_on_container_copy_assignment::value;
@@ -2888,12 +2835,7 @@
typename AllocTraits::propagate_on_container_move_assignment());
}
- ~raw_hash_set() {
- destructor_impl();
-#ifndef NDEBUG
- common().set_capacity(InvalidCapacity::kDestroyed);
-#endif
- }
+ ~raw_hash_set() { destructor_impl(); }
iterator begin() ABSL_ATTRIBUTE_LIFETIME_BOUND {
if (ABSL_PREDICT_FALSE(empty())) return end();
@@ -2901,11 +2843,10 @@
iterator it = {control(), common().slots_union(),
common().generation_ptr()};
it.skip_empty_or_deleted();
- ABSL_SWISSTABLE_ASSERT(IsFull(*it.control()));
+ assert(IsFull(*it.control()));
return it;
}
iterator end() ABSL_ATTRIBUTE_LIFETIME_BOUND {
- AssertNotDebugCapacity();
return iterator(common().generation_ptr());
}
@@ -2913,7 +2854,7 @@
return const_cast<raw_hash_set*>(this)->begin();
}
const_iterator end() const ABSL_ATTRIBUTE_LIFETIME_BOUND {
- return const_cast<raw_hash_set*>(this)->end();
+ return iterator(common().generation_ptr());
}
const_iterator cbegin() const ABSL_ATTRIBUTE_LIFETIME_BOUND {
return begin();
@@ -2921,28 +2862,18 @@
const_iterator cend() const ABSL_ATTRIBUTE_LIFETIME_BOUND { return end(); }
bool empty() const { return !size(); }
- size_t size() const {
- AssertNotDebugCapacity();
- return common().size();
- }
+ size_t size() const { return common().size(); }
size_t capacity() const {
const size_t cap = common().capacity();
- // Compiler complains when using functions in ASSUME so use local variable.
- ABSL_ATTRIBUTE_UNUSED static constexpr size_t kDefaultCapacity =
- DefaultCapacity();
- ABSL_ASSUME(cap >= kDefaultCapacity);
+ // Compiler complains when using functions in assume so use local variables.
+ ABSL_ATTRIBUTE_UNUSED static constexpr bool kEnabled = SooEnabled();
+ ABSL_ATTRIBUTE_UNUSED static constexpr size_t kCapacity = SooCapacity();
+ ABSL_ASSUME(!kEnabled || cap >= kCapacity);
return cap;
}
- size_t max_size() const {
- return CapacityToGrowth(MaxValidCapacity<sizeof(slot_type)>());
- }
+ size_t max_size() const { return (std::numeric_limits<size_t>::max)(); }
ABSL_ATTRIBUTE_REINITIALIZES void clear() {
- if (SwisstableGenerationsEnabled() &&
- capacity() >= InvalidCapacity::kMovedFrom) {
- common().set_capacity(DefaultCapacity());
- }
- AssertNotDebugCapacity();
// Iterating over this container is O(bucket_count()). When bucket_count()
// is much greater than size(), iteration becomes prohibitively expensive.
// For clear() it is more important to reuse the allocated array when the
@@ -2970,26 +2901,15 @@
//
// flat_hash_map<std::string, int> m;
// m.insert(std::make_pair("abc", 42));
- template <class T,
- std::enable_if_t<IsDecomposableAndInsertable<T>::value &&
- IsNotBitField<T>::value &&
- !IsLifetimeBoundAssignmentFrom<T>::value,
- int> = 0>
+ // TODO(cheshire): A type alias T2 is introduced as a workaround for the nvcc
+ // bug.
+ template <class T, RequiresInsertable<T> = 0, class T2 = T,
+ typename std::enable_if<IsDecomposable<T2>::value, int>::type = 0,
+ T* = nullptr>
std::pair<iterator, bool> insert(T&& value) ABSL_ATTRIBUTE_LIFETIME_BOUND {
return emplace(std::forward<T>(value));
}
- template <class T,
- std::enable_if_t<IsDecomposableAndInsertable<T>::value &&
- IsNotBitField<T>::value &&
- IsLifetimeBoundAssignmentFrom<T>::value,
- int> = 0>
- std::pair<iterator, bool> insert(
- T&& value ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this))
- ABSL_ATTRIBUTE_LIFETIME_BOUND {
- return emplace(std::forward<T>(value));
- }
-
// This overload kicks in when the argument is a bitfield or an lvalue of
// insertable and decomposable type.
//
@@ -3001,23 +2921,13 @@
// const char* p = "hello";
// s.insert(p);
//
- template <class T, std::enable_if_t<
- IsDecomposableAndInsertable<const T&>::value &&
- !IsLifetimeBoundAssignmentFrom<const T&>::value,
- int> = 0>
+ template <
+ class T, RequiresInsertable<const T&> = 0,
+ typename std::enable_if<IsDecomposable<const T&>::value, int>::type = 0>
std::pair<iterator, bool> insert(const T& value)
ABSL_ATTRIBUTE_LIFETIME_BOUND {
return emplace(value);
}
- template <class T,
- std::enable_if_t<IsDecomposableAndInsertable<const T&>::value &&
- IsLifetimeBoundAssignmentFrom<const T&>::value,
- int> = 0>
- std::pair<iterator, bool> insert(
- const T& value ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this))
- ABSL_ATTRIBUTE_LIFETIME_BOUND {
- return emplace(value);
- }
// This overload kicks in when the argument is an rvalue of init_type. Its
// purpose is to handle brace-init-list arguments.
@@ -3025,43 +2935,22 @@
// flat_hash_map<std::string, int> s;
// s.insert({"abc", 42});
std::pair<iterator, bool> insert(init_type&& value)
- ABSL_ATTRIBUTE_LIFETIME_BOUND
-#if __cplusplus >= 202002L
- requires(!IsLifetimeBoundAssignmentFrom<init_type>::value)
-#endif
- {
+ ABSL_ATTRIBUTE_LIFETIME_BOUND {
return emplace(std::move(value));
}
-#if __cplusplus >= 202002L
- std::pair<iterator, bool> insert(
- init_type&& value ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this))
- ABSL_ATTRIBUTE_LIFETIME_BOUND
- requires(IsLifetimeBoundAssignmentFrom<init_type>::value)
- {
- return emplace(std::move(value));
- }
-#endif
- template <class T,
- std::enable_if_t<IsDecomposableAndInsertable<T>::value &&
- IsNotBitField<T>::value &&
- !IsLifetimeBoundAssignmentFrom<T>::value,
- int> = 0>
+ // TODO(cheshire): A type alias T2 is introduced as a workaround for the nvcc
+ // bug.
+ template <class T, RequiresInsertable<T> = 0, class T2 = T,
+ typename std::enable_if<IsDecomposable<T2>::value, int>::type = 0,
+ T* = nullptr>
iterator insert(const_iterator, T&& value) ABSL_ATTRIBUTE_LIFETIME_BOUND {
return insert(std::forward<T>(value)).first;
}
- template <class T,
- std::enable_if_t<IsDecomposableAndInsertable<T>::value &&
- IsNotBitField<T>::value &&
- IsLifetimeBoundAssignmentFrom<T>::value,
- int> = 0>
- iterator insert(const_iterator, T&& value ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(
- this)) ABSL_ATTRIBUTE_LIFETIME_BOUND {
- return insert(std::forward<T>(value)).first;
- }
- template <class T, std::enable_if_t<
- IsDecomposableAndInsertable<const T&>::value, int> = 0>
+ template <
+ class T, RequiresInsertable<const T&> = 0,
+ typename std::enable_if<IsDecomposable<const T&>::value, int>::type = 0>
iterator insert(const_iterator,
const T& value) ABSL_ATTRIBUTE_LIFETIME_BOUND {
return insert(value).first;
@@ -3077,8 +2966,7 @@
for (; first != last; ++first) emplace(*first);
}
- template <class T, RequiresNotInit<T> = 0,
- std::enable_if_t<Insertable<const T&>::value, int> = 0>
+ template <class T, RequiresNotInit<T> = 0, RequiresInsertable<const T&> = 0>
void insert(std::initializer_list<T> ilist) {
insert(ilist.begin(), ilist.end());
}
@@ -3117,8 +3005,8 @@
// flat_hash_map<std::string, std::string> m = {{"abc", "def"}};
// // Creates no std::string copies and makes no heap allocations.
// m.emplace("abc", "xyz");
- template <class... Args,
- std::enable_if_t<IsDecomposable<Args...>::value, int> = 0>
+ template <class... Args, typename std::enable_if<
+ IsDecomposable<Args...>::value, int>::type = 0>
std::pair<iterator, bool> emplace(Args&&... args)
ABSL_ATTRIBUTE_LIFETIME_BOUND {
return PolicyTraits::apply(EmplaceDecomposable{*this},
@@ -3128,8 +3016,8 @@
// This overload kicks in if we cannot deduce the key from args. It constructs
// value_type unconditionally and then either moves it into the table or
// destroys.
- template <class... Args,
- std::enable_if_t<!IsDecomposable<Args...>::value, int> = 0>
+ template <class... Args, typename std::enable_if<
+ !IsDecomposable<Args...>::value, int>::type = 0>
std::pair<iterator, bool> emplace(Args&&... args)
ABSL_ATTRIBUTE_LIFETIME_BOUND {
alignas(slot_type) unsigned char raw[sizeof(slot_type)];
@@ -3180,7 +3068,7 @@
public:
template <class... Args>
void operator()(Args&&... args) const {
- ABSL_SWISSTABLE_ASSERT(*slot_);
+ assert(*slot_);
PolicyTraits::construct(alloc_, *slot_, std::forward<Args>(args)...);
*slot_ = nullptr;
}
@@ -3199,7 +3087,7 @@
if (res.second) {
slot_type* slot = res.first.slot();
std::forward<F>(f)(constructor(&alloc_ref(), &slot));
- ABSL_SWISSTABLE_ASSERT(!slot);
+ assert(!slot);
}
return res.first;
}
@@ -3221,16 +3109,24 @@
return 1;
}
- // Erases the element pointed to by `it`. Unlike `std::unordered_set::erase`,
- // this method returns void to reduce algorithmic complexity to O(1). The
- // iterator is invalidated so any increment should be done before calling
- // erase (e.g. `erase(it++)`).
+ // Erases the element pointed to by `it`. Unlike `std::unordered_set::erase`,
+ // this method returns void to reduce algorithmic complexity to O(1). The
+ // iterator is invalidated, so any increment should be done before calling
+ // erase. In order to erase while iterating across a map, use the following
+ // idiom (which also works for some standard containers):
+ //
+ // for (auto it = m.begin(), end = m.end(); it != end;) {
+ // // `erase()` will invalidate `it`, so advance `it` first.
+ // auto copy_it = it++;
+ // if (<pred>) {
+ // m.erase(copy_it);
+ // }
+ // }
void erase(const_iterator cit) { erase(cit.inner_); }
// This overload is necessary because otherwise erase<K>(const K&) would be
// a better match if non-const iterator is passed as an argument.
void erase(iterator it) {
- AssertNotDebugCapacity();
AssertIsFull(it.control(), it.generation(), it.generation_ptr(), "erase()");
destroy(it.slot());
if (is_soo()) {
@@ -3242,7 +3138,6 @@
iterator erase(const_iterator first,
const_iterator last) ABSL_ATTRIBUTE_LIFETIME_BOUND {
- AssertNotDebugCapacity();
// We check for empty first because ClearBackingArray requires that
// capacity() > 0 as a precondition.
if (empty()) return end();
@@ -3272,8 +3167,6 @@
// If the element already exists in `this`, it is left unmodified in `src`.
template <typename H, typename E>
void merge(raw_hash_set<Policy, H, E, Alloc>& src) { // NOLINT
- AssertNotDebugCapacity();
- src.AssertNotDebugCapacity();
assert(this != &src);
// Returns whether insertion took place.
const auto insert_slot = [this](slot_type* src_slot) {
@@ -3300,7 +3193,6 @@
}
node_type extract(const_iterator position) {
- AssertNotDebugCapacity();
AssertIsFull(position.control(), position.inner_.generation(),
position.inner_.generation_ptr(), "extract()");
auto node = CommonAccess::Transfer<node_type>(alloc_ref(), position.slot());
@@ -3312,8 +3204,9 @@
return node;
}
- template <class K = key_type,
- std::enable_if_t<!std::is_same<K, iterator>::value, int> = 0>
+ template <
+ class K = key_type,
+ typename std::enable_if<!std::is_same<K, iterator>::value, int>::type = 0>
node_type extract(const key_arg<K>& key) {
auto it = find(key);
return it == end() ? node_type() : extract(const_iterator{it});
@@ -3323,8 +3216,6 @@
IsNoThrowSwappable<hasher>() && IsNoThrowSwappable<key_equal>() &&
IsNoThrowSwappable<allocator_type>(
typename AllocTraits::propagate_on_container_swap{})) {
- AssertNotDebugCapacity();
- that.AssertNotDebugCapacity();
using std::swap;
swap_common(that);
swap(hash_ref(), that.hash_ref());
@@ -3350,7 +3241,7 @@
resize(kInitialSampledCapacity);
}
// This asserts that we didn't lose sampling coverage in `resize`.
- ABSL_SWISSTABLE_ASSERT(infoz().IsSampled());
+ assert(infoz().IsSampled());
return;
}
alignas(slot_type) unsigned char slot_space[sizeof(slot_type)];
@@ -3369,9 +3260,6 @@
auto m = NormalizeCapacity(n | GrowthToLowerboundCapacity(size()));
// n == 0 unconditionally rehashes as per the standard.
if (n == 0 || m > cap) {
- if (ABSL_PREDICT_FALSE(m > MaxValidCapacity<sizeof(slot_type)>())) {
- HashTableSizeOverflow();
- }
resize(m);
// This is after resize, to ensure that we have completed the allocation
@@ -3384,9 +3272,6 @@
const size_t max_size_before_growth =
is_soo() ? SooCapacity() : size() + growth_left();
if (n > max_size_before_growth) {
- if (ABSL_PREDICT_FALSE(n > max_size())) {
- HashTableSizeOverflow();
- }
size_t m = GrowthToLowerboundCapacity(n);
resize(NormalizeCapacity(m));
@@ -3419,7 +3304,7 @@
// specific benchmarks indicating its importance.
template <class K = key_type>
void prefetch(const key_arg<K>& key) const {
- if (capacity() == DefaultCapacity()) return;
+ if (SooEnabled() ? is_soo() : capacity() == 0) return;
(void)key;
// Avoid probing if we won't be able to prefetch the addresses received.
#ifdef ABSL_HAVE_PREFETCH
@@ -3430,27 +3315,32 @@
#endif // ABSL_HAVE_PREFETCH
}
+ // The API of find() has two extensions.
+ //
+ // 1. The hash can be passed by the user. It must be equal to the hash of the
+ // key.
+ //
+ // 2. The type of the key argument doesn't have to be key_type. This is so
+ // called heterogeneous key support.
template <class K = key_type>
- ABSL_DEPRECATE_AND_INLINE()
iterator find(const key_arg<K>& key,
- size_t) ABSL_ATTRIBUTE_LIFETIME_BOUND {
- return find(key);
+ size_t hash) ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ AssertHashEqConsistent(key);
+ if (is_soo()) return find_soo(key);
+ return find_non_soo(key, hash);
}
- // The API of find() has one extension: the type of the key argument doesn't
- // have to be key_type. This is so called heterogeneous key support.
template <class K = key_type>
iterator find(const key_arg<K>& key) ABSL_ATTRIBUTE_LIFETIME_BOUND {
- AssertOnFind(key);
+ AssertHashEqConsistent(key);
if (is_soo()) return find_soo(key);
prefetch_heap_block();
return find_non_soo(key, hash_ref()(key));
}
template <class K = key_type>
- ABSL_DEPRECATE_AND_INLINE()
const_iterator find(const key_arg<K>& key,
- size_t) const ABSL_ATTRIBUTE_LIFETIME_BOUND {
- return find(key);
+ size_t hash) const ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ return const_cast<raw_hash_set*>(this)->find(key, hash);
}
template <class K = key_type>
const_iterator find(const key_arg<K>& key) const
@@ -3502,16 +3392,7 @@
if (outer->capacity() > inner->capacity()) std::swap(outer, inner);
for (const value_type& elem : *outer) {
auto it = PolicyTraits::apply(FindElement{*inner}, elem);
- if (it == inner->end()) return false;
- // Note: we used key_equal to check for key equality in FindElement, but
- // we may need to do an additional comparison using
- // value_type::operator==. E.g. the keys could be equal and the
- // mapped_types could be unequal in a map or even in a set, key_equal
- // could ignore some fields that aren't ignored by operator==.
- static constexpr bool kKeyEqIsValueEq =
- std::is_same<key_type, value_type>::value &&
- std::is_same<key_equal, hash_default_eq<key_type>>::value;
- if (!kKeyEqIsValueEq && !(*it == elem)) return false;
+ if (it == inner->end() || !(*it == elem)) return false;
}
return true;
}
@@ -3595,26 +3476,23 @@
slot_type&& slot;
};
+ // TODO(b/303305702): re-enable reentrant validation.
template <typename... Args>
inline void construct(slot_type* slot, Args&&... args) {
- common().RunWithReentrancyGuard([&] {
- PolicyTraits::construct(&alloc_ref(), slot, std::forward<Args>(args)...);
- });
+ PolicyTraits::construct(&alloc_ref(), slot, std::forward<Args>(args)...);
}
inline void destroy(slot_type* slot) {
- common().RunWithReentrancyGuard(
- [&] { PolicyTraits::destroy(&alloc_ref(), slot); });
+ PolicyTraits::destroy(&alloc_ref(), slot);
}
inline void transfer(slot_type* to, slot_type* from) {
- common().RunWithReentrancyGuard(
- [&] { PolicyTraits::transfer(&alloc_ref(), to, from); });
+ PolicyTraits::transfer(&alloc_ref(), to, from);
}
// TODO(b/289225379): consider having a helper class that has the impls for
// SOO functionality.
template <class K = key_type>
iterator find_soo(const key_arg<K>& key) {
- ABSL_SWISSTABLE_ASSERT(is_soo());
+ assert(is_soo());
return empty() || !PolicyTraits::apply(EqualElement<K>{key, eq_ref()},
PolicyTraits::element(soo_slot()))
? end()
@@ -3623,7 +3501,7 @@
template <class K = key_type>
iterator find_non_soo(const key_arg<K>& key, size_t hash) {
- ABSL_SWISSTABLE_ASSERT(!is_soo());
+ assert(!is_soo());
auto seq = probe(common(), hash);
const ctrl_t* ctrl = control();
while (true) {
@@ -3636,7 +3514,7 @@
}
if (ABSL_PREDICT_TRUE(g.MaskEmpty())) return end();
seq.next();
- ABSL_SWISSTABLE_ASSERT(seq.index() <= capacity() && "full table!");
+ assert(seq.index() <= capacity() && "full table!");
}
}
@@ -3644,14 +3522,14 @@
// insertion into an empty SOO table and in copy construction when the size
// can fit in SOO capacity.
inline HashtablezInfoHandle try_sample_soo() {
- ABSL_SWISSTABLE_ASSERT(is_soo());
+ assert(is_soo());
if (!ShouldSampleHashtablezInfo<CharAlloc>()) return HashtablezInfoHandle{};
return Sample(sizeof(slot_type), sizeof(key_type), sizeof(value_type),
SooCapacity());
}
inline void destroy_slots() {
- ABSL_SWISSTABLE_ASSERT(!is_soo());
+ assert(!is_soo());
if (PolicyTraits::template destroy_is_trivial<Alloc>()) return;
IterateOverFullSlots(
common(), slot_array(),
@@ -3660,7 +3538,7 @@
}
inline void dealloc() {
- ABSL_SWISSTABLE_ASSERT(capacity() != 0);
+ assert(capacity() != 0);
// Unpoison before returning the memory to the allocator.
SanitizerUnpoisonMemoryRegion(slot_array(), sizeof(slot_type) * capacity());
infoz().Unregister();
@@ -3670,10 +3548,6 @@
}
inline void destructor_impl() {
- if (SwisstableGenerationsEnabled() &&
- capacity() >= InvalidCapacity::kMovedFrom) {
- return;
- }
if (capacity() == 0) return;
if (is_soo()) {
if (!empty()) {
@@ -3690,7 +3564,7 @@
// This merely updates the pertinent control byte. This can be used in
// conjunction with Policy::transfer to move the object to another place.
void erase_meta_only(const_iterator it) {
- ABSL_SWISSTABLE_ASSERT(!is_soo());
+ assert(!is_soo());
EraseMetaOnly(common(), static_cast<size_t>(it.control() - control()),
sizeof(slot_type));
}
@@ -3716,7 +3590,7 @@
// SOO tables, since they need to switch from SOO to heap in order to
// store the infoz.
void resize_with_soo_infoz(HashtablezInfoHandle forced_infoz) {
- ABSL_SWISSTABLE_ASSERT(forced_infoz.IsSampled());
+ assert(forced_infoz.IsSampled());
raw_hash_set::resize_impl(common(), NextCapacity(SooCapacity()),
forced_infoz);
}
@@ -3727,8 +3601,8 @@
CommonFields& common, size_t new_capacity,
HashtablezInfoHandle forced_infoz) {
raw_hash_set* set = reinterpret_cast<raw_hash_set*>(&common);
- ABSL_SWISSTABLE_ASSERT(IsValidCapacity(new_capacity));
- ABSL_SWISSTABLE_ASSERT(!set->fits_in_soo(new_capacity));
+ assert(IsValidCapacity(new_capacity));
+ assert(!set->fits_in_soo(new_capacity));
const bool was_soo = set->is_soo();
const bool had_soo_slot = was_soo && !set->empty();
const ctrl_t soo_slot_h2 =
@@ -3763,7 +3637,7 @@
// InitializeSlots did all the work including infoz().RecordRehash().
return;
}
- ABSL_SWISSTABLE_ASSERT(resize_helper.old_capacity() > 0);
+ assert(resize_helper.old_capacity() > 0);
// Nothing more to do in this case.
if (was_soo && !had_soo_slot) return;
@@ -3816,18 +3690,15 @@
static slot_type* to_slot(void* buf) { return static_cast<slot_type*>(buf); }
// Requires that lhs does not have a full SOO slot.
- static void move_common(bool rhs_is_full_soo, allocator_type& rhs_alloc,
+ static void move_common(bool that_is_full_soo, allocator_type& rhs_alloc,
CommonFields& lhs, CommonFields&& rhs) {
- if (PolicyTraits::transfer_uses_memcpy() || !rhs_is_full_soo) {
+ if (PolicyTraits::transfer_uses_memcpy() || !that_is_full_soo) {
lhs = std::move(rhs);
} else {
lhs.move_non_heap_or_soo_fields(rhs);
- rhs.RunWithReentrancyGuard([&] {
- lhs.RunWithReentrancyGuard([&] {
- PolicyTraits::transfer(&rhs_alloc, to_slot(lhs.soo_data()),
- to_slot(rhs.soo_data()));
- });
- });
+ // TODO(b/303305702): add reentrancy guard.
+ PolicyTraits::transfer(&rhs_alloc, to_slot(lhs.soo_data()),
+ to_slot(rhs.soo_data()));
}
}
@@ -3839,7 +3710,7 @@
swap(common(), that.common());
return;
}
- CommonFields tmp = CommonFields(uninitialized_tag_t{});
+ CommonFields tmp = CommonFields::CreateDefault<SooEnabled()>();
const bool that_is_full_soo = that.is_full_soo();
move_common(that_is_full_soo, that.alloc_ref(), tmp,
std::move(that.common()));
@@ -3847,17 +3718,8 @@
move_common(that_is_full_soo, that.alloc_ref(), common(), std::move(tmp));
}
- void annotate_for_bug_detection_on_move(
- ABSL_ATTRIBUTE_UNUSED raw_hash_set& that) {
- // We only enable moved-from validation when generations are enabled (rather
- // than using NDEBUG) to avoid issues in which NDEBUG is enabled in some
- // translation units but not in others.
- if (SwisstableGenerationsEnabled()) {
- that.common().set_capacity(this == &that ? InvalidCapacity::kSelfMovedFrom
- : InvalidCapacity::kMovedFrom);
- }
- if (!SwisstableGenerationsEnabled() || capacity() == DefaultCapacity() ||
- capacity() > kAboveMaxValidCapacity) {
+ void maybe_increment_generation_or_rehash_on_move() {
+ if (!SwisstableGenerationsEnabled() || capacity() == 0 || is_soo()) {
return;
}
common().increment_generation();
@@ -3873,12 +3735,13 @@
destructor_impl();
move_common(that.is_full_soo(), that.alloc_ref(), common(),
std::move(that.common()));
+ // TODO(b/296061262): move instead of copying hash/eq/alloc.
hash_ref() = that.hash_ref();
eq_ref() = that.eq_ref();
CopyAlloc(alloc_ref(), that.alloc_ref(),
std::integral_constant<bool, propagate_alloc>());
that.common() = CommonFields::CreateDefault<SooEnabled()>();
- annotate_for_bug_detection_on_move(that);
+ maybe_increment_generation_or_rehash_on_move();
return *this;
}
@@ -3892,7 +3755,7 @@
}
if (!that.is_soo()) that.dealloc();
that.common() = CommonFields::CreateDefault<SooEnabled()>();
- annotate_for_bug_detection_on_move(that);
+ maybe_increment_generation_or_rehash_on_move();
return *this;
}
@@ -3911,6 +3774,7 @@
// We can't take over that's memory so we need to move each element.
// While moving elements, this should have that's hash/eq so copy hash/eq
// before moving elements.
+ // TODO(b/296061262): move instead of copying hash/eq.
hash_ref() = that.hash_ref();
eq_ref() = that.eq_ref();
return move_elements_allocs_unequal(std::move(that));
@@ -3939,7 +3803,7 @@
template <class K>
std::pair<iterator, bool> find_or_prepare_insert_non_soo(const K& key) {
- ABSL_SWISSTABLE_ASSERT(!is_soo());
+ assert(!is_soo());
prefetch_heap_block();
auto hash = hash_ref()(key);
auto seq = probe(common(), hash);
@@ -3962,57 +3826,16 @@
true};
}
seq.next();
- ABSL_SWISSTABLE_ASSERT(seq.index() <= capacity() && "full table!");
+ assert(seq.index() <= capacity() && "full table!");
}
}
protected:
- // Asserts for correctness that we run on find/find_or_prepare_insert.
- template <class K>
- void AssertOnFind(ABSL_ATTRIBUTE_UNUSED const K& key) {
- AssertHashEqConsistent(key);
- AssertNotDebugCapacity();
- }
-
- // Asserts that the capacity is not a sentinel invalid value.
- void AssertNotDebugCapacity() const {
- if (ABSL_PREDICT_TRUE(capacity() <
- InvalidCapacity::kAboveMaxValidCapacity)) {
- return;
- }
- assert(capacity() != InvalidCapacity::kReentrance &&
- "Reentrant container access during element construction/destruction "
- "is not allowed.");
- assert(capacity() != InvalidCapacity::kDestroyed &&
- "Use of destroyed hash table.");
- if (SwisstableGenerationsEnabled() &&
- ABSL_PREDICT_FALSE(capacity() >= InvalidCapacity::kMovedFrom)) {
- if (capacity() == InvalidCapacity::kSelfMovedFrom) {
- // If this log triggers, then a hash table was move-assigned to itself
- // and then used again later without being reinitialized.
- ABSL_RAW_LOG(FATAL, "Use of self-move-assigned hash table.");
- }
- ABSL_RAW_LOG(FATAL, "Use of moved-from hash table.");
- }
- }
-
// Asserts that hash and equal functors provided by the user are consistent,
// meaning that `eq(k1, k2)` implies `hash(k1)==hash(k2)`.
template <class K>
- void AssertHashEqConsistent(const K& key) {
-#ifdef NDEBUG
- return;
-#endif
- // If the hash/eq functors are known to be consistent, then skip validation.
- if (std::is_same<hasher, absl::container_internal::StringHash>::value &&
- std::is_same<key_equal, absl::container_internal::StringEq>::value) {
- return;
- }
- if (std::is_scalar<key_type>::value &&
- std::is_same<hasher, absl::Hash<key_type>>::value &&
- std::is_same<key_equal, std::equal_to<key_type>>::value) {
- return;
- }
+ void AssertHashEqConsistent(ABSL_ATTRIBUTE_UNUSED const K& key) {
+#ifndef NDEBUG
if (empty()) return;
const size_t hash_of_arg = hash_ref()(key);
@@ -4024,8 +3847,21 @@
const size_t hash_of_slot =
PolicyTraits::apply(HashElement{hash_ref()}, element);
- ABSL_ATTRIBUTE_UNUSED const bool is_hash_equal =
- hash_of_arg == hash_of_slot;
+ const bool is_hash_equal = hash_of_arg == hash_of_slot;
+ if (!is_hash_equal) {
+ // In this case, we're going to crash. Do a couple of other checks for
+ // idempotence issues. Recalculating hash/eq here is also convenient for
+ // debugging with gdb/lldb.
+ const size_t once_more_hash_arg = hash_ref()(key);
+ assert(hash_of_arg == once_more_hash_arg && "hash is not idempotent.");
+ const size_t once_more_hash_slot =
+ PolicyTraits::apply(HashElement{hash_ref()}, element);
+ assert(hash_of_slot == once_more_hash_slot &&
+ "hash is not idempotent.");
+ const bool once_more_eq =
+ PolicyTraits::apply(EqualElement<K>{key, eq_ref()}, element);
+ assert(is_key_equal == once_more_eq && "equality is not idempotent.");
+ }
assert((!is_key_equal || is_hash_equal) &&
"eq(k1, k2) must imply that hash(k1) == hash(k2). "
"hash/eq functors are inconsistent.");
@@ -4038,6 +3874,7 @@
// We only do validation for small tables so that it's constant time.
if (capacity() > 16) return;
IterateOverFullSlots(common(), slot_array(), assert_consistent);
+#endif
}
// Attempts to find `key` in the table; if it isn't found, returns an iterator
@@ -4045,7 +3882,7 @@
// `key`'s H2. Returns a bool indicating whether an insertion can take place.
template <class K>
std::pair<iterator, bool> find_or_prepare_insert(const K& key) {
- AssertOnFind(key);
+ AssertHashEqConsistent(key);
if (is_soo()) return find_or_prepare_insert_soo(key);
return find_or_prepare_insert_non_soo(key);
}
@@ -4089,16 +3926,16 @@
//
// See `CapacityToGrowth()`.
size_t growth_left() const {
- ABSL_SWISSTABLE_ASSERT(!is_soo());
+ assert(!is_soo());
return common().growth_left();
}
GrowthInfo& growth_info() {
- ABSL_SWISSTABLE_ASSERT(!is_soo());
+ assert(!is_soo());
return common().growth_info();
}
GrowthInfo growth_info() const {
- ABSL_SWISSTABLE_ASSERT(!is_soo());
+ assert(!is_soo());
return common().growth_info();
}
@@ -4106,7 +3943,7 @@
// cache misses. This is intended to overlap with execution of calculating the
// hash for a key.
void prefetch_heap_block() const {
- ABSL_SWISSTABLE_ASSERT(!is_soo());
+ assert(!is_soo());
#if ABSL_HAVE_BUILTIN(__builtin_prefetch) || defined(__GNUC__)
__builtin_prefetch(control(), 0, 1);
#endif
@@ -4116,15 +3953,15 @@
const CommonFields& common() const { return settings_.template get<0>(); }
ctrl_t* control() const {
- ABSL_SWISSTABLE_ASSERT(!is_soo());
+ assert(!is_soo());
return common().control();
}
slot_type* slot_array() const {
- ABSL_SWISSTABLE_ASSERT(!is_soo());
+ assert(!is_soo());
return static_cast<slot_type*>(common().slot_array());
}
slot_type* soo_slot() {
- ABSL_SWISSTABLE_ASSERT(is_soo());
+ assert(is_soo());
return static_cast<slot_type*>(common().soo_data());
}
const slot_type* soo_slot() const {
@@ -4137,7 +3974,7 @@
return const_cast<raw_hash_set*>(this)->soo_iterator();
}
HashtablezInfoHandle infoz() {
- ABSL_SWISSTABLE_ASSERT(!is_soo());
+ assert(!is_soo());
return common().infoz();
}
@@ -4186,7 +4023,7 @@
(std::is_same<SlotAlloc, std::allocator<slot_type>>::value
? &DeallocateStandard<alignof(slot_type)>
: &raw_hash_set::dealloc_fn),
- &raw_hash_set::resize_impl
+ &raw_hash_set::resize_impl,
};
return value;
}
@@ -4210,8 +4047,7 @@
if (c->is_soo()) {
auto it = c->soo_iterator();
if (!pred(*it)) {
- ABSL_SWISSTABLE_ASSERT(c->size() == 1 &&
- "hash table was modified unexpectedly");
+ assert(c->size() == 1 && "hash table was modified unexpectedly");
return 0;
}
c->destroy(it.slot());
@@ -4231,9 +4067,8 @@
});
// NOTE: IterateOverFullSlots allow removal of the current element, so we
// verify the size additionally here.
- ABSL_SWISSTABLE_ASSERT(original_size_for_assert - num_deleted ==
- c->size() &&
- "hash table was modified unexpectedly");
+ assert(original_size_for_assert - num_deleted == c->size() &&
+ "hash table was modified unexpectedly");
return num_deleted;
}
@@ -4327,6 +4162,5 @@
#undef ABSL_SWISSTABLE_ENABLE_GENERATIONS
#undef ABSL_SWISSTABLE_IGNORE_UNINITIALIZED
#undef ABSL_SWISSTABLE_IGNORE_UNINITIALIZED_RETURN
-#undef ABSL_SWISSTABLE_ASSERT
#endif // ABSL_CONTAINER_INTERNAL_RAW_HASH_SET_H_
diff --git a/absl/container/internal/raw_hash_set_test.cc b/absl/container/internal/raw_hash_set_test.cc
index 8a17c01..f1257d4 100644
--- a/absl/container/internal/raw_hash_set_test.cc
+++ b/absl/container/internal/raw_hash_set_test.cc
@@ -24,14 +24,12 @@
#include <functional>
#include <iostream>
#include <iterator>
-#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <ostream>
#include <random>
-#include <set>
#include <string>
#include <tuple>
#include <type_traits>
@@ -64,7 +62,6 @@
#include "absl/meta/type_traits.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
-#include "absl/types/optional.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
@@ -2093,10 +2090,6 @@
t.emplace("a", "b");
EXPECT_EQ(1, t.size());
t = std::move(*&t);
- if (SwisstableGenerationsEnabled()) {
- // NOLINTNEXTLINE(bugprone-use-after-move)
- EXPECT_DEATH_IF_SUPPORTED(t.contains("a"), "self-move-assigned");
- }
// As long as we don't crash, it's fine.
}
@@ -2436,9 +2429,8 @@
}
template <typename T>
-T MakeSimpleTable(size_t size, bool do_reserve) {
+T MakeSimpleTable(size_t size) {
T t;
- if (do_reserve) t.reserve(size);
while (t.size() < size) t.insert(t.size());
return t;
}
@@ -2457,62 +2449,51 @@
// We also need to keep the old tables around to avoid getting the same memory
// blocks over and over.
TYPED_TEST(SooTest, IterationOrderChangesByInstance) {
- for (bool do_reserve : {false, true}) {
- for (size_t size : {2u, 6u, 12u, 20u}) {
- SCOPED_TRACE(absl::StrCat("size: ", size, " do_reserve: ", do_reserve));
- const auto reference_table = MakeSimpleTable<TypeParam>(size, do_reserve);
- const auto reference = OrderOfIteration(reference_table);
+ for (size_t size : {2, 6, 12, 20}) {
+ const auto reference_table = MakeSimpleTable<TypeParam>(size);
+ const auto reference = OrderOfIteration(reference_table);
- std::vector<TypeParam> tables;
- bool found_difference = false;
- for (int i = 0; !found_difference && i < 5000; ++i) {
- tables.push_back(MakeSimpleTable<TypeParam>(size, do_reserve));
- found_difference = OrderOfIteration(tables.back()) != reference;
- }
- if (!found_difference) {
- FAIL() << "Iteration order remained the same across many attempts with "
- "size "
- << size;
- }
+ std::vector<TypeParam> tables;
+ bool found_difference = false;
+ for (int i = 0; !found_difference && i < 5000; ++i) {
+ tables.push_back(MakeSimpleTable<TypeParam>(size));
+ found_difference = OrderOfIteration(tables.back()) != reference;
+ }
+ if (!found_difference) {
+ FAIL()
+ << "Iteration order remained the same across many attempts with size "
+ << size;
}
}
}
TYPED_TEST(SooTest, IterationOrderChangesOnRehash) {
-#ifdef ABSL_HAVE_ADDRESS_SANITIZER
- GTEST_SKIP() << "Hash quality is lower in asan mode, causing flakiness.";
-#endif
-
// We test different sizes with many small numbers, because small table
// resize has a different codepath.
// Note: iteration order for size() <= 1 is always the same.
- for (bool do_reserve : {false, true}) {
- for (size_t size : {2u, 3u, 6u, 7u, 12u, 15u, 20u, 50u}) {
- for (size_t rehash_size : {
- size_t{0}, // Force rehash is guaranteed.
- size * 10 // Rehash to the larger capacity is guaranteed.
- }) {
- SCOPED_TRACE(absl::StrCat("size: ", size, " rehash_size: ", rehash_size,
- " do_reserve: ", do_reserve));
- std::vector<TypeParam> garbage;
- bool ok = false;
- for (int i = 0; i < 5000; ++i) {
- auto t = MakeSimpleTable<TypeParam>(size, do_reserve);
- const auto reference = OrderOfIteration(t);
- // Force rehash.
- t.rehash(rehash_size);
- auto trial = OrderOfIteration(t);
- if (trial != reference) {
- // We are done.
- ok = true;
- break;
- }
- garbage.push_back(std::move(t));
+ for (size_t size : std::vector<size_t>{2, 3, 6, 7, 12, 15, 20, 50}) {
+ for (size_t rehash_size : {
+ size_t{0}, // Force rehash is guaranteed.
+ size * 10 // Rehash to the larger capacity is guaranteed.
+ }) {
+ std::vector<TypeParam> garbage;
+ bool ok = false;
+ for (int i = 0; i < 5000; ++i) {
+ auto t = MakeSimpleTable<TypeParam>(size);
+ const auto reference = OrderOfIteration(t);
+ // Force rehash.
+ t.rehash(rehash_size);
+ auto trial = OrderOfIteration(t);
+ if (trial != reference) {
+ // We are done.
+ ok = true;
+ break;
}
- EXPECT_TRUE(ok)
- << "Iteration order remained the same across many attempts " << size
- << "->" << rehash_size << ".";
+ garbage.push_back(std::move(t));
}
+ EXPECT_TRUE(ok)
+ << "Iteration order remained the same across many attempts " << size
+ << "->" << rehash_size << ".";
}
}
}
@@ -3613,138 +3594,6 @@
"hash/eq functors are inconsistent.");
}
-struct ConstructCaller {
- explicit ConstructCaller(int v) : val(v) {}
- ConstructCaller(int v, absl::FunctionRef<void()> func) : val(v) { func(); }
- template <typename H>
- friend H AbslHashValue(H h, const ConstructCaller& d) {
- return H::combine(std::move(h), d.val);
- }
- bool operator==(const ConstructCaller& c) const { return val == c.val; }
-
- int val;
-};
-
-struct DestroyCaller {
- explicit DestroyCaller(int v) : val(v) {}
- DestroyCaller(int v, absl::FunctionRef<void()> func)
- : val(v), destroy_func(func) {}
- DestroyCaller(DestroyCaller&& that)
- : val(that.val), destroy_func(std::move(that.destroy_func)) {
- that.Deactivate();
- }
- ~DestroyCaller() {
- if (destroy_func) (*destroy_func)();
- }
- void Deactivate() { destroy_func = absl::nullopt; }
-
- template <typename H>
- friend H AbslHashValue(H h, const DestroyCaller& d) {
- return H::combine(std::move(h), d.val);
- }
- bool operator==(const DestroyCaller& d) const { return val == d.val; }
-
- int val;
- absl::optional<absl::FunctionRef<void()>> destroy_func;
-};
-
-TEST(Table, ReentrantCallsFail) {
-#ifdef NDEBUG
- GTEST_SKIP() << "Reentrant checks only enabled in debug mode.";
-#else
- {
- ValueTable<ConstructCaller> t;
- t.insert(ConstructCaller{0});
- auto erase_begin = [&] { t.erase(t.begin()); };
- EXPECT_DEATH_IF_SUPPORTED(t.emplace(1, erase_begin), "");
- }
- {
- ValueTable<DestroyCaller> t;
- t.insert(DestroyCaller{0});
- auto find_0 = [&] { t.find(DestroyCaller{0}); };
- t.insert(DestroyCaller{1, find_0});
- for (int i = 10; i < 20; ++i) t.insert(DestroyCaller{i});
- EXPECT_DEATH_IF_SUPPORTED(t.clear(), "");
- for (auto& elem : t) elem.Deactivate();
- }
- {
- ValueTable<DestroyCaller> t;
- t.insert(DestroyCaller{0});
- auto insert_1 = [&] { t.insert(DestroyCaller{1}); };
- t.insert(DestroyCaller{1, insert_1});
- for (int i = 10; i < 20; ++i) t.insert(DestroyCaller{i});
- EXPECT_DEATH_IF_SUPPORTED(t.clear(), "");
- for (auto& elem : t) elem.Deactivate();
- }
-#endif
-}
-
-TEST(Table, DestroyedCallsFail) {
-#ifdef NDEBUG
- GTEST_SKIP() << "Destroyed checks only enabled in debug mode.";
-#else
- absl::optional<IntTable> t;
- t.emplace({1});
- IntTable* t_ptr = &*t;
- EXPECT_TRUE(t_ptr->contains(1));
- t.reset();
- EXPECT_DEATH_IF_SUPPORTED(t_ptr->contains(1), "");
-#endif
-}
-
-TEST(Table, MovedFromCallsFail) {
- if (!SwisstableGenerationsEnabled()) {
- GTEST_SKIP() << "Moved-from checks only enabled in sanitizer mode.";
- return;
- }
-
- {
- ABSL_ATTRIBUTE_UNUSED IntTable t1, t2, t3;
- t1.insert(1);
- t2 = std::move(t1);
- // NOLINTNEXTLINE(bugprone-use-after-move)
- EXPECT_DEATH_IF_SUPPORTED(t1.contains(1), "moved-from");
- // NOLINTNEXTLINE(bugprone-use-after-move)
- EXPECT_DEATH_IF_SUPPORTED(t1.swap(t3), "moved-from");
- // NOLINTNEXTLINE(bugprone-use-after-move)
- EXPECT_DEATH_IF_SUPPORTED(t1.merge(t3), "moved-from");
- // NOLINTNEXTLINE(bugprone-use-after-move)
- EXPECT_DEATH_IF_SUPPORTED(IntTable{t1}, "moved-from");
- // NOLINTNEXTLINE(bugprone-use-after-move)
- EXPECT_DEATH_IF_SUPPORTED(t1.begin(), "moved-from");
- // NOLINTNEXTLINE(bugprone-use-after-move)
- EXPECT_DEATH_IF_SUPPORTED(t1.end(), "moved-from");
- // NOLINTNEXTLINE(bugprone-use-after-move)
- EXPECT_DEATH_IF_SUPPORTED(t1.size(), "moved-from");
- }
- {
- ABSL_ATTRIBUTE_UNUSED IntTable t1;
- t1.insert(1);
- ABSL_ATTRIBUTE_UNUSED IntTable t2(std::move(t1));
- // NOLINTNEXTLINE(bugprone-use-after-move)
- EXPECT_DEATH_IF_SUPPORTED(t1.contains(1), "moved-from");
- t1.clear(); // Clearing a moved-from table is allowed.
- }
- {
- // Test that using a table (t3) that was moved-to from a moved-from table
- // (t1) fails.
- ABSL_ATTRIBUTE_UNUSED IntTable t1, t2, t3;
- t1.insert(1);
- t2 = std::move(t1);
- // NOLINTNEXTLINE(bugprone-use-after-move)
- t3 = std::move(t1);
- EXPECT_DEATH_IF_SUPPORTED(t3.contains(1), "moved-from");
- }
-}
-
-TEST(Table, MaxSizeOverflow) {
- size_t overflow = (std::numeric_limits<size_t>::max)();
- EXPECT_DEATH_IF_SUPPORTED(IntTable t(overflow), "Hash table size overflow");
- IntTable t;
- EXPECT_DEATH_IF_SUPPORTED(t.reserve(overflow), "Hash table size overflow");
- EXPECT_DEATH_IF_SUPPORTED(t.rehash(overflow), "Hash table size overflow");
-}
-
} // namespace
} // namespace container_internal
ABSL_NAMESPACE_END
diff --git a/absl/container/node_hash_map.h b/absl/container/node_hash_map.h
index 127c893..5615e49 100644
--- a/absl/container/node_hash_map.h
+++ b/absl/container/node_hash_map.h
@@ -120,7 +120,7 @@
template <class Key, class Value, class Hash = DefaultHashContainerHash<Key>,
class Eq = DefaultHashContainerEq<Key>,
class Alloc = std::allocator<std::pair<const Key, Value>>>
-class ABSL_ATTRIBUTE_OWNER node_hash_map
+class ABSL_INTERNAL_ATTRIBUTE_OWNER node_hash_map
: public absl::container_internal::raw_hash_map<
absl::container_internal::NodeHashMapPolicy<Key, Value>, Hash, Eq,
Alloc> {
@@ -236,13 +236,8 @@
// Erases the element at `position` of the `node_hash_map`, returning
// `void`.
//
- // NOTE: Returning `void` in this case is different than that of STL
- // containers in general and `std::unordered_map` in particular (which
- // return an iterator to the element following the erased element). If that
- // iterator is needed, simply post increment the iterator:
- //
- // map.erase(it++);
- //
+ // NOTE: this return behavior is different than that of STL containers in
+ // general and `std::unordered_map` in particular.
//
// iterator erase(const_iterator first, const_iterator last):
//
@@ -422,7 +417,8 @@
// node_hash_map::swap(node_hash_map& other)
//
// Exchanges the contents of this `node_hash_map` with those of the `other`
- // node hash map.
+ // node hash map, avoiding invocation of any move, copy, or swap operations on
+ // individual elements.
//
// All iterators and references on the `node_hash_map` remain valid, excepting
// for the past-the-end iterator, which is invalidated.
@@ -562,21 +558,6 @@
return container_internal::EraseIf(pred, &c);
}
-// swap(node_hash_map<>, node_hash_map<>)
-//
-// Swaps the contents of two `node_hash_map` containers.
-//
-// NOTE: we need to define this function template in order for
-// `flat_hash_set::swap` to be called instead of `std::swap`. Even though we
-// have `swap(raw_hash_set&, raw_hash_set&)` defined, that function requires a
-// derived-to-base conversion, whereas `std::swap` is a function template so
-// `std::swap` will be preferred by compiler.
-template <typename K, typename V, typename H, typename E, typename A>
-void swap(node_hash_map<K, V, H, E, A>& x,
- node_hash_map<K, V, H, E, A>& y) noexcept(noexcept(x.swap(y))) {
- return x.swap(y);
-}
-
namespace container_internal {
// c_for_each_fast(node_hash_map<>, Function)
diff --git a/absl/container/node_hash_set.h b/absl/container/node_hash_set.h
index cffa50e..53435ae 100644
--- a/absl/container/node_hash_set.h
+++ b/absl/container/node_hash_set.h
@@ -115,7 +115,7 @@
// }
template <class T, class Hash = DefaultHashContainerHash<T>,
class Eq = DefaultHashContainerEq<T>, class Alloc = std::allocator<T>>
-class ABSL_ATTRIBUTE_OWNER node_hash_set
+class ABSL_INTERNAL_ATTRIBUTE_OWNER node_hash_set
: public absl::container_internal::raw_hash_set<
absl::container_internal::NodeHashSetPolicy<T>, Hash, Eq, Alloc> {
using Base = typename node_hash_set::raw_hash_set;
@@ -230,13 +230,8 @@
// Erases the element at `position` of the `node_hash_set`, returning
// `void`.
//
- // NOTE: Returning `void` in this case is different than that of STL
- // containers in general and `std::unordered_map` in particular (which
- // return an iterator to the element following the erased element). If that
- // iterator is needed, simply post increment the iterator:
- //
- // map.erase(it++);
- //
+ // NOTE: this return behavior is different than that of STL containers in
+ // general and `std::unordered_set` in particular.
//
// iterator erase(const_iterator first, const_iterator last):
//
@@ -354,7 +349,8 @@
// node_hash_set::swap(node_hash_set& other)
//
// Exchanges the contents of this `node_hash_set` with those of the `other`
- // node hash set.
+ // node hash set, avoiding invocation of any move, copy, or swap operations on
+ // individual elements.
//
// All iterators and references on the `node_hash_set` remain valid, excepting
// for the past-the-end iterator, which is invalidated.
@@ -471,21 +467,6 @@
return container_internal::EraseIf(pred, &c);
}
-// swap(node_hash_set<>, node_hash_set<>)
-//
-// Swaps the contents of two `node_hash_set` containers.
-//
-// NOTE: we need to define this function template in order for
-// `flat_hash_set::swap` to be called instead of `std::swap`. Even though we
-// have `swap(raw_hash_set&, raw_hash_set&)` defined, that function requires a
-// derived-to-base conversion, whereas `std::swap` is a function template so
-// `std::swap` will be preferred by compiler.
-template <typename T, typename H, typename E, typename A>
-void swap(node_hash_set<T, H, E, A>& x,
- node_hash_set<T, H, E, A>& y) noexcept(noexcept(x.swap(y))) {
- return x.swap(y);
-}
-
namespace container_internal {
// c_for_each_fast(node_hash_set<>, Function)
diff --git a/absl/copts/configure_copts.bzl b/absl/copts/configure_copts.bzl
index 9e0be28..ca5f26d 100644
--- a/absl/copts/configure_copts.bzl
+++ b/absl/copts/configure_copts.bzl
@@ -15,25 +15,68 @@
"ABSL_MSVC_FLAGS",
"ABSL_MSVC_LINKOPTS",
"ABSL_MSVC_TEST_FLAGS",
+ "ABSL_RANDOM_HWAES_ARM32_FLAGS",
+ "ABSL_RANDOM_HWAES_ARM64_FLAGS",
+ "ABSL_RANDOM_HWAES_MSVC_X64_FLAGS",
+ "ABSL_RANDOM_HWAES_X64_FLAGS",
)
ABSL_DEFAULT_COPTS = select({
- "@rules_cc//cc/compiler:msvc-cl": ABSL_MSVC_FLAGS,
- "@rules_cc//cc/compiler:clang-cl": ABSL_CLANG_CL_FLAGS,
- "@rules_cc//cc/compiler:clang": ABSL_LLVM_FLAGS,
- "@rules_cc//cc/compiler:gcc": ABSL_GCC_FLAGS,
- "//conditions:default": [],
+ "//absl:msvc_compiler": ABSL_MSVC_FLAGS,
+ "//absl:clang-cl_compiler": ABSL_CLANG_CL_FLAGS,
+ "//absl:clang_compiler": ABSL_LLVM_FLAGS,
+ "//absl:gcc_compiler": ABSL_GCC_FLAGS,
+ "//conditions:default": ABSL_GCC_FLAGS,
})
ABSL_TEST_COPTS = select({
- "@rules_cc//cc/compiler:msvc-cl": ABSL_MSVC_TEST_FLAGS,
- "@rules_cc//cc/compiler:clang-cl": ABSL_CLANG_CL_TEST_FLAGS,
- "@rules_cc//cc/compiler:clang": ABSL_LLVM_TEST_FLAGS,
- "@rules_cc//cc/compiler:gcc": ABSL_GCC_TEST_FLAGS,
- "//conditions:default": [],
+ "//absl:msvc_compiler": ABSL_MSVC_TEST_FLAGS,
+ "//absl:clang-cl_compiler": ABSL_CLANG_CL_TEST_FLAGS,
+ "//absl:clang_compiler": ABSL_LLVM_TEST_FLAGS,
+ "//absl:gcc_compiler": ABSL_GCC_TEST_FLAGS,
+ "//conditions:default": ABSL_GCC_TEST_FLAGS,
})
ABSL_DEFAULT_LINKOPTS = select({
- "@rules_cc//cc/compiler:msvc-cl": ABSL_MSVC_LINKOPTS,
+ "//absl:msvc_compiler": ABSL_MSVC_LINKOPTS,
"//conditions:default": [],
})
+
+# ABSL_RANDOM_RANDEN_COPTS blaze copts flags which are required by each
+# environment to build an accelerated RandenHwAes library.
+ABSL_RANDOM_RANDEN_COPTS = select({
+ # APPLE
+ ":cpu_darwin_x86_64": ABSL_RANDOM_HWAES_X64_FLAGS,
+ ":cpu_darwin": ABSL_RANDOM_HWAES_X64_FLAGS,
+ ":cpu_x64_windows_msvc": ABSL_RANDOM_HWAES_MSVC_X64_FLAGS,
+ ":cpu_x64_windows": ABSL_RANDOM_HWAES_MSVC_X64_FLAGS,
+ ":cpu_k8": ABSL_RANDOM_HWAES_X64_FLAGS,
+ ":cpu_ppc": ["-mcrypto"],
+ ":cpu_aarch64": ABSL_RANDOM_HWAES_ARM64_FLAGS,
+
+ # Supported by default or unsupported.
+ "//conditions:default": [],
+})
+
+# absl_random_randen_copts_init:
+# Initialize the config targets based on cpu, os, etc. used to select
+# the required values for ABSL_RANDOM_RANDEN_COPTS
+def absl_random_randen_copts_init():
+ """Initialize the config_settings used by ABSL_RANDOM_RANDEN_COPTS."""
+
+ # CPU configs.
+ # These configs have consistent flags to enable HWAES intsructions.
+ cpu_configs = [
+ "ppc",
+ "k8",
+ "darwin_x86_64",
+ "darwin",
+ "x64_windows_msvc",
+ "x64_windows",
+ "aarch64",
+ ]
+ for cpu in cpu_configs:
+ native.config_setting(
+ name = "cpu_%s" % cpu,
+ values = {"cpu": cpu},
+ )
diff --git a/absl/copts/copts.py b/absl/copts/copts.py
index d1cfe42..2d85ac7 100644
--- a/absl/copts/copts.py
+++ b/absl/copts/copts.py
@@ -180,4 +180,15 @@
# Object file doesn't export any previously undefined symbols
"-ignore:4221",
],
+ # "HWAES" is an abbreviation for "hardware AES" (AES - Advanced Encryption
+ # Standard). These flags are used for detecting whether or not the target
+ # architecture has hardware support for AES instructions which can be used
+ # to improve performance of some random bit generators.
+ "ABSL_RANDOM_HWAES_ARM64_FLAGS": ["-march=armv8-a+crypto"],
+ "ABSL_RANDOM_HWAES_ARM32_FLAGS": ["-mfpu=neon"],
+ "ABSL_RANDOM_HWAES_X64_FLAGS": [
+ "-maes",
+ "-msse4.1",
+ ],
+ "ABSL_RANDOM_HWAES_MSVC_X64_FLAGS": [],
}
diff --git a/absl/crc/BUILD.bazel b/absl/crc/BUILD.bazel
index b659a7e..890d637 100644
--- a/absl/crc/BUILD.bazel
+++ b/absl/crc/BUILD.bazel
@@ -42,7 +42,6 @@
deps = [
"//absl/base",
"//absl/base:config",
- "//absl/types:optional",
],
)
@@ -112,8 +111,8 @@
":crc32c",
"//absl/strings",
"//absl/strings:str_format",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -159,8 +158,8 @@
"//absl/random",
"//absl/random:distributions",
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -172,8 +171,8 @@
visibility = ["//visibility:private"],
deps = [
":non_temporal_memcpy",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -201,8 +200,8 @@
deps = [
":crc32c",
":crc_cord_state",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -220,6 +219,6 @@
":crc32c",
"//absl/memory",
"//absl/strings",
- "@google_benchmark//:benchmark_main",
+ "@com_github_google_benchmark//:benchmark_main",
],
)
diff --git a/absl/crc/CMakeLists.txt b/absl/crc/CMakeLists.txt
index f068e54..d52a1bc 100644
--- a/absl/crc/CMakeLists.txt
+++ b/absl/crc/CMakeLists.txt
@@ -25,7 +25,6 @@
DEPS
absl::base
absl::config
- absl::optional
)
# Internal-only target, do not depend on directly.
diff --git a/absl/crc/internal/cpu_detect.cc b/absl/crc/internal/cpu_detect.cc
index c59f773..d7eedd1 100644
--- a/absl/crc/internal/cpu_detect.cc
+++ b/absl/crc/internal/cpu_detect.cc
@@ -18,21 +18,12 @@
#include <string>
#include "absl/base/config.h"
-#include "absl/types/optional.h" // IWYU pragma: keep
#if defined(__aarch64__) && defined(__linux__)
#include <asm/hwcap.h>
#include <sys/auxv.h>
#endif
-#if defined(__aarch64__) && defined(__APPLE__)
-#if defined(__has_include) && __has_include(<arm/cpu_capabilities_public.h>)
-#include <arm/cpu_capabilities_public.h>
-#endif
-#include <sys/sysctl.h>
-#include <sys/types.h>
-#endif
-
#if defined(_WIN32) || defined(_WIN64)
#include <intrin.h>
#endif
@@ -278,55 +269,8 @@
}
bool SupportsArmCRC32PMULL() {
-#if defined(HWCAP_CRC32) && defined(HWCAP_PMULL)
uint64_t hwcaps = getauxval(AT_HWCAP);
return (hwcaps & HWCAP_CRC32) && (hwcaps & HWCAP_PMULL);
-#else
- return false;
-#endif
-}
-
-#elif defined(__aarch64__) && defined(__APPLE__)
-
-CpuType GetCpuType() { return CpuType::kUnknown; }
-
-template <typename T>
-static absl::optional<T> ReadSysctlByName(const char* name) {
- T val;
- size_t val_size = sizeof(T);
- int ret = sysctlbyname(name, &val, &val_size, nullptr, 0);
- if (ret == -1) {
- return absl::nullopt;
- }
- return val;
-}
-
-bool SupportsArmCRC32PMULL() {
- // Newer XNU kernels support querying all capabilities in a single
- // sysctlbyname.
-#if defined(CAP_BIT_CRC32) && defined(CAP_BIT_FEAT_PMULL)
- static const absl::optional<uint64_t> caps =
- ReadSysctlByName<uint64_t>("hw.optional.arm.caps");
- if (caps.has_value()) {
- constexpr uint64_t kCrc32AndPmullCaps =
- (uint64_t{1} << CAP_BIT_CRC32) | (uint64_t{1} << CAP_BIT_FEAT_PMULL);
- return (*caps & kCrc32AndPmullCaps) == kCrc32AndPmullCaps;
- }
-#endif
-
- // https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics#3915619
- static const absl::optional<int> armv8_crc32 =
- ReadSysctlByName<int>("hw.optional.armv8_crc32");
- if (armv8_crc32.value_or(0) == 0) {
- return false;
- }
- // https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics#3918855
- static const absl::optional<int> feat_pmull =
- ReadSysctlByName<int>("hw.optional.arm.FEAT_PMULL");
- if (feat_pmull.value_or(0) == 0) {
- return false;
- }
- return true;
}
#else
diff --git a/absl/crc/internal/non_temporal_memcpy.h b/absl/crc/internal/non_temporal_memcpy.h
index 5d3e4e3..7ae83bd 100644
--- a/absl/crc/internal/non_temporal_memcpy.h
+++ b/absl/crc/internal/non_temporal_memcpy.h
@@ -111,31 +111,20 @@
#endif // __SSE3__ || __aarch64__ || (_MSC_VER && __AVX__)
}
-// We try to force non_temporal_store_memcpy_avx to use AVX instructions
-// so that we can select it at runtime when AVX is available.
-// Clang on Windows has gnu::target but does not make AVX types like __m256i
-// available when trying to force specific functions to use AVX compiles.
-#if ABSL_HAVE_CPP_ATTRIBUTE(gnu::target) && !defined(_MSC_VER) && \
- (defined(__x86_64__) || defined(__i386__))
-#define ABSL_INTERNAL_CAN_FORCE_AVX 1
-#endif
-
// If the objects overlap, the behavior is undefined. Uses regular memcpy
// instead of non-temporal memcpy if the required CPU intrinsics are unavailable
// at compile time.
-#ifdef ABSL_INTERNAL_CAN_FORCE_AVX
+#if ABSL_HAVE_CPP_ATTRIBUTE(gnu::target) && \
+ (defined(__x86_64__) || defined(__i386__))
[[gnu::target("avx")]]
#endif
inline void *non_temporal_store_memcpy_avx(void *__restrict dst,
const void *__restrict src,
size_t len) {
- // This function requires AVX. If possible we compile it with AVX even if the
- // translation unit isn't built with AVX support. This works because we only
- // select this implementation at runtime if the CPU supports AVX.
- // MSVC AVX support implies SSE3 support.
-#if ((defined(__AVX__) || defined(ABSL_INTERNAL_CAN_FORCE_AVX)) && \
- defined(__SSE3__)) || \
- (defined(_MSC_VER) && defined(__AVX__))
+ // This function requires AVX. For clang and gcc we compile it with AVX even
+ // if the translation unit isn't built with AVX support. This works because we
+ // only select this implementation at runtime if the CPU supports AVX.
+#if defined(__SSE3__) || (defined(_MSC_VER) && defined(__AVX__))
uint8_t *d = reinterpret_cast<uint8_t *>(dst);
const uint8_t *s = reinterpret_cast<const uint8_t *>(src);
@@ -181,13 +170,10 @@
}
return dst;
#else
- // Fallback to regular memcpy so that this function compiles.
return memcpy(dst, src, len);
-#endif
+#endif // __SSE3__ || (_MSC_VER && __AVX__)
}
-#undef ABSL_INTERNAL_CAN_FORCE_AVX
-
} // namespace crc_internal
ABSL_NAMESPACE_END
} // namespace absl
diff --git a/absl/crc/internal/non_temporal_memcpy_test.cc b/absl/crc/internal/non_temporal_memcpy_test.cc
index b2b19d3..eb07a55 100644
--- a/absl/crc/internal/non_temporal_memcpy_test.cc
+++ b/absl/crc/internal/non_temporal_memcpy_test.cc
@@ -57,7 +57,6 @@
}
}
-#ifdef __AVX__
TEST_P(NonTemporalMemcpyTest, AVXEquality) {
uint8_t* src = a_.data() + GetParam().src_offset;
uint8_t* dst = b_.data() + GetParam().dst_offset;
@@ -68,7 +67,6 @@
EXPECT_EQ(src[i], dst[i]);
}
}
-#endif
// 63B is smaller than one cacheline operation thus the non-temporal routine
// will not be called.
diff --git a/absl/debugging/BUILD.bazel b/absl/debugging/BUILD.bazel
index 6e61bb3..52b407c 100644
--- a/absl/debugging/BUILD.bazel
+++ b/absl/debugging/BUILD.bazel
@@ -67,8 +67,8 @@
deps = [
":stacktrace",
"//absl/base:core_headers",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -88,8 +88,8 @@
],
copts = ABSL_DEFAULT_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS + select({
- "@rules_cc//cc/compiler:msvc-cl": ["-DEFAULTLIB:dbghelp.lib"],
- "@rules_cc//cc/compiler:clang-cl": ["-DEFAULTLIB:dbghelp.lib"],
+ "//absl:msvc_compiler": ["-DEFAULTLIB:dbghelp.lib"],
+ "//absl:clang-cl_compiler": ["-DEFAULTLIB:dbghelp.lib"],
"//absl:mingw_compiler": [
"-DEFAULTLIB:dbghelp.lib",
"-ldbghelp",
@@ -113,13 +113,13 @@
name = "symbolize_test",
srcs = ["symbolize_test.cc"],
copts = ABSL_TEST_COPTS + select({
- "@rules_cc//cc/compiler:msvc-cl": ["/Z7"],
- "@rules_cc//cc/compiler:clang-cl": ["/Z7"],
+ "//absl:msvc_compiler": ["/Z7"],
+ "//absl:clang-cl_compiler": ["/Z7"],
"//conditions:default": [],
}),
linkopts = ABSL_DEFAULT_LINKOPTS + select({
- "@rules_cc//cc/compiler:msvc-cl": ["/DEBUG"],
- "@rules_cc//cc/compiler:clang-cl": ["/DEBUG"],
+ "//absl:msvc_compiler": ["/DEBUG"],
+ "//absl:clang-cl_compiler": ["/DEBUG"],
"//conditions:default": [],
}),
deps = [
@@ -132,7 +132,7 @@
"//absl/log:check",
"//absl/memory",
"//absl/strings",
- "@googletest//:gtest",
+ "@com_google_googletest//:gtest",
],
)
@@ -177,9 +177,9 @@
srcs = ["failure_signal_handler_test.cc"],
copts = ABSL_TEST_COPTS,
linkopts = select({
- "@rules_cc//cc/compiler:msvc-cl": [],
- "@rules_cc//cc/compiler:clang-cl": [],
- "@rules_cc//cc/compiler:emscripten": [],
+ "//absl:msvc_compiler": [],
+ "//absl:clang-cl_compiler": [],
+ "//absl:wasm": [],
"//conditions:default": ["-pthread"],
}) + ABSL_DEFAULT_LINKOPTS,
deps = [
@@ -189,7 +189,7 @@
"//absl/base:raw_logging_internal",
"//absl/log:check",
"//absl/strings",
- "@googletest//:gtest",
+ "@com_google_googletest//:gtest",
],
)
@@ -249,8 +249,8 @@
"//absl/base:core_headers",
"//absl/log",
"//absl/memory",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -273,8 +273,8 @@
deps = [
":bounded_utf8_length_sequence",
"//absl/base:config",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -300,8 +300,8 @@
deps = [
":decode_rust_punycode",
"//absl/base:config",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -327,8 +327,8 @@
":demangle_rust",
"//absl/base:config",
"//absl/base:core_headers",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -349,8 +349,8 @@
deps = [
":utf8_for_code_point",
"//absl/base:config",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -376,8 +376,8 @@
":leak_check",
"//absl/base:config",
"//absl/log",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -394,8 +394,8 @@
deps = [
":leak_check",
"//absl/log",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -424,8 +424,8 @@
":stack_consumption",
"//absl/base:core_headers",
"//absl/log",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -440,6 +440,6 @@
":stacktrace",
"//absl/base:config",
"//absl/base:core_headers",
- "@google_benchmark//:benchmark_main",
+ "@com_github_google_benchmark//:benchmark_main",
],
)
diff --git a/absl/debugging/failure_signal_handler.cc b/absl/debugging/failure_signal_handler.cc
index d31f5a1..570d1e5 100644
--- a/absl/debugging/failure_signal_handler.cc
+++ b/absl/debugging/failure_signal_handler.cc
@@ -21,7 +21,6 @@
#ifdef _WIN32
#include <windows.h>
#else
-#include <pthread.h>
#include <sched.h>
#include <unistd.h>
#endif
@@ -66,23 +65,6 @@
#endif
#endif
-// ABSL_HAVE_PTHREAD_CPU_NUMBER_NP
-//
-// Checks whether pthread_cpu_number_np is available.
-#ifdef ABSL_HAVE_PTHREAD_CPU_NUMBER_NP
-#error ABSL_HAVE_PTHREAD_CPU_NUMBER_NP cannot be directly set
-#elif defined(__APPLE__) && defined(__has_include) && \
- ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
- __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 110000) || \
- (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
- __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 140200) || \
- (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && \
- __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 70100) || \
- (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && \
- __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 140200))
-#define ABSL_HAVE_PTHREAD_CPU_NUMBER_NP 1
-#endif
-
namespace absl {
ABSL_NAMESPACE_BEGIN
@@ -348,20 +330,6 @@
using GetTidType = decltype(absl::base_internal::GetTID());
ABSL_CONST_INIT static std::atomic<GetTidType> failed_tid(0);
-static int GetCpuNumber() {
-#ifdef ABSL_HAVE_SCHED_GETCPU
- return sched_getcpu();
-#elif defined(ABSL_HAVE_PTHREAD_CPU_NUMBER_NP)
- size_t cpu_num;
- if (pthread_cpu_number_np(&cpu_num) == 0) {
- return static_cast<int>(cpu_num);
- }
- return -1;
-#else
- return -1;
-#endif
-}
-
#ifndef ABSL_HAVE_SIGACTION
static void AbslFailureSignalHandler(int signo) {
void* ucontext = nullptr;
@@ -392,7 +360,10 @@
// Increase the chance that the CPU we report was the same CPU on which the
// signal was received by doing this as early as possible, i.e. after
// verifying that this is not a recursive signal handler invocation.
- int my_cpu = GetCpuNumber();
+ int my_cpu = -1;
+#ifdef ABSL_HAVE_SCHED_GETCPU
+ my_cpu = sched_getcpu();
+#endif
#ifdef ABSL_HAVE_ALARM
// Set an alarm to abort the program in case this code hangs or deadlocks.
diff --git a/absl/debugging/internal/elf_mem_image.h b/absl/debugging/internal/elf_mem_image.h
index 1fac29c..19c4952 100644
--- a/absl/debugging/internal/elf_mem_image.h
+++ b/absl/debugging/internal/elf_mem_image.h
@@ -35,7 +35,7 @@
#if defined(__ELF__) && !defined(__OpenBSD__) && !defined(__QNX__) && \
!defined(__native_client__) && !defined(__asmjs__) && \
!defined(__wasm__) && !defined(__HAIKU__) && !defined(__sun) && \
- !defined(__VXWORKS__) && !defined(__hexagon__) && !defined(__XTENSA__)
+ !defined(__VXWORKS__) && !defined(__hexagon__)
#define ABSL_HAVE_ELF_MEM_IMAGE 1
#endif
diff --git a/absl/debugging/internal/stack_consumption.h b/absl/debugging/internal/stack_consumption.h
index f5ba557..f41b64c 100644
--- a/absl/debugging/internal/stack_consumption.h
+++ b/absl/debugging/internal/stack_consumption.h
@@ -24,7 +24,7 @@
// Use this feature test macro to detect its availability.
#ifdef ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION
#error ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION cannot be set directly
-#elif !defined(__APPLE__) && !defined(_WIN32) && !defined(__Fuchsia__) && \
+#elif !defined(__APPLE__) && !defined(_WIN32) && \
(defined(__i386__) || defined(__x86_64__) || defined(__ppc__) || \
defined(__aarch64__) || defined(__riscv))
#define ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION 1
diff --git a/absl/debugging/internal/stacktrace_aarch64-inl.inc b/absl/debugging/internal/stacktrace_aarch64-inl.inc
index 4490c4e..b123479 100644
--- a/absl/debugging/internal/stacktrace_aarch64-inl.inc
+++ b/absl/debugging/internal/stacktrace_aarch64-inl.inc
@@ -178,20 +178,6 @@
return new_frame_pointer;
}
-// When PAC-RET (-mbranch-protection=pac-ret) is enabled, return addresses
-// stored on the stack will be signed, which means that pointer bits outside of
-// the VA range are potentially set. Since the stacktrace code is expected to
-// return normal code pointers, this function clears those bits.
-inline void* ClearPacBits(void* ptr) {
- register void* x30 __asm__("x30") = ptr;
- // The normal instruction for clearing PAC bits is XPACI, but for
- // compatibility with ARM platforms that do not support pointer
- // authentication, we use the hint space instruction XPACLRI instead. Hint
- // space instructions behave as NOPs on unsupported platforms.
- asm("xpaclri" : "+r"(x30));
- return x30;
-}
-
template <bool IS_STACK_FRAMES, bool IS_WITH_CONTEXT>
// We count on the bottom frame being this one. See the comment
// at prev_return_address
@@ -233,7 +219,7 @@
if (skip_count > 0) {
skip_count--;
} else {
- result[n] = ClearPacBits(prev_return_address);
+ result[n] = prev_return_address;
if (IS_STACK_FRAMES) {
sizes[n] = static_cast<int>(
ComputeStackFrameSize(prev_frame_pointer, frame_pointer));
diff --git a/absl/debugging/internal/stacktrace_config.h b/absl/debugging/internal/stacktrace_config.h
index 88949fe..3929b1b 100644
--- a/absl/debugging/internal/stacktrace_config.h
+++ b/absl/debugging/internal/stacktrace_config.h
@@ -42,13 +42,6 @@
#define ABSL_STACKTRACE_INL_HEADER \
"absl/debugging/internal/stacktrace_emscripten-inl.inc"
-#elif defined(__ANDROID__) && __ANDROID_API__ >= 33
-
-// Use the generic implementation for Android 33+ (Android T+). This is the
-// first version of Android for which <execinfo.h> implements backtrace().
-#define ABSL_STACKTRACE_INL_HEADER \
- "absl/debugging/internal/stacktrace_generic-inl.inc"
-
#elif defined(__linux__) && !defined(__ANDROID__)
#if defined(NO_FRAME_POINTER) && \
diff --git a/absl/debugging/internal/stacktrace_riscv-inl.inc b/absl/debugging/internal/stacktrace_riscv-inl.inc
index 3f9e124..20183fa 100644
--- a/absl/debugging/internal/stacktrace_riscv-inl.inc
+++ b/absl/debugging/internal/stacktrace_riscv-inl.inc
@@ -36,16 +36,15 @@
#include "absl/base/attributes.h"
#include "absl/debugging/stacktrace.h"
-static constexpr ptrdiff_t kUnknownFrameSize = 0;
+static const uintptr_t kUnknownFrameSize = 0;
// Compute the size of a stack frame in [low..high). We assume that low < high.
// Return size of kUnknownFrameSize.
template <typename T>
-static inline ptrdiff_t ComputeStackFrameSize(const T *low, const T *high) {
+static inline uintptr_t ComputeStackFrameSize(const T *low, const T *high) {
const char *low_char_ptr = reinterpret_cast<const char *>(low);
const char *high_char_ptr = reinterpret_cast<const char *>(high);
- return low < high ? static_cast<ptrdiff_t>(high_char_ptr - low_char_ptr)
- : kUnknownFrameSize;
+ return low < high ? high_char_ptr - low_char_ptr : kUnknownFrameSize;
}
// Given a pointer to a stack frame, locate and return the calling stackframe,
@@ -94,8 +93,8 @@
// Check frame size. In strict mode, we assume frames to be under 100,000
// bytes. In non-strict mode, we relax the limit to 1MB.
- const ptrdiff_t max_size = STRICT_UNWINDING ? 100000 : 1000000;
- const ptrdiff_t frame_size =
+ const uintptr_t max_size = STRICT_UNWINDING ? 100000 : 1000000;
+ const uintptr_t frame_size =
ComputeStackFrameSize(old_frame_pointer, new_frame_pointer);
if (frame_size == kUnknownFrameSize) {
if (STRICT_UNWINDING)
@@ -152,9 +151,7 @@
} else {
result[n] = return_address;
if (IS_STACK_FRAMES) {
- // NextStackFrame() has already checked that frame size fits to int
- sizes[n] = static_cast<int>(ComputeStackFrameSize(frame_pointer,
- next_frame_pointer));
+ sizes[n] = ComputeStackFrameSize(frame_pointer, next_frame_pointer);
}
n++;
}
diff --git a/absl/debugging/leak_check.cc b/absl/debugging/leak_check.cc
index 1370bcc..fdb8798 100644
--- a/absl/debugging/leak_check.cc
+++ b/absl/debugging/leak_check.cc
@@ -28,7 +28,7 @@
#include <sanitizer/lsan_interface.h>
#if ABSL_HAVE_ATTRIBUTE_WEAK
-extern "C" ABSL_ATTRIBUTE_WEAK int __lsan_is_turned_off() { return 0; }
+extern "C" ABSL_ATTRIBUTE_WEAK int __lsan_is_turned_off();
#endif
namespace absl {
@@ -37,13 +37,13 @@
#if ABSL_HAVE_ATTRIBUTE_WEAK
bool LeakCheckerIsActive() {
- return __lsan_is_turned_off() == 0;
+ return !(&__lsan_is_turned_off && __lsan_is_turned_off());
}
#else
bool LeakCheckerIsActive() { return true; }
#endif
-bool FindAndReportLeaks() { return __lsan_do_recoverable_leak_check() != 0; }
+bool FindAndReportLeaks() { return __lsan_do_recoverable_leak_check(); }
void DoIgnoreLeak(const void* ptr) { __lsan_ignore_object(ptr); }
void RegisterLivePointers(const void* ptr, size_t size) {
__lsan_register_root_region(ptr, size);
diff --git a/absl/debugging/symbolize.cc b/absl/debugging/symbolize.cc
index 344436f..638d395 100644
--- a/absl/debugging/symbolize.cc
+++ b/absl/debugging/symbolize.cc
@@ -12,13 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-// SKIP_ABSL_INLINE_NAMESPACE_CHECK
-
#include "absl/debugging/symbolize.h"
#ifdef _WIN32
#include <winapifamily.h>
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#if !(WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)) || \
+ WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// UWP doesn't have access to win32 APIs.
#define ABSL_INTERNAL_HAVE_SYMBOLIZE_WIN32
#endif
diff --git a/absl/debugging/symbolize_elf.inc b/absl/debugging/symbolize_elf.inc
index a98ca81..ae75cd4 100644
--- a/absl/debugging/symbolize_elf.inc
+++ b/absl/debugging/symbolize_elf.inc
@@ -52,7 +52,6 @@
#include <elf.h>
#include <fcntl.h>
#include <link.h> // For ElfW() macro.
-#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
@@ -377,46 +376,6 @@
SymbolCacheLine symbol_cache_[SYMBOL_CACHE_LINES];
};
-// Protect against client code closing low-valued file descriptors it doesn't
-// actually own.
-int OpenReadOnlyWithHighFD(const char *fname) {
- static int high_fd = [] {
- struct rlimit rlim{};
- const int rc = getrlimit(RLIMIT_NOFILE, &rlim);
- if (rc == 0 && rlim.rlim_cur >= 2000) {
- const int max_fd = static_cast<int>(rlim.rlim_cur);
-
- // This will return 2000 on reasonably-configured systems.
- return std::min<int>(2000, max_fd - 1000);
- }
- ABSL_RAW_LOG(WARNING, "Unable to get high fd: rc=%d, limit=%ld", //
- rc, static_cast<long>(rlim.rlim_cur));
- return -1;
- }();
- constexpr int kOpenFlags = O_RDONLY | O_CLOEXEC;
- if (high_fd >= 1000) {
- const int fd = open(fname, kOpenFlags);
- if (fd != -1 && fd < high_fd) {
- // Try to relocate fd to high range.
- static_assert(kOpenFlags & O_CLOEXEC,
- "F_DUPFD_CLOEXEC assumes O_CLOEXEC");
- const int fd2 = fcntl(fd, F_DUPFD_CLOEXEC, high_fd);
- if (fd2 != -1) {
- // Successfully obtained high fd. Use it.
- close(fd);
- return fd2;
- } else {
- ABSL_RAW_LOG(WARNING, "Unable to dup fd=%d above %d, errno=%d", fd,
- high_fd, errno);
- }
- }
- // Either open failed and fd==-1, or fd is already above high_fd, or fcntl
- // failed and fd is valid (but low).
- return fd;
- }
- return open(fname, kOpenFlags);
-}
-
static std::atomic<Symbolizer *> g_cached_symbolizer;
} // namespace
@@ -582,9 +541,11 @@
(buf_bytes > num_bytes_left) ? num_bytes_left : buf_bytes;
const off_t offset = sh_offset + static_cast<off_t>(i * sizeof(buf[0]));
const ssize_t len = file->ReadFromOffset(buf, num_bytes_to_read, offset);
- if (len <= 0) {
- ABSL_RAW_LOG(WARNING, "Reading %zu bytes from offset %ju returned %zd.",
- num_bytes_to_read, static_cast<intmax_t>(offset), len);
+ if (len < 0) {
+ ABSL_RAW_LOG(
+ WARNING,
+ "Reading %zu bytes from offset %ju returned %zd which is negative.",
+ num_bytes_to_read, static_cast<intmax_t>(offset), len);
return false;
}
if (static_cast<size_t>(len) % sizeof(buf[0]) != 0) {
@@ -1105,7 +1066,7 @@
snprintf(maps_path, sizeof(maps_path), "/proc/self/task/%d/maps", getpid());
int maps_fd;
- NO_INTR(maps_fd = OpenReadOnlyWithHighFD(maps_path));
+ NO_INTR(maps_fd = open(maps_path, O_RDONLY));
FileDescriptor wrapped_maps_fd(maps_fd);
if (wrapped_maps_fd.get() < 0) {
ABSL_RAW_LOG(WARNING, "%s: errno=%d", maps_path, errno);
@@ -1379,7 +1340,7 @@
if (memcmp(obj->start_addr, ELFMAG, SELFMAG) != 0) {
return;
}
- int fd = OpenReadOnlyWithHighFD("/proc/self/exe");
+ int fd = open("/proc/self/exe", O_RDONLY);
if (fd == -1) {
return;
}
@@ -1403,7 +1364,7 @@
static bool MaybeInitializeObjFile(ObjFile *obj) {
if (obj->fd < 0) {
- obj->fd = OpenReadOnlyWithHighFD(obj->filename);
+ obj->fd = open(obj->filename, O_RDONLY);
if (obj->fd < 0) {
// Getting /proc/self/exe here means that we were hinted.
@@ -1411,7 +1372,7 @@
// /proc/self/exe may be inaccessible (due to setuid, etc.), so try
// accessing the binary via argv0.
if (argv0_value != nullptr) {
- obj->fd = OpenReadOnlyWithHighFD(argv0_value);
+ obj->fd = open(argv0_value, O_RDONLY);
}
} else {
MaybeOpenFdFromSelfExe(obj);
diff --git a/absl/debugging/symbolize_test.cc b/absl/debugging/symbolize_test.cc
index 69b0a26..d0feab2 100644
--- a/absl/debugging/symbolize_test.cc
+++ b/absl/debugging/symbolize_test.cc
@@ -167,8 +167,9 @@
#if defined(ABSL_HAVE_ATTRIBUTE_NOINLINE)
void *return_address = __builtin_return_address(0);
const char *symbol = TrySymbolize(return_address);
- ASSERT_NE(symbol, nullptr) << "TestWithReturnAddress failed";
- EXPECT_STREQ(symbol, "main") << "TestWithReturnAddress failed";
+ CHECK_NE(symbol, nullptr) << "TestWithReturnAddress failed";
+ CHECK_STREQ(symbol, "main") << "TestWithReturnAddress failed";
+ std::cout << "TestWithReturnAddress passed" << std::endl;
#endif
}
@@ -489,9 +490,10 @@
(defined(__i386__) || defined(__x86_64__))
void *pc = non_inline_func();
const char *symbol = TrySymbolize(pc);
- ASSERT_NE(symbol, nullptr) << "TestWithPCInsideNonInlineFunction failed";
- EXPECT_STREQ(symbol, "non_inline_func")
+ CHECK_NE(symbol, nullptr) << "TestWithPCInsideNonInlineFunction failed";
+ CHECK_STREQ(symbol, "non_inline_func")
<< "TestWithPCInsideNonInlineFunction failed";
+ std::cout << "TestWithPCInsideNonInlineFunction passed" << std::endl;
#endif
}
@@ -500,8 +502,9 @@
(defined(__i386__) || defined(__x86_64__))
void *pc = inline_func(); // Must be inlined.
const char *symbol = TrySymbolize(pc);
- ASSERT_NE(symbol, nullptr) << "TestWithPCInsideInlineFunction failed";
- EXPECT_STREQ(symbol, __FUNCTION__) << "TestWithPCInsideInlineFunction failed";
+ CHECK_NE(symbol, nullptr) << "TestWithPCInsideInlineFunction failed";
+ CHECK_STREQ(symbol, __FUNCTION__) << "TestWithPCInsideInlineFunction failed";
+ std::cout << "TestWithPCInsideInlineFunction passed" << std::endl;
#endif
}
}
@@ -542,8 +545,9 @@
void ABSL_ATTRIBUTE_NOINLINE TestArmThumbOverlap() {
#if defined(ABSL_HAVE_ATTRIBUTE_NOINLINE)
const char *symbol = TrySymbolize((void *)&ArmThumbOverlapArm);
- ASSERT_NE(symbol, nullptr) << "TestArmThumbOverlap failed";
- EXPECT_STREQ("ArmThumbOverlapArm()", symbol) << "TestArmThumbOverlap failed";
+ CHECK_NE(symbol, nullptr) << "TestArmThumbOverlap failed";
+ CHECK_STREQ("ArmThumbOverlapArm()", symbol) << "TestArmThumbOverlap failed";
+ std::cout << "TestArmThumbOverlap passed" << std::endl;
#endif
}
diff --git a/absl/flags/BUILD.bazel b/absl/flags/BUILD.bazel
index d9a3034..7a8ec7e 100644
--- a/absl/flags/BUILD.bazel
+++ b/absl/flags/BUILD.bazel
@@ -66,7 +66,6 @@
":path_util",
"//absl/base:config",
"//absl/base:core_headers",
- "//absl/base:no_destructor",
"//absl/strings",
"//absl/synchronization",
],
@@ -88,7 +87,6 @@
":program_name",
"//absl/base:config",
"//absl/base:core_headers",
- "//absl/base:no_destructor",
"//absl/strings",
"//absl/synchronization",
],
@@ -221,7 +219,6 @@
"//absl/base:config",
"//absl/base:core_headers",
"//absl/base:dynamic_annotations",
- "//absl/base:no_destructor",
"//absl/memory",
"//absl/meta:type_traits",
"//absl/strings",
@@ -273,7 +270,6 @@
":reflection",
"//absl/base:config",
"//absl/base:core_headers",
- "//absl/base:no_destructor",
"//absl/strings",
"//absl/synchronization",
],
@@ -322,7 +318,6 @@
"//absl/algorithm:container",
"//absl/base:config",
"//absl/base:core_headers",
- "//absl/base:no_destructor",
"//absl/strings",
"//absl/synchronization",
],
@@ -354,8 +349,8 @@
":reflection",
"//absl/memory",
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -369,8 +364,8 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":config",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -404,8 +399,8 @@
"//absl/strings",
"//absl/time",
"//absl/types:optional",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -430,7 +425,7 @@
"//absl/strings",
"//absl/time",
"//absl/types:optional",
- "@google_benchmark//:benchmark_main",
+ "@com_github_google_benchmark//:benchmark_main",
],
)
@@ -444,8 +439,8 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":marshalling",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -475,8 +470,8 @@
"//absl/log",
"//absl/strings",
"//absl/types:span",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -490,8 +485,8 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":path_util",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -503,15 +498,12 @@
],
copts = ABSL_TEST_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
- tags = [
- "no_test_fuchsia_x64",
- "no_test_wasm",
- ],
+ tags = ["no_test_wasm"],
deps = [
":program_name",
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -536,8 +528,8 @@
":reflection",
"//absl/memory",
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -557,8 +549,8 @@
"//absl/base",
"//absl/container:fixed_array",
"//absl/time",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -575,8 +567,8 @@
":path_util",
":program_name",
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -605,6 +597,6 @@
":usage",
":usage_internal",
"//absl/strings",
- "@googletest//:gtest",
+ "@com_google_googletest//:gtest",
],
)
diff --git a/absl/flags/CMakeLists.txt b/absl/flags/CMakeLists.txt
index 5430429..7376d11 100644
--- a/absl/flags/CMakeLists.txt
+++ b/absl/flags/CMakeLists.txt
@@ -45,7 +45,6 @@
DEPS
absl::config
absl::core_headers
- absl::no_destructor
absl::flags_path_util
absl::strings
absl::synchronization
@@ -69,7 +68,6 @@
absl::flags_path_util
absl::flags_program_name
absl::core_headers
- absl::no_destructor
absl::strings
absl::synchronization
)
@@ -194,7 +192,6 @@
absl::flags_commandlineflag_internal
absl::flags_config
absl::flags_marshalling
- absl::no_destructor
absl::synchronization
absl::meta
absl::utility
@@ -262,7 +259,6 @@
absl::config
absl::core_headers
absl::flags_usage_internal
- absl::no_destructor
absl::raw_logging_internal
absl::strings
absl::synchronization
@@ -293,7 +289,6 @@
absl::flags_program_name
absl::flags_reflection
absl::flags_usage
- absl::no_destructor
absl::strings
absl::synchronization
)
diff --git a/absl/flags/commandlineflag.cc b/absl/flags/commandlineflag.cc
index 4140230..9f3b4a5 100644
--- a/absl/flags/commandlineflag.cc
+++ b/absl/flags/commandlineflag.cc
@@ -24,7 +24,6 @@
namespace absl {
ABSL_NAMESPACE_BEGIN
-absl::string_view CommandLineFlag::TypeName() const { return ""; }
bool CommandLineFlag::IsRetired() const { return false; }
bool CommandLineFlag::ParseFrom(absl::string_view value, std::string* error) {
return ParseFrom(value, flags_internal::SET_FLAGS_VALUE,
diff --git a/absl/flags/commandlineflag.h b/absl/flags/commandlineflag.h
index a9ffd02..26ec0e7 100644
--- a/absl/flags/commandlineflag.h
+++ b/absl/flags/commandlineflag.h
@@ -200,13 +200,6 @@
// Checks that flags default value can be converted to string and back to the
// flag's value type.
virtual void CheckDefaultValueParsingRoundtrip() const = 0;
-
- // absl::CommandLineFlag::TypeName()
- //
- // Returns string representation of the type of this flag
- // (the way it is spelled in the ABSL_FLAG macro).
- // The default implementation returns the empty string.
- virtual absl::string_view TypeName() const;
};
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
diff --git a/absl/flags/flag.h b/absl/flags/flag.h
index 19d0ef9..a8e0e93 100644
--- a/absl/flags/flag.h
+++ b/absl/flags/flag.h
@@ -204,14 +204,12 @@
#if ABSL_FLAGS_STRIP_NAMES
#define ABSL_FLAG_IMPL_FLAGNAME(txt) ""
-#define ABSL_FLAG_IMPL_TYPENAME(txt) ""
#define ABSL_FLAG_IMPL_FILENAME() ""
#define ABSL_FLAG_IMPL_REGISTRAR(T, flag) \
absl::flags_internal::FlagRegistrar<T, false>(ABSL_FLAG_IMPL_FLAG_PTR(flag), \
nullptr)
#else
#define ABSL_FLAG_IMPL_FLAGNAME(txt) txt
-#define ABSL_FLAG_IMPL_TYPENAME(txt) txt
#define ABSL_FLAG_IMPL_FILENAME() __FILE__
#define ABSL_FLAG_IMPL_REGISTRAR(T, flag) \
absl::flags_internal::FlagRegistrar<T, true>(ABSL_FLAG_IMPL_FLAG_PTR(flag), \
@@ -263,17 +261,16 @@
// Note: Name of registrar object is not arbitrary. It is used to "grab"
// global name for FLAGS_no<flag_name> symbol, thus preventing the possibility
// of defining two flags with names foo and nofoo.
-#define ABSL_FLAG_IMPL(Type, name, default_value, help) \
- extern ::absl::Flag<Type> FLAGS_##name; \
- namespace absl /* block flags in namespaces */ {} \
- ABSL_FLAG_IMPL_DECLARE_DEF_VAL_WRAPPER(name, Type, default_value) \
- ABSL_FLAG_IMPL_DECLARE_HELP_WRAPPER(name, help) \
- ABSL_CONST_INIT absl::Flag<Type> FLAGS_##name{ \
- ABSL_FLAG_IMPL_FLAGNAME(#name), ABSL_FLAG_IMPL_TYPENAME(#Type), \
- ABSL_FLAG_IMPL_FILENAME(), ABSL_FLAG_IMPL_HELP_ARG(name), \
- ABSL_FLAG_IMPL_DEFAULT_ARG(Type, name)}; \
- extern absl::flags_internal::FlagRegistrarEmpty FLAGS_no##name; \
- absl::flags_internal::FlagRegistrarEmpty FLAGS_no##name = \
+#define ABSL_FLAG_IMPL(Type, name, default_value, help) \
+ extern ::absl::Flag<Type> FLAGS_##name; \
+ namespace absl /* block flags in namespaces */ {} \
+ ABSL_FLAG_IMPL_DECLARE_DEF_VAL_WRAPPER(name, Type, default_value) \
+ ABSL_FLAG_IMPL_DECLARE_HELP_WRAPPER(name, help) \
+ ABSL_CONST_INIT absl::Flag<Type> FLAGS_##name{ \
+ ABSL_FLAG_IMPL_FLAGNAME(#name), ABSL_FLAG_IMPL_FILENAME(), \
+ ABSL_FLAG_IMPL_HELP_ARG(name), ABSL_FLAG_IMPL_DEFAULT_ARG(Type, name)}; \
+ extern absl::flags_internal::FlagRegistrarEmpty FLAGS_no##name; \
+ absl::flags_internal::FlagRegistrarEmpty FLAGS_no##name = \
ABSL_FLAG_IMPL_REGISTRAR(Type, FLAGS_##name)
// ABSL_RETIRED_FLAG
@@ -293,7 +290,8 @@
// arguments unchanged (unless of course you actually want to retire the flag
// type at this time as well).
//
-// `default_value` and `explanation` are unused.
+// `default_value` is only used as a double check on the type. `explanation` is
+// unused.
// TODO(rogeeff): replace RETIRED_FLAGS with FLAGS once forward declarations of
// retired flags are cleaned up.
#define ABSL_RETIRED_FLAG(type, name, default_value, explanation) \
diff --git a/absl/flags/flag_test.cc b/absl/flags/flag_test.cc
index e3ab24c..8af5bf7 100644
--- a/absl/flags/flag_test.cc
+++ b/absl/flags/flag_test.cc
@@ -149,9 +149,9 @@
#define DEFINE_CONSTRUCTED_FLAG(T, dflt, dflt_kind) \
constexpr flags::FlagDefaultArg f1default##T{ \
flags::FlagDefaultSrc{dflt}, flags::FlagDefaultKind::dflt_kind}; \
- constexpr absl::Flag<T> f1##T{"f1", #T, "file", help_arg, f1default##T}; \
+ constexpr absl::Flag<T> f1##T{"f1", "file", help_arg, f1default##T}; \
ABSL_CONST_INIT absl::Flag<T> f2##T { \
- "f2", #T, "file", \
+ "f2", "file", \
{flags::FlagHelpMsg(&TestHelpMsg), flags::FlagHelpKind::kGenFunc}, \
flags::FlagDefaultArg { \
flags::FlagDefaultSrc(&TestMakeDflt<T>), \
diff --git a/absl/flags/internal/flag.cc b/absl/flags/internal/flag.cc
index ccd2667..981f19f 100644
--- a/absl/flags/internal/flag.cc
+++ b/absl/flags/internal/flag.cc
@@ -34,9 +34,7 @@
#include "absl/base/config.h"
#include "absl/base/const_init.h"
#include "absl/base/dynamic_annotations.h"
-#include "absl/base/no_destructor.h"
#include "absl/base/optimization.h"
-#include "absl/base/thread_annotations.h"
#include "absl/flags/config.h"
#include "absl/flags/internal/commandlineflag.h"
#include "absl/flags/usage_config.h"
@@ -87,15 +85,11 @@
// we move the memory to the freelist where it lives indefinitely, so it can
// still be safely accessed. This also prevents leak checkers from complaining
// about the leaked memory that can no longer be accessed through any pointer.
-absl::Mutex* FreelistMutex() {
- static absl::NoDestructor<absl::Mutex> mutex;
- return mutex.get();
-}
-ABSL_CONST_INIT std::vector<void*>* s_freelist ABSL_GUARDED_BY(FreelistMutex())
- ABSL_PT_GUARDED_BY(FreelistMutex()) = nullptr;
+ABSL_CONST_INIT absl::Mutex s_freelist_guard(absl::kConstInit);
+ABSL_CONST_INIT std::vector<void*>* s_freelist = nullptr;
void AddToFreelist(void* p) {
- absl::MutexLock l(FreelistMutex());
+ absl::MutexLock l(&s_freelist_guard);
if (!s_freelist) {
s_freelist = new std::vector<void*>;
}
@@ -107,7 +101,7 @@
///////////////////////////////////////////////////////////////////////////////
uint64_t NumLeakedFlagValues() {
- absl::MutexLock l(FreelistMutex());
+ absl::MutexLock l(&s_freelist_guard);
return s_freelist == nullptr ? 0u : s_freelist->size();
}
@@ -342,8 +336,6 @@
absl::string_view FlagImpl::Name() const { return name_; }
-absl::string_view FlagImpl::TypeName() const { return type_name_; }
-
std::string FlagImpl::Filename() const {
return flags_internal::GetUsageConfig().normalize_filename(filename_);
}
diff --git a/absl/flags/internal/flag.h b/absl/flags/internal/flag.h
index a6e7986..a0be31d 100644
--- a/absl/flags/internal/flag.h
+++ b/absl/flags/internal/flag.h
@@ -373,13 +373,9 @@
static constexpr int RequiredAlignment() { return 4; }
- constexpr MaskedPointer() : ptr_(nullptr) {}
constexpr explicit MaskedPointer(ptr_t rhs) : ptr_(rhs) {}
MaskedPointer(ptr_t rhs, bool is_candidate);
- MaskedPointer(const MaskedPointer& rhs) = default;
- MaskedPointer& operator=(const MaskedPointer& rhs) = default;
-
void* Ptr() const {
return reinterpret_cast<void*>(reinterpret_cast<mask_t>(ptr_) &
kPtrValueMask);
@@ -582,12 +578,10 @@
#endif
class FlagImpl final : public CommandLineFlag {
public:
- constexpr FlagImpl(const char* name, const char* type_name,
- const char* filename, FlagOpFn op, FlagHelpArg help,
- FlagValueStorageKind value_kind,
+ constexpr FlagImpl(const char* name, const char* filename, FlagOpFn op,
+ FlagHelpArg help, FlagValueStorageKind value_kind,
FlagDefaultArg default_arg)
: name_(name),
- type_name_(type_name),
filename_(filename),
op_(op),
help_(help.source),
@@ -700,7 +694,6 @@
// CommandLineFlag interface implementation
absl::string_view Name() const override;
- absl::string_view TypeName() const override;
std::string Filename() const override;
std::string Help() const override;
FlagFastTypeId TypeId() const override;
@@ -734,10 +727,6 @@
// Flags name passed to ABSL_FLAG as second arg.
const char* const name_;
-
- // Flags type passed to ABSL_FLAG as first arg.
- const char* const type_name_;
-
// The file name where ABSL_FLAG resides.
const char* const filename_;
// Type-specific operations vtable.
@@ -796,9 +785,9 @@
template <typename T>
class Flag {
public:
- constexpr Flag(const char* name, const char* type_name, const char* filename,
- FlagHelpArg help, const FlagDefaultArg default_arg)
- : impl_(name, type_name, filename, &FlagOps<T>, help,
+ constexpr Flag(const char* name, const char* filename, FlagHelpArg help,
+ const FlagDefaultArg default_arg)
+ : impl_(name, filename, &FlagOps<T>, help,
flags_internal::StorageKind<T>(), default_arg),
value_() {}
diff --git a/absl/flags/internal/private_handle_accessor.cc b/absl/flags/internal/private_handle_accessor.cc
index 610d1ff..a7eb58b 100644
--- a/absl/flags/internal/private_handle_accessor.cc
+++ b/absl/flags/internal/private_handle_accessor.cc
@@ -59,10 +59,6 @@
return flag.ParseFrom(value, set_mode, source, error);
}
-absl::string_view PrivateHandleAccessor::TypeName(const CommandLineFlag& flag) {
- return flag.TypeName();
-}
-
} // namespace flags_internal
ABSL_NAMESPACE_END
} // namespace absl
diff --git a/absl/flags/internal/private_handle_accessor.h b/absl/flags/internal/private_handle_accessor.h
index bf4154c..c64435c 100644
--- a/absl/flags/internal/private_handle_accessor.h
+++ b/absl/flags/internal/private_handle_accessor.h
@@ -52,9 +52,6 @@
static bool ParseFrom(CommandLineFlag& flag, absl::string_view value,
flags_internal::FlagSettingMode set_mode,
flags_internal::ValueSource source, std::string& error);
-
- // Access to CommandLineFlag::TypeName.
- static absl::string_view TypeName(const CommandLineFlag& flag);
};
} // namespace flags_internal
diff --git a/absl/flags/internal/program_name.cc b/absl/flags/internal/program_name.cc
index fb06643..51d698d 100644
--- a/absl/flags/internal/program_name.cc
+++ b/absl/flags/internal/program_name.cc
@@ -19,7 +19,7 @@
#include "absl/base/attributes.h"
#include "absl/base/config.h"
-#include "absl/base/no_destructor.h"
+#include "absl/base/const_init.h"
#include "absl/base/thread_annotations.h"
#include "absl/flags/internal/path_util.h"
#include "absl/strings/string_view.h"
@@ -29,31 +29,30 @@
ABSL_NAMESPACE_BEGIN
namespace flags_internal {
-static absl::Mutex* ProgramNameMutex() {
- static absl::NoDestructor<absl::Mutex> mutex;
- return mutex.get();
-}
-ABSL_CONST_INIT static std::string* program_name ABSL_GUARDED_BY(
- ProgramNameMutex()) ABSL_PT_GUARDED_BY(ProgramNameMutex()) = nullptr;
+ABSL_CONST_INIT static absl::Mutex program_name_guard(absl::kConstInit);
+ABSL_CONST_INIT static std::string* program_name
+ ABSL_GUARDED_BY(program_name_guard) = nullptr;
std::string ProgramInvocationName() {
- absl::MutexLock l(ProgramNameMutex());
+ absl::MutexLock l(&program_name_guard);
+
return program_name ? *program_name : "UNKNOWN";
}
std::string ShortProgramInvocationName() {
- absl::MutexLock l(ProgramNameMutex());
+ absl::MutexLock l(&program_name_guard);
+
return program_name ? std::string(flags_internal::Basename(*program_name))
: "UNKNOWN";
}
void SetProgramInvocationName(absl::string_view prog_name_str) {
- absl::MutexLock l(ProgramNameMutex());
- if (!program_name) {
+ absl::MutexLock l(&program_name_guard);
+
+ if (!program_name)
program_name = new std::string(prog_name_str);
- } else {
+ else
program_name->assign(prog_name_str.data(), prog_name_str.size());
- }
}
} // namespace flags_internal
diff --git a/absl/flags/internal/usage.cc b/absl/flags/internal/usage.cc
index fc68b03..8b169bc 100644
--- a/absl/flags/internal/usage.cc
+++ b/absl/flags/internal/usage.cc
@@ -29,7 +29,7 @@
#include "absl/base/attributes.h"
#include "absl/base/config.h"
-#include "absl/base/no_destructor.h"
+#include "absl/base/const_init.h"
#include "absl/base/thread_annotations.h"
#include "absl/flags/commandlineflag.h"
#include "absl/flags/flag.h"
@@ -434,48 +434,45 @@
namespace {
-absl::Mutex* HelpAttributesMutex() {
- static absl::NoDestructor<absl::Mutex> mutex;
- return mutex.get();
-}
-ABSL_CONST_INIT std::string* match_substr ABSL_GUARDED_BY(HelpAttributesMutex())
- ABSL_PT_GUARDED_BY(HelpAttributesMutex()) = nullptr;
-ABSL_CONST_INIT HelpMode help_mode ABSL_GUARDED_BY(HelpAttributesMutex()) =
+ABSL_CONST_INIT absl::Mutex help_attributes_guard(absl::kConstInit);
+ABSL_CONST_INIT std::string* match_substr
+ ABSL_GUARDED_BY(help_attributes_guard) = nullptr;
+ABSL_CONST_INIT HelpMode help_mode ABSL_GUARDED_BY(help_attributes_guard) =
HelpMode::kNone;
-ABSL_CONST_INIT HelpFormat help_format ABSL_GUARDED_BY(HelpAttributesMutex()) =
+ABSL_CONST_INIT HelpFormat help_format ABSL_GUARDED_BY(help_attributes_guard) =
HelpFormat::kHumanReadable;
} // namespace
std::string GetFlagsHelpMatchSubstr() {
- absl::MutexLock l(HelpAttributesMutex());
+ absl::MutexLock l(&help_attributes_guard);
if (match_substr == nullptr) return "";
return *match_substr;
}
void SetFlagsHelpMatchSubstr(absl::string_view substr) {
- absl::MutexLock l(HelpAttributesMutex());
+ absl::MutexLock l(&help_attributes_guard);
if (match_substr == nullptr) match_substr = new std::string;
match_substr->assign(substr.data(), substr.size());
}
HelpMode GetFlagsHelpMode() {
- absl::MutexLock l(HelpAttributesMutex());
+ absl::MutexLock l(&help_attributes_guard);
return help_mode;
}
void SetFlagsHelpMode(HelpMode mode) {
- absl::MutexLock l(HelpAttributesMutex());
+ absl::MutexLock l(&help_attributes_guard);
help_mode = mode;
}
HelpFormat GetFlagsHelpFormat() {
- absl::MutexLock l(HelpAttributesMutex());
+ absl::MutexLock l(&help_attributes_guard);
return help_format;
}
void SetFlagsHelpFormat(HelpFormat format) {
- absl::MutexLock l(HelpAttributesMutex());
+ absl::MutexLock l(&help_attributes_guard);
help_format = format;
}
diff --git a/absl/flags/parse.cc b/absl/flags/parse.cc
index 8be2016..526b61d 100644
--- a/absl/flags/parse.cc
+++ b/absl/flags/parse.cc
@@ -35,7 +35,7 @@
#include "absl/algorithm/container.h"
#include "absl/base/attributes.h"
#include "absl/base/config.h"
-#include "absl/base/no_destructor.h"
+#include "absl/base/const_init.h"
#include "absl/base/thread_annotations.h"
#include "absl/flags/commandlineflag.h"
#include "absl/flags/config.h"
@@ -64,17 +64,14 @@
namespace flags_internal {
namespace {
-absl::Mutex* ProcessingChecksMutex() {
- static absl::NoDestructor<absl::Mutex> mutex;
- return mutex.get();
-}
+ABSL_CONST_INIT absl::Mutex processing_checks_guard(absl::kConstInit);
ABSL_CONST_INIT bool flagfile_needs_processing
- ABSL_GUARDED_BY(ProcessingChecksMutex()) = false;
+ ABSL_GUARDED_BY(processing_checks_guard) = false;
ABSL_CONST_INIT bool fromenv_needs_processing
- ABSL_GUARDED_BY(ProcessingChecksMutex()) = false;
+ ABSL_GUARDED_BY(processing_checks_guard) = false;
ABSL_CONST_INIT bool tryfromenv_needs_processing
- ABSL_GUARDED_BY(ProcessingChecksMutex()) = false;
+ ABSL_GUARDED_BY(processing_checks_guard) = false;
ABSL_CONST_INIT absl::Mutex specified_flags_guard(absl::kConstInit);
ABSL_CONST_INIT std::vector<const CommandLineFlag*>* specified_flags
@@ -109,7 +106,7 @@
.OnUpdate([]() {
if (absl::GetFlag(FLAGS_flagfile).empty()) return;
- absl::MutexLock l(absl::flags_internal::ProcessingChecksMutex());
+ absl::MutexLock l(&absl::flags_internal::processing_checks_guard);
// Setting this flag twice before it is handled most likely an internal
// error and should be reviewed by developers.
@@ -125,7 +122,7 @@
.OnUpdate([]() {
if (absl::GetFlag(FLAGS_fromenv).empty()) return;
- absl::MutexLock l(absl::flags_internal::ProcessingChecksMutex());
+ absl::MutexLock l(&absl::flags_internal::processing_checks_guard);
// Setting this flag twice before it is handled most likely an internal
// error and should be reviewed by developers.
@@ -141,7 +138,7 @@
.OnUpdate([]() {
if (absl::GetFlag(FLAGS_tryfromenv).empty()) return;
- absl::MutexLock l(absl::flags_internal::ProcessingChecksMutex());
+ absl::MutexLock l(&absl::flags_internal::processing_checks_guard);
// Setting this flag twice before it is handled most likely an internal
// error and should be reviewed by developers.
@@ -418,7 +415,7 @@
std::vector<std::string>& flagfile_value) {
bool success = true;
- absl::MutexLock l(flags_internal::ProcessingChecksMutex());
+ absl::MutexLock l(&flags_internal::processing_checks_guard);
// flagfile could have been set either on a command line or
// programmatically before invoking ParseCommandLine. Note that we do not
@@ -481,7 +478,7 @@
// going to be {"f1", "f2"}
if (!flagfile_value.empty()) {
absl::SetFlag(&FLAGS_flagfile, flagfile_value);
- absl::MutexLock l(flags_internal::ProcessingChecksMutex());
+ absl::MutexLock l(&flags_internal::processing_checks_guard);
flags_internal::flagfile_needs_processing = false;
}
@@ -493,7 +490,7 @@
absl::SetFlag(&FLAGS_tryfromenv, {});
}
- absl::MutexLock l(flags_internal::ProcessingChecksMutex());
+ absl::MutexLock l(&flags_internal::processing_checks_guard);
flags_internal::fromenv_needs_processing = false;
flags_internal::tryfromenv_needs_processing = false;
}
diff --git a/absl/flags/usage_config.cc b/absl/flags/usage_config.cc
index 5922c5e..5d7426d 100644
--- a/absl/flags/usage_config.cc
+++ b/absl/flags/usage_config.cc
@@ -22,7 +22,6 @@
#include "absl/base/attributes.h"
#include "absl/base/config.h"
#include "absl/base/const_init.h"
-#include "absl/base/no_destructor.h"
#include "absl/base/thread_annotations.h"
#include "absl/flags/internal/path_util.h"
#include "absl/flags/internal/program_name.h"
@@ -105,18 +104,14 @@
// --------------------------------------------------------------------
-absl::Mutex* CustomUsageConfigMutex() {
- static absl::NoDestructor<absl::Mutex> mutex;
- return mutex.get();
-}
+ABSL_CONST_INIT absl::Mutex custom_usage_config_guard(absl::kConstInit);
ABSL_CONST_INIT FlagsUsageConfig* custom_usage_config
- ABSL_GUARDED_BY(CustomUsageConfigMutex())
- ABSL_PT_GUARDED_BY(CustomUsageConfigMutex()) = nullptr;
+ ABSL_GUARDED_BY(custom_usage_config_guard) = nullptr;
} // namespace
FlagsUsageConfig GetUsageConfig() {
- absl::MutexLock l(CustomUsageConfigMutex());
+ absl::MutexLock l(&custom_usage_config_guard);
if (custom_usage_config) return *custom_usage_config;
@@ -141,7 +136,7 @@
} // namespace flags_internal
void SetFlagsUsageConfig(FlagsUsageConfig usage_config) {
- absl::MutexLock l(flags_internal::CustomUsageConfigMutex());
+ absl::MutexLock l(&flags_internal::custom_usage_config_guard);
if (!usage_config.contains_helpshort_flags)
usage_config.contains_helpshort_flags =
diff --git a/absl/functional/BUILD.bazel b/absl/functional/BUILD.bazel
index 56380cb..1a18af2 100644
--- a/absl/functional/BUILD.bazel
+++ b/absl/functional/BUILD.bazel
@@ -62,8 +62,8 @@
"//absl/base:core_headers",
"//absl/meta:type_traits",
"//absl/utility",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -89,8 +89,8 @@
deps = [
":bind_front",
"//absl/memory",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -118,8 +118,8 @@
":function_ref",
"//absl/container:test_instance_tracker",
"//absl/memory",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -145,8 +145,8 @@
"//absl/strings",
"//absl/strings:string_view",
"//absl/types:variant",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -162,7 +162,7 @@
":any_invocable",
":function_ref",
"//absl/base:core_headers",
- "@google_benchmark//:benchmark_main",
- "@googletest//:gtest",
+ "@com_github_google_benchmark//:benchmark_main",
+ "@com_google_googletest//:gtest",
],
)
diff --git a/absl/functional/bind_front_test.cc b/absl/functional/bind_front_test.cc
index 5d94ecc..4801a81 100644
--- a/absl/functional/bind_front_test.cc
+++ b/absl/functional/bind_front_test.cc
@@ -210,9 +210,13 @@
constexpr auto plus5 = absl::bind_front(Plus, five);
EXPECT_EQ(plus5(1), 6);
+ // There seems to be a bug in MSVC dealing constexpr construction of
+ // char[]. Notice 'plus5' above; 'int' works just fine.
+#if !(defined(_MSC_VER) && _MSC_VER < 1910)
static constexpr char data[] = "DEF";
constexpr auto g = absl::bind_front(CharAt, data);
EXPECT_EQ(g(1), 'E');
+#endif
}
struct ManglingCall {
diff --git a/absl/hash/BUILD.bazel b/absl/hash/BUILD.bazel
index 66ad2ad..fe567e9 100644
--- a/absl/hash/BUILD.bazel
+++ b/absl/hash/BUILD.bazel
@@ -69,7 +69,7 @@
"//absl/meta:type_traits",
"//absl/strings",
"//absl/types:variant",
- "@googletest//:gtest",
+ "@com_google_googletest//:gtest",
],
)
@@ -86,16 +86,21 @@
":hash_testing",
":spy_hash_state",
"//absl/base:config",
+ "//absl/base:core_headers",
+ "//absl/container:btree",
+ "//absl/container:flat_hash_map",
"//absl/container:flat_hash_set",
+ "//absl/container:node_hash_map",
+ "//absl/container:node_hash_set",
"//absl/memory",
"//absl/meta:type_traits",
- "//absl/numeric:bits",
+ "//absl/numeric:int128",
"//absl/strings:cord_test_helpers",
"//absl/strings:string_view",
"//absl/types:optional",
"//absl/types:variant",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -116,8 +121,8 @@
"//absl/container:flat_hash_set",
"//absl/container:node_hash_map",
"//absl/container:node_hash_set",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -137,7 +142,7 @@
"//absl/strings",
"//absl/strings:cord",
"//absl/strings:cord_test_helpers",
- "@google_benchmark//:benchmark_main",
+ "@com_github_google_benchmark//:benchmark_main",
],
)
@@ -177,8 +182,8 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":city",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -206,7 +211,7 @@
deps = [
":low_level_hash",
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
diff --git a/absl/hash/CMakeLists.txt b/absl/hash/CMakeLists.txt
index 2281d7b..99d6fa1 100644
--- a/absl/hash/CMakeLists.txt
+++ b/absl/hash/CMakeLists.txt
@@ -68,13 +68,18 @@
COPTS
${ABSL_TEST_COPTS}
DEPS
- absl::bits
+ absl::btree
absl::cord_test_helpers
+ absl::core_headers
+ absl::flat_hash_map
absl::flat_hash_set
absl::hash
absl::hash_testing
+ absl::int128
absl::memory
absl::meta
+ absl::node_hash_map
+ absl::node_hash_set
absl::optional
absl::spy_hash_state
absl::string_view
diff --git a/absl/hash/hash.h b/absl/hash/hash.h
index 479b17b..470cca4 100644
--- a/absl/hash/hash.h
+++ b/absl/hash/hash.h
@@ -78,16 +78,11 @@
#ifndef ABSL_HASH_HASH_H_
#define ABSL_HASH_HASH_H_
-#include <cstddef>
-#include <cstdint>
#include <tuple>
-#include <type_traits>
#include <utility>
-#include "absl/base/config.h"
#include "absl/functional/function_ref.h"
#include "absl/hash/internal/hash.h"
-#include "absl/meta/type_traits.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
@@ -324,12 +319,8 @@
// Create a new `HashState` instance that wraps `state`. All calls to
// `combine()` and `combine_contiguous()` on the new instance will be
// redirected to the original `state` object. The `state` object must outlive
- // the `HashState` instance. `T` must be a subclass of `HashStateBase<T>` -
- // users should not define their own HashState types.
- template <
- typename T,
- absl::enable_if_t<
- std::is_base_of<hash_internal::HashStateBase<T>, T>::value, int> = 0>
+ // the `HashState` instance.
+ template <typename T>
static HashState Create(T* state) {
HashState s;
s.Init(state);
@@ -362,7 +353,6 @@
HashState() = default;
friend class HashState::HashStateBase;
- friend struct hash_internal::CombineRaw;
template <typename T>
static void CombineContiguousImpl(void* p, const unsigned char* first,
@@ -371,22 +361,10 @@
state = T::combine_contiguous(std::move(state), first, size);
}
- static HashState combine_raw(HashState hash_state, uint64_t value) {
- hash_state.combine_raw_(hash_state.state_, value);
- return hash_state;
- }
-
- template <typename T>
- static void CombineRawImpl(void* p, uint64_t value) {
- T& state = *static_cast<T*>(p);
- state = hash_internal::CombineRaw()(std::move(state), value);
- }
-
template <typename T>
void Init(T* state) {
state_ = state;
combine_contiguous_ = &CombineContiguousImpl<T>;
- combine_raw_ = &CombineRawImpl<T>;
run_combine_unordered_ = &RunCombineUnorderedImpl<T>;
}
@@ -425,7 +403,6 @@
void Init(HashState* state) {
state_ = state->state_;
combine_contiguous_ = state->combine_contiguous_;
- combine_raw_ = state->combine_raw_;
run_combine_unordered_ = state->run_combine_unordered_;
}
@@ -436,7 +413,6 @@
void* state_;
void (*combine_contiguous_)(void*, const unsigned char*, size_t);
- void (*combine_raw_)(void*, uint64_t);
HashState (*run_combine_unordered_)(
HashState state,
absl::FunctionRef<void(HashState, absl::FunctionRef<void(HashState&)>)>);
diff --git a/absl/hash/hash_benchmark.cc b/absl/hash/hash_benchmark.cc
index c2b95e8..9b73f46 100644
--- a/absl/hash/hash_benchmark.cc
+++ b/absl/hash/hash_benchmark.cc
@@ -146,59 +146,6 @@
return result;
}
-template <typename T>
-struct LongCombine {
- T a[200]{};
- template <typename H>
- friend H AbslHashValue(H state, const LongCombine& v) {
- // This is testing a single call to `combine` with a lot of arguments to
- // test the performance of the folding logic.
- return H::combine(
- std::move(state), //
- v.a[0], v.a[1], v.a[2], v.a[3], v.a[4], v.a[5], v.a[6], v.a[7], v.a[8],
- v.a[9], v.a[10], v.a[11], v.a[12], v.a[13], v.a[14], v.a[15], v.a[16],
- v.a[17], v.a[18], v.a[19], v.a[20], v.a[21], v.a[22], v.a[23], v.a[24],
- v.a[25], v.a[26], v.a[27], v.a[28], v.a[29], v.a[30], v.a[31], v.a[32],
- v.a[33], v.a[34], v.a[35], v.a[36], v.a[37], v.a[38], v.a[39], v.a[40],
- v.a[41], v.a[42], v.a[43], v.a[44], v.a[45], v.a[46], v.a[47], v.a[48],
- v.a[49], v.a[50], v.a[51], v.a[52], v.a[53], v.a[54], v.a[55], v.a[56],
- v.a[57], v.a[58], v.a[59], v.a[60], v.a[61], v.a[62], v.a[63], v.a[64],
- v.a[65], v.a[66], v.a[67], v.a[68], v.a[69], v.a[70], v.a[71], v.a[72],
- v.a[73], v.a[74], v.a[75], v.a[76], v.a[77], v.a[78], v.a[79], v.a[80],
- v.a[81], v.a[82], v.a[83], v.a[84], v.a[85], v.a[86], v.a[87], v.a[88],
- v.a[89], v.a[90], v.a[91], v.a[92], v.a[93], v.a[94], v.a[95], v.a[96],
- v.a[97], v.a[98], v.a[99], v.a[100], v.a[101], v.a[102], v.a[103],
- v.a[104], v.a[105], v.a[106], v.a[107], v.a[108], v.a[109], v.a[110],
- v.a[111], v.a[112], v.a[113], v.a[114], v.a[115], v.a[116], v.a[117],
- v.a[118], v.a[119], v.a[120], v.a[121], v.a[122], v.a[123], v.a[124],
- v.a[125], v.a[126], v.a[127], v.a[128], v.a[129], v.a[130], v.a[131],
- v.a[132], v.a[133], v.a[134], v.a[135], v.a[136], v.a[137], v.a[138],
- v.a[139], v.a[140], v.a[141], v.a[142], v.a[143], v.a[144], v.a[145],
- v.a[146], v.a[147], v.a[148], v.a[149], v.a[150], v.a[151], v.a[152],
- v.a[153], v.a[154], v.a[155], v.a[156], v.a[157], v.a[158], v.a[159],
- v.a[160], v.a[161], v.a[162], v.a[163], v.a[164], v.a[165], v.a[166],
- v.a[167], v.a[168], v.a[169], v.a[170], v.a[171], v.a[172], v.a[173],
- v.a[174], v.a[175], v.a[176], v.a[177], v.a[178], v.a[179], v.a[180],
- v.a[181], v.a[182], v.a[183], v.a[184], v.a[185], v.a[186], v.a[187],
- v.a[188], v.a[189], v.a[190], v.a[191], v.a[192], v.a[193], v.a[194],
- v.a[195], v.a[196], v.a[197], v.a[198], v.a[199]);
- }
-};
-
-template <typename T>
-auto MakeLongTuple() {
- auto t1 = std::tuple<T>();
- auto t2 = std::tuple_cat(t1, t1);
- auto t3 = std::tuple_cat(t2, t2);
- auto t4 = std::tuple_cat(t3, t3);
- auto t5 = std::tuple_cat(t4, t4);
- auto t6 = std::tuple_cat(t5, t5);
- // Ideally this would be much larger, but some configurations can't handle
- // making tuples with that many elements. They break inside std::tuple itself.
- static_assert(std::tuple_size<decltype(t6)>::value == 32, "");
- return t6;
-}
-
// Generates a benchmark and a codegen method for the provided types. The
// codegen method provides a well known entrypoint for dumping assembly.
#define MAKE_BENCHMARK(hash, name, ...) \
@@ -224,10 +171,6 @@
MAKE_BENCHMARK(AbslHash, TupleInt32BoolInt64,
std::tuple<int32_t, bool, int64_t>{});
MAKE_BENCHMARK(AbslHash, String_0, std::string());
-MAKE_BENCHMARK(AbslHash, String_1, std::string(1, 'a'));
-MAKE_BENCHMARK(AbslHash, String_2, std::string(2, 'a'));
-MAKE_BENCHMARK(AbslHash, String_4, std::string(4, 'a'));
-MAKE_BENCHMARK(AbslHash, String_8, std::string(8, 'a'));
MAKE_BENCHMARK(AbslHash, String_10, std::string(10, 'a'));
MAKE_BENCHMARK(AbslHash, String_30, std::string(30, 'a'));
MAKE_BENCHMARK(AbslHash, String_90, std::string(90, 'a'));
@@ -269,10 +212,6 @@
std::make_pair(std::string(200, 'a'), std::string(200, 'b')));
MAKE_BENCHMARK(AbslHash, PairStringString_5000,
std::make_pair(std::string(5000, 'a'), std::string(5000, 'b')));
-MAKE_BENCHMARK(AbslHash, LongTupleInt32, MakeLongTuple<int>());
-MAKE_BENCHMARK(AbslHash, LongTupleString, MakeLongTuple<std::string>());
-MAKE_BENCHMARK(AbslHash, LongCombineInt32, LongCombine<int>());
-MAKE_BENCHMARK(AbslHash, LongCombineString, LongCombine<std::string>());
MAKE_BENCHMARK(TypeErasedAbslHash, Int32, int32_t{});
MAKE_BENCHMARK(TypeErasedAbslHash, Int64, int64_t{});
diff --git a/absl/hash/hash_test.cc b/absl/hash/hash_test.cc
index e25c0ac..7fecf53 100644
--- a/absl/hash/hash_test.cc
+++ b/absl/hash/hash_test.cc
@@ -35,7 +35,6 @@
#include <utility>
#include <vector>
-#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "absl/base/config.h"
#include "absl/container/flat_hash_set.h"
@@ -44,7 +43,6 @@
#include "absl/hash/internal/spy_hash_state.h"
#include "absl/memory/memory.h"
#include "absl/meta/type_traits.h"
-#include "absl/numeric/bits.h"
#include "absl/strings/cord_test_helpers.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
@@ -63,7 +61,6 @@
using ::absl::hash_test_internal::is_hashable;
using ::absl::hash_test_internal::TypeErasedContainer;
using ::absl::hash_test_internal::TypeErasedValue;
-using ::testing::SizeIs;
template <typename T>
using TypeErasedVector = TypeErasedContainer<std::vector<T>>;
@@ -120,15 +117,6 @@
std::make_tuple(true, false)));
}
-TEST(HashValueTest, HashConsistentAcrossIntTypes){
- std::vector<size_t> hashes = {
- absl::Hash<int8_t>{}(1), absl::Hash<uint8_t>{}(1),
- absl::Hash<int16_t>{}(1), absl::Hash<uint16_t>{}(1),
- absl::Hash<int32_t>{}(1), absl::Hash<uint32_t>{}(1),
- absl::Hash<int64_t>{}(1), absl::Hash<uint64_t>{}(1)};
- EXPECT_THAT(hashes, testing::Each(absl::Hash<int>{}(1)));
-}
-
TEST(HashValueTest, FloatingPoint) {
EXPECT_TRUE((is_hashable<float>::value));
EXPECT_TRUE((is_hashable<double>::value));
@@ -165,8 +153,8 @@
}
TEST(HashValueTest, PointerAlignment) {
- // We want to make sure that pointer alignment will not cause too many bits to
- // be stuck.
+ // We want to make sure that pointer alignment will not cause bits to be
+ // stuck.
constexpr size_t kTotalSize = 1 << 20;
std::unique_ptr<char[]> data(new char[kTotalSize]);
@@ -190,9 +178,7 @@
// Limit the scope to the bits we would be using for Swisstable.
constexpr size_t kMask = (1 << (kLog2NumValues + 7)) - 1;
size_t stuck_bits = (~bits_or | bits_and) & kMask;
- // Test that there are at most 2 stuck bits. Sometimes we see stuck_bits
- // of 0x3.
- EXPECT_LE(absl::popcount(stuck_bits), 2) << "0x" << std::hex << stuck_bits;
+ EXPECT_EQ(stuck_bits, 0u) << "0x" << std::hex << stuck_bits;
}
}
@@ -315,7 +301,7 @@
struct DummyDeleter {
template <typename T>
- void operator() (T*) {}
+ void operator() (T* ptr) {}
};
struct SmartPointerEq {
@@ -395,36 +381,6 @@
return absl::MakeFragmentedCord(parts);
}
-#ifdef ABSL_HAVE_INTRINSIC_INT128
-TEST(HashValueTest, TestIntrinsicInt128) {
- EXPECT_TRUE((is_hashable<__int128_t>::value));
- EXPECT_TRUE((is_hashable<__uint128_t>::value));
-
- absl::flat_hash_set<size_t> hashes;
- std::vector<__uint128_t> values;
- for (int i = 0; i < 128; ++i) {
- // Some arbitrary pattern to check if changing each bit changes the hash.
- static constexpr __uint128_t kPattern =
- __uint128_t{0x0123456789abcdef} |
- (__uint128_t{0x0123456789abcdef} << 64);
- const __uint128_t value = kPattern ^ (__uint128_t{1} << i);
- const __int128_t as_signed = static_cast<__int128_t>(value);
-
- values.push_back(value);
- hashes.insert(absl::Hash<__uint128_t>{}(value));
-
- // Verify that the fast-path for MixingHashState does not break the hash.
- EXPECT_EQ(absl::HashOf(value), absl::Hash<__uint128_t>{}(value));
- EXPECT_EQ(absl::HashOf(as_signed), absl::Hash<__int128_t>{}(as_signed));
- }
- EXPECT_THAT(hashes, SizeIs(128));
-
- EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly(values));
- EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly(
- std::vector<__int128_t>(values.begin(), values.end())));
-}
-#endif // ABSL_HAVE_INTRINSIC_INT128
-
TEST(HashValueTest, Strings) {
EXPECT_TRUE((is_hashable<std::string>::value));
@@ -433,39 +389,33 @@
const std::string large = std::string(2048, 'x'); // multiple of chunk size
const std::string huge = std::string(5000, 'a'); // not a multiple
- EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly(std::make_tuple(
- std::string(), absl::string_view(), absl::Cord(), std::string(""),
- absl::string_view(""), absl::Cord(""), std::string(small),
- absl::string_view(small), absl::Cord(small), FragmentedCord(small),
- std::string(dup), absl::string_view(dup), absl::Cord(dup),
- std::string(large), absl::string_view(large), absl::Cord(large),
- std::string(huge), absl::string_view(huge), FlatCord(huge),
+ EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly(std::make_tuple( //
+ std::string(), absl::string_view(), absl::Cord(), //
+ std::string(""), absl::string_view(""), absl::Cord(""), //
+ std::string(small), absl::string_view(small), absl::Cord(small), //
+ std::string(dup), absl::string_view(dup), absl::Cord(dup), //
+ std::string(large), absl::string_view(large), absl::Cord(large), //
+ std::string(huge), absl::string_view(huge), FlatCord(huge), //
FragmentedCord(huge))));
// Also check that nested types maintain the same hash.
const WrapInTuple t{};
- EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly(std::make_tuple(
- t(std::string()), t(absl::string_view()), t(absl::Cord()),
- t(std::string("")), t(absl::string_view("")), t(absl::Cord("")),
- t(std::string(small)), t(absl::string_view(small)), t(absl::Cord(small)),
- t(FragmentedCord(small)), t(std::string(dup)), t(absl::string_view(dup)),
- t(absl::Cord(dup)), t(std::string(large)), t(absl::string_view(large)),
- t(absl::Cord(large)), t(std::string(huge)), t(absl::string_view(huge)),
- t(FlatCord(huge)), t(FragmentedCord(huge)))));
+ EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly(std::make_tuple( //
+ t(std::string()), t(absl::string_view()), t(absl::Cord()), //
+ t(std::string("")), t(absl::string_view("")), t(absl::Cord("")), //
+ t(std::string(small)), t(absl::string_view(small)), //
+ t(absl::Cord(small)), //
+ t(std::string(dup)), t(absl::string_view(dup)), t(absl::Cord(dup)), //
+ t(std::string(large)), t(absl::string_view(large)), //
+ t(absl::Cord(large)), //
+ t(std::string(huge)), t(absl::string_view(huge)), //
+ t(FlatCord(huge)), t(FragmentedCord(huge)))));
// Make sure that hashing a `const char*` does not use its string-value.
EXPECT_NE(SpyHash(static_cast<const char*>("ABC")),
SpyHash(absl::string_view("ABC")));
}
-TEST(HashValueTest, StringsVector) {
- using Vec = std::vector<std::string>;
- EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly(std::make_tuple(
- Vec{"abc", "def"}, Vec{"abcde", "f"},
- Vec{"abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"},
- Vec{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXY", "Z"})));
-}
-
TEST(HashValueTest, WString) {
EXPECT_TRUE((is_hashable<std::wstring>::value));
@@ -1195,22 +1145,4 @@
EXPECT_FALSE(HashOfExplicitParameter<int>(0));
}
-struct TypeErasedHashStateUser {
- int a;
- std::string b;
-
- template <typename H>
- friend H AbslHashValue(H state, const TypeErasedHashStateUser& value) {
- absl::HashState type_erased_state = absl::HashState::Create(&state);
- absl::HashState::combine(std::move(type_erased_state), value.a, value.b);
- return state;
- }
-};
-
-TEST(HashOf, MatchesTypeErasedHashState) {
- std::string s = "s";
- EXPECT_EQ(absl::HashOf(1, s), absl::Hash<TypeErasedHashStateUser>{}(
- TypeErasedHashStateUser{1, s}));
-}
-
} // namespace
diff --git a/absl/hash/hash_testing.h b/absl/hash/hash_testing.h
index 673366d..1e1c574 100644
--- a/absl/hash/hash_testing.h
+++ b/absl/hash/hash_testing.h
@@ -244,8 +244,7 @@
if (v.expand() != expected) {
return testing::AssertionFailure()
<< "Values " << c[0].ToString() << " and " << v.ToString()
- << " evaluate as equal but have unequal hash expansions ("
- << expected << " vs. " << v.expand() << ").";
+ << " evaluate as equal but have an unequal hash expansion.";
}
}
@@ -257,18 +256,17 @@
case SpyHashState::CompareResult::kEqual:
return testing::AssertionFailure()
<< "Values " << c[0].ToString() << " and " << c2[0].ToString()
- << " evaluate as unequal but have an equal hash expansion:"
- << c2_hash << ".";
+ << " evaluate as unequal but have an equal hash expansion.";
case SpyHashState::CompareResult::kBSuffixA:
return testing::AssertionFailure()
- << "Hash expansion of " << c2[0].ToString() << ";" << c2_hash
+ << "Hash expansion of " << c2[0].ToString()
<< " is a suffix of the hash expansion of " << c[0].ToString()
- << ";" << expected << ".";
+ << ".";
case SpyHashState::CompareResult::kASuffixB:
return testing::AssertionFailure()
- << "Hash expansion of " << c[0].ToString() << ";"
- << expected << " is a suffix of the hash expansion of "
- << c2[0].ToString() << ";" << c2_hash << ".";
+ << "Hash expansion of " << c[0].ToString()
+ << " is a suffix of the hash expansion of " << c2[0].ToString()
+ << ".";
case SpyHashState::CompareResult::kUnequal:
break;
}
diff --git a/absl/hash/internal/hash.cc b/absl/hash/internal/hash.cc
index e0a8ea9..93906ef 100644
--- a/absl/hash/internal/hash.cc
+++ b/absl/hash/internal/hash.cc
@@ -14,14 +14,6 @@
#include "absl/hash/internal/hash.h"
-#include <cstddef>
-#include <cstdint>
-#include <type_traits>
-
-#include "absl/base/attributes.h"
-#include "absl/base/config.h"
-#include "absl/hash/internal/low_level_hash.h"
-
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace hash_internal {
@@ -29,10 +21,9 @@
uint64_t MixingHashState::CombineLargeContiguousImpl32(
uint64_t state, const unsigned char* first, size_t len) {
while (len >= PiecewiseChunkSize()) {
- state = Mix(
- state ^ hash_internal::CityHash32(reinterpret_cast<const char*>(first),
- PiecewiseChunkSize()),
- kMul);
+ state = Mix(state,
+ hash_internal::CityHash32(reinterpret_cast<const char*>(first),
+ PiecewiseChunkSize()));
len -= PiecewiseChunkSize();
first += PiecewiseChunkSize();
}
@@ -44,7 +35,7 @@
uint64_t MixingHashState::CombineLargeContiguousImpl64(
uint64_t state, const unsigned char* first, size_t len) {
while (len >= PiecewiseChunkSize()) {
- state = Mix(state ^ Hash64(first, PiecewiseChunkSize()), kMul);
+ state = Mix(state, Hash64(first, PiecewiseChunkSize()));
len -= PiecewiseChunkSize();
first += PiecewiseChunkSize();
}
@@ -55,13 +46,22 @@
ABSL_CONST_INIT const void* const MixingHashState::kSeed = &kSeed;
-#ifdef ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
-constexpr uint64_t MixingHashState::kStaticRandomData[];
-#endif
+// The salt array used by LowLevelHash. This array is NOT the mechanism used to
+// make absl::Hash non-deterministic between program invocations. See `Seed()`
+// for that mechanism.
+//
+// Any random values are fine. These values are just digits from the decimal
+// part of pi.
+// https://en.wikipedia.org/wiki/Nothing-up-my-sleeve_number
+constexpr uint64_t kHashSalt[5] = {
+ uint64_t{0x243F6A8885A308D3}, uint64_t{0x13198A2E03707344},
+ uint64_t{0xA4093822299F31D0}, uint64_t{0x082EFA98EC4E6C89},
+ uint64_t{0x452821E638D01377},
+};
uint64_t MixingHashState::LowLevelHashImpl(const unsigned char* data,
size_t len) {
- return LowLevelHashLenGt16(data, len, Seed(), &kStaticRandomData[0]);
+ return LowLevelHashLenGt16(data, len, Seed(), kHashSalt);
}
} // namespace hash_internal
diff --git a/absl/hash/internal/hash.h b/absl/hash/internal/hash.h
index f4a0d78..03bf183 100644
--- a/absl/hash/internal/hash.h
+++ b/absl/hash/internal/hash.h
@@ -36,10 +36,8 @@
#include <algorithm>
#include <array>
#include <bitset>
-#include <cassert>
#include <cmath>
#include <cstddef>
-#include <cstdint>
#include <cstring>
#include <deque>
#include <forward_list>
@@ -58,10 +56,7 @@
#include <utility>
#include <vector>
-#include "absl/base/attributes.h"
-#include "absl/base/internal/endian.h"
#include "absl/base/internal/unaligned_access.h"
-#include "absl/base/optimization.h"
#include "absl/base/port.h"
#include "absl/container/fixed_array.h"
#include "absl/hash/internal/city.h"
@@ -74,7 +69,8 @@
#include "absl/types/variant.h"
#include "absl/utility/utility.h"
-#if defined(__cpp_lib_filesystem) && __cpp_lib_filesystem >= 201703L
+#if defined(__cpp_lib_filesystem) && __cpp_lib_filesystem >= 201703L && \
+ !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
#include <filesystem> // NOLINT
#endif
@@ -82,10 +78,6 @@
#include <string_view>
#endif
-#ifdef __ARM_ACLE
-#include <arm_acle.h>
-#endif
-
namespace absl {
ABSL_NAMESPACE_BEGIN
@@ -348,47 +340,11 @@
template <>
struct is_uniquely_represented<bool> : std::false_type {};
-#ifdef ABSL_HAVE_INTRINSIC_INT128
-// Specialize the trait for GNU extension types.
-template <>
-struct is_uniquely_represented<__int128> : std::true_type {};
-template <>
-struct is_uniquely_represented<unsigned __int128> : std::true_type {};
-#endif // ABSL_HAVE_INTRINSIC_INT128
-
-template <typename T>
-struct FitsIn64Bits : std::integral_constant<bool, sizeof(T) <= 8> {};
-
-struct CombineRaw {
- template <typename H>
- H operator()(H state, uint64_t value) const {
- return H::combine_raw(std::move(state), value);
- }
-};
-
// hash_bytes()
//
// Convenience function that combines `hash_state` with the byte representation
// of `value`.
-template <typename H, typename T,
- absl::enable_if_t<FitsIn64Bits<T>::value, int> = 0>
-H hash_bytes(H hash_state, const T& value) {
- const unsigned char* start = reinterpret_cast<const unsigned char*>(&value);
- uint64_t v;
- if (sizeof(T) == 1) {
- v = *start;
- } else if (sizeof(T) == 2) {
- v = absl::base_internal::UnalignedLoad16(start);
- } else if (sizeof(T) == 4) {
- v = absl::base_internal::UnalignedLoad32(start);
- } else {
- assert(sizeof(T) == 8);
- v = absl::base_internal::UnalignedLoad64(start);
- }
- return CombineRaw()(std::move(hash_state), v);
-}
-template <typename H, typename T,
- absl::enable_if_t<!FitsIn64Bits<T>::value, int> = 0>
+template <typename H, typename T>
H hash_bytes(H hash_state, const T& value) {
const unsigned char* start = reinterpret_cast<const unsigned char*>(&value);
return H::combine_contiguous(std::move(hash_state), start, sizeof(value));
@@ -490,9 +446,9 @@
T ptr) {
auto v = reinterpret_cast<uintptr_t>(ptr);
// Due to alignment, pointers tend to have low bits as zero, and the next few
- // bits follow a pattern since they are also multiples of some base value. The
- // byte swap in WeakMix helps ensure we still have good entropy in low bits.
- // Mix pointers twice to ensure we have good entropy in low bits.
+ // bits follow a pattern since they are also multiples of some base value.
+ // Mixing the pointer twice helps prevent stuck low bits for certain alignment
+ // values.
return H::combine(std::move(hash_state), v, v);
}
@@ -641,6 +597,7 @@
#endif // ABSL_HAVE_STD_STRING_VIEW
#if defined(__cpp_lib_filesystem) && __cpp_lib_filesystem >= 201703L && \
+ !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY) && \
(!defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) || \
__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130000) && \
(!defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || \
@@ -972,7 +929,6 @@
static State combine_contiguous(State hash_state, const unsigned char*,
size_t);
using State::HashStateBase::combine_contiguous;
- static State combine_raw(State state, uint64_t value);
};
struct UniquelyRepresentedProbe {
@@ -1055,21 +1011,13 @@
using uint128 = absl::uint128;
#endif // ABSL_HAVE_INTRINSIC_INT128
- // Random data taken from the hexadecimal digits of Pi's fractional component.
- // https://en.wikipedia.org/wiki/Nothing-up-my-sleeve_number
- ABSL_CACHELINE_ALIGNED static constexpr uint64_t kStaticRandomData[] = {
- 0x243f'6a88'85a3'08d3, 0x1319'8a2e'0370'7344, 0xa409'3822'299f'31d0,
- 0x082e'fa98'ec4e'6c89, 0x4528'21e6'38d0'1377,
- };
-
static constexpr uint64_t kMul =
sizeof(size_t) == 4 ? uint64_t{0xcc9e2d51}
- : uint64_t{0xdcb22ca68cb134ed};
+ : uint64_t{0x9ddfea08eb382d69};
template <typename T>
using IntegralFastPath =
- conjunction<std::is_integral<T>, is_uniquely_represented<T>,
- FitsIn64Bits<T>>;
+ conjunction<std::is_integral<T>, is_uniquely_represented<T>>;
public:
// Move only
@@ -1099,7 +1047,7 @@
template <typename T, absl::enable_if_t<IntegralFastPath<T>::value, int> = 0>
static size_t hash(T value) {
return static_cast<size_t>(
- WeakMix(Seed() ^ static_cast<std::make_unsigned_t<T>>(value)));
+ Mix(Seed(), static_cast<std::make_unsigned_t<T>>(value)));
}
// Overload of MixingHashState::hash()
@@ -1137,7 +1085,6 @@
// Allow the HashState type-erasure implementation to invoke
// RunCombinedUnordered() directly.
friend class absl::HashState;
- friend struct CombineRaw;
// Workaround for MSVC bug.
// We make the type copyable to fix the calling convention, even though we
@@ -1147,14 +1094,6 @@
explicit MixingHashState(uint64_t state) : state_(state) {}
- // Combines a raw value from e.g. integrals/floats/pointers/etc. This allows
- // us to be consistent with IntegralFastPath when combining raw types, but
- // optimize Read1To3 and Read4To8 differently for the string case.
- static MixingHashState combine_raw(MixingHashState hash_state,
- uint64_t value) {
- return MixingHashState(WeakMix(hash_state.state_ ^ value));
- }
-
// Implementation of the base case for combine_contiguous where we actually
// mix the bytes into the state.
// Dispatch to different implementations of the combine_contiguous depending
@@ -1168,49 +1107,6 @@
std::integral_constant<int, 8>
/* sizeof_size_t */);
- ABSL_ATTRIBUTE_ALWAYS_INLINE static uint64_t CombineSmallContiguousImpl(
- uint64_t state, const unsigned char* first, size_t len) {
- ABSL_ASSUME(len <= 8);
- uint64_t v;
- if (len >= 4) {
- v = Read4To8(first, len);
- } else if (len > 0) {
- v = Read1To3(first, len);
- } else {
- // Empty ranges have no effect.
- return state;
- }
- return WeakMix(state ^ v);
- }
-
- ABSL_ATTRIBUTE_ALWAYS_INLINE static uint64_t CombineContiguousImpl9to16(
- uint64_t state, const unsigned char* first, size_t len) {
- ABSL_ASSUME(len >= 9);
- ABSL_ASSUME(len <= 16);
- // Note: any time one half of the mix function becomes zero it will fail to
- // incorporate any bits from the other half. However, there is exactly 1 in
- // 2^64 values for each side that achieve this, and only when the size is
- // exactly 16 -- for smaller sizes there is an overlapping byte that makes
- // this impossible unless the seed is *also* incredibly unlucky.
- auto p = Read9To16(first, len);
- return Mix(state ^ p.first, kMul ^ p.second);
- }
-
- ABSL_ATTRIBUTE_ALWAYS_INLINE static uint64_t CombineContiguousImpl17to32(
- uint64_t state, const unsigned char* first, size_t len) {
- ABSL_ASSUME(len >= 17);
- ABSL_ASSUME(len <= 32);
- // Do two mixes of overlapping 16-byte ranges in parallel to minimize
- // latency.
- const uint64_t m0 =
- Mix(Read8(first) ^ kStaticRandomData[1], Read8(first + 8) ^ state);
-
- const unsigned char* tail_16b_ptr = first + (len - 16);
- const uint64_t m1 = Mix(Read8(tail_16b_ptr) ^ kStaticRandomData[3],
- Read8(tail_16b_ptr + 8) ^ state);
- return m0 ^ m1;
- }
-
// Slow dispatch path for calls to CombineContiguousImpl with a size argument
// larger than PiecewiseChunkSize(). Has the same effect as calling
// CombineContiguousImpl() repeatedly with the chunk stride size.
@@ -1226,8 +1122,8 @@
// are in .second.
static std::pair<uint64_t, uint64_t> Read9To16(const unsigned char* p,
size_t len) {
- uint64_t low_mem = Read8(p);
- uint64_t high_mem = Read8(p + len - 8);
+ uint64_t low_mem = absl::base_internal::UnalignedLoad64(p);
+ uint64_t high_mem = absl::base_internal::UnalignedLoad64(p + len - 8);
#ifdef ABSL_IS_LITTLE_ENDIAN
uint64_t most_significant = high_mem;
uint64_t least_significant = low_mem;
@@ -1238,81 +1134,55 @@
return {least_significant, most_significant};
}
- // Reads 8 bytes from p.
- static uint64_t Read8(const unsigned char* p) {
- // Suppress erroneous array bounds errors on GCC.
-#if defined(__GNUC__) && !defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Warray-bounds"
-#endif
- return absl::base_internal::UnalignedLoad64(p);
-#if defined(__GNUC__) && !defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
- }
-
// Reads 4 to 8 bytes from p. Zero pads to fill uint64_t.
- // TODO(b/384509507): consider optimizing this by not requiring the output to
- // be equivalent to an integer load for 4/8 bytes. Currently, we rely on this
- // behavior for the HashConsistentAcrossIntTypes test case. Ditto for
- // Read1To3.
static uint64_t Read4To8(const unsigned char* p, size_t len) {
- // If `len < 8`, we duplicate bytes in the middle.
- // E.g.:
- // `ABCD` will be read as `ABCDABCD`.
- // `ABCDE` will be read as `ABCDBCDE`.
- // `ABCDEF` will be read as `ABCDCDEF`.
- // `ABCDEFG` will be read as `ABCDDEFG`.
- // We also do not care about endianness. On big-endian platforms, bytes will
- // be shuffled (it's fine). We always shift low memory by 32, because that
- // can be pipelined earlier. Reading high memory requires computing
- // `p + len - 4`.
- uint64_t most_significant =
- static_cast<uint64_t>(absl::base_internal::UnalignedLoad32(p)) << 32;
- uint64_t least_significant =
- absl::base_internal::UnalignedLoad32(p + len - 4);
- return most_significant | least_significant;
+ uint32_t low_mem = absl::base_internal::UnalignedLoad32(p);
+ uint32_t high_mem = absl::base_internal::UnalignedLoad32(p + len - 4);
+#ifdef ABSL_IS_LITTLE_ENDIAN
+ uint32_t most_significant = high_mem;
+ uint32_t least_significant = low_mem;
+#else
+ uint32_t most_significant = low_mem;
+ uint32_t least_significant = high_mem;
+#endif
+ return (static_cast<uint64_t>(most_significant) << (len - 4) * 8) |
+ least_significant;
}
// Reads 1 to 3 bytes from p. Zero pads to fill uint32_t.
static uint32_t Read1To3(const unsigned char* p, size_t len) {
- // The trick used by this implementation is to avoid branches.
- // We always read three bytes by duplicating.
- // E.g.,
- // `A` is read as `AAA`.
- // `AB` is read as `ABB`.
- // `ABC` is read as `ABC`.
- // We always shift `p[0]` so that it can be pipelined better.
- // Other bytes require extra computation to find indices.
- uint32_t mem0 = (static_cast<uint32_t>(p[0]) << 16) | p[len - 1];
- uint32_t mem1 = static_cast<uint32_t>(p[len / 2]) << 8;
- return mem0 | mem1;
+ // The trick used by this implementation is to avoid branches if possible.
+ unsigned char mem0 = p[0];
+ unsigned char mem1 = p[len / 2];
+ unsigned char mem2 = p[len - 1];
+#ifdef ABSL_IS_LITTLE_ENDIAN
+ unsigned char significant2 = mem2;
+ unsigned char significant1 = mem1;
+ unsigned char significant0 = mem0;
+#else
+ unsigned char significant2 = mem0;
+ unsigned char significant1 = len == 2 ? mem0 : mem1;
+ unsigned char significant0 = mem2;
+#endif
+ return static_cast<uint32_t>(significant0 | //
+ (significant1 << (len / 2 * 8)) | //
+ (significant2 << ((len - 1) * 8)));
}
- ABSL_ATTRIBUTE_ALWAYS_INLINE static uint64_t Mix(uint64_t lhs, uint64_t rhs) {
+ ABSL_ATTRIBUTE_ALWAYS_INLINE static uint64_t Mix(uint64_t state, uint64_t v) {
// Though the 128-bit product on AArch64 needs two instructions, it is
// still a good balance between speed and hash quality.
using MultType =
absl::conditional_t<sizeof(size_t) == 4, uint64_t, uint128>;
- MultType m = lhs;
- m *= rhs;
+ // We do the addition in 64-bit space to make sure the 128-bit
+ // multiplication is fast. If we were to do it as MultType the compiler has
+ // to assume that the high word is non-zero and needs to perform 2
+ // multiplications instead of one.
+ MultType m = state + v;
+ m *= kMul;
return static_cast<uint64_t>(m ^ (m >> (sizeof(m) * 8 / 2)));
}
- // Slightly lower latency than Mix, but with lower quality. The byte swap
- // helps ensure that low bits still have high quality.
- ABSL_ATTRIBUTE_ALWAYS_INLINE static uint64_t WeakMix(uint64_t n) {
- // WeakMix doesn't work well on 32-bit platforms so just use Mix.
- if (sizeof(size_t) < 8) return Mix(n, kMul);
-#ifdef __ARM_ACLE
- // gbswap_64 compiles to `rev` on ARM, but `rbit` is better because it
- // reverses bits rather than reversing bytes.
- return __rbitll(n * kMul);
-#else
- return absl::gbswap_64(n * kMul);
-#endif
- }
-
// An extern to avoid bloat on a direct call to LowLevelHash() with fixed
// values for both the seed and salt parameters.
static uint64_t LowLevelHashImpl(const unsigned char* data, size_t len);
@@ -1364,15 +1234,21 @@
std::integral_constant<int, 4> /* sizeof_size_t */) {
// For large values we use CityHash, for small ones we just use a
// multiplicative hash.
- if (len <= 8) {
- return CombineSmallContiguousImpl(state, first, len);
+ uint64_t v;
+ if (len > 8) {
+ if (ABSL_PREDICT_FALSE(len > PiecewiseChunkSize())) {
+ return CombineLargeContiguousImpl32(state, first, len);
+ }
+ v = hash_internal::CityHash32(reinterpret_cast<const char*>(first), len);
+ } else if (len >= 4) {
+ v = Read4To8(first, len);
+ } else if (len > 0) {
+ v = Read1To3(first, len);
+ } else {
+ // Empty ranges have no effect.
+ return state;
}
- if (ABSL_PREDICT_TRUE(len <= PiecewiseChunkSize())) {
- return Mix(state ^ hash_internal::CityHash32(
- reinterpret_cast<const char*>(first), len),
- kMul);
- }
- return CombineLargeContiguousImpl32(state, first, len);
+ return Mix(state, v);
}
// Overload of MixingHashState::CombineContiguousImpl()
@@ -1381,19 +1257,38 @@
std::integral_constant<int, 8> /* sizeof_size_t */) {
// For large values we use LowLevelHash or CityHash depending on the platform,
// for small ones we just use a multiplicative hash.
- if (len <= 8) {
- return CombineSmallContiguousImpl(state, first, len);
+ uint64_t v;
+ if (len > 16) {
+ if (ABSL_PREDICT_FALSE(len > PiecewiseChunkSize())) {
+ return CombineLargeContiguousImpl64(state, first, len);
+ }
+ v = Hash64(first, len);
+ } else if (len > 8) {
+ // This hash function was constructed by the ML-driven algorithm discovery
+ // using reinforcement learning. We fed the agent lots of inputs from
+ // microbenchmarks, SMHasher, low hamming distance from generated inputs and
+ // picked up the one that was good on micro and macrobenchmarks.
+ auto p = Read9To16(first, len);
+ uint64_t lo = p.first;
+ uint64_t hi = p.second;
+ // Rotation by 53 was found to be most often useful when discovering these
+ // hashing algorithms with ML techniques.
+ lo = absl::rotr(lo, 53);
+ state += kMul;
+ lo += state;
+ state ^= hi;
+ uint128 m = state;
+ m *= lo;
+ return static_cast<uint64_t>(m ^ (m >> 64));
+ } else if (len >= 4) {
+ v = Read4To8(first, len);
+ } else if (len > 0) {
+ v = Read1To3(first, len);
+ } else {
+ // Empty ranges have no effect.
+ return state;
}
- if (len <= 16) {
- return CombineContiguousImpl9to16(state, first, len);
- }
- if (len <= 32) {
- return CombineContiguousImpl17to32(state, first, len);
- }
- if (ABSL_PREDICT_TRUE(len <= PiecewiseChunkSize())) {
- return Mix(state ^ Hash64(first, len), kMul);
- }
- return CombineLargeContiguousImpl64(state, first, len);
+ return Mix(state, v);
}
struct AggregateBarrier {};
diff --git a/absl/hash/internal/low_level_hash.cc b/absl/hash/internal/low_level_hash.cc
index ec02d7e..6dc71cf 100644
--- a/absl/hash/internal/low_level_hash.cc
+++ b/absl/hash/internal/low_level_hash.cc
@@ -33,6 +33,8 @@
uint64_t LowLevelHashLenGt16(const void* data, size_t len, uint64_t seed,
const uint64_t salt[5]) {
+ // Prefetch the cacheline that data resides in.
+ PrefetchToLocalCache(data);
const uint8_t* ptr = static_cast<const uint8_t*>(data);
uint64_t starting_length = static_cast<uint64_t>(len);
const uint8_t* last_16_ptr = ptr + starting_length - 16;
@@ -40,8 +42,8 @@
if (len > 64) {
// If we have more than 64 bytes, we're going to handle chunks of 64
- // bytes at a time. We're going to build up four separate hash states
- // which we will then hash together. This avoids short dependency chains.
+ // bytes at a time. We're going to build up two separate hash states
+ // which we will then hash together.
uint64_t duplicated_state0 = current_state;
uint64_t duplicated_state1 = current_state;
uint64_t duplicated_state2 = current_state;
diff --git a/absl/hash/internal/spy_hash_state.h b/absl/hash/internal/spy_hash_state.h
index 92490b1..357c301 100644
--- a/absl/hash/internal/spy_hash_state.h
+++ b/absl/hash/internal/spy_hash_state.h
@@ -16,7 +16,6 @@
#define ABSL_HASH_INTERNAL_SPY_HASH_STATE_H_
#include <algorithm>
-#include <cstdint>
#include <ostream>
#include <string>
#include <vector>
@@ -197,7 +196,6 @@
private:
template <typename U>
friend class SpyHashStateImpl;
- friend struct CombineRaw;
struct UnorderedCombinerCallback {
std::vector<std::string> element_hash_representations;
@@ -215,12 +213,6 @@
}
};
- // Combines raw data from e.g. integrals/floats/pointers/etc.
- static SpyHashStateImpl combine_raw(SpyHashStateImpl state, uint64_t value) {
- const unsigned char* data = reinterpret_cast<const unsigned char*>(&value);
- return SpyHashStateImpl::combine_contiguous(std::move(state), data, 8);
- }
-
// This is true if SpyHashStateImpl<T> has been passed to a call of
// AbslHashValue with the wrong type. This detects that the user called
// AbslHashValue directly (because the hash state type does not match).
diff --git a/absl/log/BUILD.bazel b/absl/log/BUILD.bazel
index dc9b0b4..b13cf4d 100644
--- a/absl/log/BUILD.bazel
+++ b/absl/log/BUILD.bazel
@@ -187,7 +187,6 @@
deps = [
":log_sink",
"//absl/base:config",
- "//absl/base:nullability",
"//absl/log/internal:log_sink_set",
],
)
@@ -223,7 +222,7 @@
"//absl/base:log_severity",
"//absl/base:raw_logging_internal",
"//absl/strings",
- "@googletest//:gtest",
+ "@com_google_googletest//:gtest",
],
)
@@ -234,7 +233,6 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
"//absl/base:config",
- "//absl/base:core_headers",
"//absl/log/internal:structured",
"//absl/strings",
],
@@ -281,8 +279,8 @@
"//absl/base:log_severity",
"//absl/flags:flag",
"//absl/types:optional",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -303,23 +301,22 @@
deps = [
":absl_check",
":check_test_impl",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
cc_test(
name = "absl_log_basic_test",
size = "small",
- timeout = "moderate",
srcs = ["absl_log_basic_test.cc"],
copts = ABSL_TEST_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":absl_log",
":log_basic_test_impl",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -338,8 +335,8 @@
deps = [
":check",
":check_test_impl",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -362,7 +359,7 @@
"//absl/status",
"//absl/strings",
"//absl/strings:string_view",
- "@googletest//:gtest",
+ "@com_google_googletest//:gtest",
],
)
@@ -376,8 +373,8 @@
":die_if_null",
"//absl/base:core_headers",
"//absl/log/internal:test_helpers",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -400,8 +397,8 @@
"//absl/log/internal:test_helpers",
"//absl/log/internal:test_matchers",
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -419,23 +416,22 @@
"//absl/base:log_severity",
"//absl/log/internal:globals",
"//absl/log/internal:test_helpers",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
cc_test(
name = "log_basic_test",
size = "small",
- timeout = "moderate",
srcs = ["log_basic_test.cc"],
copts = ABSL_TEST_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":log",
":log_basic_test_impl",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -456,7 +452,7 @@
"//absl/log/internal:test_actions",
"//absl/log/internal:test_helpers",
"//absl/log/internal:test_matchers",
- "@googletest//:gtest",
+ "@com_google_googletest//:gtest",
],
)
@@ -477,8 +473,8 @@
"//absl/strings",
"//absl/time",
"//absl/types:span",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -496,8 +492,8 @@
"//absl/strings",
"//absl/strings:str_format",
"//absl/types:optional",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -512,8 +508,8 @@
":scoped_mock_log",
"//absl/base:core_headers",
"//absl/base:log_severity",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -538,8 +534,8 @@
"//absl/log/internal:test_helpers",
"//absl/log/internal:test_matchers",
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -560,8 +556,8 @@
"//absl/log/internal:test_helpers",
"//absl/log/internal:test_matchers",
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -580,8 +576,8 @@
"//absl/log/internal:test_matchers",
"//absl/strings",
"//absl/time",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -608,8 +604,8 @@
"//absl/memory",
"//absl/strings",
"//absl/synchronization",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -632,8 +628,8 @@
"//absl/status",
"//absl/strings",
"//absl/strings:str_format",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -650,8 +646,8 @@
"//absl/base:core_headers",
"//absl/log/internal:test_helpers",
"//absl/log/internal:test_matchers",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -675,6 +671,6 @@
"//absl/base:log_severity",
"//absl/flags:flag",
"//absl/log/internal:flags",
- "@google_benchmark//:benchmark_main",
+ "@com_github_google_benchmark//:benchmark_main",
],
)
diff --git a/absl/log/CMakeLists.txt b/absl/log/CMakeLists.txt
index 73deb45..4384465 100644
--- a/absl/log/CMakeLists.txt
+++ b/absl/log/CMakeLists.txt
@@ -44,14 +44,11 @@
LINKOPTS
${ABSL_DEFAULT_LINKOPTS}
DEPS
- absl::base
absl::config
absl::core_headers
- absl::leak_check
absl::log_internal_nullguard
absl::log_internal_nullstream
absl::log_internal_strip
- absl::nullability
absl::strings
)
@@ -198,27 +195,25 @@
absl::config
absl::core_headers
absl::errno_saver
- absl::examine_stack
absl::inlined_vector
+ absl::examine_stack
absl::log_internal_append_truncated
absl::log_internal_format
absl::log_internal_globals
absl::log_internal_proto
absl::log_internal_log_sink_set
absl::log_internal_nullguard
- absl::log_internal_structured_proto
absl::log_globals
absl::log_entry
absl::log_severity
absl::log_sink
absl::log_sink_registry
absl::memory
- absl::nullability
absl::raw_logging_internal
- absl::span
- absl::strerror
absl::strings
+ absl::strerror
absl::time
+ absl::span
)
absl_cc_library(
@@ -607,7 +602,6 @@
absl::config
absl::log_sink
absl::log_internal_log_sink_set
- absl::nullability
PUBLIC
)
@@ -667,54 +661,13 @@
LINKOPTS
${ABSL_DEFAULT_LINKOPTS}
DEPS
- absl::any_invocable
absl::config
- absl::core_headers
absl::log_internal_message
- absl::log_internal_structured_proto
absl::strings
)
absl_cc_library(
NAME
- log_internal_structured_proto
- SRCS
- "internal/structured_proto.cc"
- HDRS
- "internal/structured_proto.h"
- COPTS
- ${ABSL_DEFAULT_COPTS}
- LINKOPTS
- ${ABSL_DEFAULT_LINKOPTS}
- DEPS
- absl::log_internal_proto
- absl::config
- absl::span
- absl::strings
- absl::variant
- PUBLIC
-)
-
-absl_cc_test(
- NAME
- log_internal_structured_proto_test
- SRCS
- "internal/structured_proto_test.cc"
- COPTS
- ${ABSL_TEST_COPTS}
- LINKOPTS
- ${ABSL_DEFAULT_LINKOPTS}
- DEPS
- absl::config
- absl::log_internal_structured_proto
- absl::span
- absl::string_view
- absl::utility
- GTest::gmock_main
-)
-
-absl_cc_library(
- NAME
log_structured
HDRS
"structured.h"
@@ -724,7 +677,6 @@
${ABSL_DEFAULT_LINKOPTS}
DEPS
absl::config
- absl::core_headers
absl::log_internal_structured
absl::strings
PUBLIC
diff --git a/absl/log/absl_vlog_is_on.h b/absl/log/absl_vlog_is_on.h
index e4ec86d..6bf6c41 100644
--- a/absl/log/absl_vlog_is_on.h
+++ b/absl/log/absl_vlog_is_on.h
@@ -40,8 +40,6 @@
// last . and everything after it) is stripped from each filename prior to
// matching, as is the special suffix "-inl".
//
-// Example: --vmodule=module_a=1,module_b=2
-//
// Files are matched against globs in `--vmodule` in order, and the first match
// determines the verbosity level.
//
diff --git a/absl/log/globals_test.cc b/absl/log/globals_test.cc
index 78430d4..0dc54d5 100644
--- a/absl/log/globals_test.cc
+++ b/absl/log/globals_test.cc
@@ -100,15 +100,6 @@
EXPECT_EQ(absl::SetVLogLevel("setvloglevel", 42), 0);
EXPECT_EQ(absl::SetVLogLevel("setvloglevel", 1337), 42);
EXPECT_EQ(absl::SetVLogLevel("othersetvloglevel", 50), 0);
-
- EXPECT_EQ(absl::SetVLogLevel("*pattern*", 1), 0);
- EXPECT_EQ(absl::SetVLogLevel("*less_generic_pattern*", 2), 1);
- // "pattern_match" matches the pattern "*pattern*". Therefore, the previous
- // level must be 1.
- EXPECT_EQ(absl::SetVLogLevel("pattern_match", 3), 1);
- // "less_generic_pattern_match" matches the pattern "*pattern*". Therefore,
- // the previous level must be 2.
- EXPECT_EQ(absl::SetVLogLevel("less_generic_pattern_match", 4), 2);
}
TEST(TestGlobals, AndroidLogTag) {
diff --git a/absl/log/internal/BUILD.bazel b/absl/log/internal/BUILD.bazel
index 594f867..2dbf337 100644
--- a/absl/log/internal/BUILD.bazel
+++ b/absl/log/internal/BUILD.bazel
@@ -23,7 +23,7 @@
package(
default_visibility = [
- ":internal_users",
+ "//absl/log:__pkg__",
],
features = [
"header_modules",
@@ -34,20 +34,6 @@
licenses(["notice"])
-package_group(
- name = "internal_users",
- packages = [
- "//absl/log",
- ],
-)
-
-package_group(
- name = "structured_proto_users",
- packages = [
- "//absl/log/...",
- ],
-)
-
cc_library(
name = "check_impl",
hdrs = ["check_impl.h"],
@@ -75,11 +61,8 @@
":nullguard",
":nullstream",
":strip",
- "//absl/base",
"//absl/base:config",
"//absl/base:core_headers",
- "//absl/base:nullability",
- "//absl/debugging:leak_check",
"//absl/strings",
],
)
@@ -190,13 +173,11 @@
":log_sink_set",
":nullguard",
":proto",
- ":structured_proto",
"//absl/base",
"//absl/base:config",
"//absl/base:core_headers",
"//absl/base:errno_saver",
"//absl/base:log_severity",
- "//absl/base:nullability",
"//absl/base:raw_logging_internal",
"//absl/base:strerror",
"//absl/container:inlined_vector",
@@ -295,49 +276,10 @@
hdrs = ["structured.h"],
copts = ABSL_DEFAULT_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
- visibility = [
- ":internal_users",
- ":structured_proto_users",
- ],
deps = [
":log_message",
- ":structured_proto",
- "//absl/base:config",
- "//absl/base:core_headers",
- "//absl/functional:any_invocable",
- "//absl/strings",
- ],
-)
-
-cc_library(
- name = "structured_proto",
- srcs = ["structured_proto.cc"],
- hdrs = ["structured_proto.h"],
- copts = ABSL_DEFAULT_COPTS,
- linkopts = ABSL_DEFAULT_LINKOPTS,
- visibility = [
- ":structured_proto_users",
- ],
- deps = [
- ":proto",
"//absl/base:config",
"//absl/strings",
- "//absl/types:span",
- "//absl/types:variant",
- ],
-)
-
-cc_test(
- name = "structured_proto_test",
- srcs = ["structured_proto_test.cc"],
- deps = [
- ":structured_proto",
- "//absl/base:config",
- "//absl/strings:string_view",
- "//absl/types:span",
- "//absl/utility",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
],
)
@@ -356,7 +298,7 @@
"//absl/strings",
"//absl/time",
] + select({
- "@rules_cc//cc/compiler:msvc-cl": [],
+ "//absl:msvc_compiler": [],
"//conditions:default": [
],
}),
@@ -369,17 +311,13 @@
hdrs = ["test_helpers.h"],
copts = ABSL_DEFAULT_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
- visibility = [
- ":internal_users",
- ":structured_proto_users",
- ],
deps = [
":globals",
"//absl/base:config",
"//absl/base:log_severity",
"//absl/log:globals",
"//absl/log:initialize",
- "@googletest//:gtest",
+ "@com_google_googletest//:gtest",
],
)
@@ -390,10 +328,6 @@
hdrs = ["test_matchers.h"],
copts = ABSL_DEFAULT_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
- visibility = [
- ":internal_users",
- ":structured_proto_users",
- ],
deps = [
":test_helpers",
"//absl/base:config",
@@ -402,9 +336,9 @@
"//absl/log:log_entry",
"//absl/strings",
"//absl/time",
- "@googletest//:gtest",
+ "@com_google_googletest//:gtest",
] + select({
- "@rules_cc//cc/compiler:msvc-cl": [],
+ "//absl:msvc_compiler": [],
"//conditions:default": [
],
}),
@@ -424,10 +358,6 @@
hdrs = ["proto.h"],
copts = ABSL_DEFAULT_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
- visibility = [
- ":internal_users",
- ":structured_proto_users",
- ],
deps = [
"//absl/base",
"//absl/base:config",
@@ -489,7 +419,7 @@
"//absl/memory",
"//absl/random:distributions",
"//absl/strings",
- "@google_benchmark//:benchmark_main",
+ "@com_github_google_benchmark//:benchmark_main",
],
)
@@ -497,7 +427,6 @@
cc_test(
name = "stderr_log_sink_test",
size = "small",
- timeout = "moderate",
srcs = ["stderr_log_sink_test.cc"],
copts = ABSL_TEST_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
@@ -505,9 +434,7 @@
"no_test:os:android",
"no_test:os:ios",
"no_test_android",
- "no_test_darwin_arm64",
"no_test_darwin_x86_64",
- "no_test_fuchsia_x64",
"no_test_ios",
"no_test_wasm",
],
@@ -517,8 +444,8 @@
"//absl/base:log_severity",
"//absl/log",
"//absl/log:globals",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -529,8 +456,8 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":fnmatch",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -542,6 +469,6 @@
tags = ["benchmark"],
deps = [
":fnmatch",
- "@google_benchmark//:benchmark_main",
+ "@com_github_google_benchmark//:benchmark_main",
],
)
diff --git a/absl/log/internal/check_op.cc b/absl/log/internal/check_op.cc
index cec9421..23c4a3b 100644
--- a/absl/log/internal/check_op.cc
+++ b/absl/log/internal/check_op.cc
@@ -14,15 +14,10 @@
#include "absl/log/internal/check_op.h"
-#include <cstring>
-#include <ostream>
-#include <string>
-#include <utility>
+#include <string.h>
-#include "absl/base/config.h"
-#include "absl/base/nullability.h"
-#include "absl/debugging/leak_check.h"
-#include "absl/strings/str_cat.h"
+#include <ostream>
+
#include "absl/strings/string_view.h"
#ifdef _MSC_VER
@@ -31,13 +26,18 @@
#include <strings.h> // for strcasecmp, but msvc does not have this header
#endif
+#include <sstream>
+#include <string>
+
+#include "absl/base/config.h"
+#include "absl/strings/str_cat.h"
+
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace log_internal {
#define ABSL_LOGGING_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING(x) \
- template absl::Nonnull<const char*> MakeCheckOpString( \
- x, x, absl::Nonnull<const char*>)
+ template std::string* MakeCheckOpString(x, x, const char*)
ABSL_LOGGING_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING(bool);
ABSL_LOGGING_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING(int64_t);
ABSL_LOGGING_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING(uint64_t);
@@ -53,8 +53,7 @@
ABSL_LOGGING_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING(const void*);
#undef ABSL_LOGGING_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING
-CheckOpMessageBuilder::CheckOpMessageBuilder(
- absl::Nonnull<const char*> exprtext) {
+CheckOpMessageBuilder::CheckOpMessageBuilder(const char* exprtext) {
stream_ << exprtext << " (";
}
@@ -63,10 +62,9 @@
return stream_;
}
-absl::Nonnull<const char*> CheckOpMessageBuilder::NewString() {
+std::string* CheckOpMessageBuilder::NewString() {
stream_ << ")";
- // There's no need to free this string since the process is crashing.
- return absl::IgnoreLeak(new std::string(std::move(stream_).str()))->c_str();
+ return new std::string(stream_.str());
}
void MakeCheckOpValueString(std::ostream& os, const char v) {
@@ -102,19 +100,16 @@
}
// Helper functions for string comparisons.
-#define DEFINE_CHECK_STROP_IMPL(name, func, expected) \
- absl::Nullable<const char*> Check##func##expected##Impl( \
- absl::Nullable<const char*> s1, absl::Nullable<const char*> s2, \
- absl::Nonnull<const char*> exprtext) { \
- bool equal = s1 == s2 || (s1 && s2 && !func(s1, s2)); \
- if (equal == expected) { \
- return nullptr; \
- } else { \
- /* There's no need to free this string since the process is crashing. */ \
- return absl::IgnoreLeak(new std::string(absl::StrCat(exprtext, " (", s1, \
- " vs. ", s2, ")"))) \
- ->c_str(); \
- } \
+#define DEFINE_CHECK_STROP_IMPL(name, func, expected) \
+ std::string* Check##func##expected##Impl(const char* s1, const char* s2, \
+ const char* exprtext) { \
+ bool equal = s1 == s2 || (s1 && s2 && !func(s1, s2)); \
+ if (equal == expected) { \
+ return nullptr; \
+ } else { \
+ return new std::string( \
+ absl::StrCat(exprtext, " (", s1, " vs. ", s2, ")")); \
+ } \
}
DEFINE_CHECK_STROP_IMPL(CHECK_STREQ, strcmp, true)
DEFINE_CHECK_STROP_IMPL(CHECK_STRNE, strcmp, false)
diff --git a/absl/log/internal/check_op.h b/absl/log/internal/check_op.h
index d56aa31..2159220 100644
--- a/absl/log/internal/check_op.h
+++ b/absl/log/internal/check_op.h
@@ -32,9 +32,7 @@
#include <utility>
#include "absl/base/attributes.h"
-#include "absl/base/casts.h"
#include "absl/base/config.h"
-#include "absl/base/nullability.h"
#include "absl/base/optimization.h"
#include "absl/log/internal/nullguard.h"
#include "absl/log/internal/nullstream.h"
@@ -64,7 +62,7 @@
#endif
#define ABSL_LOG_INTERNAL_CHECK_OP(name, op, val1, val1_text, val2, val2_text) \
- while (absl::Nullable<const char*> absl_log_internal_check_op_result \
+ while (::std::string* absl_log_internal_check_op_result \
ABSL_LOG_INTERNAL_ATTRIBUTE_UNUSED_IF_STRIP_LOG = \
::absl::log_internal::name##Impl( \
::absl::log_internal::GetReferenceableValue(val1), \
@@ -72,44 +70,37 @@
ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL( \
val1_text " " #op " " val2_text))) \
ABSL_LOG_INTERNAL_CONDITION_FATAL(STATELESS, true) \
- ABSL_LOG_INTERNAL_CHECK(absl::implicit_cast<absl::Nonnull<const char*>>( \
- absl_log_internal_check_op_result)) \
- .InternalStream()
-#define ABSL_LOG_INTERNAL_QCHECK_OP(name, op, val1, val1_text, val2, \
- val2_text) \
- while (absl::Nullable<const char*> absl_log_internal_qcheck_op_result = \
- ::absl::log_internal::name##Impl( \
- ::absl::log_internal::GetReferenceableValue(val1), \
- ::absl::log_internal::GetReferenceableValue(val2), \
- ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL( \
- val1_text " " #op " " val2_text))) \
- ABSL_LOG_INTERNAL_CONDITION_QFATAL(STATELESS, true) \
- ABSL_LOG_INTERNAL_QCHECK(absl::implicit_cast<absl::Nonnull<const char*>>( \
- absl_log_internal_qcheck_op_result)) \
- .InternalStream()
+ ABSL_LOG_INTERNAL_CHECK(*absl_log_internal_check_op_result).InternalStream()
+#define ABSL_LOG_INTERNAL_QCHECK_OP(name, op, val1, val1_text, val2, \
+ val2_text) \
+ while (::std::string* absl_log_internal_qcheck_op_result = \
+ ::absl::log_internal::name##Impl( \
+ ::absl::log_internal::GetReferenceableValue(val1), \
+ ::absl::log_internal::GetReferenceableValue(val2), \
+ ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL( \
+ val1_text " " #op " " val2_text))) \
+ ABSL_LOG_INTERNAL_CONDITION_QFATAL(STATELESS, true) \
+ ABSL_LOG_INTERNAL_QCHECK(*absl_log_internal_qcheck_op_result).InternalStream()
#define ABSL_LOG_INTERNAL_CHECK_STROP(func, op, expected, s1, s1_text, s2, \
s2_text) \
- while (absl::Nullable<const char*> absl_log_internal_check_strop_result = \
+ while (::std::string* absl_log_internal_check_strop_result = \
::absl::log_internal::Check##func##expected##Impl( \
(s1), (s2), \
ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL(s1_text " " #op \
" " s2_text))) \
ABSL_LOG_INTERNAL_CONDITION_FATAL(STATELESS, true) \
- ABSL_LOG_INTERNAL_CHECK(absl::implicit_cast<absl::Nonnull<const char*>>( \
- absl_log_internal_check_strop_result)) \
+ ABSL_LOG_INTERNAL_CHECK(*absl_log_internal_check_strop_result) \
.InternalStream()
#define ABSL_LOG_INTERNAL_QCHECK_STROP(func, op, expected, s1, s1_text, s2, \
s2_text) \
- while (absl::Nullable<const char*> absl_log_internal_qcheck_strop_result = \
+ while (::std::string* absl_log_internal_qcheck_strop_result = \
::absl::log_internal::Check##func##expected##Impl( \
(s1), (s2), \
ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL(s1_text " " #op \
" " s2_text))) \
ABSL_LOG_INTERNAL_CONDITION_QFATAL(STATELESS, true) \
- ABSL_LOG_INTERNAL_QCHECK(absl::implicit_cast<absl::Nonnull<const char*>>( \
- absl_log_internal_qcheck_strop_result)) \
+ ABSL_LOG_INTERNAL_QCHECK(*absl_log_internal_qcheck_strop_result) \
.InternalStream()
-
// This one is tricky:
// * We must evaluate `val` exactly once, yet we need to do two things with it:
// evaluate `.ok()` and (sometimes) `.ToString()`.
@@ -134,41 +125,37 @@
// string literal and abort without doing any streaming. We don't need to
// strip the call to stringify the non-ok `Status` as long as we don't log it;
// dropping the `Status`'s message text is out of scope.
-#define ABSL_LOG_INTERNAL_CHECK_OK(val, val_text) \
- for (::std::pair<absl::Nonnull<const ::absl::Status*>, \
- absl::Nullable<const char*>> \
- absl_log_internal_check_ok_goo; \
- absl_log_internal_check_ok_goo.first = \
- ::absl::log_internal::AsStatus(val), \
- absl_log_internal_check_ok_goo.second = \
- ABSL_PREDICT_TRUE(absl_log_internal_check_ok_goo.first->ok()) \
- ? nullptr \
- : ::absl::status_internal::MakeCheckFailString( \
- absl_log_internal_check_ok_goo.first, \
- ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL(val_text \
- " is OK")), \
- !ABSL_PREDICT_TRUE(absl_log_internal_check_ok_goo.first->ok());) \
- ABSL_LOG_INTERNAL_CONDITION_FATAL(STATELESS, true) \
- ABSL_LOG_INTERNAL_CHECK(absl::implicit_cast<absl::Nonnull<const char*>>( \
- absl_log_internal_check_ok_goo.second)) \
+#define ABSL_LOG_INTERNAL_CHECK_OK(val, val_text) \
+ for (::std::pair<const ::absl::Status*, ::std::string*> \
+ absl_log_internal_check_ok_goo; \
+ absl_log_internal_check_ok_goo.first = \
+ ::absl::log_internal::AsStatus(val), \
+ absl_log_internal_check_ok_goo.second = \
+ ABSL_PREDICT_TRUE(absl_log_internal_check_ok_goo.first->ok()) \
+ ? nullptr \
+ : ::absl::status_internal::MakeCheckFailString( \
+ absl_log_internal_check_ok_goo.first, \
+ ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL(val_text \
+ " is OK")), \
+ !ABSL_PREDICT_TRUE(absl_log_internal_check_ok_goo.first->ok());) \
+ ABSL_LOG_INTERNAL_CONDITION_FATAL(STATELESS, true) \
+ ABSL_LOG_INTERNAL_CHECK(*absl_log_internal_check_ok_goo.second) \
.InternalStream()
-#define ABSL_LOG_INTERNAL_QCHECK_OK(val, val_text) \
- for (::std::pair<absl::Nonnull<const ::absl::Status*>, \
- absl::Nullable<const char*>> \
- absl_log_internal_qcheck_ok_goo; \
- absl_log_internal_qcheck_ok_goo.first = \
- ::absl::log_internal::AsStatus(val), \
- absl_log_internal_qcheck_ok_goo.second = \
- ABSL_PREDICT_TRUE(absl_log_internal_qcheck_ok_goo.first->ok()) \
- ? nullptr \
- : ::absl::status_internal::MakeCheckFailString( \
- absl_log_internal_qcheck_ok_goo.first, \
- ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL(val_text \
- " is OK")), \
- !ABSL_PREDICT_TRUE(absl_log_internal_qcheck_ok_goo.first->ok());) \
- ABSL_LOG_INTERNAL_CONDITION_QFATAL(STATELESS, true) \
- ABSL_LOG_INTERNAL_QCHECK(absl::implicit_cast<absl::Nonnull<const char*>>( \
- absl_log_internal_qcheck_ok_goo.second)) \
+#define ABSL_LOG_INTERNAL_QCHECK_OK(val, val_text) \
+ for (::std::pair<const ::absl::Status*, ::std::string*> \
+ absl_log_internal_qcheck_ok_goo; \
+ absl_log_internal_qcheck_ok_goo.first = \
+ ::absl::log_internal::AsStatus(val), \
+ absl_log_internal_qcheck_ok_goo.second = \
+ ABSL_PREDICT_TRUE(absl_log_internal_qcheck_ok_goo.first->ok()) \
+ ? nullptr \
+ : ::absl::status_internal::MakeCheckFailString( \
+ absl_log_internal_qcheck_ok_goo.first, \
+ ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL(val_text \
+ " is OK")), \
+ !ABSL_PREDICT_TRUE(absl_log_internal_qcheck_ok_goo.first->ok());) \
+ ABSL_LOG_INTERNAL_CONDITION_QFATAL(STATELESS, true) \
+ ABSL_LOG_INTERNAL_QCHECK(*absl_log_internal_qcheck_ok_goo.second) \
.InternalStream()
namespace absl {
@@ -179,9 +166,8 @@
class StatusOr;
namespace status_internal {
-ABSL_ATTRIBUTE_PURE_FUNCTION absl::Nonnull<const char*> MakeCheckFailString(
- absl::Nonnull<const absl::Status*> status,
- absl::Nonnull<const char*> prefix);
+ABSL_ATTRIBUTE_PURE_FUNCTION std::string* MakeCheckFailString(
+ const absl::Status* status, const char* prefix);
} // namespace status_internal
namespace log_internal {
@@ -189,11 +175,9 @@
// Convert a Status or a StatusOr to its underlying status value.
//
// (This implementation does not require a dep on absl::Status to work.)
-inline absl::Nonnull<const absl::Status*> AsStatus(const absl::Status& s) {
- return &s;
-}
+inline const absl::Status* AsStatus(const absl::Status& s) { return &s; }
template <typename T>
-absl::Nonnull<const absl::Status*> AsStatus(const absl::StatusOr<T>& s) {
+const absl::Status* AsStatus(const absl::StatusOr<T>& s) {
return &s.status();
}
@@ -202,14 +186,14 @@
class CheckOpMessageBuilder final {
public:
// Inserts `exprtext` and ` (` to the stream.
- explicit CheckOpMessageBuilder(absl::Nonnull<const char*> exprtext);
+ explicit CheckOpMessageBuilder(const char* exprtext);
~CheckOpMessageBuilder() = default;
// For inserting the first variable.
std::ostream& ForVar1() { return stream_; }
// For inserting the second variable (adds an intermediate ` vs. `).
std::ostream& ForVar2();
// Get the result (inserts the closing `)`).
- absl::Nonnull<const char*> NewString();
+ std::string* NewString();
private:
std::ostringstream stream_;
@@ -352,12 +336,11 @@
// Build the error message string. Specify no inlining for code size.
template <typename T1, typename T2>
-ABSL_ATTRIBUTE_RETURNS_NONNULL absl::Nonnull<const char*> MakeCheckOpString(
- T1 v1, T2 v2, absl::Nonnull<const char*> exprtext) ABSL_ATTRIBUTE_NOINLINE;
+ABSL_ATTRIBUTE_RETURNS_NONNULL std::string* MakeCheckOpString(
+ T1 v1, T2 v2, const char* exprtext) ABSL_ATTRIBUTE_NOINLINE;
template <typename T1, typename T2>
-absl::Nonnull<const char*> MakeCheckOpString(
- T1 v1, T2 v2, absl::Nonnull<const char*> exprtext) {
+std::string* MakeCheckOpString(T1 v1, T2 v2, const char* exprtext) {
CheckOpMessageBuilder comb(exprtext);
MakeCheckOpValueString(comb.ForVar1(), v1);
MakeCheckOpValueString(comb.ForVar2(), v2);
@@ -367,8 +350,7 @@
// Add a few commonly used instantiations as extern to reduce size of objects
// files.
#define ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING_EXTERN(x) \
- extern template absl::Nonnull<const char*> MakeCheckOpString( \
- x, x, absl::Nonnull<const char*>)
+ extern template std::string* MakeCheckOpString(x, x, const char*)
ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING_EXTERN(bool);
ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING_EXTERN(int64_t);
ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING_EXTERN(uint64_t);
@@ -392,7 +374,7 @@
((::absl::LogSeverity::kFatal >= \
static_cast<::absl::LogSeverity>(ABSL_MIN_LOG_LEVEL)) \
? MakeCheckOpString<U1, U2>(v1, v2, exprtext) \
- : "")
+ : new std::string())
#else
#define ABSL_LOG_INTERNAL_CHECK_OP_IMPL_RESULT(U1, U2, v1, v2, exprtext) \
MakeCheckOpString<U1, U2>(v1, v2, exprtext)
@@ -404,8 +386,8 @@
// type.
#define ABSL_LOG_INTERNAL_CHECK_OP_IMPL(name, op) \
template <typename T1, typename T2> \
- inline constexpr absl::Nullable<const char*> name##Impl( \
- const T1& v1, const T2& v2, absl::Nonnull<const char*> exprtext) { \
+ inline constexpr ::std::string* name##Impl(const T1& v1, const T2& v2, \
+ const char* exprtext) { \
using U1 = CheckOpStreamType<T1>; \
using U2 = CheckOpStreamType<T2>; \
return ABSL_PREDICT_TRUE(v1 op v2) \
@@ -413,8 +395,8 @@
: ABSL_LOG_INTERNAL_CHECK_OP_IMPL_RESULT(U1, U2, U1(v1), \
U2(v2), exprtext); \
} \
- inline constexpr absl::Nullable<const char*> name##Impl( \
- int v1, int v2, absl::Nonnull<const char*> exprtext) { \
+ inline constexpr ::std::string* name##Impl(int v1, int v2, \
+ const char* exprtext) { \
return name##Impl<int, int>(v1, v2, exprtext); \
}
@@ -427,18 +409,14 @@
#undef ABSL_LOG_INTERNAL_CHECK_OP_IMPL_RESULT
#undef ABSL_LOG_INTERNAL_CHECK_OP_IMPL
-absl::Nullable<const char*> CheckstrcmptrueImpl(
- absl::Nullable<const char*> s1, absl::Nullable<const char*> s2,
- absl::Nonnull<const char*> exprtext);
-absl::Nullable<const char*> CheckstrcmpfalseImpl(
- absl::Nullable<const char*> s1, absl::Nullable<const char*> s2,
- absl::Nonnull<const char*> exprtext);
-absl::Nullable<const char*> CheckstrcasecmptrueImpl(
- absl::Nullable<const char*> s1, absl::Nullable<const char*> s2,
- absl::Nonnull<const char*> exprtext);
-absl::Nullable<const char*> CheckstrcasecmpfalseImpl(
- absl::Nullable<const char*> s1, absl::Nullable<const char*> s2,
- absl::Nonnull<const char*> exprtext);
+std::string* CheckstrcmptrueImpl(const char* s1, const char* s2,
+ const char* exprtext);
+std::string* CheckstrcmpfalseImpl(const char* s1, const char* s2,
+ const char* exprtext);
+std::string* CheckstrcasecmptrueImpl(const char* s1, const char* s2,
+ const char* exprtext);
+std::string* CheckstrcasecmpfalseImpl(const char* s1, const char* s2,
+ const char* exprtext);
// `CHECK_EQ` and friends want to pass their arguments by reference, however
// this winds up exposing lots of cases where people have defined and
@@ -446,8 +424,6 @@
// file), meaning they are not referenceable. This function avoids that problem
// for integers (the most common cases) by overloading for every primitive
// integer type, even the ones we discourage, and returning them by value.
-// NOLINTBEGIN(runtime/int)
-// NOLINTBEGIN(google-runtime-int)
template <typename T>
inline constexpr const T& GetReferenceableValue(const T& t) {
return t;
@@ -457,25 +433,27 @@
return t;
}
inline constexpr signed char GetReferenceableValue(signed char t) { return t; }
-inline constexpr short GetReferenceableValue(short t) { return t; }
-inline constexpr unsigned short GetReferenceableValue(unsigned short t) {
+inline constexpr short GetReferenceableValue(short t) { return t; } // NOLINT
+inline constexpr unsigned short GetReferenceableValue( // NOLINT
+ unsigned short t) { // NOLINT
return t;
}
inline constexpr int GetReferenceableValue(int t) { return t; }
inline constexpr unsigned int GetReferenceableValue(unsigned int t) {
return t;
}
-inline constexpr long GetReferenceableValue(long t) { return t; }
-inline constexpr unsigned long GetReferenceableValue(unsigned long t) {
+inline constexpr long GetReferenceableValue(long t) { return t; } // NOLINT
+inline constexpr unsigned long GetReferenceableValue( // NOLINT
+ unsigned long t) { // NOLINT
return t;
}
-inline constexpr long long GetReferenceableValue(long long t) { return t; }
-inline constexpr unsigned long long GetReferenceableValue(
- unsigned long long t) {
+inline constexpr long long GetReferenceableValue(long long t) { // NOLINT
return t;
}
-// NOLINTEND(google-runtime-int)
-// NOLINTEND(runtime/int)
+inline constexpr unsigned long long GetReferenceableValue( // NOLINT
+ unsigned long long t) { // NOLINT
+ return t;
+}
} // namespace log_internal
ABSL_NAMESPACE_END
diff --git a/absl/log/internal/log_message.cc b/absl/log/internal/log_message.cc
index 9e7722d..4e9b08a 100644
--- a/absl/log/internal/log_message.cc
+++ b/absl/log/internal/log_message.cc
@@ -39,7 +39,6 @@
#include "absl/base/internal/strerror.h"
#include "absl/base/internal/sysinfo.h"
#include "absl/base/log_severity.h"
-#include "absl/base/nullability.h"
#include "absl/container/inlined_vector.h"
#include "absl/debugging/internal/examine_stack.h"
#include "absl/log/globals.h"
@@ -48,7 +47,6 @@
#include "absl/log/internal/log_format.h"
#include "absl/log/internal/log_sink_set.h"
#include "absl/log/internal/proto.h"
-#include "absl/log/internal/structured_proto.h"
#include "absl/log/log_entry.h"
#include "absl/log/log_sink.h"
#include "absl/log/log_sink_registry.h"
@@ -147,8 +145,8 @@
} // namespace
struct LogMessage::LogMessageData final {
- LogMessageData(absl::Nonnull<const char*> file, int line,
- absl::LogSeverity severity, absl::Time timestamp);
+ LogMessageData(const char* file, int line, absl::LogSeverity severity,
+ absl::Time timestamp);
LogMessageData(const LogMessageData&) = delete;
LogMessageData& operator=(const LogMessageData&) = delete;
@@ -163,7 +161,7 @@
bool is_perror;
// Extra `LogSink`s to log to, in addition to `global_sinks`.
- absl::InlinedVector<absl::Nonnull<absl::LogSink*>, 16> extra_sinks;
+ absl::InlinedVector<absl::LogSink*, 16> extra_sinks;
// If true, log to `extra_sinks` but not to `global_sinks` or hardcoded
// non-sink targets (e.g. stderr, log files).
bool extra_sinks_only;
@@ -199,8 +197,8 @@
void FinalizeEncodingAndFormat();
};
-LogMessage::LogMessageData::LogMessageData(absl::Nonnull<const char*> file,
- int line, absl::LogSeverity severity,
+LogMessage::LogMessageData::LogMessageData(const char* file, int line,
+ absl::LogSeverity severity,
absl::Time timestamp)
: extra_sinks_only(false), manipulated(nullptr) {
// Legacy defaults for LOG's ostream:
@@ -270,8 +268,7 @@
absl::MakeSpan(string_buf).subspan(0, chars_written);
}
-LogMessage::LogMessage(absl::Nonnull<const char*> file, int line,
- absl::LogSeverity severity)
+LogMessage::LogMessage(const char* file, int line, absl::LogSeverity severity)
: data_(absl::make_unique<LogMessageData>(file, line, severity,
absl::Now())) {
data_->first_fatal = false;
@@ -284,11 +281,11 @@
LogBacktraceIfNeeded();
}
-LogMessage::LogMessage(absl::Nonnull<const char*> file, int line, InfoTag)
+LogMessage::LogMessage(const char* file, int line, InfoTag)
: LogMessage(file, line, absl::LogSeverity::kInfo) {}
-LogMessage::LogMessage(absl::Nonnull<const char*> file, int line, WarningTag)
+LogMessage::LogMessage(const char* file, int line, WarningTag)
: LogMessage(file, line, absl::LogSeverity::kWarning) {}
-LogMessage::LogMessage(absl::Nonnull<const char*> file, int line, ErrorTag)
+LogMessage::LogMessage(const char* file, int line, ErrorTag)
: LogMessage(file, line, absl::LogSeverity::kError) {}
LogMessage::~LogMessage() {
@@ -351,13 +348,13 @@
return *this;
}
-LogMessage& LogMessage::ToSinkAlso(absl::Nonnull<absl::LogSink*> sink) {
+LogMessage& LogMessage::ToSinkAlso(absl::LogSink* sink) {
ABSL_INTERNAL_CHECK(sink, "null LogSink*");
data_->extra_sinks.push_back(sink);
return *this;
}
-LogMessage& LogMessage::ToSinkOnly(absl::Nonnull<absl::LogSink*> sink) {
+LogMessage& LogMessage::ToSinkOnly(absl::LogSink* sink) {
ABSL_INTERNAL_CHECK(sink, "null LogSink*");
data_->extra_sinks.clear();
data_->extra_sinks.push_back(sink);
@@ -421,26 +418,23 @@
data_->manipulated << m;
return *this;
}
-// NOLINTBEGIN(runtime/int)
-// NOLINTBEGIN(google-runtime-int)
template LogMessage& LogMessage::operator<<(const char& v);
template LogMessage& LogMessage::operator<<(const signed char& v);
template LogMessage& LogMessage::operator<<(const unsigned char& v);
-template LogMessage& LogMessage::operator<<(const short& v);
-template LogMessage& LogMessage::operator<<(const unsigned short& v);
+template LogMessage& LogMessage::operator<<(const short& v); // NOLINT
+template LogMessage& LogMessage::operator<<(const unsigned short& v); // NOLINT
template LogMessage& LogMessage::operator<<(const int& v);
template LogMessage& LogMessage::operator<<(const unsigned int& v);
-template LogMessage& LogMessage::operator<<(const long& v);
-template LogMessage& LogMessage::operator<<(const unsigned long& v);
-template LogMessage& LogMessage::operator<<(const long long& v);
-template LogMessage& LogMessage::operator<<(const unsigned long long& v);
+template LogMessage& LogMessage::operator<<(const long& v); // NOLINT
+template LogMessage& LogMessage::operator<<(const unsigned long& v); // NOLINT
+template LogMessage& LogMessage::operator<<(const long long& v); // NOLINT
+template LogMessage& LogMessage::operator<<(
+ const unsigned long long& v); // NOLINT
template LogMessage& LogMessage::operator<<(void* const& v);
template LogMessage& LogMessage::operator<<(const void* const& v);
template LogMessage& LogMessage::operator<<(const float& v);
template LogMessage& LogMessage::operator<<(const double& v);
template LogMessage& LogMessage::operator<<(const bool& v);
-// NOLINTEND(google-runtime-int)
-// NOLINTEND(runtime/int)
void LogMessage::Flush() {
if (data_->entry.log_severity() < absl::MinLogLevel()) return;
@@ -581,17 +575,16 @@
template <LogMessage::StringType str_type>
void LogMessage::CopyToEncodedBuffer(absl::string_view str) {
auto encoded_remaining_copy = data_->encoded_remaining();
- constexpr uint8_t tag_value = str_type == StringType::kLiteral
- ? ValueTag::kStringLiteral
- : ValueTag::kString;
auto start = EncodeMessageStart(
- EventTag::kValue,
- BufferSizeFor(tag_value, WireType::kLengthDelimited) + str.size(),
+ EventTag::kValue, BufferSizeFor(WireType::kLengthDelimited) + str.size(),
&encoded_remaining_copy);
// If the `logging.proto.Event.value` field header did not fit,
// `EncodeMessageStart` will have zeroed `encoded_remaining_copy`'s size and
// `EncodeStringTruncate` will fail too.
- if (EncodeStringTruncate(tag_value, str, &encoded_remaining_copy)) {
+ if (EncodeStringTruncate(str_type == StringType::kLiteral
+ ? ValueTag::kStringLiteral
+ : ValueTag::kString,
+ str, &encoded_remaining_copy)) {
// The string may have been truncated, but the field header fit.
EncodeMessageLength(start, &encoded_remaining_copy);
data_->encoded_remaining() = encoded_remaining_copy;
@@ -608,14 +601,13 @@
template <LogMessage::StringType str_type>
void LogMessage::CopyToEncodedBuffer(char ch, size_t num) {
auto encoded_remaining_copy = data_->encoded_remaining();
- constexpr uint8_t tag_value = str_type == StringType::kLiteral
- ? ValueTag::kStringLiteral
- : ValueTag::kString;
auto value_start = EncodeMessageStart(
- EventTag::kValue,
- BufferSizeFor(tag_value, WireType::kLengthDelimited) + num,
+ EventTag::kValue, BufferSizeFor(WireType::kLengthDelimited) + num,
&encoded_remaining_copy);
- auto str_start = EncodeMessageStart(tag_value, num, &encoded_remaining_copy);
+ auto str_start = EncodeMessageStart(str_type == StringType::kLiteral
+ ? ValueTag::kStringLiteral
+ : ValueTag::kString,
+ num, &encoded_remaining_copy);
if (str_start.data()) {
// The field headers fit.
log_internal::AppendTruncated(ch, num, encoded_remaining_copy);
@@ -633,47 +625,6 @@
template void LogMessage::CopyToEncodedBuffer<
LogMessage::StringType::kNotLiteral>(char ch, size_t num);
-template void LogMessage::CopyToEncodedBufferWithStructuredProtoField<
- LogMessage::StringType::kLiteral>(StructuredProtoField field,
- absl::string_view str);
-template void LogMessage::CopyToEncodedBufferWithStructuredProtoField<
- LogMessage::StringType::kNotLiteral>(StructuredProtoField field,
- absl::string_view str);
-
-template <LogMessage::StringType str_type>
-void LogMessage::CopyToEncodedBufferWithStructuredProtoField(
- StructuredProtoField field, absl::string_view str) {
- auto encoded_remaining_copy = data_->encoded_remaining();
- size_t encoded_field_size = BufferSizeForStructuredProtoField(field);
- constexpr uint8_t tag_value = str_type == StringType::kLiteral
- ? ValueTag::kStringLiteral
- : ValueTag::kString;
- auto start = EncodeMessageStart(
- EventTag::kValue,
- encoded_field_size +
- BufferSizeFor(tag_value, WireType::kLengthDelimited) + str.size(),
- &encoded_remaining_copy);
-
- // Write the encoded proto field.
- if (!EncodeStructuredProtoField(field, encoded_remaining_copy)) {
- // The header / field will not fit; zero `encoded_remaining()` so we
- // don't write anything else later.
- data_->encoded_remaining().remove_suffix(data_->encoded_remaining().size());
- return;
- }
-
- // Write the string, truncating if necessary.
- if (!EncodeStringTruncate(ValueTag::kString, str, &encoded_remaining_copy)) {
- // The length of the string itself did not fit; zero `encoded_remaining()`
- // so the value is not encoded at all.
- data_->encoded_remaining().remove_suffix(data_->encoded_remaining().size());
- return;
- }
-
- EncodeMessageLength(start, &encoded_remaining_copy);
- data_->encoded_remaining() = encoded_remaining_copy;
-}
-
// We intentionally don't return from these destructors. Disable MSVC's warning
// about the destructor never returning as we do so intentionally here.
#if defined(_MSC_VER) && !defined(__clang__)
@@ -681,11 +632,11 @@
#pragma warning(disable : 4722)
#endif
-LogMessageFatal::LogMessageFatal(absl::Nonnull<const char*> file, int line)
+LogMessageFatal::LogMessageFatal(const char* file, int line)
: LogMessage(file, line, absl::LogSeverity::kFatal) {}
-LogMessageFatal::LogMessageFatal(absl::Nonnull<const char*> file, int line,
- absl::Nonnull<const char*> failure_msg)
+LogMessageFatal::LogMessageFatal(const char* file, int line,
+ absl::string_view failure_msg)
: LogMessage(file, line, absl::LogSeverity::kFatal) {
*this << "Check failed: " << failure_msg << " ";
}
@@ -695,8 +646,7 @@
FailWithoutStackTrace();
}
-LogMessageDebugFatal::LogMessageDebugFatal(absl::Nonnull<const char*> file,
- int line)
+LogMessageDebugFatal::LogMessageDebugFatal(const char* file, int line)
: LogMessage(file, line, absl::LogSeverity::kFatal) {}
LogMessageDebugFatal::~LogMessageDebugFatal() {
@@ -704,8 +654,8 @@
FailWithoutStackTrace();
}
-LogMessageQuietlyDebugFatal::LogMessageQuietlyDebugFatal(
- absl::Nonnull<const char*> file, int line)
+LogMessageQuietlyDebugFatal::LogMessageQuietlyDebugFatal(const char* file,
+ int line)
: LogMessage(file, line, absl::LogSeverity::kFatal) {
SetFailQuietly();
}
@@ -715,17 +665,15 @@
FailQuietly();
}
-LogMessageQuietlyFatal::LogMessageQuietlyFatal(absl::Nonnull<const char*> file,
- int line)
+LogMessageQuietlyFatal::LogMessageQuietlyFatal(const char* file, int line)
: LogMessage(file, line, absl::LogSeverity::kFatal) {
SetFailQuietly();
}
-LogMessageQuietlyFatal::LogMessageQuietlyFatal(
- absl::Nonnull<const char*> file, int line,
- absl::Nonnull<const char*> failure_msg)
+LogMessageQuietlyFatal::LogMessageQuietlyFatal(const char* file, int line,
+ absl::string_view failure_msg)
: LogMessageQuietlyFatal(file, line) {
- *this << "Check failed: " << failure_msg << " ";
+ *this << "Check failed: " << failure_msg << " ";
}
LogMessageQuietlyFatal::~LogMessageQuietlyFatal() {
diff --git a/absl/log/internal/log_message.h b/absl/log/internal/log_message.h
index 7d0e403..0c067da 100644
--- a/absl/log/internal/log_message.h
+++ b/absl/log/internal/log_message.h
@@ -27,21 +27,17 @@
#ifndef ABSL_LOG_INTERNAL_LOG_MESSAGE_H_
#define ABSL_LOG_INTERNAL_LOG_MESSAGE_H_
-#include <cstddef>
#include <ios>
#include <memory>
#include <ostream>
#include <streambuf>
#include <string>
-#include <type_traits>
#include "absl/base/attributes.h"
#include "absl/base/config.h"
#include "absl/base/internal/errno_saver.h"
#include "absl/base/log_severity.h"
-#include "absl/base/nullability.h"
#include "absl/log/internal/nullguard.h"
-#include "absl/log/internal/structured_proto.h"
#include "absl/log/log_entry.h"
#include "absl/log/log_sink.h"
#include "absl/strings/has_absl_stringify.h"
@@ -53,8 +49,6 @@
namespace log_internal {
constexpr int kLogMessageBufferSize = 15000;
-enum class StructuredStringType;
-
class LogMessage {
public:
struct InfoTag {};
@@ -62,15 +56,15 @@
struct ErrorTag {};
// Used for `LOG`.
- LogMessage(absl::Nonnull<const char*> file, int line,
+ LogMessage(const char* file, int line,
absl::LogSeverity severity) ABSL_ATTRIBUTE_COLD;
// These constructors are slightly smaller/faster to call; the severity is
// curried into the function pointer.
- LogMessage(absl::Nonnull<const char*> file, int line,
+ LogMessage(const char* file, int line,
InfoTag) ABSL_ATTRIBUTE_COLD ABSL_ATTRIBUTE_NOINLINE;
- LogMessage(absl::Nonnull<const char*> file, int line,
+ LogMessage(const char* file, int line,
WarningTag) ABSL_ATTRIBUTE_COLD ABSL_ATTRIBUTE_NOINLINE;
- LogMessage(absl::Nonnull<const char*> file, int line,
+ LogMessage(const char* file, int line,
ErrorTag) ABSL_ATTRIBUTE_COLD ABSL_ATTRIBUTE_NOINLINE;
LogMessage(const LogMessage&) = delete;
LogMessage& operator=(const LogMessage&) = delete;
@@ -101,67 +95,59 @@
// of `errno`.
LogMessage& WithPerror();
// Sends this message to `*sink` in addition to whatever other sinks it would
- // otherwise have been sent to.
- LogMessage& ToSinkAlso(absl::Nonnull<absl::LogSink*> sink);
- // Sends this message to `*sink` and no others.
- LogMessage& ToSinkOnly(absl::Nonnull<absl::LogSink*> sink);
+ // otherwise have been sent to. `sink` must not be null.
+ LogMessage& ToSinkAlso(absl::LogSink* sink);
+ // Sends this message to `*sink` and no others. `sink` must not be null.
+ LogMessage& ToSinkOnly(absl::LogSink* sink);
// Don't call this method from outside this library.
LogMessage& InternalStream() { return *this; }
// By-value overloads for small, common types let us overlook common failures
// to define globals and static data members (i.e. in a .cc file).
- // NOLINTBEGIN(runtime/int)
- // NOLINTBEGIN(google-runtime-int)
- // clang-format off: The CUDA toolchain cannot handle these <<<'s
+ // clang-format off
+ // The CUDA toolchain cannot handle these <<<'s:
LogMessage& operator<<(char v) { return operator<< <char>(v); }
LogMessage& operator<<(signed char v) { return operator<< <signed char>(v); }
LogMessage& operator<<(unsigned char v) {
return operator<< <unsigned char>(v);
}
- LogMessage& operator<<(signed short v) {
- return operator<< <signed short>(v);
+ LogMessage& operator<<(signed short v) { // NOLINT
+ return operator<< <signed short>(v); // NOLINT
}
LogMessage& operator<<(signed int v) { return operator<< <signed int>(v); }
- LogMessage& operator<<(signed long v) {
- return operator<< <signed long>(v);
+ LogMessage& operator<<(signed long v) { // NOLINT
+ return operator<< <signed long>(v); // NOLINT
}
- LogMessage& operator<<(signed long long v) {
- return operator<< <signed long long>(v);
+ LogMessage& operator<<(signed long long v) { // NOLINT
+ return operator<< <signed long long>(v); // NOLINT
}
- LogMessage& operator<<(unsigned short v) {
- return operator<< <unsigned short>(v);
+ LogMessage& operator<<(unsigned short v) { // NOLINT
+ return operator<< <unsigned short>(v); // NOLINT
}
LogMessage& operator<<(unsigned int v) {
return operator<< <unsigned int>(v);
}
- LogMessage& operator<<(unsigned long v) {
- return operator<< <unsigned long>(v);
+ LogMessage& operator<<(unsigned long v) { // NOLINT
+ return operator<< <unsigned long>(v); // NOLINT
}
- LogMessage& operator<<(unsigned long long v) {
- return operator<< <unsigned long long>(v);
+ LogMessage& operator<<(unsigned long long v) { // NOLINT
+ return operator<< <unsigned long long>(v); // NOLINT
}
- LogMessage& operator<<(absl::Nullable<void*> v) {
- return operator<< <void*>(v);
- }
- LogMessage& operator<<(absl::Nullable<const void*> v) {
- return operator<< <const void*>(v);
- }
+ LogMessage& operator<<(void* v) { return operator<< <void*>(v); }
+ LogMessage& operator<<(const void* v) { return operator<< <const void*>(v); }
LogMessage& operator<<(float v) { return operator<< <float>(v); }
LogMessage& operator<<(double v) { return operator<< <double>(v); }
LogMessage& operator<<(bool v) { return operator<< <bool>(v); }
// clang-format on
- // NOLINTEND(google-runtime-int)
- // NOLINTEND(runtime/int)
// These overloads are more efficient since no `ostream` is involved.
LogMessage& operator<<(const std::string& v);
LogMessage& operator<<(absl::string_view v);
// Handle stream manipulators e.g. std::endl.
- LogMessage& operator<<(absl::Nonnull<std::ostream& (*)(std::ostream & os)> m);
- LogMessage& operator<<(
- absl::Nonnull<std::ios_base& (*)(std::ios_base & os)> m);
+ LogMessage& operator<<(std::ostream& (*m)(std::ostream& os));
+ LogMessage& operator<<(std::ios_base& (*m)(std::ios_base& os));
// Literal strings. This allows us to record C string literals as literals in
// the logging.proto.Value.
@@ -220,10 +206,6 @@
struct LogMessageData; // Opaque type containing message state
friend class AsLiteralImpl;
friend class StringifySink;
- template <StructuredStringType str_type>
- friend class AsStructuredStringTypeImpl;
- template <typename T>
- friend class AsStructuredValueImpl;
// This streambuf writes directly into the structured logging buffer so that
// arbitrary types can be encoded as string data (using
@@ -254,13 +236,6 @@
template <StringType str_type>
void CopyToEncodedBuffer(char ch, size_t num) ABSL_ATTRIBUTE_NOINLINE;
- // Copies `field` to the encoded buffer, then appends `str` after it
- // (truncating `str` if necessary to fit).
- template <StringType str_type>
- void CopyToEncodedBufferWithStructuredProtoField(StructuredProtoField field,
- absl::string_view str)
- ABSL_ATTRIBUTE_NOINLINE;
-
// Returns `true` if the message is fatal or enabled debug-fatal.
bool IsFatal() const;
@@ -280,7 +255,7 @@
// We keep the data in a separate struct so that each instance of `LogMessage`
// uses less stack space.
- absl::Nonnull<std::unique_ptr<LogMessageData>> data_;
+ std::unique_ptr<LogMessageData> data_;
};
// Helper class so that `AbslStringify()` can modify the LogMessage.
@@ -298,8 +273,7 @@
}
// For types that implement `AbslStringify` using `absl::Format()`.
- friend void AbslFormatFlush(absl::Nonnull<StringifySink*> sink,
- absl::string_view v) {
+ friend void AbslFormatFlush(StringifySink* sink, absl::string_view v) {
sink->Append(v);
}
@@ -341,28 +315,27 @@
// We instantiate these specializations in the library's TU to save space in
// other TUs. Since the template is marked `ABSL_ATTRIBUTE_NOINLINE` we will be
// emitting a function call either way.
-// NOLINTBEGIN(runtime/int)
-// NOLINTBEGIN(google-runtime-int)
extern template LogMessage& LogMessage::operator<<(const char& v);
extern template LogMessage& LogMessage::operator<<(const signed char& v);
extern template LogMessage& LogMessage::operator<<(const unsigned char& v);
-extern template LogMessage& LogMessage::operator<<(const short& v);
-extern template LogMessage& LogMessage::operator<<(const unsigned short& v);
+extern template LogMessage& LogMessage::operator<<(const short& v); // NOLINT
+extern template LogMessage& LogMessage::operator<<(
+ const unsigned short& v); // NOLINT
extern template LogMessage& LogMessage::operator<<(const int& v);
-extern template LogMessage& LogMessage::operator<<(const unsigned int& v);
-extern template LogMessage& LogMessage::operator<<(const long& v);
-extern template LogMessage& LogMessage::operator<<(const unsigned long& v);
-extern template LogMessage& LogMessage::operator<<(const long long& v);
-extern template LogMessage& LogMessage::operator<<(const unsigned long long& v);
extern template LogMessage& LogMessage::operator<<(
- absl::Nullable<void*> const& v);
+ const unsigned int& v); // NOLINT
+extern template LogMessage& LogMessage::operator<<(const long& v); // NOLINT
extern template LogMessage& LogMessage::operator<<(
- absl::Nullable<const void*> const& v);
+ const unsigned long& v); // NOLINT
+extern template LogMessage& LogMessage::operator<<(
+ const long long& v); // NOLINT
+extern template LogMessage& LogMessage::operator<<(
+ const unsigned long long& v); // NOLINT
+extern template LogMessage& LogMessage::operator<<(void* const& v);
+extern template LogMessage& LogMessage::operator<<(const void* const& v);
extern template LogMessage& LogMessage::operator<<(const float& v);
extern template LogMessage& LogMessage::operator<<(const double& v);
extern template LogMessage& LogMessage::operator<<(const bool& v);
-// NOLINTEND(google-runtime-int)
-// NOLINTEND(runtime/int)
extern template void LogMessage::CopyToEncodedBuffer<
LogMessage::StringType::kLiteral>(absl::string_view str);
@@ -378,10 +351,9 @@
// message.
class LogMessageFatal final : public LogMessage {
public:
- LogMessageFatal(absl::Nonnull<const char*> file,
- int line) ABSL_ATTRIBUTE_COLD;
- LogMessageFatal(absl::Nonnull<const char*> file, int line,
- absl::Nonnull<const char*> failure_msg) ABSL_ATTRIBUTE_COLD;
+ LogMessageFatal(const char* file, int line) ABSL_ATTRIBUTE_COLD;
+ LogMessageFatal(const char* file, int line,
+ absl::string_view failure_msg) ABSL_ATTRIBUTE_COLD;
[[noreturn]] ~LogMessageFatal();
};
@@ -390,8 +362,7 @@
// for DLOG(FATAL) variants.
class LogMessageDebugFatal final : public LogMessage {
public:
- LogMessageDebugFatal(absl::Nonnull<const char*> file,
- int line) ABSL_ATTRIBUTE_COLD;
+ LogMessageDebugFatal(const char* file, int line) ABSL_ATTRIBUTE_COLD;
~LogMessageDebugFatal();
};
@@ -400,19 +371,16 @@
// DLOG(QFATAL) calls this instead of LogMessageQuietlyFatal to make sure the
// destructor is not [[noreturn]] even if this is always FATAL as this is only
// invoked when DLOG() is enabled.
- LogMessageQuietlyDebugFatal(absl::Nonnull<const char*> file,
- int line) ABSL_ATTRIBUTE_COLD;
+ LogMessageQuietlyDebugFatal(const char* file, int line) ABSL_ATTRIBUTE_COLD;
~LogMessageQuietlyDebugFatal();
};
// Used for LOG(QFATAL) to make sure it's properly understood as [[noreturn]].
class LogMessageQuietlyFatal final : public LogMessage {
public:
- LogMessageQuietlyFatal(absl::Nonnull<const char*> file,
- int line) ABSL_ATTRIBUTE_COLD;
- LogMessageQuietlyFatal(absl::Nonnull<const char*> file, int line,
- absl::Nonnull<const char*> failure_msg)
- ABSL_ATTRIBUTE_COLD;
+ LogMessageQuietlyFatal(const char* file, int line) ABSL_ATTRIBUTE_COLD;
+ LogMessageQuietlyFatal(const char* file, int line,
+ absl::string_view failure_msg) ABSL_ATTRIBUTE_COLD;
[[noreturn]] ~LogMessageQuietlyFatal();
};
diff --git a/absl/log/internal/proto.cc b/absl/log/internal/proto.cc
index 3513b15..eb699ae 100644
--- a/absl/log/internal/proto.cc
+++ b/absl/log/internal/proto.cc
@@ -35,6 +35,9 @@
}
buf->remove_prefix(size);
}
+constexpr uint64_t MakeTagType(uint64_t tag, WireType type) {
+ return tag << 3 | static_cast<uint64_t>(type);
+}
} // namespace
bool EncodeVarint(uint64_t tag, uint64_t value, absl::Span<char> *buf) {
diff --git a/absl/log/internal/proto.h b/absl/log/internal/proto.h
index 20a9f3a..c8d14ac 100644
--- a/absl/log/internal/proto.h
+++ b/absl/log/internal/proto.h
@@ -199,33 +199,23 @@
return size >= 10 ? (std::numeric_limits<uint64_t>::max)()
: (static_cast<uint64_t>(1) << size * 7) - 1;
}
-constexpr uint64_t MakeTagType(uint64_t tag, WireType type) {
- return tag << 3 | static_cast<uint64_t>(type);
-}
// `BufferSizeFor` returns a number of bytes guaranteed to be sufficient to
-// store encoded fields as `(tag, WireType)`, regardless of data values. This
-// only makes sense for `WireType::kLengthDelimited` if you add in the length of
-// the contents yourself, e.g. for string and bytes fields by adding the lengths
-// of any encoded strings to the return value or for submessage fields by
-// enumerating the fields you may encode into their contents.
-constexpr size_t BufferSizeFor(uint64_t tag, WireType type) {
- size_t buffer_size = VarintSize(MakeTagType(tag, type));
- switch (type) {
- case WireType::kVarint:
- buffer_size += MaxVarintSize();
- break;
- case WireType::k64Bit:
- buffer_size += size_t{8};
- break;
- case WireType::kLengthDelimited:
- buffer_size += MaxVarintSize();
- break;
- case WireType::k32Bit:
- buffer_size += size_t{4};
- break;
- }
- return buffer_size;
+// store encoded fields of the specified WireTypes regardless of tag numbers and
+// data values. This only makes sense for `WireType::kLengthDelimited` if you
+// add in the length of the contents yourself, e.g. for string and bytes fields
+// by adding the lengths of any encoded strings to the return value or for
+// submessage fields by enumerating the fields you may encode into their
+// contents.
+constexpr size_t BufferSizeFor() { return 0; }
+template <typename... T>
+constexpr size_t BufferSizeFor(WireType type, T... tail) {
+ // tag_type + data + ...
+ return MaxVarintSize() +
+ (type == WireType::kVarint ? MaxVarintSize() : //
+ type == WireType::k64Bit ? 8 : //
+ type == WireType::k32Bit ? 4 : MaxVarintSize()) + //
+ BufferSizeFor(tail...);
}
// absl::Span<const char> represents a view into the un-processed space in a
diff --git a/absl/log/internal/structured.h b/absl/log/internal/structured.h
index 50783df..5223dbc 100644
--- a/absl/log/internal/structured.h
+++ b/absl/log/internal/structured.h
@@ -20,14 +20,9 @@
#define ABSL_LOG_INTERNAL_STRUCTURED_H_
#include <ostream>
-#include <string>
-#include "absl/base/attributes.h"
#include "absl/base/config.h"
-#include "absl/functional/any_invocable.h"
#include "absl/log/internal/log_message.h"
-#include "absl/log/internal/structured_proto.h"
-#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
namespace absl {
@@ -36,16 +31,14 @@
class ABSL_MUST_USE_RESULT AsLiteralImpl final {
public:
- explicit AsLiteralImpl(absl::string_view str ABSL_ATTRIBUTE_LIFETIME_BOUND)
- : str_(str) {}
+ explicit AsLiteralImpl(absl::string_view str) : str_(str) {}
AsLiteralImpl(const AsLiteralImpl&) = default;
AsLiteralImpl& operator=(const AsLiteralImpl&) = default;
private:
absl::string_view str_;
- friend std::ostream& operator<<(std::ostream& os,
- AsLiteralImpl&& as_literal) {
+ friend std::ostream& operator<<(std::ostream& os, AsLiteralImpl as_literal) {
return os << as_literal.str_;
}
void AddToMessage(log_internal::LogMessage& m) {
@@ -58,105 +51,6 @@
}
};
-enum class StructuredStringType {
- kLiteral,
- kNotLiteral,
-};
-
-// Structured log data for a string and associated structured proto field,
-// both of which must outlive this object.
-template <StructuredStringType str_type>
-class ABSL_MUST_USE_RESULT AsStructuredStringTypeImpl final {
- public:
- constexpr AsStructuredStringTypeImpl(
- absl::string_view str ABSL_ATTRIBUTE_LIFETIME_BOUND,
- StructuredProtoField field ABSL_ATTRIBUTE_LIFETIME_BOUND)
- : str_(str), field_(field) {}
-
- private:
- absl::string_view str_;
- StructuredProtoField field_;
-
- friend std::ostream& operator<<(std::ostream& os,
- const AsStructuredStringTypeImpl& impl) {
- return os << impl.str_;
- }
- void AddToMessage(LogMessage& m) const {
- if (str_type == StructuredStringType::kLiteral) {
- return m.CopyToEncodedBufferWithStructuredProtoField<
- log_internal::LogMessage::StringType::kLiteral>(field_, str_);
- } else {
- return m.CopyToEncodedBufferWithStructuredProtoField<
- log_internal::LogMessage::StringType::kNotLiteral>(field_, str_);
- }
- }
- friend LogMessage& operator<<(LogMessage& m,
- const AsStructuredStringTypeImpl& impl) {
- impl.AddToMessage(m);
- return m;
- }
-};
-
-using AsStructuredLiteralImpl =
- AsStructuredStringTypeImpl<StructuredStringType::kLiteral>;
-using AsStructuredNotLiteralImpl =
- AsStructuredStringTypeImpl<StructuredStringType::kNotLiteral>;
-
-// Structured log data for a stringifyable type T and associated structured
-// proto field, both of which must outlive this object.
-template <typename T>
-class ABSL_MUST_USE_RESULT AsStructuredValueImpl final {
- public:
- using ValueFormatter = absl::AnyInvocable<std::string(T) const>;
-
- constexpr AsStructuredValueImpl(
- T value ABSL_ATTRIBUTE_LIFETIME_BOUND,
- StructuredProtoField field ABSL_ATTRIBUTE_LIFETIME_BOUND,
- ValueFormatter value_formatter =
- [](T value) { return absl::StrCat(value); })
- : value_(value),
- field_(field),
- value_formatter_(std::move(value_formatter)) {}
-
- private:
- T value_;
- StructuredProtoField field_;
- ValueFormatter value_formatter_;
-
- friend std::ostream& operator<<(std::ostream& os,
- const AsStructuredValueImpl& impl) {
- return os << impl.value_formatter_(impl.value_);
- }
- void AddToMessage(LogMessage& m) const {
- m.CopyToEncodedBufferWithStructuredProtoField<
- log_internal::LogMessage::StringType::kNotLiteral>(
- field_, value_formatter_(value_));
- }
- friend LogMessage& operator<<(LogMessage& m,
- const AsStructuredValueImpl& impl) {
- impl.AddToMessage(m);
- return m;
- }
-};
-
-#ifdef ABSL_HAVE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION
-
-// Template deduction guide so `AsStructuredValueImpl(42, data)` works
-// without specifying the template type.
-template <typename T>
-AsStructuredValueImpl(T value, StructuredProtoField field)
- -> AsStructuredValueImpl<T>;
-
-// Template deduction guide so `AsStructuredValueImpl(42, data, formatter)`
-// works without specifying the template type.
-template <typename T>
-AsStructuredValueImpl(
- T value, StructuredProtoField field,
- typename AsStructuredValueImpl<T>::ValueFormatter value_formatter)
- -> AsStructuredValueImpl<T>;
-
-#endif // ABSL_HAVE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION
-
} // namespace log_internal
ABSL_NAMESPACE_END
} // namespace absl
diff --git a/absl/log/internal/structured_proto.cc b/absl/log/internal/structured_proto.cc
deleted file mode 100644
index e3829e4..0000000
--- a/absl/log/internal/structured_proto.cc
+++ /dev/null
@@ -1,115 +0,0 @@
-//
-// Copyright 2024 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
-//
-// https://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/log/internal/structured_proto.h"
-
-#include <cstdint>
-
-#include "absl/base/config.h"
-#include "absl/log/internal/proto.h"
-#include "absl/types/span.h"
-#include "absl/types/variant.h"
-
-namespace absl {
-ABSL_NAMESPACE_BEGIN
-namespace log_internal {
-
-namespace {
-
-// Handles protobuf-encoding a type contained inside
-// `StructuredProtoField::Varint`.
-struct VarintEncoderVisitor final {
- template <typename T>
- bool operator()(T value) const {
- return EncodeVarint(field_number, value, &buf);
- }
-
- uint64_t field_number;
- absl::Span<char>& buf;
-};
-
-// Handles protobuf-encoding a type contained inside
-// `StructuredProtoField::I64`.
-struct I64EncoderVisitor final {
- bool operator()(uint64_t value) const {
- return Encode64Bit(field_number, value, &buf);
- }
-
- bool operator()(int64_t value) const {
- return Encode64Bit(field_number, value, &buf);
- }
-
- bool operator()(double value) const {
- return EncodeDouble(field_number, value, &buf);
- }
-
- uint64_t field_number;
- absl::Span<char>& buf;
-};
-
-// Handles protobuf-encoding a type contained inside
-// `StructuredProtoField::I32`.
-struct I32EncoderVisitor final {
- bool operator()(uint32_t value) const {
- return Encode32Bit(field_number, value, &buf);
- }
-
- bool operator()(int32_t value) const {
- return Encode32Bit(field_number, value, &buf);
- }
-
- bool operator()(float value) const {
- return EncodeFloat(field_number, value, &buf);
- }
-
- uint64_t field_number;
- absl::Span<char>& buf;
-};
-
-// Handles protobuf-encoding a type contained inside `StructuredProtoField`.
-struct EncoderVisitor final {
- bool operator()(StructuredProtoField::Varint varint) {
- return absl::visit(VarintEncoderVisitor{field_number, buf}, varint);
- }
-
- bool operator()(StructuredProtoField::I64 i64) {
- return absl::visit(I64EncoderVisitor{field_number, buf}, i64);
- }
-
- bool operator()(StructuredProtoField::LengthDelimited length_delimited) {
- // No need for a visitor, since `StructuredProtoField::LengthDelimited` is
- // just `absl::Span<const char>`.
- return EncodeBytes(field_number, length_delimited, &buf);
- }
-
- bool operator()(StructuredProtoField::I32 i32) {
- return absl::visit(I32EncoderVisitor{field_number, buf}, i32);
- }
-
- uint64_t field_number;
- absl::Span<char>& buf;
-};
-
-} // namespace
-
-bool EncodeStructuredProtoField(StructuredProtoField field,
- absl::Span<char>& buf) {
- return absl::visit(EncoderVisitor{field.field_number, buf}, field.value);
-}
-
-} // namespace log_internal
-
-ABSL_NAMESPACE_END
-} // namespace absl
diff --git a/absl/log/internal/structured_proto.h b/absl/log/internal/structured_proto.h
deleted file mode 100644
index 3ebc4be..0000000
--- a/absl/log/internal/structured_proto.h
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright 2024 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
-//
-// https://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.
-//
-// -----------------------------------------------------------------------------
-// File: log/internal/structured_proto.h
-// -----------------------------------------------------------------------------
-
-#ifndef ABSL_LOG_INTERNAL_STRUCTURED_PROTO_H_
-#define ABSL_LOG_INTERNAL_STRUCTURED_PROTO_H_
-
-#include <cstddef>
-#include <cstdint>
-
-#include "absl/base/config.h"
-#include "absl/log/internal/proto.h"
-#include "absl/types/span.h"
-#include "absl/types/variant.h"
-
-namespace absl {
-ABSL_NAMESPACE_BEGIN
-namespace log_internal {
-
-// Sum type holding a single valid protobuf field suitable for encoding.
-struct StructuredProtoField final {
- // Numeric type encoded with varint encoding:
- // https://protobuf.dev/programming-guides/encoding/#varints
- using Varint = absl::variant<uint64_t, int64_t, uint32_t, int32_t, bool>;
-
- // Fixed-length 64-bit integer encoding:
- // https://protobuf.dev/programming-guides/encoding/#non-varints
- using I64 = absl::variant<uint64_t, int64_t, double>;
-
- // Length-delimited record type (string, sub-message):
- // https://protobuf.dev/programming-guides/encoding/#length-types
- using LengthDelimited = absl::Span<const char>;
-
- // Fixed-length 32-bit integer encoding:
- // https://protobuf.dev/programming-guides/encoding/#non-varints
- using I32 = absl::variant<uint32_t, int32_t, float>;
-
- // Valid record type:
- // https://protobuf.dev/programming-guides/encoding/#structure
- using Value = absl::variant<Varint, I64, LengthDelimited, I32>;
-
- // Field number for the protobuf value.
- uint64_t field_number;
-
- // Value to encode.
- Value value;
-};
-
-// Estimates the number of bytes needed to encode `field` using
-// protobuf encoding.
-//
-// The returned value might be larger than the actual number of bytes needed.
-inline size_t BufferSizeForStructuredProtoField(StructuredProtoField field) {
- // Visitor to estimate the number of bytes of one of the types contained
- // inside `StructuredProtoField`.
- struct BufferSizeVisitor final {
- size_t operator()(StructuredProtoField::Varint /*unused*/) {
- return BufferSizeFor(field_number, WireType::kVarint);
- }
-
- size_t operator()(StructuredProtoField::I64 /*unused*/) {
- return BufferSizeFor(field_number, WireType::k64Bit);
- }
-
- size_t operator()(StructuredProtoField::LengthDelimited length_delimited) {
- return BufferSizeFor(field_number, WireType::kLengthDelimited) +
- length_delimited.size();
- }
-
- size_t operator()(StructuredProtoField::I32 /*unused*/) {
- return BufferSizeFor(field_number, WireType::k32Bit);
- }
-
- uint64_t field_number;
- };
-
- return absl::visit(BufferSizeVisitor{field.field_number}, field.value);
-}
-
-// Encodes `field` into `buf` using protobuf encoding.
-//
-// On success, returns `true` and advances `buf` to the end of
-// the bytes consumed.
-//
-// On failure (if `buf` was too small), returns `false`.
-bool EncodeStructuredProtoField(StructuredProtoField field,
- absl::Span<char>& buf);
-
-} // namespace log_internal
-ABSL_NAMESPACE_END
-} // namespace absl
-
-#endif // ABSL_LOG_INTERNAL_STRUCTURED_PROTO_H_
diff --git a/absl/log/internal/structured_proto_test.cc b/absl/log/internal/structured_proto_test.cc
deleted file mode 100644
index a4deebc..0000000
--- a/absl/log/internal/structured_proto_test.cc
+++ /dev/null
@@ -1,120 +0,0 @@
-//
-// Copyright 2024 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
-//
-// https://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/log/internal/structured_proto.h"
-
-#include <cstddef>
-#include <cstdint>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "gtest/gtest.h"
-#include "absl/base/config.h"
-#include "absl/strings/string_view.h"
-#include "absl/types/span.h"
-#include "absl/utility/utility.h"
-
-namespace absl {
-ABSL_NAMESPACE_BEGIN
-namespace log_internal {
-namespace {
-
-using ::testing::TestWithParam;
-
-struct StructuredProtoTestCase {
- std::string test_name;
- StructuredProtoField field;
- std::vector<char> expected_encoded_field;
-};
-
-using StructuredProtoTest = TestWithParam<StructuredProtoTestCase>;
-
-TEST_P(StructuredProtoTest, Encoding) {
- const StructuredProtoTestCase& test_case = GetParam();
-
- // Greater than or equal to since BufferSizeForStructuredProtoField() is just
- // an estimate of the data size and not an exact measurement.
- ASSERT_GE(BufferSizeForStructuredProtoField(test_case.field),
- test_case.expected_encoded_field.size());
-
- std::vector<char> buf;
- buf.resize(1024);
-
- absl::Span<char> buf_span(buf);
- EXPECT_TRUE(EncodeStructuredProtoField(test_case.field, buf_span));
- size_t encoded_field_size = buf.size() - buf_span.size();
-
- ASSERT_EQ(encoded_field_size, test_case.expected_encoded_field.size());
- buf.resize(encoded_field_size);
- EXPECT_EQ(buf, test_case.expected_encoded_field);
-}
-
-INSTANTIATE_TEST_SUITE_P(
- StructuredProtoTestSuiteInstantiation,
- StructuredProtoTest, // This is the name of your parameterized test
- testing::ValuesIn<StructuredProtoTestCase>({
- {
- "Varint",
- {
- 42,
- StructuredProtoField::Value{
- absl::in_place_type<StructuredProtoField::Varint>,
- int32_t{23},
- },
- },
- {'\xD0', '\x02', '\x17'},
- },
- {
- "I64",
- {
- 42,
- StructuredProtoField::Value{
- absl::in_place_type<StructuredProtoField::I64>,
- int64_t{23},
- },
- },
- {'\xD1', '\x02', '\x17', '\x00', '\x00', '\x00', '\x00', '\x00',
- '\x00', '\x00'},
- },
- {
- "LengthDelimited",
- {
- 42,
- // Use a string_view so the terminating NUL is excluded.
- absl::string_view("Hello"),
- },
- {'\xD2', '\x02', '\x05', 'H', 'e', 'l', 'l', 'o'},
- },
- {
- "I32",
- {
- 42,
- StructuredProtoField::Value{
- absl::in_place_type<StructuredProtoField::I32>,
- int32_t{23},
- },
- },
- {'\xD5', '\x02', '\x17', '\x00', '\x00', '\x00'},
- },
- }),
- [](const testing::TestParamInfo<StructuredProtoTest::ParamType>& info) {
- return info.param.test_name;
- });
-
-} // namespace
-} // namespace log_internal
-ABSL_NAMESPACE_END
-} // namespace absl
diff --git a/absl/log/internal/vlog_config.cc b/absl/log/internal/vlog_config.cc
index f7c61be..b578850 100644
--- a/absl/log/internal/vlog_config.cc
+++ b/absl/log/internal/vlog_config.cc
@@ -207,14 +207,7 @@
get_vmodule_info().erase(
std::remove_if(++iter, get_vmodule_info().end(),
[module_pattern](const VModuleInfo& info) {
- // Remove the previous pattern if it is less generic than
- // the new one. For example, if the new pattern
- // `module_pattern` is "foo*" and the previous pattern
- // `info.module_pattern` is "foo", we should remove the
- // previous pattern. Because the new pattern "foo*" will
- // match all the files that the previous pattern "foo"
- // matches.
- return FNMatch(module_pattern, info.module_pattern);
+ return FNMatch(info.module_pattern, module_pattern);
}),
get_vmodule_info().cend());
return old_log_level.value_or(global_v);
diff --git a/absl/log/log_basic_test_impl.inc b/absl/log/log_basic_test_impl.inc
index 2c84b45..7baf5e7 100644
--- a/absl/log/log_basic_test_impl.inc
+++ b/absl/log/log_basic_test_impl.inc
@@ -111,7 +111,7 @@
ENCODED_MESSAGE(MatchesEvent(
Eq(__FILE__), Eq(log_line), InMatchWindow(),
Eq(logging::proto::INFO), Eq(absl::base_internal::GetTID()),
- ElementsAre(ValueWithLiteral(Eq("hello world"))))),
+ ElementsAre(EqualsProto(R"pb(literal: "hello world")pb")))),
Stacktrace(IsEmpty()))));
}
@@ -142,7 +142,7 @@
ENCODED_MESSAGE(MatchesEvent(
Eq(__FILE__), Eq(log_line), InMatchWindow(),
Eq(logging::proto::WARNING), Eq(absl::base_internal::GetTID()),
- ElementsAre(ValueWithLiteral(Eq("hello world"))))),
+ ElementsAre(EqualsProto(R"pb(literal: "hello world")pb")))),
Stacktrace(IsEmpty()))));
}
@@ -173,7 +173,7 @@
ENCODED_MESSAGE(MatchesEvent(
Eq(__FILE__), Eq(log_line), InMatchWindow(),
Eq(logging::proto::ERROR), Eq(absl::base_internal::GetTID()),
- ElementsAre(ValueWithLiteral(Eq("hello world"))))),
+ ElementsAre(EqualsProto(R"pb(literal: "hello world")pb")))),
Stacktrace(IsEmpty()))));
}
@@ -226,7 +226,8 @@
Eq(__FILE__), Eq(log_line), InMatchWindow(),
Eq(logging::proto::FATAL),
Eq(absl::base_internal::GetTID()),
- ElementsAre(ValueWithLiteral(Eq("hello world"))))),
+ ElementsAre(EqualsProto(
+ R"pb(literal: "hello world")pb")))),
Stacktrace(IsEmpty()))))
.WillOnce(DeathTestExpectedLogging());
@@ -245,7 +246,8 @@
Eq(__FILE__), Eq(log_line), InMatchWindow(),
Eq(logging::proto::FATAL),
Eq(absl::base_internal::GetTID()),
- ElementsAre(ValueWithLiteral(Eq("hello world"))))),
+ ElementsAre(EqualsProto(
+ R"pb(literal: "hello world")pb")))),
Stacktrace(Not(IsEmpty())))))
.WillOnce(DeathTestExpectedLogging());
}
@@ -286,7 +288,8 @@
Eq(__FILE__), Eq(log_line), InMatchWindow(),
Eq(logging::proto::FATAL),
Eq(absl::base_internal::GetTID()),
- ElementsAre(ValueWithLiteral(Eq("hello world"))))),
+ ElementsAre(EqualsProto(
+ R"pb(literal: "hello world")pb")))),
Stacktrace(IsEmpty()))))
.WillOnce(DeathTestExpectedLogging());
}
@@ -322,7 +325,7 @@
ENCODED_MESSAGE(MatchesEvent(
Eq(__FILE__), Eq(log_line), InMatchWindow(),
Eq(logging::proto::ERROR), Eq(absl::base_internal::GetTID()),
- ElementsAre(ValueWithLiteral(Eq("hello world"))))),
+ ElementsAre(EqualsProto(R"pb(literal: "hello world")pb")))),
Stacktrace(IsEmpty()))));
}
@@ -365,7 +368,8 @@
Eq(__FILE__), Eq(log_line), InMatchWindow(),
Eq(logging::proto::FATAL),
Eq(absl::base_internal::GetTID()),
- ElementsAre(ValueWithLiteral(Eq("hello world"))))),
+ ElementsAre(EqualsProto(
+ R"pb(literal: "hello world")pb")))),
Stacktrace(IsEmpty()))))
.WillOnce(DeathTestExpectedLogging());
@@ -384,7 +388,8 @@
Eq(__FILE__), Eq(log_line), InMatchWindow(),
Eq(logging::proto::FATAL),
Eq(absl::base_internal::GetTID()),
- ElementsAre(ValueWithLiteral(Eq("hello world"))))),
+ ElementsAre(EqualsProto(
+ R"pb(literal: "hello world")pb")))),
Stacktrace(Not(IsEmpty())))))
.WillOnce(DeathTestExpectedLogging());
}
@@ -449,7 +454,7 @@
? logging::proto::ERROR
: 0),
Eq(absl::base_internal::GetTID()),
- ElementsAre(ValueWithLiteral(Eq("hello world"))))),
+ ElementsAre(EqualsProto(R"pb(literal: "hello world")pb")))),
Stacktrace(IsEmpty()))));
}
test_sink.StartCapturingLogs();
@@ -495,7 +500,8 @@
Eq(__FILE__), Eq(log_line), InMatchWindow(),
Eq(logging::proto::FATAL),
Eq(absl::base_internal::GetTID()),
- ElementsAre(ValueWithLiteral(Eq("hello world"))))),
+ ElementsAre(EqualsProto(
+ R"pb(literal: "hello world")pb")))),
Stacktrace(IsEmpty()))))
.WillOnce(DeathTestExpectedLogging());
@@ -513,7 +519,8 @@
Eq(__FILE__), Eq(log_line), InMatchWindow(),
Eq(logging::proto::FATAL),
Eq(absl::base_internal::GetTID()),
- ElementsAre(ValueWithLiteral(Eq("hello world"))))),
+ ElementsAre(EqualsProto(
+ R"pb(literal: "hello world")pb")))),
Stacktrace(Not(IsEmpty())))))
.WillOnce(DeathTestExpectedLogging());
}
diff --git a/absl/log/log_format_test.cc b/absl/log/log_format_test.cc
index 7a75ca4..beee966 100644
--- a/absl/log/log_format_test.cc
+++ b/absl/log/log_format_test.cc
@@ -96,11 +96,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)), TextMessage(Eq("x")),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("x"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("x")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "x")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -113,12 +113,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("\xee")),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("\xee"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("\xee")),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "\xee")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -137,12 +136,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("224")),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("224"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("224")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "224")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -157,11 +155,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value.bits;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)), TextMessage(Eq("42")),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("42"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("42")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "42")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value.bits;
@@ -180,12 +178,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("224")),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("224"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("224")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "224")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -198,12 +195,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("-112")),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("-112"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("-112")),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "-112")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -218,11 +214,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value.bits;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)), TextMessage(Eq("21")),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("21"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("21")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "21")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value.bits;
@@ -237,12 +233,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value.bits;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("-21")),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("-21"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("-21")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "-21")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value.bits;
@@ -279,12 +274,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("224")),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("224"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("224")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "224")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -299,11 +293,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value.bits;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)), TextMessage(Eq("42")),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("42"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("42")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "42")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value.bits;
@@ -339,12 +333,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("224")),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("224"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("224")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "224")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -357,12 +350,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("-112")),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("-112"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("-112")),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "-112")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -377,11 +369,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value.bits;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)), TextMessage(Eq("21")),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("21"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("21")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "21")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value.bits;
@@ -396,12 +388,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value.bits;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("-21")),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("-21"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("-21")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "-21")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value.bits;
@@ -418,8 +409,8 @@
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("6.02e+23")),
- ENCODED_MESSAGE(HasValues(
- ElementsAre(ValueWithStr(Eq("6.02e+23"))))))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "6.02e+23")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -435,8 +426,8 @@
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("-6.02e+23")),
- ENCODED_MESSAGE(HasValues(
- ElementsAre(ValueWithStr(Eq("-6.02e+23"))))))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "-6.02e+23")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -452,8 +443,8 @@
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("6.02e-23")),
- ENCODED_MESSAGE(HasValues(
- ElementsAre(ValueWithStr(Eq("6.02e-23"))))))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "6.02e-23")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -469,8 +460,8 @@
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("6.02e+23")),
- ENCODED_MESSAGE(HasValues(
- ElementsAre(ValueWithStr(Eq("6.02e+23"))))))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "6.02e+23")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -486,8 +477,8 @@
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("-6.02e+23")),
- ENCODED_MESSAGE(HasValues(
- ElementsAre(ValueWithStr(Eq("-6.02e+23"))))))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "-6.02e+23")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -503,8 +494,8 @@
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("6.02e-23")),
- ENCODED_MESSAGE(HasValues(
- ElementsAre(ValueWithStr(Eq("6.02e-23"))))))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "6.02e-23")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -522,11 +513,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)), TextMessage(Eq("0")),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("0"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("0")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "0")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -539,11 +530,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)), TextMessage(Eq("1")),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("1"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("1")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "1")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -556,12 +547,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(AnyOf(Eq("inf"), Eq("Inf"))),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("inf"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(AnyOf(Eq("inf"), Eq("Inf"))),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "inf")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -574,12 +564,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(AnyOf(Eq("-inf"), Eq("-Inf"))),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("-inf"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(AnyOf(Eq("-inf"), Eq("-Inf"))),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "-inf")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -592,12 +581,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(AnyOf(Eq("nan"), Eq("NaN"))),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("nan"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(AnyOf(Eq("nan"), Eq("NaN"))),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "nan")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
}
@@ -614,20 +602,24 @@
// streaming it. #ifdefing out just the relevant line breaks the MSVC build,
// so duplicate the entire EXPECT_CALL.
#ifdef __riscv
- EXPECT_CALL(test_sink,
- Send(AllOf(TextMessage(AnyOf(Eq("-nan"), Eq("nan"), Eq("NaN"),
- Eq("-nan(ind)"))),
- ENCODED_MESSAGE(HasValues(ElementsAre(AnyOf(
- ValueWithStr(Eq("-nan")), ValueWithStr(Eq("nan")),
- ValueWithStr(Eq("-nan(ind)")))))))));
+ EXPECT_CALL(
+ test_sink,
+ Send(AllOf(
+ TextMessage(AnyOf(Eq("-nan"), Eq("nan"), Eq("NaN"), Eq("-nan(ind)"))),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(AnyOf(EqualsProto(R"pb(str: "-nan")pb"),
+ EqualsProto(R"pb(str: "nan")pb"),
+ EqualsProto(R"pb(str: "-nan(ind)")pb"))))))));
#else
- EXPECT_CALL(test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(AnyOf(Eq("-nan"), Eq("nan"), Eq("NaN"),
- Eq("-nan(ind)"))),
- ENCODED_MESSAGE(HasValues(ElementsAre(AnyOf(
- ValueWithStr(Eq("-nan")), ValueWithStr(Eq("nan")),
- ValueWithStr(Eq("-nan(ind)")))))))));
+ EXPECT_CALL(
+ test_sink,
+ Send(AllOf(
+ TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(AnyOf(Eq("-nan"), Eq("nan"), Eq("NaN"), Eq("-nan(ind)"))),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(AnyOf(EqualsProto(R"pb(str: "-nan")pb"),
+ EqualsProto(R"pb(str: "nan")pb"),
+ EqualsProto(R"pb(str: "-nan(ind)")pb"))))))));
#endif
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -662,13 +654,14 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(AnyOf(Eq("0xdeadbeef"), Eq("DEADBEEF"),
- Eq("00000000DEADBEEF"))),
- ENCODED_MESSAGE(HasValues(ElementsAre(
- AnyOf(ValueWithStr(Eq("0xdeadbeef")),
- ValueWithStr(Eq("00000000DEADBEEF")))))))));
+ EXPECT_CALL(
+ test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(AnyOf(Eq("0xdeadbeef"), Eq("DEADBEEF"),
+ Eq("00000000DEADBEEF"))),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ AnyOf(EqualsProto(R"pb(str: "0xdeadbeef")pb"),
+ EqualsProto(R"pb(str: "00000000DEADBEEF")pb"))))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -690,12 +683,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("false")),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("false"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("false")),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "false")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -708,12 +700,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("true")),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("true"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("true")),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "true")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -738,8 +729,9 @@
test_sink,
Send(AllOf(
// `MatchesOstream` deliberately omitted since we deliberately differ.
- TextMessage(Eq("(null)")), ENCODED_MESSAGE(HasValues(ElementsAre(
- ValueWithStr(Eq("(null)"))))))));
+ TextMessage(Eq("(null)")),
+ ENCODED_MESSAGE(
+ HasValues(ElementsAre(EqualsProto(R"pb(str: "(null)")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -753,12 +745,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("value")),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("value"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("value")),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "value")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -771,12 +762,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("true")),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("true"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("true")),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "true")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -789,12 +779,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("false")),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("false"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("false")),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "false")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -809,8 +798,8 @@
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("value")),
- ENCODED_MESSAGE(HasValues(
- ElementsAre(ValueWithLiteral(Eq("value"))))))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(literal: "value")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << "value";
@@ -823,12 +812,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("value")),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("value"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("value")),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "value")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -850,7 +838,7 @@
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("CustomClass{}")),
ENCODED_MESSAGE(HasValues(ElementsAre(
- ValueWithStr(Eq("CustomClass{}"))))))));
+ EqualsProto(R"pb(str: "CustomClass{}")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
}
@@ -875,8 +863,8 @@
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("CustomClassNonCopyable{}")),
- ENCODED_MESSAGE(HasValues(ElementsAre(
- ValueWithStr(Eq("CustomClassNonCopyable{}"))))))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(EqualsProto(
+ R"pb(str: "CustomClassNonCopyable{}")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -900,8 +888,8 @@
EXPECT_CALL(
test_sink,
Send(AllOf(TextMessage(Eq("(10, 20)")), TextMessage(Eq(absl::StrCat(p))),
- ENCODED_MESSAGE(
- HasValues(ElementsAre(ValueWithStr(Eq("(10, 20)"))))))));
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "(10, 20)")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << p;
@@ -931,8 +919,8 @@
EXPECT_CALL(
test_sink,
Send(AllOf(TextMessage(Eq("(10, 20)")), TextMessage(Eq(absl::StrCat(p))),
- ENCODED_MESSAGE(
- HasValues(ElementsAre(ValueWithStr(Eq("(10, 20)"))))))));
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "(10, 20)")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << p;
@@ -951,11 +939,10 @@
PointStreamsNothing p;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(Eq("77")), TextMessage(Eq(absl::StrCat(p, 77))),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("77"))))))));
+ EXPECT_CALL(test_sink, Send(AllOf(TextMessage(Eq("77")),
+ TextMessage(Eq(absl::StrCat(p, 77))),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "77")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << p << 77;
@@ -980,8 +967,9 @@
EXPECT_CALL(
test_sink,
Send(AllOf(TextMessage(Eq("(10, 20)")), TextMessage(Eq(absl::StrCat(p))),
- ENCODED_MESSAGE(HasValues(ElementsAre(
- ValueWithStr(Eq("(")), ValueWithStr(Eq("10, 20)"))))))));
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "(")pb"),
+ EqualsProto(R"pb(str: "10, 20)")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << p;
@@ -996,14 +984,15 @@
<< std::boolalpha << value << " " //
<< std::noboolalpha << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("1 true 1")),
- ENCODED_MESSAGE(HasValues(ElementsAre(
- ValueWithStr(Eq("1")), ValueWithLiteral(Eq(" ")),
- ValueWithStr(Eq("true")), ValueWithLiteral(Eq(" ")),
- ValueWithStr(Eq("1"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("1 true 1")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "1")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "true")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "1")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::noboolalpha << value << " " //
@@ -1020,14 +1009,15 @@
<< std::boolalpha << value << " " //
<< std::noboolalpha << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("0 false 0")),
- ENCODED_MESSAGE(HasValues(ElementsAre(
- ValueWithStr(Eq("0")), ValueWithLiteral(Eq(" ")),
- ValueWithStr(Eq("false")), ValueWithLiteral(Eq(" ")),
- ValueWithStr(Eq("0"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("0 false 0")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "0")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "false")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "0")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::noboolalpha << value << " " //
@@ -1044,14 +1034,15 @@
<< std::showpoint << value << " " //
<< std::noshowpoint << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("77 77.0000 77")),
- ENCODED_MESSAGE(HasValues(ElementsAre(
- ValueWithStr(Eq("77")), ValueWithLiteral(Eq(" ")),
- ValueWithStr(Eq("77.0000")), ValueWithLiteral(Eq(" ")),
- ValueWithStr(Eq("77"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("77 77.0000 77")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "77")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "77.0000")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "77")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::noshowpoint << value << " " //
@@ -1071,10 +1062,12 @@
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("77 +77 77")),
- ENCODED_MESSAGE(HasValues(ElementsAre(
- ValueWithStr(Eq("77")), ValueWithLiteral(Eq(" ")),
- ValueWithStr(Eq("+77")), ValueWithLiteral(Eq(" ")),
- ValueWithStr(Eq("77"))))))));
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "77")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "+77")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "77")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::noshowpos << value << " " //
@@ -1091,14 +1084,15 @@
<< std::uppercase << value << " " //
<< std::nouppercase << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("7.7e+07 7.7E+07 7.7e+07")),
- ENCODED_MESSAGE(HasValues(ElementsAre(
- ValueWithStr(Eq("7.7e+07")), ValueWithLiteral(Eq(" ")),
- ValueWithStr(Eq("7.7E+07")), ValueWithLiteral(Eq(" ")),
- ValueWithStr(Eq("7.7e+07"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("7.7e+07 7.7E+07 7.7e+07")),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "7.7e+07")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "7.7E+07")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "7.7e+07")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::nouppercase << value << " " //
@@ -1113,12 +1107,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << std::hex << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("0x77")),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("0x77"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("0x77")),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "0x77")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::hex << value;
}
@@ -1130,12 +1123,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << std::oct << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("077")),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("077"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("077")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "077")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::oct << value;
@@ -1148,11 +1140,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << std::hex << std::dec << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)), TextMessage(Eq("77")),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("77"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("77")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "77")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::hex << std::dec << value;
@@ -1168,14 +1160,15 @@
<< std::showbase << value << " " //
<< std::noshowbase << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("77 0x77 77")),
- ENCODED_MESSAGE(HasValues(ElementsAre(
- ValueWithStr(Eq("77")), ValueWithLiteral(Eq(" ")),
- ValueWithStr(Eq("0x77")), ValueWithLiteral(Eq(" ")),
- ValueWithStr(Eq("77"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("77 0x77 77")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "77")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "0x77")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "77")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::hex //
@@ -1197,10 +1190,12 @@
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("77 077 77")),
- ENCODED_MESSAGE(HasValues(ElementsAre(
- ValueWithStr(Eq("77")), ValueWithLiteral(Eq(" ")),
- ValueWithStr(Eq("077")), ValueWithLiteral(Eq(" ")),
- ValueWithStr(Eq("77"))))))));
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "77")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "077")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "77")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::oct //
@@ -1220,14 +1215,15 @@
<< std::uppercase << value << " " //
<< std::nouppercase << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("0xbeef 0XBEEF 0xbeef")),
- ENCODED_MESSAGE(HasValues(ElementsAre(
- ValueWithStr(Eq("0xbeef")), ValueWithLiteral(Eq(" ")),
- ValueWithStr(Eq("0XBEEF")), ValueWithLiteral(Eq(" ")),
- ValueWithStr(Eq("0xbeef"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("0xbeef 0XBEEF 0xbeef")),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "0xbeef")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "0XBEEF")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "0xbeef")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::hex //
@@ -1247,7 +1243,7 @@
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("77000000.000000")),
ENCODED_MESSAGE(HasValues(ElementsAre(
- ValueWithStr(Eq("77000000.000000"))))))));
+ EqualsProto(R"pb(str: "77000000.000000")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::fixed << value;
@@ -1263,8 +1259,8 @@
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("7.700000e+07")),
- ENCODED_MESSAGE(HasValues(
- ElementsAre(ValueWithStr(Eq("7.700000e+07"))))))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "7.700000e+07")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::scientific << value;
@@ -1290,9 +1286,9 @@
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(AnyOf(Eq("0x1.25bb50p+26"), Eq("0x1.25bb5p+26"),
Eq("0x1.25bb500000000p+26"))),
- ENCODED_MESSAGE(HasValues(ElementsAre(
- AnyOf(ValueWithStr(Eq("0x1.25bb5p+26")),
- ValueWithStr(Eq("0x1.25bb500000000p+26")))))))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(AnyOf(
+ EqualsProto(R"pb(str: "0x1.25bb5p+26")pb"),
+ EqualsProto(R"pb(str: "0x1.25bb500000000p+26")pb"))))))));
test_sink.StartCapturingLogs();
@@ -1321,9 +1317,9 @@
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(AnyOf(Eq("0x1.25bb50p+26"), Eq("0x1.25bb5p+26"),
Eq("0x1.25bb500000000p+26"))),
- ENCODED_MESSAGE(HasValues(ElementsAre(
- AnyOf(ValueWithStr(Eq("0x1.25bb5p+26")),
- ValueWithStr(Eq("0x1.25bb500000000p+26")))))))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(AnyOf(
+ EqualsProto(R"pb(str: "0x1.25bb5p+26")pb"),
+ EqualsProto(R"pb(str: "0x1.25bb500000000p+26")pb"))))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::hexfloat << value;
@@ -1340,8 +1336,8 @@
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("7.7e+07")),
- ENCODED_MESSAGE(HasValues(
- ElementsAre(ValueWithStr(Eq("7.7e+07"))))))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "7.7e+07")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::hexfloat << std::defaultfloat << value;
@@ -1356,8 +1352,8 @@
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq(absl::string_view("\0", 1))),
- ENCODED_MESSAGE(HasValues(ElementsAre(
- ValueWithStr(Eq(absl::string_view("\0", 1)))))))));
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "\0")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::ends;
@@ -1374,7 +1370,8 @@
Send(AllOf(
TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("\n")),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("\n"))))))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(EqualsProto(R"pb(str:
+ "\n")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::endl;
@@ -1398,9 +1395,10 @@
// `std::setiosflags` and `std::resetiosflags` aren't manipulators.
// We're unable to distinguish their return type(s) from arbitrary
// user-defined types and thus don't suppress the empty str value.
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("0x77")),
- ValueWithLiteral(Eq(" ")),
- ValueWithStr(Eq("119"))))))));
+ ENCODED_MESSAGE(
+ HasValues(ElementsAre(EqualsProto(R"pb(str: "0x77")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "119")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::resetiosflags(std::ios_base::basefield)
@@ -1424,9 +1422,10 @@
// `std::setbase` isn't a manipulator. We're unable to
// distinguish its return type from arbitrary user-defined
// types and thus don't suppress the empty str value.
- ENCODED_MESSAGE(HasValues(ElementsAre(
- ValueWithStr(Eq("0x77")), ValueWithLiteral(Eq(" ")),
- ValueWithStr(Eq("119"))))))));
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "0x77")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "119")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::setbase(16) << value << " " //
@@ -1447,8 +1446,8 @@
// `std::setprecision` isn't a manipulator. We're unable to
// distinguish its return type from arbitrary user-defined
// types and thus don't suppress the empty str value.
- ENCODED_MESSAGE(
- HasValues(ElementsAre(ValueWithStr(Eq("6.022e+23"))))))));
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "6.022e+23")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::setprecision(4) << value;
@@ -1464,8 +1463,8 @@
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("602214085700000015187968")),
- ENCODED_MESSAGE(HasValues(ElementsAre(
- ValueWithStr(Eq("602214085700000015187968"))))))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(EqualsProto(
+ R"pb(str: "602214085700000015187968")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::setprecision(200) << value;
@@ -1485,8 +1484,8 @@
// `std::setw` isn't a manipulator. We're unable to
// distinguish its return type from arbitrary user-defined
// types and thus don't suppress the empty str value.
- ENCODED_MESSAGE(
- HasValues(ElementsAre(ValueWithStr(Eq(" 77"))))))));
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: " 77")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::setw(8) << value;
@@ -1502,8 +1501,8 @@
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("-77 ")),
- ENCODED_MESSAGE(HasValues(
- ElementsAre(ValueWithStr(Eq("-77 "))))))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "-77 ")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::left << std::setw(8) << value;
@@ -1519,8 +1518,8 @@
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq(" -77")),
- ENCODED_MESSAGE(HasValues(
- ElementsAre(ValueWithStr(Eq(" -77"))))))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: " -77")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::right << std::setw(8) << value;
@@ -1536,8 +1535,8 @@
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("- 77")),
- ENCODED_MESSAGE(HasValues(
- ElementsAre(ValueWithStr(Eq("- 77"))))))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "- 77")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::internal << std::setw(8) << value;
@@ -1557,8 +1556,8 @@
// unable to distinguish its return
// type from arbitrary user-defined types and
// thus don't suppress the empty str value.
- ENCODED_MESSAGE(HasValues(
- ElementsAre(ValueWithStr(Eq("00000077"))))))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "00000077")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::setfill('0') << std::setw(8) << value;
@@ -1576,13 +1575,13 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value << " " << 0x77;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("FromCustomClass{} 0x77")),
- ENCODED_MESSAGE(HasValues(ElementsAre(
- ValueWithStr(Eq("FromCustomClass{}")),
- ValueWithLiteral(Eq(" ")), ValueWithStr(Eq("0x77"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("FromCustomClass{} 0x77")),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "FromCustomClass{}")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "0x77")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value << " " << 0x77;
@@ -1598,11 +1597,11 @@
auto comparison_stream = ComparisonStream();
comparison_stream << value << 77;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)), TextMessage(Eq("77")),
- ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("77"))))))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("77")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "77")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value << 77;
@@ -1626,8 +1625,8 @@
EXPECT_CALL(
test_sink,
Send(AllOf(TextMessage(Eq("(10, 20)")), TextMessage(Eq(absl::StrCat(p))),
- ENCODED_MESSAGE(
- HasValues(ElementsAre(ValueWithStr(Eq("(10, 20)"))))))));
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "(10, 20)")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::hex << p;
diff --git a/absl/log/log_modifier_methods_test.cc b/absl/log/log_modifier_methods_test.cc
index fc98e1f..4ccde40 100644
--- a/absl/log/log_modifier_methods_test.cc
+++ b/absl/log/log_modifier_methods_test.cc
@@ -159,8 +159,8 @@
ENCODED_MESSAGE(MatchesEvent(
Eq("fake/file"), Eq(123), Eq(absl::UnixEpoch()),
Eq(logging::proto::WARNING), Eq(456),
- ElementsAre(ValueWithLiteral(Eq("forwarded: ")),
- ValueWithStr(Eq("hello world"))))))));
+ ElementsAre(EqualsProto(R"pb(literal: "forwarded: ")pb"),
+ EqualsProto(R"pb(str: "hello world")pb")))))));
test_sink.StartCapturingLogs();
LOG(WARNING)
@@ -178,17 +178,18 @@
EXPECT_CALL(
test_sink,
- Send(AllOf(
- TextMessage(AnyOf(Eq("hello world: Bad file number [9]"),
- Eq("hello world: Bad file descriptor [9]"),
- Eq("hello world: Bad file descriptor [8]"))),
- ENCODED_MESSAGE(HasValues(ElementsAre(
- ValueWithLiteral(Eq("hello world")), ValueWithLiteral(Eq(": ")),
- AnyOf(ValueWithStr(Eq("Bad file number")),
- ValueWithStr(Eq("Bad file descriptor"))),
- ValueWithLiteral(Eq(" [")),
- AnyOf(ValueWithStr(Eq("8")), ValueWithStr(Eq("9"))),
- ValueWithLiteral(Eq("]"))))))));
+ Send(AllOf(TextMessage(AnyOf(Eq("hello world: Bad file number [9]"),
+ Eq("hello world: Bad file descriptor [9]"),
+ Eq("hello world: Bad file descriptor [8]"))),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(literal: "hello world")pb"),
+ EqualsProto(R"pb(literal: ": ")pb"),
+ AnyOf(EqualsProto(R"pb(str: "Bad file number")pb"),
+ EqualsProto(R"pb(str: "Bad file descriptor")pb")),
+ EqualsProto(R"pb(literal: " [")pb"),
+ AnyOf(EqualsProto(R"pb(str: "8")pb"),
+ EqualsProto(R"pb(str: "9")pb")),
+ EqualsProto(R"pb(literal: "]")pb")))))));
test_sink.StartCapturingLogs();
errno = EBADF;
diff --git a/absl/log/log_sink_registry.h b/absl/log/log_sink_registry.h
index 3aa3bf6..bf76cce 100644
--- a/absl/log/log_sink_registry.h
+++ b/absl/log/log_sink_registry.h
@@ -22,7 +22,6 @@
#define ABSL_LOG_LOG_SINK_REGISTRY_H_
#include "absl/base/config.h"
-#include "absl/base/nullability.h"
#include "absl/log/internal/log_sink_set.h"
#include "absl/log/log_sink.h"
@@ -44,10 +43,8 @@
// sink instead which writes them to `stderr`.
//
// Do not call these inside `absl::LogSink::Send`.
-inline void AddLogSink(absl::Nonnull<absl::LogSink*> sink) {
- log_internal::AddLogSink(sink);
-}
-inline void RemoveLogSink(absl::Nonnull<absl::LogSink*> sink) {
+inline void AddLogSink(absl::LogSink* sink) { log_internal::AddLogSink(sink); }
+inline void RemoveLogSink(absl::LogSink* sink) {
log_internal::RemoveLogSink(sink);
}
diff --git a/absl/log/log_streamer_test.cc b/absl/log/log_streamer_test.cc
index 4fe88e9..b9b9428 100644
--- a/absl/log/log_streamer_test.cc
+++ b/absl/log/log_streamer_test.cc
@@ -69,17 +69,17 @@
EXPECT_CALL(
test_sink,
- Send(
- AllOf(SourceFilename(Eq("path/file.cc")), SourceLine(Eq(1234)),
- Prefix(IsTrue()), LogSeverity(Eq(absl::LogSeverity::kInfo)),
- Timestamp(InMatchWindow()),
- ThreadID(Eq(absl::base_internal::GetTID())),
- TextMessage(Eq("WriteToStream: foo")),
- ENCODED_MESSAGE(MatchesEvent(
- Eq("path/file.cc"), Eq(1234), InMatchWindow(),
- Eq(logging::proto::INFO), Eq(absl::base_internal::GetTID()),
- ElementsAre(ValueWithStr(Eq("WriteToStream: foo"))))),
- Stacktrace(IsEmpty()))));
+ Send(AllOf(
+ SourceFilename(Eq("path/file.cc")), SourceLine(Eq(1234)),
+ Prefix(IsTrue()), LogSeverity(Eq(absl::LogSeverity::kInfo)),
+ Timestamp(InMatchWindow()),
+ ThreadID(Eq(absl::base_internal::GetTID())),
+ TextMessage(Eq("WriteToStream: foo")),
+ ENCODED_MESSAGE(MatchesEvent(
+ Eq("path/file.cc"), Eq(1234), InMatchWindow(),
+ Eq(logging::proto::INFO), Eq(absl::base_internal::GetTID()),
+ ElementsAre(EqualsProto(R"pb(str: "WriteToStream: foo")pb")))),
+ Stacktrace(IsEmpty()))));
test_sink.StartCapturingLogs();
WriteToStream("foo", &absl::LogInfoStreamer("path/file.cc", 1234).stream());
@@ -99,7 +99,7 @@
ENCODED_MESSAGE(MatchesEvent(
Eq("path/file.cc"), Eq(1234), InMatchWindow(),
Eq(logging::proto::WARNING), Eq(absl::base_internal::GetTID()),
- ElementsAre(ValueWithStr(Eq("WriteToStream: foo"))))),
+ ElementsAre(EqualsProto(R"pb(str: "WriteToStream: foo")pb")))),
Stacktrace(IsEmpty()))));
test_sink.StartCapturingLogs();
@@ -121,7 +121,7 @@
ENCODED_MESSAGE(MatchesEvent(
Eq("path/file.cc"), Eq(1234), InMatchWindow(),
Eq(logging::proto::ERROR), Eq(absl::base_internal::GetTID()),
- ElementsAre(ValueWithStr(Eq("WriteToStream: foo"))))),
+ ElementsAre(EqualsProto(R"pb(str: "WriteToStream: foo")pb")))),
Stacktrace(IsEmpty()))));
test_sink.StartCapturingLogs();
@@ -138,19 +138,19 @@
.Times(AnyNumber())
.WillRepeatedly(DeathTestUnexpectedLogging());
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- SourceFilename(Eq("path/file.cc")), SourceLine(Eq(1234)),
- Prefix(IsTrue()), LogSeverity(Eq(absl::LogSeverity::kFatal)),
- Timestamp(InMatchWindow()),
- ThreadID(Eq(absl::base_internal::GetTID())),
- TextMessage(Eq("WriteToStream: foo")),
- ENCODED_MESSAGE(MatchesEvent(
- Eq("path/file.cc"), Eq(1234), InMatchWindow(),
- Eq(logging::proto::FATAL),
- Eq(absl::base_internal::GetTID()),
- ElementsAre(ValueWithStr(Eq("WriteToStream: foo"))))))))
+ EXPECT_CALL(test_sink,
+ Send(AllOf(SourceFilename(Eq("path/file.cc")),
+ SourceLine(Eq(1234)), Prefix(IsTrue()),
+ LogSeverity(Eq(absl::LogSeverity::kFatal)),
+ Timestamp(InMatchWindow()),
+ ThreadID(Eq(absl::base_internal::GetTID())),
+ TextMessage(Eq("WriteToStream: foo")),
+ ENCODED_MESSAGE(MatchesEvent(
+ Eq("path/file.cc"), Eq(1234),
+ InMatchWindow(), Eq(logging::proto::FATAL),
+ Eq(absl::base_internal::GetTID()),
+ ElementsAre(EqualsProto(
+ R"pb(str: "WriteToStream: foo")pb")))))))
.WillOnce(DeathTestExpectedLogging());
test_sink.StartCapturingLogs();
@@ -176,7 +176,7 @@
ENCODED_MESSAGE(MatchesEvent(
Eq("path/file.cc"), Eq(1234), InMatchWindow(),
Eq(logging::proto::ERROR), Eq(absl::base_internal::GetTID()),
- ElementsAre(ValueWithStr(Eq("WriteToStream: foo"))))),
+ ElementsAre(EqualsProto(R"pb(str: "WriteToStream: foo")pb")))),
Stacktrace(IsEmpty()))));
test_sink.StartCapturingLogs();
@@ -193,19 +193,19 @@
.Times(AnyNumber())
.WillRepeatedly(DeathTestUnexpectedLogging());
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- SourceFilename(Eq("path/file.cc")), SourceLine(Eq(1234)),
- Prefix(IsTrue()), LogSeverity(Eq(absl::LogSeverity::kFatal)),
- Timestamp(InMatchWindow()),
- ThreadID(Eq(absl::base_internal::GetTID())),
- TextMessage(Eq("WriteToStream: foo")),
- ENCODED_MESSAGE(MatchesEvent(
- Eq("path/file.cc"), Eq(1234), InMatchWindow(),
- Eq(logging::proto::FATAL),
- Eq(absl::base_internal::GetTID()),
- ElementsAre(ValueWithStr(Eq("WriteToStream: foo"))))))))
+ EXPECT_CALL(test_sink,
+ Send(AllOf(SourceFilename(Eq("path/file.cc")),
+ SourceLine(Eq(1234)), Prefix(IsTrue()),
+ LogSeverity(Eq(absl::LogSeverity::kFatal)),
+ Timestamp(InMatchWindow()),
+ ThreadID(Eq(absl::base_internal::GetTID())),
+ TextMessage(Eq("WriteToStream: foo")),
+ ENCODED_MESSAGE(MatchesEvent(
+ Eq("path/file.cc"), Eq(1234),
+ InMatchWindow(), Eq(logging::proto::FATAL),
+ Eq(absl::base_internal::GetTID()),
+ ElementsAre(EqualsProto(
+ R"pb(str: "WriteToStream: foo")pb")))))))
.WillOnce(DeathTestExpectedLogging());
test_sink.StartCapturingLogs();
@@ -230,7 +230,7 @@
ENCODED_MESSAGE(MatchesEvent(
Eq("path/file.cc"), Eq(1234), InMatchWindow(),
Eq(logging::proto::ERROR), Eq(absl::base_internal::GetTID()),
- ElementsAre(ValueWithStr(Eq("WriteToStream: foo"))))),
+ ElementsAre(EqualsProto(R"pb(str: "WriteToStream: foo")pb")))),
Stacktrace(IsEmpty()))));
test_sink.StartCapturingLogs();
@@ -249,19 +249,19 @@
.Times(AnyNumber())
.WillRepeatedly(DeathTestUnexpectedLogging());
- EXPECT_CALL(
- test_sink,
- Send(AllOf(
- SourceFilename(Eq("path/file.cc")), SourceLine(Eq(1234)),
- Prefix(IsTrue()), LogSeverity(Eq(absl::LogSeverity::kFatal)),
- Timestamp(InMatchWindow()),
- ThreadID(Eq(absl::base_internal::GetTID())),
- TextMessage(Eq("WriteToStream: foo")),
- ENCODED_MESSAGE(MatchesEvent(
- Eq("path/file.cc"), Eq(1234), InMatchWindow(),
- Eq(logging::proto::FATAL),
- Eq(absl::base_internal::GetTID()),
- ElementsAre(ValueWithStr(Eq("WriteToStream: foo"))))))))
+ EXPECT_CALL(test_sink,
+ Send(AllOf(SourceFilename(Eq("path/file.cc")),
+ SourceLine(Eq(1234)), Prefix(IsTrue()),
+ LogSeverity(Eq(absl::LogSeverity::kFatal)),
+ Timestamp(InMatchWindow()),
+ ThreadID(Eq(absl::base_internal::GetTID())),
+ TextMessage(Eq("WriteToStream: foo")),
+ ENCODED_MESSAGE(MatchesEvent(
+ Eq("path/file.cc"), Eq(1234),
+ InMatchWindow(), Eq(logging::proto::FATAL),
+ Eq(absl::base_internal::GetTID()),
+ ElementsAre(EqualsProto(
+ R"pb(str: "WriteToStream: foo")pb")))))))
.WillOnce(DeathTestExpectedLogging());
test_sink.StartCapturingLogs();
@@ -278,12 +278,13 @@
EXPECT_CALL(
test_sink,
- Send(AllOf(SourceFilename(Eq("path/file.cc")), SourceLine(Eq(1234)),
- TextMessage(Eq("WriteToStreamRef: foo")),
- ENCODED_MESSAGE(MatchesEvent(
- Eq("path/file.cc"), Eq(1234), _, _, _,
- ElementsAre(ValueWithStr(Eq("WriteToStreamRef: foo"))))),
- Stacktrace(IsEmpty()))));
+ Send(AllOf(
+ SourceFilename(Eq("path/file.cc")), SourceLine(Eq(1234)),
+ TextMessage(Eq("WriteToStreamRef: foo")),
+ ENCODED_MESSAGE(MatchesEvent(
+ Eq("path/file.cc"), Eq(1234), _, _, _,
+ ElementsAre(EqualsProto(R"pb(str: "WriteToStreamRef: foo")pb")))),
+ Stacktrace(IsEmpty()))));
test_sink.StartCapturingLogs();
WriteToStreamRef("foo", absl::LogInfoStreamer("path/file.cc", 1234).stream());
@@ -302,13 +303,14 @@
// test would fail.
EXPECT_CALL(
test_sink,
- Send(AllOf(SourceFilename(Eq("path/file.cc")), SourceLine(Eq(1234)),
- TextMessage(Eq("WriteToStream: foo WriteToStreamRef: bar")),
- ENCODED_MESSAGE(MatchesEvent(
- Eq("path/file.cc"), Eq(1234), _, _, _,
- ElementsAre(ValueWithStr(
- Eq("WriteToStream: foo WriteToStreamRef: bar"))))),
- Stacktrace(IsEmpty()))));
+ Send(AllOf(
+ SourceFilename(Eq("path/file.cc")), SourceLine(Eq(1234)),
+ TextMessage(Eq("WriteToStream: foo WriteToStreamRef: bar")),
+ ENCODED_MESSAGE(MatchesEvent(
+ Eq("path/file.cc"), Eq(1234), _, _, _,
+ ElementsAre(EqualsProto(
+ R"pb(str: "WriteToStream: foo WriteToStreamRef: bar")pb")))),
+ Stacktrace(IsEmpty()))));
test_sink.StartCapturingLogs();
}
@@ -329,12 +331,13 @@
TEST(LogStreamerTest, LogsEmptyLine) {
absl::ScopedMockLog test_sink(absl::MockLogDefault::kDisallowUnexpected);
- EXPECT_CALL(test_sink, Send(AllOf(SourceFilename(Eq("path/file.cc")),
- SourceLine(Eq(1234)), TextMessage(Eq("")),
- ENCODED_MESSAGE(MatchesEvent(
- Eq("path/file.cc"), Eq(1234), _, _, _,
- ElementsAre(ValueWithStr(Eq(""))))),
- Stacktrace(IsEmpty()))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(SourceFilename(Eq("path/file.cc")),
+ SourceLine(Eq(1234)), TextMessage(Eq("")),
+ ENCODED_MESSAGE(MatchesEvent(
+ Eq("path/file.cc"), Eq(1234), _, _, _,
+ ElementsAre(EqualsProto(R"pb(str: "")pb")))),
+ Stacktrace(IsEmpty()))));
test_sink.StartCapturingLogs();
absl::LogInfoStreamer("path/file.cc", 1234);
@@ -353,9 +356,9 @@
EXPECT_CALL(
test_sink,
Send(AllOf(SourceFilename(Eq("path/file.cc")), TextMessage(Eq("")),
- ENCODED_MESSAGE(
- MatchesEvent(Eq("path/file.cc"), _, _, _, _,
- ElementsAre(ValueWithStr(Eq(""))))))))
+ ENCODED_MESSAGE(MatchesEvent(
+ Eq("path/file.cc"), _, _, _, _,
+ ElementsAre(EqualsProto(R"pb(str: "")pb")))))))
.WillOnce(DeathTestExpectedLogging());
test_sink.StartCapturingLogs();
@@ -371,14 +374,14 @@
EXPECT_CALL(
test_sink,
- Send(
- AllOf(SourceFilename(Eq("path/file.cc")), SourceLine(Eq(1234)),
- LogSeverity(Eq(absl::LogSeverity::kInfo)),
- TextMessage(Eq("hello 0x10 world 0x10")),
- ENCODED_MESSAGE(MatchesEvent(
- Eq("path/file.cc"), Eq(1234), _, Eq(logging::proto::INFO),
- _, ElementsAre(ValueWithStr(Eq("hello 0x10 world 0x10"))))),
- Stacktrace(IsEmpty()))));
+ Send(AllOf(
+ SourceFilename(Eq("path/file.cc")), SourceLine(Eq(1234)),
+ LogSeverity(Eq(absl::LogSeverity::kInfo)),
+ TextMessage(Eq("hello 0x10 world 0x10")),
+ ENCODED_MESSAGE(MatchesEvent(
+ Eq("path/file.cc"), Eq(1234), _, Eq(logging::proto::INFO), _,
+ ElementsAre(EqualsProto(R"pb(str: "hello 0x10 world 0x10")pb")))),
+ Stacktrace(IsEmpty()))));
test_sink.StartCapturingLogs();
auto streamer1 = absl::LogInfoStreamer("path/file.cc", 1234);
@@ -399,18 +402,18 @@
TextMessage(Eq("something else")),
ENCODED_MESSAGE(MatchesEvent(
Eq("path/file2.cc"), Eq(5678), _, Eq(logging::proto::WARNING), _,
- ElementsAre(ValueWithStr(Eq("something else"))))),
+ ElementsAre(EqualsProto(R"pb(str: "something else")pb")))),
Stacktrace(IsEmpty()))));
EXPECT_CALL(
test_sink,
- Send(
- AllOf(SourceFilename(Eq("path/file.cc")), SourceLine(Eq(1234)),
- LogSeverity(Eq(absl::LogSeverity::kInfo)),
- TextMessage(Eq("hello 0x10 world 0x10")),
- ENCODED_MESSAGE(MatchesEvent(
- Eq("path/file.cc"), Eq(1234), _, Eq(logging::proto::INFO),
- _, ElementsAre(ValueWithStr(Eq("hello 0x10 world 0x10"))))),
- Stacktrace(IsEmpty()))));
+ Send(AllOf(
+ SourceFilename(Eq("path/file.cc")), SourceLine(Eq(1234)),
+ LogSeverity(Eq(absl::LogSeverity::kInfo)),
+ TextMessage(Eq("hello 0x10 world 0x10")),
+ ENCODED_MESSAGE(MatchesEvent(
+ Eq("path/file.cc"), Eq(1234), _, Eq(logging::proto::INFO), _,
+ ElementsAre(EqualsProto(R"pb(str: "hello 0x10 world 0x10")pb")))),
+ Stacktrace(IsEmpty()))));
test_sink.StartCapturingLogs();
auto streamer1 = absl::LogInfoStreamer("path/file.cc", 1234);
diff --git a/absl/log/scoped_mock_log.h b/absl/log/scoped_mock_log.h
index a383066..399e604 100644
--- a/absl/log/scoped_mock_log.h
+++ b/absl/log/scoped_mock_log.h
@@ -40,8 +40,8 @@
// ScopedMockLog
//
-// ScopedMockLog is a LogSink that intercepts LOG() messages issued by all
-// threads when active.
+// ScopedMockLog is a LogSink that intercepts LOG() messages issued during its
+// lifespan.
//
// Using this together with GoogleTest, it's easy to test how a piece of code
// calls LOG(). The typical usage, noting the distinction between
diff --git a/absl/log/structured.h b/absl/log/structured.h
index 89d241e..9ad69fb 100644
--- a/absl/log/structured.h
+++ b/absl/log/structured.h
@@ -32,7 +32,6 @@
#include <ostream>
-#include "absl/base/attributes.h"
#include "absl/base/config.h"
#include "absl/log/internal/structured.h"
#include "absl/strings/string_view.h"
@@ -61,11 +60,7 @@
// int line) {
// LOG(LEVEL(severity)).AtLocation(file, line) << absl::LogAsLiteral(str);
// }
-//
-// `LogAsLiteral` should only be used as a streaming operand and not, for
-// example, as a local variable initializer.
-inline log_internal::AsLiteralImpl LogAsLiteral(
- absl::string_view s ABSL_ATTRIBUTE_LIFETIME_BOUND) {
+inline log_internal::AsLiteralImpl LogAsLiteral(absl::string_view s) {
return log_internal::AsLiteralImpl(s);
}
diff --git a/absl/log/structured_test.cc b/absl/log/structured_test.cc
index 9fe0756..6f1df18 100644
--- a/absl/log/structured_test.cc
+++ b/absl/log/structured_test.cc
@@ -51,10 +51,11 @@
absl::ScopedMockLog sink;
- EXPECT_CALL(sink, Send(AllOf(TextMessage(MatchesOstream(stream)),
- TextMessage(Eq("hello world")),
- ENCODED_MESSAGE(HasValues(ElementsAre(
- ValueWithLiteral(Eq("hello world"))))))));
+ EXPECT_CALL(sink,
+ Send(AllOf(TextMessage(MatchesOstream(stream)),
+ TextMessage(Eq("hello world")),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(literal: "hello world")pb")))))));
sink.StartCapturingLogs();
LOG(INFO) << absl::LogAsLiteral(not_a_literal);
diff --git a/absl/log/vlog_is_on.h b/absl/log/vlog_is_on.h
index c33fcc1..f7539df 100644
--- a/absl/log/vlog_is_on.h
+++ b/absl/log/vlog_is_on.h
@@ -40,8 +40,6 @@
// last . and everything after it) is stripped from each filename prior to
// matching, as is the special suffix "-inl".
//
-// Example: --vmodule=module_a=1,module_b=2
-//
// Files are matched against globs in `--vmodule` in order, and the first match
// determines the verbosity level.
//
diff --git a/absl/log/vlog_is_on_test.cc b/absl/log/vlog_is_on_test.cc
index f612283..883d798 100644
--- a/absl/log/vlog_is_on_test.cc
+++ b/absl/log/vlog_is_on_test.cc
@@ -44,23 +44,7 @@
#endif
}
-// This fixture is used to reset the VLOG levels to their default values before
-// each test.
-class VLogIsOnTest : public ::testing::Test {
- protected:
- void SetUp() override { ResetVLogLevels(); }
-
- private:
- // Resets the VLOG levels to their default values.
- // It is supposed to be called in the SetUp() method of the test fixture to
- // eliminate any side effects from other tests.
- static void ResetVLogLevels() {
- absl::log_internal::UpdateVModule("");
- absl::SetGlobalVLogLevel(0);
- }
-};
-
-TEST_F(VLogIsOnTest, GlobalWorksWithoutMaxVerbosityAndMinLogLevel) {
+TEST(VLogIsOn, GlobalWorksWithoutMaxVerbosityAndMinLogLevel) {
if (MaxLogVerbosity().has_value() || MinLogLevel().has_value()) {
GTEST_SKIP();
}
@@ -75,7 +59,7 @@
VLOG(4) << "spam";
}
-TEST_F(VLogIsOnTest, FileWorksWithoutMaxVerbosityAndMinLogLevel) {
+TEST(VLogIsOn, FileWorksWithoutMaxVerbosityAndMinLogLevel) {
if (MaxLogVerbosity().has_value() || MinLogLevel().has_value()) {
GTEST_SKIP();
}
@@ -90,7 +74,7 @@
VLOG(4) << "spam";
}
-TEST_F(VLogIsOnTest, PatternWorksWithoutMaxVerbosityAndMinLogLevel) {
+TEST(VLogIsOn, PatternWorksWithoutMaxVerbosityAndMinLogLevel) {
if (MaxLogVerbosity().has_value() || MinLogLevel().has_value()) {
GTEST_SKIP();
}
@@ -105,48 +89,7 @@
VLOG(4) << "spam";
}
-TEST_F(VLogIsOnTest,
- PatternOverridesLessGenericOneWithoutMaxVerbosityAndMinLogLevel) {
- if (MaxLogVerbosity().has_value() || MinLogLevel().has_value()) {
- GTEST_SKIP();
- }
-
- // This should disable logging in this file
- absl::SetVLogLevel("vlog_is_on*", -1);
- // This overrides the previous setting, because "vlog*" is more generic than
- // "vlog_is_on*". This should enable VLOG level 3 in this file.
- absl::SetVLogLevel("vlog*", 3);
- absl::ScopedMockLog log(absl::MockLogDefault::kDisallowUnexpected);
-
- EXPECT_CALL(log, Log(absl::LogSeverity::kInfo, _, "important"));
-
- log.StartCapturingLogs();
- VLOG(3) << "important";
- VLOG(4) << "spam";
-}
-
-TEST_F(VLogIsOnTest,
- PatternDoesNotOverridesMoreGenericOneWithoutMaxVerbosityAndMinLogLevel) {
- if (MaxLogVerbosity().has_value() || MinLogLevel().has_value()) {
- GTEST_SKIP();
- }
-
- // This should enable VLOG level 3 in this file.
- absl::SetVLogLevel("vlog*", 3);
- // This should not change the VLOG level in this file. The pattern does not
- // match this file and it is less generic than the previous patter "vlog*".
- // Therefore, it does not disable VLOG level 3 in this file.
- absl::SetVLogLevel("vlog_is_on_some_other_test*", -1);
- absl::ScopedMockLog log(absl::MockLogDefault::kDisallowUnexpected);
-
- EXPECT_CALL(log, Log(absl::LogSeverity::kInfo, _, "important"));
-
- log.StartCapturingLogs();
- VLOG(3) << "important";
- VLOG(5) << "spam";
-}
-
-TEST_F(VLogIsOnTest, GlobalDoesNotFilterBelowMaxVerbosity) {
+TEST(VLogIsOn, GlobalDoesNotFilterBelowMaxVerbosity) {
if (!MaxLogVerbosity().has_value() || *MaxLogVerbosity() < 2) {
GTEST_SKIP();
}
@@ -161,7 +104,7 @@
VLOG(2) << "asdf";
}
-TEST_F(VLogIsOnTest, FileDoesNotFilterBelowMaxVerbosity) {
+TEST(VLogIsOn, FileDoesNotFilterBelowMaxVerbosity) {
if (!MaxLogVerbosity().has_value() || *MaxLogVerbosity() < 2) {
GTEST_SKIP();
}
@@ -176,7 +119,7 @@
VLOG(2) << "asdf";
}
-TEST_F(VLogIsOnTest, PatternDoesNotFilterBelowMaxVerbosity) {
+TEST(VLogIsOn, PatternDoesNotFilterBelowMaxVerbosity) {
if (!MaxLogVerbosity().has_value() || *MaxLogVerbosity() < 2) {
GTEST_SKIP();
}
@@ -191,7 +134,7 @@
VLOG(2) << "asdf";
}
-TEST_F(VLogIsOnTest, GlobalFiltersAboveMaxVerbosity) {
+TEST(VLogIsOn, GlobalFiltersAboveMaxVerbosity) {
if (!MaxLogVerbosity().has_value() || *MaxLogVerbosity() >= 4) {
GTEST_SKIP();
}
@@ -204,7 +147,7 @@
VLOG(4) << "dfgh";
}
-TEST_F(VLogIsOnTest, FileFiltersAboveMaxVerbosity) {
+TEST(VLogIsOn, FileFiltersAboveMaxVerbosity) {
if (!MaxLogVerbosity().has_value() || *MaxLogVerbosity() >= 4) {
GTEST_SKIP();
}
@@ -217,7 +160,7 @@
VLOG(4) << "dfgh";
}
-TEST_F(VLogIsOnTest, PatternFiltersAboveMaxVerbosity) {
+TEST(VLogIsOn, PatternFiltersAboveMaxVerbosity) {
if (!MaxLogVerbosity().has_value() || *MaxLogVerbosity() >= 4) {
GTEST_SKIP();
}
diff --git a/absl/memory/BUILD.bazel b/absl/memory/BUILD.bazel
index d50a502..4573f17 100644
--- a/absl/memory/BUILD.bazel
+++ b/absl/memory/BUILD.bazel
@@ -54,7 +54,7 @@
deps = [
":memory",
"//absl/base:core_headers",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
diff --git a/absl/meta/BUILD.bazel b/absl/meta/BUILD.bazel
index d01cb8a..cf5df9b 100644
--- a/absl/meta/BUILD.bazel
+++ b/absl/meta/BUILD.bazel
@@ -53,7 +53,7 @@
"//absl/base:config",
"//absl/base:core_headers",
"//absl/time",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
diff --git a/absl/meta/type_traits.h b/absl/meta/type_traits.h
index 02da067..ded5582 100644
--- a/absl/meta/type_traits.h
+++ b/absl/meta/type_traits.h
@@ -503,11 +503,10 @@
// remove the condition.
//
// Clang on all platforms fails to detect that a type with a user-provided
-// move-assignment operator is not trivially relocatable so we also check for
-// is_trivially_move_assignable for Clang.
+// move-assignment operator is not trivially relocatable. So in fact we
+// opt out of Clang altogether, for now.
//
-// TODO(b/325479096): Remove the Clang is_trivially_move_assignable version once
-// Clang's behavior is fixed.
+// TODO(b/325479096): Remove the opt-out once Clang's behavior is fixed.
//
// According to https://github.com/abseil/abseil-cpp/issues/1479, this does not
// work with NVCC either.
@@ -517,15 +516,6 @@
template <class T>
struct is_trivially_relocatable
: std::integral_constant<bool, __is_trivially_relocatable(T)> {};
-#elif ABSL_HAVE_BUILTIN(__is_trivially_relocatable) && defined(__clang__) && \
- !(defined(_WIN32) || defined(_WIN64)) && !defined(__APPLE__) && \
- !defined(__NVCC__)
-template <class T>
-struct is_trivially_relocatable
- : std::integral_constant<
- bool, std::is_trivially_copyable<T>::value ||
- (__is_trivially_relocatable(T) &&
- std::is_trivially_move_assignable<T>::value)> {};
#else
// Otherwise we use a fallback that detects only those types we can feasibly
// detect. Any type that is trivially copyable is by definition trivially
@@ -658,9 +648,9 @@
// Until then, we consider an assignment from an "owner" (such as std::string)
// to a "view" (such as std::string_view) to be a lifetime-bound assignment.
template <typename T, typename U>
-using IsLifetimeBoundAssignment = absl::conjunction<
- std::integral_constant<bool, !std::is_lvalue_reference<U>::value>,
- IsOwner<absl::remove_cvref_t<U>>, IsView<absl::remove_cvref_t<T>>>;
+using IsLifetimeBoundAssignment =
+ std::integral_constant<bool, IsView<absl::remove_cvref_t<T>>::value &&
+ IsOwner<absl::remove_cvref_t<U>>::value>;
} // namespace type_traits_internal
diff --git a/absl/meta/type_traits_test.cc b/absl/meta/type_traits_test.cc
index be42572..1e056bb 100644
--- a/absl/meta/type_traits_test.cc
+++ b/absl/meta/type_traits_test.cc
@@ -769,8 +769,6 @@
// __is_trivially_relocatable is used there again.
// TODO(b/324278148): remove the opt-out for Apple once
// __is_trivially_relocatable is fixed there.
-// TODO(b/325479096): remove the opt-out for Clang once
-// __is_trivially_relocatable is fixed there.
#if defined(ABSL_HAVE_ATTRIBUTE_TRIVIAL_ABI) && \
ABSL_HAVE_BUILTIN(__is_trivially_relocatable) && \
(defined(__cpp_impl_trivially_relocatable) || \
@@ -781,28 +779,8 @@
struct ABSL_ATTRIBUTE_TRIVIAL_ABI S {
S(S&&) {} // NOLINT(modernize-use-equals-default)
S(const S&) {} // NOLINT(modernize-use-equals-default)
- S& operator=(S&&) { return *this; }
- S& operator=(const S&) { return *this; }
- ~S() {} // NOLINT(modernize-use-equals-default)
- };
-
- static_assert(absl::is_trivially_relocatable<S>::value, "");
-}
-#endif
-
-// TODO(b/275003464): remove the opt-out for Clang on Windows once
-// __is_trivially_relocatable is used there again.
-// TODO(b/324278148): remove the opt-out for Apple once
-// __is_trivially_relocatable is fixed there.
-#if defined(ABSL_HAVE_ATTRIBUTE_TRIVIAL_ABI) && \
- ABSL_HAVE_BUILTIN(__is_trivially_relocatable) && defined(__clang__) && \
- !(defined(_WIN32) || defined(_WIN64)) && !defined(__APPLE__) && \
- !defined(__NVCC__)
-// A type marked with the "trivial ABI" attribute is trivially relocatable even
-// if it has a user-provided copy constructor and a user-provided destructor.
-TEST(TriviallyRelocatable, TrivialAbi_NoUserProvidedMove) {
- struct ABSL_ATTRIBUTE_TRIVIAL_ABI S {
- S(const S&) {} // NOLINT(modernize-use-equals-default)
+ void operator=(S&&) {}
+ void operator=(const S&) {}
~S() {} // NOLINT(modernize-use-equals-default)
};
diff --git a/absl/numeric/BUILD.bazel b/absl/numeric/BUILD.bazel
index 7b92eed..f202c6e 100644
--- a/absl/numeric/BUILD.bazel
+++ b/absl/numeric/BUILD.bazel
@@ -54,8 +54,8 @@
":bits",
"//absl/base:core_headers",
"//absl/random",
- "@google_benchmark//:benchmark_main",
- "@googletest//:gtest",
+ "@com_github_google_benchmark//:benchmark_main",
+ "@com_google_googletest//:gtest",
],
)
@@ -70,8 +70,8 @@
deps = [
":bits",
"//absl/random",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -109,8 +109,8 @@
"//absl/meta:type_traits",
"//absl/strings",
"//absl/types:compare",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -123,8 +123,8 @@
deps = [
":int128",
"//absl/base:config",
- "@google_benchmark//:benchmark_main",
- "@googletest//:gtest",
+ "@com_github_google_benchmark//:benchmark_main",
+ "@com_google_googletest//:gtest",
],
)
diff --git a/absl/numeric/int128.h b/absl/numeric/int128.h
index ae736b2..5a067d1 100644
--- a/absl/numeric/int128.h
+++ b/absl/numeric/int128.h
@@ -216,11 +216,7 @@
// Support for absl::Hash.
template <typename H>
friend H AbslHashValue(H h, uint128 v) {
-#if defined(ABSL_HAVE_INTRINSIC_INT128)
- return H::combine(std::move(h), static_cast<unsigned __int128>(v));
-#else
return H::combine(std::move(h), Uint128High64(v), Uint128Low64(v));
-#endif
}
// Support for absl::StrCat() etc.
@@ -462,11 +458,7 @@
// Support for absl::Hash.
template <typename H>
friend H AbslHashValue(H h, int128 v) {
-#if defined(ABSL_HAVE_INTRINSIC_INT128)
- return H::combine(std::move(h), v.v_);
-#else
return H::combine(std::move(h), Int128High64(v), Int128Low64(v));
-#endif
}
// Support for absl::StrCat() etc.
@@ -789,20 +781,16 @@
// Conversion operators to floating point types.
inline uint128::operator float() const {
- // Note: This method might return Inf.
- constexpr float pow_2_64 = 18446744073709551616.0f;
- return static_cast<float>(lo_) + static_cast<float>(hi_) * pow_2_64;
+ return static_cast<float>(lo_) + std::ldexp(static_cast<float>(hi_), 64);
}
inline uint128::operator double() const {
- constexpr double pow_2_64 = 18446744073709551616.0;
- return static_cast<double>(lo_) + static_cast<double>(hi_) * pow_2_64;
+ return static_cast<double>(lo_) + std::ldexp(static_cast<double>(hi_), 64);
}
inline uint128::operator long double() const {
- constexpr long double pow_2_64 = 18446744073709551616.0L;
return static_cast<long double>(lo_) +
- static_cast<long double>(hi_) * pow_2_64;
+ std::ldexp(static_cast<long double>(hi_), 64);
}
// Comparison operators.
diff --git a/absl/numeric/int128_have_intrinsic.inc b/absl/numeric/int128_have_intrinsic.inc
index 216115a..51e4b9d 100644
--- a/absl/numeric/int128_have_intrinsic.inc
+++ b/absl/numeric/int128_have_intrinsic.inc
@@ -170,29 +170,27 @@
// complement overwhelms the precision of the mantissa.
//
// Also check to make sure we don't negate Int128Min()
- constexpr float pow_2_64 = 18446744073709551616.0f;
return v_ < 0 && *this != Int128Min()
? -static_cast<float>(-*this)
: static_cast<float>(Int128Low64(*this)) +
- static_cast<float>(Int128High64(*this)) * pow_2_64;
+ std::ldexp(static_cast<float>(Int128High64(*this)), 64);
}
inline int128::operator double() const {
// See comment in int128::operator float() above.
- constexpr double pow_2_64 = 18446744073709551616.0;
return v_ < 0 && *this != Int128Min()
? -static_cast<double>(-*this)
: static_cast<double>(Int128Low64(*this)) +
- static_cast<double>(Int128High64(*this)) * pow_2_64;
+ std::ldexp(static_cast<double>(Int128High64(*this)), 64);
}
inline int128::operator long double() const {
// See comment in int128::operator float() above.
- constexpr long double pow_2_64 = 18446744073709551616.0L;
return v_ < 0 && *this != Int128Min()
? -static_cast<long double>(-*this)
: static_cast<long double>(Int128Low64(*this)) +
- static_cast<long double>(Int128High64(*this)) * pow_2_64;
+ std::ldexp(static_cast<long double>(Int128High64(*this)),
+ 64);
}
#endif // Clang on PowerPC
diff --git a/absl/numeric/int128_no_intrinsic.inc b/absl/numeric/int128_no_intrinsic.inc
index a7cdcea..195b745 100644
--- a/absl/numeric/int128_no_intrinsic.inc
+++ b/absl/numeric/int128_no_intrinsic.inc
@@ -139,29 +139,26 @@
// complement overwhelms the precision of the mantissa.
//
// Also check to make sure we don't negate Int128Min()
- constexpr float pow_2_64 = 18446744073709551616.0f;
return hi_ < 0 && *this != Int128Min()
? -static_cast<float>(-*this)
: static_cast<float>(lo_) +
- static_cast<float>(hi_) * pow_2_64;
+ std::ldexp(static_cast<float>(hi_), 64);
}
inline int128::operator double() const {
// See comment in int128::operator float() above.
- constexpr double pow_2_64 = 18446744073709551616.0;
return hi_ < 0 && *this != Int128Min()
? -static_cast<double>(-*this)
: static_cast<double>(lo_) +
- static_cast<double>(hi_) * pow_2_64;
+ std::ldexp(static_cast<double>(hi_), 64);
}
inline int128::operator long double() const {
// See comment in int128::operator float() above.
- constexpr long double pow_2_64 = 18446744073709551616.0L;
return hi_ < 0 && *this != Int128Min()
? -static_cast<long double>(-*this)
: static_cast<long double>(lo_) +
- static_cast<long double>(hi_) * pow_2_64;
+ std::ldexp(static_cast<long double>(hi_), 64);
}
// Comparison operators.
diff --git a/absl/numeric/int128_test.cc b/absl/numeric/int128_test.cc
index c31e28f..3f16e05 100644
--- a/absl/numeric/int128_test.cc
+++ b/absl/numeric/int128_test.cc
@@ -17,13 +17,11 @@
#include <algorithm>
#include <limits>
#include <random>
-#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>
#include "gtest/gtest.h"
-#include "absl/base/casts.h"
#include "absl/base/internal/cycleclock.h"
#include "absl/hash/hash_testing.h"
#include "absl/meta/type_traits.h"
@@ -475,51 +473,29 @@
EXPECT_EQ(absl::Uint128Max(), std::numeric_limits<absl::uint128>::max());
}
-// Some arbitrary constant to test hashing. The first hex digits of pi.
-constexpr absl::uint128 kPi = (absl::uint128(0x3243f6a8885a308d) << 64) |
- absl::uint128(0x313198a2e0370734);
-
TEST(Uint128, Hash) {
-#if defined(ABSL_HAVE_INTRINSIC_INT128)
- using Ext128 = unsigned __int128;
-#endif
- // Make the tuple outside the EXPECT_TRUE because putting the #if inside the
- // macro argument is not ok.
- const auto values = std::make_tuple(
+ EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly({
// Some simple values
- absl::uint128{0}, absl::uint128{1}, ~absl::uint128{},
+ absl::uint128{0},
+ absl::uint128{1},
+ ~absl::uint128{},
// 64 bit limits
absl::uint128{std::numeric_limits<int64_t>::max()},
absl::uint128{std::numeric_limits<uint64_t>::max()} + 0,
absl::uint128{std::numeric_limits<uint64_t>::max()} + 1,
absl::uint128{std::numeric_limits<uint64_t>::max()} + 2,
// Keeping high same
- absl::uint128{1} << 62, absl::uint128{1} << 63,
+ absl::uint128{1} << 62,
+ absl::uint128{1} << 63,
// Keeping low same
- absl::uint128{1} << 64, absl::uint128{1} << 65,
+ absl::uint128{1} << 64,
+ absl::uint128{1} << 65,
// 128 bit limits
std::numeric_limits<absl::uint128>::max(),
std::numeric_limits<absl::uint128>::max() - 1,
std::numeric_limits<absl::uint128>::min() + 1,
std::numeric_limits<absl::uint128>::min(),
- // arbitrary constant
- kPi
-#if defined(ABSL_HAVE_INTRINSIC_INT128)
- // Same but with the intrinsic to verify that they match
- ,
- Ext128{0}, Ext128{1}, ~Ext128{},
- Ext128{std::numeric_limits<int64_t>::max()},
- Ext128{std::numeric_limits<uint64_t>::max()} + 0,
- Ext128{std::numeric_limits<uint64_t>::max()} + 1,
- Ext128{std::numeric_limits<uint64_t>::max()} + 2, Ext128{1} << 62,
- Ext128{1} << 63, Ext128{1} << 64, Ext128{1} << 65,
- std::numeric_limits<Ext128>::max(),
- std::numeric_limits<Ext128>::max() - 1,
- std::numeric_limits<Ext128>::min() + 1,
- std::numeric_limits<Ext128>::min(), static_cast<Ext128>(kPi)
-#endif
- );
- EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly(values));
+ }));
}
@@ -1306,50 +1282,4 @@
EXPECT_EQ(absl::Int128Max(), std::numeric_limits<absl::int128>::max());
}
-TEST(Int128, BitCastable) {
- // NOTE: This test is not intended to be an example that demonstrate usages of
- // `static_cast` and `std::bit_cast`, rather it is here simply to verify
- // behavior. When deciding whether you should use `static_cast` or
- // `std::bit_cast` when converting between `absl::int128` and `absl::uint128`,
- // use your best judgement. As a rule of thumb, use the same cast that you
- // would use when converting between the signed and unsigned counterparts of a
- // builtin integral type.
-
- // Verify bit casting between signed and unsigned works with regards to two's
- // complement. This verifies we exhibit the same behavior as a theoretical
- // builtin int128_t and uint128_t in C++20 onwards.
- EXPECT_EQ(absl::bit_cast<absl::uint128>(absl::int128(-1)),
- std::numeric_limits<absl::uint128>::max());
- EXPECT_EQ(
- absl::bit_cast<absl::int128>(std::numeric_limits<absl::uint128>::max()),
- absl::int128(-1));
- EXPECT_EQ(
- absl::bit_cast<absl::uint128>(std::numeric_limits<absl::int128>::min()),
- absl::uint128(1) << 127);
- EXPECT_EQ(absl::bit_cast<absl::int128>(absl::uint128(1) << 127),
- std::numeric_limits<absl::int128>::min());
- EXPECT_EQ(
- absl::bit_cast<absl::uint128>(std::numeric_limits<absl::int128>::max()),
- (absl::uint128(1) << 127) - 1);
- EXPECT_EQ(absl::bit_cast<absl::int128>((absl::uint128(1) << 127) - 1),
- std::numeric_limits<absl::int128>::max());
-
- // Also verify static casting has the same behavior as bit casting.
- EXPECT_EQ(static_cast<absl::uint128>(absl::int128(-1)),
- std::numeric_limits<absl::uint128>::max());
- EXPECT_EQ(
- static_cast<absl::int128>(std::numeric_limits<absl::uint128>::max()),
- absl::int128(-1));
- EXPECT_EQ(
- static_cast<absl::uint128>(std::numeric_limits<absl::int128>::min()),
- absl::uint128(1) << 127);
- EXPECT_EQ(static_cast<absl::int128>(absl::uint128(1) << 127),
- std::numeric_limits<absl::int128>::min());
- EXPECT_EQ(
- static_cast<absl::uint128>(std::numeric_limits<absl::int128>::max()),
- (absl::uint128(1) << 127) - 1);
- EXPECT_EQ(static_cast<absl::int128>((absl::uint128(1) << 127) - 1),
- std::numeric_limits<absl::int128>::max());
-}
-
} // namespace
diff --git a/absl/profiling/BUILD.bazel b/absl/profiling/BUILD.bazel
index c5e3b00..abe127e 100644
--- a/absl/profiling/BUILD.bazel
+++ b/absl/profiling/BUILD.bazel
@@ -59,8 +59,8 @@
"//absl/synchronization",
"//absl/synchronization:thread_pool",
"//absl/time",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -88,8 +88,8 @@
deps = [
":exponential_biased",
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -119,8 +119,8 @@
deps = [
":periodic_sampler",
"//absl/base:core_headers",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -135,6 +135,6 @@
deps = [
":periodic_sampler",
"//absl/base:core_headers",
- "@google_benchmark//:benchmark_main",
+ "@com_github_google_benchmark//:benchmark_main",
],
)
diff --git a/absl/random/BUILD.bazel b/absl/random/BUILD.bazel
index ef8ac7e..f276cc0 100644
--- a/absl/random/BUILD.bazel
+++ b/absl/random/BUILD.bazel
@@ -75,6 +75,7 @@
"//absl/base:config",
"//absl/base:core_headers",
"//absl/meta:type_traits",
+ "//absl/numeric:bits",
"//absl/random/internal:distribution_caller",
"//absl/random/internal:fast_uniform_bits",
"//absl/random/internal:fastmath",
@@ -93,10 +94,7 @@
hdrs = ["seed_gen_exception.h"],
copts = ABSL_DEFAULT_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
- deps = [
- "//absl/base:config",
- "//absl/base:raw_logging_internal",
- ],
+ deps = ["//absl/base:config"],
)
cc_library(
@@ -126,7 +124,6 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":random",
- "//absl/base:config",
"//absl/base:core_headers",
"//absl/base:fast_type_id",
"//absl/meta:type_traits",
@@ -159,12 +156,13 @@
deps = [
":random",
"//absl/base:config",
+ "//absl/base:core_headers",
"//absl/base:fast_type_id",
"//absl/container:flat_hash_map",
"//absl/meta:type_traits",
"//absl/random/internal:mock_helpers",
"//absl/utility",
- "@googletest//:gtest",
+ "@com_google_googletest//:gtest",
],
)
@@ -180,8 +178,8 @@
":random",
"//absl/random/internal:pcg_engine",
"//absl/random/internal:sequence_urbg",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -206,8 +204,8 @@
"//absl/random/internal:sequence_urbg",
"//absl/strings",
"//absl/strings:str_format",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -226,8 +224,8 @@
"//absl/meta:type_traits",
"//absl/numeric:int128",
"//absl/random/internal:distribution_test_util",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -240,8 +238,8 @@
deps = [
":distributions",
":random",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -265,8 +263,8 @@
"//absl/random/internal:sequence_urbg",
"//absl/strings",
"//absl/strings:str_format",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -286,8 +284,8 @@
"//absl/random/internal:pcg_engine",
"//absl/random/internal:sequence_urbg",
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -316,8 +314,8 @@
"//absl/random/internal:sequence_urbg",
"//absl/strings",
"//absl/strings:str_format",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -339,8 +337,8 @@
"//absl/random/internal:sequence_urbg",
"//absl/strings",
"//absl/strings:str_format",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -363,8 +361,8 @@
"//absl/random/internal:sequence_urbg",
"//absl/strings",
"//absl/strings:str_format",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -385,8 +383,8 @@
"//absl/random/internal:pcg_engine",
"//absl/random/internal:sequence_urbg",
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -412,8 +410,8 @@
"//absl/random/internal:pcg_engine",
"//absl/random/internal:sequence_urbg",
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -433,8 +431,8 @@
"//absl/random/internal:pcg_engine",
"//absl/random/internal:sequence_urbg",
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -449,8 +447,8 @@
":random",
"//absl/base:fast_type_id",
"//absl/random/internal:sequence_urbg",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -468,15 +466,14 @@
":mock_distributions",
":mocking_bit_gen",
":random",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
cc_test(
name = "mock_distributions_test",
size = "small",
- timeout = "moderate",
srcs = ["mock_distributions_test.cc"],
copts = ABSL_TEST_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
@@ -489,8 +486,8 @@
":mocking_bit_gen",
":random",
"//absl/numeric:int128",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -505,8 +502,8 @@
],
deps = [
":random",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -520,8 +517,8 @@
":random",
":seed_sequences",
"//absl/random/internal:nonsecure_base",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -543,6 +540,6 @@
"//absl/meta:type_traits",
"//absl/random/internal:fast_uniform_bits",
"//absl/random/internal:randen_engine",
- "@google_benchmark//:benchmark_main",
+ "@com_github_google_benchmark//:benchmark_main",
],
)
diff --git a/absl/random/CMakeLists.txt b/absl/random/CMakeLists.txt
index 8f62696..ad5477e 100644
--- a/absl/random/CMakeLists.txt
+++ b/absl/random/CMakeLists.txt
@@ -42,7 +42,6 @@
LINKOPTS
${ABSL_DEFAULT_LINKOPTS}
DEPS
- absl::config
absl::core_headers
absl::random_internal_distribution_caller
absl::random_internal_fast_uniform_bits
@@ -211,7 +210,6 @@
${ABSL_DEFAULT_LINKOPTS}
DEPS
absl::config
- absl::raw_logging_internal
)
absl_cc_library(
@@ -551,7 +549,6 @@
absl::config
absl::utility
absl::fast_type_id
- absl::type_traits
)
# Internal-only target, do not depend on directly.
@@ -675,7 +672,6 @@
LINKOPTS
${ABSL_DEFAULT_LINKOPTS}
DEPS
- absl::config
absl::int128
absl::type_traits
)
@@ -853,7 +849,6 @@
absl::random_internal_platform
absl::random_internal_randen_hwaes_impl
absl::config
- absl::optional
)
# Internal-only target, do not depend on directly.
@@ -1036,7 +1031,8 @@
absl::random_internal_nonsecure_base
absl::random_random
absl::random_distributions
- absl::type_traits
+ absl::random_seed_sequences
+ absl::strings
GTest::gtest_main
)
diff --git a/absl/random/benchmarks.cc b/absl/random/benchmarks.cc
index 170589f..26bc95e 100644
--- a/absl/random/benchmarks.cc
+++ b/absl/random/benchmarks.cc
@@ -359,7 +359,7 @@
// ABSL Recommended interfaces.
BM_BASIC(absl::InsecureBitGen); // === pcg64_2018_engine
-BM_BASIC(absl::BitGen); // === randen_engine<uint64_t>.
+BM_BASIC(absl::BitGen); // === randen_engine<uint64_t>.
BM_THREAD(absl::BitGen);
BM_EXTENDED(absl::BitGen);
diff --git a/absl/random/bernoulli_distribution.h b/absl/random/bernoulli_distribution.h
index 10c24e6..d81b6ae 100644
--- a/absl/random/bernoulli_distribution.h
+++ b/absl/random/bernoulli_distribution.h
@@ -15,12 +15,10 @@
#ifndef ABSL_RANDOM_BERNOULLI_DISTRIBUTION_H_
#define ABSL_RANDOM_BERNOULLI_DISTRIBUTION_H_
-#include <cassert>
#include <cstdint>
#include <istream>
-#include <ostream>
+#include <limits>
-#include "absl/base/config.h"
#include "absl/base/optimization.h"
#include "absl/random/internal/fast_uniform_bits.h"
#include "absl/random/internal/iostream_state_saver.h"
diff --git a/absl/random/beta_distribution.h b/absl/random/beta_distribution.h
index a362345..432c516 100644
--- a/absl/random/beta_distribution.h
+++ b/absl/random/beta_distribution.h
@@ -17,16 +17,14 @@
#include <cassert>
#include <cmath>
-#include <cstdint>
#include <istream>
#include <limits>
#include <ostream>
#include <type_traits>
-#include "absl/base/attributes.h"
-#include "absl/base/config.h"
#include "absl/meta/type_traits.h"
#include "absl/random/internal/fast_uniform_bits.h"
+#include "absl/random/internal/fastmath.h"
#include "absl/random/internal/generate_real.h"
#include "absl/random/internal/iostream_state_saver.h"
diff --git a/absl/random/bit_gen_ref.h b/absl/random/bit_gen_ref.h
index 40e7b60..ac26d9d 100644
--- a/absl/random/bit_gen_ref.h
+++ b/absl/random/bit_gen_ref.h
@@ -24,14 +24,13 @@
#ifndef ABSL_RANDOM_BIT_GEN_REF_H_
#define ABSL_RANDOM_BIT_GEN_REF_H_
-#include <cstdint>
#include <limits>
#include <type_traits>
#include <utility>
#include "absl/base/attributes.h"
-#include "absl/base/config.h"
#include "absl/base/internal/fast_type_id.h"
+#include "absl/base/macros.h"
#include "absl/meta/type_traits.h"
#include "absl/random/internal/distribution_caller.h"
#include "absl/random/internal/fast_uniform_bits.h"
diff --git a/absl/random/discrete_distribution.cc b/absl/random/discrete_distribution.cc
index 247faa8..081acce 100644
--- a/absl/random/discrete_distribution.cc
+++ b/absl/random/discrete_distribution.cc
@@ -14,16 +14,6 @@
#include "absl/random/discrete_distribution.h"
-#include <cassert>
-#include <cmath>
-#include <cstddef>
-#include <iterator>
-#include <numeric>
-#include <utility>
-#include <vector>
-
-#include "absl/base/config.h"
-
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
diff --git a/absl/random/discrete_distribution.h b/absl/random/discrete_distribution.h
index f579a64..171aa11 100644
--- a/absl/random/discrete_distribution.h
+++ b/absl/random/discrete_distribution.h
@@ -16,16 +16,14 @@
#define ABSL_RANDOM_DISCRETE_DISTRIBUTION_H_
#include <cassert>
-#include <cstddef>
-#include <initializer_list>
+#include <cmath>
#include <istream>
#include <limits>
-#include <ostream>
+#include <numeric>
#include <type_traits>
#include <utility>
#include <vector>
-#include "absl/base/config.h"
#include "absl/random/bernoulli_distribution.h"
#include "absl/random/internal/iostream_state_saver.h"
#include "absl/random/uniform_int_distribution.h"
diff --git a/absl/random/distributions_test.cc b/absl/random/distributions_test.cc
index 4340aeb..ea32183 100644
--- a/absl/random/distributions_test.cc
+++ b/absl/random/distributions_test.cc
@@ -97,16 +97,17 @@
template <typename A, typename B, typename ExplicitRet>
auto ExplicitUniformReturnT(int) -> decltype(absl::Uniform<ExplicitRet>(
- std::declval<absl::InsecureBitGen&>(), std::declval<A>(),
- std::declval<B>()));
+ std::declval<absl::InsecureBitGen&>(),
+ std::declval<A>(), std::declval<B>()));
template <typename, typename, typename ExplicitRet>
Invalid ExplicitUniformReturnT(...);
template <typename TagType, typename A, typename B, typename ExplicitRet>
-auto ExplicitTaggedUniformReturnT(int) -> decltype(absl::Uniform<ExplicitRet>(
- std::declval<TagType>(), std::declval<absl::InsecureBitGen&>(),
- std::declval<A>(), std::declval<B>()));
+auto ExplicitTaggedUniformReturnT(int)
+ -> decltype(absl::Uniform<ExplicitRet>(
+ std::declval<TagType>(), std::declval<absl::InsecureBitGen&>(),
+ std::declval<A>(), std::declval<B>()));
template <typename, typename, typename, typename ExplicitRet>
Invalid ExplicitTaggedUniformReturnT(...);
@@ -470,13 +471,6 @@
EXPECT_NEAR(6.5944, moments.mean, 2000) << moments;
}
-TEST_F(RandomDistributionsTest, ZipfWithZeroMax) {
- absl::InsecureBitGen gen;
- for (int i = 0; i < 100; ++i) {
- EXPECT_EQ(0, absl::Zipf(gen, 0));
- }
-}
-
TEST_F(RandomDistributionsTest, Gaussian) {
std::vector<double> values(kSize);
diff --git a/absl/random/examples_test.cc b/absl/random/examples_test.cc
index 29c27f1..1dcb514 100644
--- a/absl/random/examples_test.cc
+++ b/absl/random/examples_test.cc
@@ -96,3 +96,4 @@
EXPECT_EQ(absl::Uniform<uint32_t>(gen_1), absl::Uniform<uint32_t>(gen_2));
}
}
+
diff --git a/absl/random/exponential_distribution.h b/absl/random/exponential_distribution.h
index 4af2fb4..b5caf8a 100644
--- a/absl/random/exponential_distribution.h
+++ b/absl/random/exponential_distribution.h
@@ -21,7 +21,6 @@
#include <limits>
#include <type_traits>
-#include "absl/base/config.h"
#include "absl/meta/type_traits.h"
#include "absl/random/internal/fast_uniform_bits.h"
#include "absl/random/internal/generate_real.h"
diff --git a/absl/random/gaussian_distribution.h b/absl/random/gaussian_distribution.h
index ce84d4a..4b07a5c 100644
--- a/absl/random/gaussian_distribution.h
+++ b/absl/random/gaussian_distribution.h
@@ -26,7 +26,6 @@
#include <cstdint>
#include <istream>
#include <limits>
-#include <ostream>
#include <type_traits>
#include "absl/base/config.h"
@@ -58,7 +57,7 @@
bool neg);
// Constants used for the gaussian distribution.
- static constexpr double kR = 3.442619855899; // Start of the tail.
+ static constexpr double kR = 3.442619855899; // Start of the tail.
static constexpr double kRInv = 0.29047645161474317; // ~= (1.0 / kR) .
static constexpr double kV = 9.91256303526217e-3;
static constexpr uint64_t kMask = 0x07f;
diff --git a/absl/random/generators_test.cc b/absl/random/generators_test.cc
index c367567..2009130 100644
--- a/absl/random/generators_test.cc
+++ b/absl/random/generators_test.cc
@@ -117,6 +117,7 @@
absl::Bernoulli(*gen, 0.5);
}
+
template <typename URBG>
void TestZipf(URBG* gen) {
absl::Zipf<int>(*gen, 100);
diff --git a/absl/random/internal/BUILD.bazel b/absl/random/internal/BUILD.bazel
index 666f411..5e05130 100644
--- a/absl/random/internal/BUILD.bazel
+++ b/absl/random/internal/BUILD.bazel
@@ -14,14 +14,14 @@
# limitations under the License.
#
-load("@bazel_skylib//lib:selects.bzl", "selects")
-
# Internal-only implementation classes for Abseil Random
load(
"//absl:copts/configure_copts.bzl",
"ABSL_DEFAULT_COPTS",
"ABSL_DEFAULT_LINKOPTS",
+ "ABSL_RANDOM_RANDEN_COPTS",
"ABSL_TEST_COPTS",
+ "absl_random_randen_copts_init",
)
default_package_visibility = [
@@ -39,72 +39,6 @@
licenses(["notice"])
-# Used to select on compilers that support GCC-compatible options
-# (e.g. "-maes").
-selects.config_setting_group(
- name = "gcc_compatible",
- match_any = [
- "@rules_cc//cc/compiler:clang",
- "@rules_cc//cc/compiler:gcc",
- ],
-)
-
-selects.config_setting_group(
- name = "gcc_compatible-aarch32",
- match_all = [
- ":gcc_compatible",
- "@platforms//cpu:aarch32",
- ],
-)
-
-selects.config_setting_group(
- name = "gcc_compatible-aarch64",
- match_all = [
- ":gcc_compatible",
- "@platforms//cpu:aarch64",
- ],
-)
-
-selects.config_setting_group(
- name = "ppc_crypto",
- match_any = [
- "@platforms//cpu:ppc",
- "@platforms//cpu:ppc32",
- "@platforms//cpu:ppc64le",
- ],
-)
-
-selects.config_setting_group(
- name = "gcc_compatible-ppc_crypto",
- match_all = [
- ":gcc_compatible",
- ":ppc_crypto",
- ],
-)
-
-selects.config_setting_group(
- name = "gcc_compatible-x86_64",
- match_all = [
- ":gcc_compatible",
- "@platforms//cpu:x86_64",
- ],
-)
-
-# Some libraries are compiled with options to generate AES-NI
-# instructions, and runtime dispatch is used to determine if the host
-# microarchitecture supports AES-NI or if a portable fallback library
-# should be called.
-ABSL_RANDOM_RANDEN_COPTS = select({
- ":gcc_compatible-aarch32": ["-mfpu=neon"],
- ":gcc_compatible-aarch64": ["-march=armv8-a+crypto"],
- ":gcc_compatible-ppc_crypto": ["-mcrypto"],
- ":gcc_compatible-x86_64": [
- "-maes",
- "-msse4.1",
- ],
- "//conditions:default": [],
-})
-
cc_library(
name = "traits",
hdrs = ["traits.h"],
@@ -125,7 +59,6 @@
deps = [
"//absl/base:config",
"//absl/base:fast_type_id",
- "//absl/meta:type_traits",
"//absl/utility",
],
)
@@ -154,8 +87,8 @@
],
copts = ABSL_DEFAULT_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS + select({
- "@rules_cc//cc/compiler:msvc-cl": ["-DEFAULTLIB:bcrypt.lib"],
- "@rules_cc//cc/compiler:clang-cl": ["-DEFAULTLIB:bcrypt.lib"],
+ "//absl:msvc_compiler": ["-DEFAULTLIB:bcrypt.lib"],
+ "//absl:clang-cl_compiler": ["-DEFAULTLIB:bcrypt.lib"],
"//absl:mingw_compiler": [
"-DEFAULTLIB:bcrypt.lib",
"-lbcrypt",
@@ -183,9 +116,9 @@
],
copts = ABSL_DEFAULT_COPTS,
linkopts = select({
- "@rules_cc//cc/compiler:msvc-cl": [],
- "@rules_cc//cc/compiler:clang-cl": [],
- "@rules_cc//cc/compiler:emscripten": [],
+ "//absl:msvc_compiler": [],
+ "//absl:clang-cl_compiler": [],
+ "//absl:wasm": [],
"//conditions:default": ["-pthread"],
}) + ABSL_DEFAULT_LINKOPTS,
deps = [
@@ -249,7 +182,6 @@
copts = ABSL_DEFAULT_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
- "//absl/base:config",
"//absl/meta:type_traits",
"//absl/numeric:int128",
],
@@ -388,6 +320,8 @@
],
)
+absl_random_randen_copts_init()
+
cc_library(
name = "randen_hwaes",
srcs = [
@@ -403,7 +337,6 @@
":platform",
":randen_hwaes_impl",
"//absl/base:config",
- "//absl/types:optional",
],
)
@@ -415,8 +348,8 @@
"randen_hwaes.h",
],
copts = ABSL_DEFAULT_COPTS + ABSL_RANDOM_RANDEN_COPTS + select({
- "@rules_cc//cc/compiler:msvc-cl": [],
- "@rules_cc//cc/compiler:clang-cl": [],
+ "//absl:msvc_compiler": [],
+ "//absl:clang-cl_compiler": [],
"//conditions:default": ["-Wno-pass-failed"],
}),
linkopts = ABSL_DEFAULT_LINKOPTS,
@@ -483,8 +416,8 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":traits",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -500,8 +433,8 @@
":generate_real",
"//absl/flags:flag",
"//absl/numeric:bits",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -513,8 +446,8 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":distribution_test_util",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -526,8 +459,8 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":fastmath",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -540,8 +473,8 @@
deps = [
":explicit_seed_seq",
"//absl/random:seed_sequences",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -553,8 +486,8 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":salted_seed_seq",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -569,8 +502,8 @@
deps = [
":distribution_test_util",
"//absl/base:core_headers",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -584,8 +517,8 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":fast_uniform_bits",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -609,7 +542,7 @@
":mock_helpers",
"//absl/base:config",
"//absl/random:mocking_bit_gen",
- "@googletest//:gtest",
+ "@com_google_googletest//:gtest",
],
)
@@ -623,11 +556,12 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":nonsecure_base",
- "//absl/meta:type_traits",
"//absl/random",
"//absl/random:distributions",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "//absl/random:seed_sequences",
+ "//absl/strings",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -639,8 +573,8 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":seed_material",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -656,8 +590,8 @@
":pool_urbg",
"//absl/meta:type_traits",
"//absl/types:span",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -672,8 +606,8 @@
":explicit_seed_seq",
":pcg_engine",
"//absl/time",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -691,8 +625,8 @@
"//absl/log",
"//absl/strings",
"//absl/time",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -705,8 +639,8 @@
deps = [
":randen",
"//absl/meta:type_traits",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -720,8 +654,8 @@
":platform",
":randen_slow",
"//absl/base:endian",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -738,7 +672,7 @@
":randen_hwaes_impl", # build_cleaner: keep
"//absl/log",
"//absl/strings:str_format",
- "@googletest//:gtest",
+ "@com_google_googletest//:gtest",
],
)
@@ -752,8 +686,8 @@
":wide_multiply",
"//absl/numeric:bits",
"//absl/numeric:int128",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -845,8 +779,8 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":iostream_state_saver",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -858,7 +792,7 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":uniform_helper",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
diff --git a/absl/random/internal/chi_square.cc b/absl/random/internal/chi_square.cc
index 4cfc4d7..fbe0173 100644
--- a/absl/random/internal/chi_square.cc
+++ b/absl/random/internal/chi_square.cc
@@ -25,7 +25,9 @@
#if defined(__EMSCRIPTEN__)
// Workaround __EMSCRIPTEN__ error: llvm_fma_f64 not found.
-inline double fma(double x, double y, double z) { return (x * y) + z; }
+inline double fma(double x, double y, double z) {
+ return (x * y) + z;
+}
#endif
// Use Horner's method to evaluate a polynomial.
@@ -103,8 +105,9 @@
// p-value, usually using bisection. Also known by the name CRITCHI.
double ChiSquareValue(int dof, double p) {
static constexpr double kChiEpsilon =
- 0.000001; // Accuracy of the approximation.
- static constexpr double kChiMax = 99999.0; // Maximum chi-squared value.
+ 0.000001; // Accuracy of the approximation.
+ static constexpr double kChiMax =
+ 99999.0; // Maximum chi-squared value.
const double p_value = 1.0 - p;
if (dof < 1 || p_value > 1.0) {
diff --git a/absl/random/internal/chi_square_test.cc b/absl/random/internal/chi_square_test.cc
index 29fd988..5025def 100644
--- a/absl/random/internal/chi_square_test.cc
+++ b/absl/random/internal/chi_square_test.cc
@@ -291,7 +291,8 @@
/*97*/ {115.223, 120.990, 126.141, 132.309, 145.789},
/*98*/ {116.315, 122.108, 127.282, 133.476, 147.010},
/*99*/ {117.407, 123.225, 128.422, 134.642, 148.230},
- /*100*/ {118.498, 124.342, 129.561, 135.807, 149.449} /**/};
+ /*100*/ {118.498, 124.342, 129.561, 135.807, 149.449}
+ /**/};
// 0.90 0.95 0.975 0.99 0.999
for (int i = 0; i < ABSL_ARRAYSIZE(data); i++) {
diff --git a/absl/random/internal/distribution_caller.h b/absl/random/internal/distribution_caller.h
index 2534ca9..0f162a4 100644
--- a/absl/random/internal/distribution_caller.h
+++ b/absl/random/internal/distribution_caller.h
@@ -17,13 +17,11 @@
#ifndef ABSL_RANDOM_INTERNAL_DISTRIBUTION_CALLER_H_
#define ABSL_RANDOM_INTERNAL_DISTRIBUTION_CALLER_H_
-#include <tuple>
-#include <type_traits>
#include <utility>
+#include <type_traits>
#include "absl/base/config.h"
#include "absl/base/internal/fast_type_id.h"
-#include "absl/meta/type_traits.h"
#include "absl/utility/utility.h"
namespace absl {
diff --git a/absl/random/internal/distribution_test_util.h b/absl/random/internal/distribution_test_util.h
index 1189340..6d94cf6 100644
--- a/absl/random/internal/distribution_test_util.h
+++ b/absl/random/internal/distribution_test_util.h
@@ -16,9 +16,9 @@
#define ABSL_RANDOM_INTERNAL_DISTRIBUTION_TEST_UTIL_H_
#include <cstddef>
-#include <ostream>
+#include <iostream>
+#include <vector>
-#include "absl/base/config.h"
#include "absl/strings/string_view.h"
#include "absl/types/span.h"
@@ -96,7 +96,7 @@
// https://www.jstor.org/stable/2346798
// https://www.jstor.org/stable/2346887
//
-// BetaIncompleteInv(p, q, beta, alpha)
+// BetaIncompleteInv(p, q, beta, alhpa)
// `p` is beta parameter p, `q` is beta parameter q.
// `alpha` is the value of the lower tail area.
//
diff --git a/absl/random/internal/explicit_seed_seq_test.cc b/absl/random/internal/explicit_seed_seq_test.cc
index 68c9ab2..e36d5fa 100644
--- a/absl/random/internal/explicit_seed_seq_test.cc
+++ b/absl/random/internal/explicit_seed_seq_test.cc
@@ -29,18 +29,14 @@
template <typename Sseq>
bool ConformsToInterface() {
// Check that the SeedSequence can be default-constructed.
- {
- Sseq default_constructed_seq;
- }
+ { Sseq default_constructed_seq; }
// Check that the SeedSequence can be constructed with two iterators.
{
uint32_t init_array[] = {1, 3, 5, 7, 9};
Sseq iterator_constructed_seq(init_array, &init_array[5]);
}
// Check that the SeedSequence can be std::initializer_list-constructed.
- {
- Sseq list_constructed_seq = {1, 3, 5, 7, 9, 11, 13};
- }
+ { Sseq list_constructed_seq = {1, 3, 5, 7, 9, 11, 13}; }
// Check that param() and size() return state provided to constructor.
{
uint32_t init_array[] = {1, 2, 3, 4, 5};
diff --git a/absl/random/internal/gaussian_distribution_gentables.cc b/absl/random/internal/gaussian_distribution_gentables.cc
index 3561251..a95333d 100644
--- a/absl/random/internal/gaussian_distribution_gentables.cc
+++ b/absl/random/internal/gaussian_distribution_gentables.cc
@@ -16,6 +16,8 @@
//
// $ blaze run :gaussian_distribution_gentables > gaussian_distribution.cc
//
+#include "absl/random/gaussian_distribution.h"
+
#include <cmath>
#include <cstddef>
#include <iostream>
@@ -23,7 +25,6 @@
#include <string>
#include "absl/base/macros.h"
-#include "absl/random/gaussian_distribution.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
diff --git a/absl/random/internal/iostream_state_saver.h b/absl/random/internal/iostream_state_saver.h
index 0f56bcb..e6e242e 100644
--- a/absl/random/internal/iostream_state_saver.h
+++ b/absl/random/internal/iostream_state_saver.h
@@ -16,14 +16,10 @@
#define ABSL_RANDOM_INTERNAL_IOSTREAM_STATE_SAVER_H_
#include <cmath>
-#include <cstdint>
-#include <ios>
-#include <istream>
+#include <iostream>
#include <limits>
-#include <ostream>
#include <type_traits>
-#include "absl/base/config.h"
#include "absl/meta/type_traits.h"
#include "absl/numeric/int128.h"
@@ -99,6 +95,7 @@
null_state_saver<T>>
make_ostream_state_saver(T& is, // NOLINT(runtime/references)
std::ios_base::fmtflags flags = std::ios_base::dec) {
+ std::cerr << "null_state_saver";
using result_type = null_state_saver<T>;
return result_type(is, flags);
}
diff --git a/absl/random/internal/mock_overload_set.h b/absl/random/internal/mock_overload_set.h
index a09f035..cfaeeee 100644
--- a/absl/random/internal/mock_overload_set.h
+++ b/absl/random/internal/mock_overload_set.h
@@ -51,8 +51,10 @@
auto gmock_Call(MockURBG& gen, const ::testing::Matcher<Args>&... matchers)
-> decltype(MockHelpers::MockFor<KeyT>(gen, ValidatorT())
.gmock_Call(matchers...)) {
- static_assert(std::is_base_of<MockingBitGen, MockURBG>::value,
- "Mocking requires an absl::MockingBitGen");
+ static_assert(
+ std::is_base_of<MockingBitGenImpl<true>, MockURBG>::value ||
+ std::is_base_of<MockingBitGenImpl<false>, MockURBG>::value,
+ "Mocking requires an absl::MockingBitGen");
return MockHelpers::MockFor<KeyT>(gen, ValidatorT())
.gmock_Call(matchers...);
}
@@ -72,8 +74,10 @@
const ::testing::Matcher<Args>&... matchers)
-> decltype(MockHelpers::MockFor<KeyT>(gen, ValidatorT())
.gmock_Call(matcher, matchers...)) {
- static_assert(std::is_base_of<MockingBitGen, MockURBG>::value,
- "Mocking requires an absl::MockingBitGen");
+ static_assert(
+ std::is_base_of<MockingBitGenImpl<true>, MockURBG>::value ||
+ std::is_base_of<MockingBitGenImpl<false>, MockURBG>::value,
+ "Mocking requires an absl::MockingBitGen");
return MockHelpers::MockFor<KeyT>(gen, ValidatorT())
.gmock_Call(matcher, matchers...);
}
diff --git a/absl/random/internal/nonsecure_base_test.cc b/absl/random/internal/nonsecure_base_test.cc
index 78eea8e..3502243 100644
--- a/absl/random/internal/nonsecure_base_test.cc
+++ b/absl/random/internal/nonsecure_base_test.cc
@@ -14,18 +14,17 @@
#include "absl/random/internal/nonsecure_base.h"
-#include <cstddef>
+#include <algorithm>
#include <cstdint>
-#include <iterator>
+#include <iostream>
+#include <memory>
#include <random>
-#include <type_traits>
-#include <utility>
-#include <vector>
+#include <sstream>
#include "gtest/gtest.h"
-#include "absl/meta/type_traits.h"
#include "absl/random/distributions.h"
#include "absl/random/random.h"
+#include "absl/strings/str_cat.h"
namespace {
diff --git a/absl/random/internal/platform.h b/absl/random/internal/platform.h
index bd2993e..d779f48 100644
--- a/absl/random/internal/platform.h
+++ b/absl/random/internal/platform.h
@@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-// SKIP_ABSL_INLINE_NAMESPACE_CHECK
-
#ifndef ABSL_RANDOM_INTERNAL_PLATFORM_H_
#define ABSL_RANDOM_INTERNAL_PLATFORM_H_
@@ -136,14 +134,7 @@
// accelerated Randen implementation.
#define ABSL_RANDOM_INTERNAL_AES_DISPATCH 0
-// iOS does not support dispatch, even on x86, since applications
-// should be bundled as fat binaries, with a different build tailored for
-// each specific supported platform/architecture.
-#if (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || \
- (defined(TARGET_OS_IPHONE_SIMULATOR) && TARGET_OS_IPHONE_SIMULATOR)
-#undef ABSL_RANDOM_INTERNAL_AES_DISPATCH
-#define ABSL_RANDOM_INTERNAL_AES_DISPATCH 0
-#elif defined(ABSL_ARCH_X86_64)
+#if defined(ABSL_ARCH_X86_64)
// Dispatch is available on x86_64
#undef ABSL_RANDOM_INTERNAL_AES_DISPATCH
#define ABSL_RANDOM_INTERNAL_AES_DISPATCH 1
@@ -151,8 +142,8 @@
// Or when running linux PPC
#undef ABSL_RANDOM_INTERNAL_AES_DISPATCH
#define ABSL_RANDOM_INTERNAL_AES_DISPATCH 1
-#elif (defined(__linux__) || defined(__APPLE__)) && defined(ABSL_ARCH_AARCH64)
-// Or when running linux or macOS AArch64
+#elif defined(__linux__) && defined(ABSL_ARCH_AARCH64)
+// Or when running linux AArch64
#undef ABSL_RANDOM_INTERNAL_AES_DISPATCH
#define ABSL_RANDOM_INTERNAL_AES_DISPATCH 1
#elif defined(__linux__) && defined(ABSL_ARCH_ARM) && (__ARM_ARCH >= 8)
@@ -168,4 +159,13 @@
#define ABSL_RANDOM_INTERNAL_AES_DISPATCH 0
#endif
+// iOS does not support dispatch, even on x86, since applications
+// should be bundled as fat binaries, with a different build tailored for
+// each specific supported platform/architecture.
+#if (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || \
+ (defined(TARGET_OS_IPHONE_SIMULATOR) && TARGET_OS_IPHONE_SIMULATOR)
+#undef ABSL_RANDOM_INTERNAL_AES_DISPATCH
+#define ABSL_RANDOM_INTERNAL_AES_DISPATCH 0
+#endif
+
#endif // ABSL_RANDOM_INTERNAL_PLATFORM_H_
diff --git a/absl/random/internal/randen_benchmarks.cc b/absl/random/internal/randen_benchmarks.cc
index 237c95b..ec086ce 100644
--- a/absl/random/internal/randen_benchmarks.cc
+++ b/absl/random/internal/randen_benchmarks.cc
@@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
+#include "absl/random/internal/randen.h"
+
#include <cstdint>
#include <cstdio>
#include <cstring>
@@ -19,7 +21,6 @@
#include "absl/base/internal/raw_logging.h"
#include "absl/random/internal/nanobenchmark.h"
#include "absl/random/internal/platform.h"
-#include "absl/random/internal/randen.h"
#include "absl/random/internal/randen_engine.h"
#include "absl/random/internal/randen_hwaes.h"
#include "absl/random/internal/randen_slow.h"
diff --git a/absl/random/internal/randen_detect.cc b/absl/random/internal/randen_detect.cc
index 58948d5..bdeab87 100644
--- a/absl/random/internal/randen_detect.cc
+++ b/absl/random/internal/randen_detect.cc
@@ -19,21 +19,10 @@
#include "absl/random/internal/randen_detect.h"
-#if defined(__APPLE__) && defined(__aarch64__)
-#if defined(__has_include)
-#if __has_include(<arm/cpu_capabilities_public.h>)
-#include <arm/cpu_capabilities_public.h>
-#endif
-#endif
-#include <sys/sysctl.h>
-#include <sys/types.h>
-#endif
-
#include <cstdint>
#include <cstring>
#include "absl/random/internal/platform.h"
-#include "absl/types/optional.h" // IWYU pragma: keep
#if !defined(__UCLIBC__) && defined(__GLIBC__) && \
(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16))
@@ -113,19 +102,6 @@
#endif
-#if defined(__APPLE__) && defined(ABSL_ARCH_AARCH64)
-template <typename T>
-static absl::optional<T> ReadSysctlByName(const char* name) {
- T val;
- size_t val_size = sizeof(T);
- int ret = sysctlbyname(name, &val, &val_size, nullptr, 0);
- if (ret == -1) {
- return absl::nullopt;
- }
- return val;
-}
-#endif
-
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
@@ -153,9 +129,7 @@
// cpu capabilities, and should allow us to enable crypto in the android
// builds where it is supported.
//
-// 3. When __APPLE__ is defined on AARCH64, use sysctlbyname().
-//
-// 4. Use the default for the compiler architecture.
+// 3. Use the default for the compiler architecture.
//
bool CPUSupportsRandenHwAes() {
@@ -204,36 +178,8 @@
return ((hwcap & kNEON) != 0) && ((hwcap & kAES) != 0);
#endif
-#elif defined(__APPLE__) && defined(ABSL_ARCH_AARCH64)
- // 3. Use sysctlbyname.
-
- // Newer XNU kernels support querying all capabilities in a single
- // sysctlbyname.
-#if defined(CAP_BIT_AdvSIMD) && defined(CAP_BIT_FEAT_AES)
- static const absl::optional<uint64_t> caps =
- ReadSysctlByName<uint64_t>("hw.optional.arm.caps");
- if (caps.has_value()) {
- constexpr uint64_t kNeonAndAesCaps =
- (uint64_t{1} << CAP_BIT_AdvSIMD) | (uint64_t{1} << CAP_BIT_FEAT_AES);
- return (*caps & kNeonAndAesCaps) == kNeonAndAesCaps;
- }
-#endif
-
- // https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics#overview
- static const absl::optional<int> adv_simd =
- ReadSysctlByName<int>("hw.optional.AdvSIMD");
- if (adv_simd.value_or(0) == 0) {
- return false;
- }
- // https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics#3918855
- static const absl::optional<int> feat_aes =
- ReadSysctlByName<int>("hw.optional.arm.FEAT_AES");
- if (feat_aes.value_or(0) == 0) {
- return false;
- }
- return true;
#else // ABSL_INTERNAL_USE_GETAUXVAL
- // 4. By default, assume that the compiler default.
+ // 3. By default, assume that the compiler default.
return ABSL_HAVE_ACCELERATED_AES ? true : false;
#endif
@@ -269,6 +215,9 @@
// __asm __volatile("mrs %0, id_aa64isar0_el1" :"=&r" (val));
//
// * Use a CPUID-style heuristic database.
+ //
+ // * On Apple (__APPLE__), AES is available on Arm v8.
+ // https://stackoverflow.com/questions/45637888/how-to-determine-armv8-features-at-runtime-on-ios
}
#if defined(__clang__)
diff --git a/absl/random/internal/randen_engine.h b/absl/random/internal/randen_engine.h
index 925e1bb..fe2d9f6 100644
--- a/absl/random/internal/randen_engine.h
+++ b/absl/random/internal/randen_engine.h
@@ -18,10 +18,9 @@
#include <algorithm>
#include <cinttypes>
#include <cstdlib>
-#include <istream>
+#include <iostream>
#include <iterator>
#include <limits>
-#include <ostream>
#include <type_traits>
#include "absl/base/internal/endian.h"
diff --git a/absl/random/internal/randen_hwaes_test.cc b/absl/random/internal/randen_hwaes_test.cc
index 0378972..00d96ef 100644
--- a/absl/random/internal/randen_hwaes_test.cc
+++ b/absl/random/internal/randen_hwaes_test.cc
@@ -89,7 +89,7 @@
LOG(INFO) << "HasRandenHwAesImplementation = " << x;
int y = absl::random_internal::CPUSupportsRandenHwAes();
- LOG(INFO) << "CPUSupportsRandenHwAes = " << y;
+ LOG(INFO) << "CPUSupportsRandenHwAes = " << x;
if (!x || !y) {
LOG(INFO) << "Skipping Randen HWAES tests.";
diff --git a/absl/random/internal/salted_seed_seq_test.cc b/absl/random/internal/salted_seed_seq_test.cc
index 6f48c61..0bf19a6 100644
--- a/absl/random/internal/salted_seed_seq_test.cc
+++ b/absl/random/internal/salted_seed_seq_test.cc
@@ -33,18 +33,14 @@
template <typename Sseq>
void ConformsToInterface() {
// Check that the SeedSequence can be default-constructed.
- {
- Sseq default_constructed_seq;
- }
+ { Sseq default_constructed_seq; }
// Check that the SeedSequence can be constructed with two iterators.
{
uint32_t init_array[] = {1, 3, 5, 7, 9};
Sseq iterator_constructed_seq(std::begin(init_array), std::end(init_array));
}
// Check that the SeedSequence can be std::initializer_list-constructed.
- {
- Sseq list_constructed_seq = {1, 3, 5, 7, 9, 11, 13};
- }
+ { Sseq list_constructed_seq = {1, 3, 5, 7, 9, 11, 13}; }
// Check that param() and size() return state provided to constructor.
{
uint32_t init_array[] = {1, 2, 3, 4, 5};
diff --git a/absl/random/internal/traits_test.cc b/absl/random/internal/traits_test.cc
index 2164582..a844887 100644
--- a/absl/random/internal/traits_test.cc
+++ b/absl/random/internal/traits_test.cc
@@ -104,11 +104,14 @@
TEST(TraitsTest, IsWideningConvertibleTest) {
constexpr bool kInvalid = false;
- CheckWideningConvertsToSelf<uint8_t, uint16_t, uint32_t, uint64_t, int8_t,
- int16_t, int32_t, int64_t, float, double>();
- CheckNotWideningConvertibleWithSigned<uint8_t, uint16_t, uint32_t,
- uint64_t>();
- CheckWideningConvertsToLargerTypes<uint8_t, uint16_t, uint32_t, uint64_t>();
+ CheckWideningConvertsToSelf<
+ uint8_t, uint16_t, uint32_t, uint64_t,
+ int8_t, int16_t, int32_t, int64_t,
+ float, double>();
+ CheckNotWideningConvertibleWithSigned<
+ uint8_t, uint16_t, uint32_t, uint64_t>();
+ CheckWideningConvertsToLargerTypes<
+ uint8_t, uint16_t, uint32_t, uint64_t>();
CheckWideningConvertsTo<float, double>();
CheckWideningConvertsTo<uint16_t, float>();
diff --git a/absl/random/internal/uniform_helper.h b/absl/random/internal/uniform_helper.h
index d230073..db737e1 100644
--- a/absl/random/internal/uniform_helper.h
+++ b/absl/random/internal/uniform_helper.h
@@ -201,8 +201,8 @@
}
template <typename IntType>
-absl::enable_if_t<IsIntegral<IntType>::value, bool> is_uniform_range_valid(
- IntType a, IntType b) {
+absl::enable_if_t<IsIntegral<IntType>::value, bool>
+is_uniform_range_valid(IntType a, IntType b) {
return a <= b;
}
diff --git a/absl/random/internal/wide_multiply.h b/absl/random/internal/wide_multiply.h
index b125681..891e363 100644
--- a/absl/random/internal/wide_multiply.h
+++ b/absl/random/internal/wide_multiply.h
@@ -75,6 +75,7 @@
c00 + (c64a << 64) + (c64b << 64)};
}
+
template <>
struct wide_multiply<uint128> {
using input_type = uint128;
diff --git a/absl/random/log_uniform_int_distribution.h b/absl/random/log_uniform_int_distribution.h
index cbd5e0c..4afff8f 100644
--- a/absl/random/log_uniform_int_distribution.h
+++ b/absl/random/log_uniform_int_distribution.h
@@ -21,8 +21,11 @@
#include <istream>
#include <limits>
#include <ostream>
+#include <type_traits>
-#include "absl/base/config.h"
+#include "absl/numeric/bits.h"
+#include "absl/random/internal/fastmath.h"
+#include "absl/random/internal/generate_real.h"
#include "absl/random/internal/iostream_state_saver.h"
#include "absl/random/internal/traits.h"
#include "absl/random/uniform_int_distribution.h"
diff --git a/absl/random/log_uniform_int_distribution_test.cc b/absl/random/log_uniform_int_distribution_test.cc
index 2530c9e..5df3eda 100644
--- a/absl/random/log_uniform_int_distribution_test.cc
+++ b/absl/random/log_uniform_int_distribution_test.cc
@@ -148,8 +148,8 @@
const auto bucket_index = [base_log, is_2, ¶m](int32_t x) {
uint64_t y = static_cast<uint64_t>(x) - param.min();
return (y == 0) ? 0
- : is_2 ? static_cast<int>(1 + std::log2(y))
- : static_cast<int>(1 + std::log(y) * base_log);
+ : is_2 ? static_cast<int>(1 + std::log2(y))
+ : static_cast<int>(1 + std::log(y) * base_log);
};
const int max_bucket = bucket_index(param.max()); // inclusive
const size_t trials = 15 + (max_bucket + 1) * 10;
diff --git a/absl/random/mock_distributions.h b/absl/random/mock_distributions.h
index 1983547..b379262 100644
--- a/absl/random/mock_distributions.h
+++ b/absl/random/mock_distributions.h
@@ -17,14 +17,14 @@
// -----------------------------------------------------------------------------
//
// This file contains mock distribution functions for use alongside an
-// `absl::MockingBitGen` object within the GoogleTest testing framework. Such
+// `absl::MockingBitGen` object within the Googletest testing framework. Such
// mocks are useful to provide deterministic values as return values within
// (otherwise random) Abseil distribution functions.
//
// The return type of each function is a mock expectation object which
// is used to set the match result.
//
-// More information about the GoogleTest testing framework is available at
+// More information about the Googletest testing framework is available at
// https://github.com/google/googletest
//
// EXPECT_CALL and ON_CALL need to be made within the same DLL component as
diff --git a/absl/random/mock_distributions_test.cc b/absl/random/mock_distributions_test.cc
index 622aff7..05e313c 100644
--- a/absl/random/mock_distributions_test.cc
+++ b/absl/random/mock_distributions_test.cc
@@ -75,7 +75,14 @@
EXPECT_EQ(absl::LogUniform<int>(gen, 0, 1000000, 2), 2040);
}
-TEST(MockDistributions, UniformUInt128BoundariesAreAllowed) {
+TEST(MockUniform, OutOfBoundsIsAllowed) {
+ absl::UnvalidatedMockingBitGen gen;
+
+ EXPECT_CALL(absl::MockUniform<int>(), Call(gen, 1, 100)).WillOnce(Return(0));
+ EXPECT_EQ(absl::Uniform<int>(gen, 1, 100), 0);
+}
+
+TEST(ValidatedMockDistributions, UniformUInt128Works) {
absl::MockingBitGen gen;
EXPECT_CALL(absl::MockUniform<absl::uint128>(), Call(gen))
@@ -83,7 +90,7 @@
EXPECT_EQ(absl::Uniform<absl::uint128>(gen), absl::Uint128Max());
}
-TEST(MockDistributions, UniformDoubleBoundaryCasesAreAllowed) {
+TEST(ValidatedMockDistributions, UniformDoubleBoundaryCases) {
absl::MockingBitGen gen;
EXPECT_CALL(absl::MockUniform<double>(), Call(gen, 1.0, 10.0))
@@ -107,7 +114,7 @@
std::nextafter(1.0, std::numeric_limits<double>::infinity()));
}
-TEST(MockDistributions, UniformDoubleEmptyRangesAllowTheBoundary) {
+TEST(ValidatedMockDistributions, UniformDoubleEmptyRangeCases) {
absl::MockingBitGen gen;
ON_CALL(absl::MockUniform<double>(), Call(absl::IntervalOpen, gen, 1.0, 1.0))
@@ -127,7 +134,7 @@
1.0);
}
-TEST(MockDistributions, UniformIntEmptyRangeCasesAllowTheBoundary) {
+TEST(ValidatedMockDistributions, UniformIntEmptyRangeCases) {
absl::MockingBitGen gen;
ON_CALL(absl::MockUniform<int>(), Call(absl::IntervalOpen, gen, 1, 1))
@@ -143,7 +150,7 @@
EXPECT_EQ(absl::Uniform<int>(absl::IntervalClosedOpen, gen, 1, 1), 1);
}
-TEST(MockUniformDeathTest, OutOfBoundsValuesAreRejected) {
+TEST(ValidatedMockUniformDeathTest, Examples) {
absl::MockingBitGen gen;
EXPECT_DEATH_IF_SUPPORTED(
@@ -245,7 +252,7 @@
" 101 is not in \\[1, 100\\]");
}
-TEST(MockUniformDeathTest, OutOfBoundsDoublesAreRejected) {
+TEST(ValidatedMockUniformDeathTest, DoubleBoundaryCases) {
absl::MockingBitGen gen;
EXPECT_DEATH_IF_SUPPORTED(
diff --git a/absl/random/mocking_bit_gen.h b/absl/random/mocking_bit_gen.h
index ba7ceae..041989d 100644
--- a/absl/random/mocking_bit_gen.h
+++ b/absl/random/mocking_bit_gen.h
@@ -17,12 +17,12 @@
// -----------------------------------------------------------------------------
//
// This file includes an `absl::MockingBitGen` class to use as a mock within the
-// GoogleTest testing framework. Such a mock is useful to provide deterministic
+// Googletest testing framework. Such a mock is useful to provide deterministic
// values as return values within (otherwise random) Abseil distribution
// functions. Such determinism within a mock is useful within testing frameworks
// to test otherwise indeterminate APIs.
//
-// More information about the GoogleTest testing framework is available at
+// More information about the Googletest testing framework is available at
// https://github.com/google/googletest
#ifndef ABSL_RANDOM_MOCKING_BIT_GEN_H_
@@ -34,6 +34,7 @@
#include <utility>
#include "gmock/gmock.h"
+#include "absl/base/attributes.h"
#include "absl/base/config.h"
#include "absl/base/internal/fast_type_id.h"
#include "absl/container/flat_hash_map.h"
@@ -51,53 +52,13 @@
template <typename>
struct DistributionCaller;
class MockHelpers;
-} // namespace random_internal
-// MockingBitGen
-//
-// `absl::MockingBitGen` is a mock Uniform Random Bit Generator (URBG) class
-// which can act in place of an `absl::BitGen` URBG within tests using the
-// GoogleTest testing framework.
-//
-// Usage:
-//
-// Use an `absl::MockingBitGen` along with a mock distribution object (within
-// mock_distributions.h) inside Googletest constructs such as ON_CALL(),
-// EXPECT_TRUE(), etc. to produce deterministic results conforming to the
-// distribution's API contract.
-//
-// Example:
-//
-// // Mock a call to an `absl::Bernoulli` distribution using Googletest
-// absl::MockingBitGen bitgen;
-//
-// ON_CALL(absl::MockBernoulli(), Call(bitgen, 0.5))
-// .WillByDefault(testing::Return(true));
-// EXPECT_TRUE(absl::Bernoulli(bitgen, 0.5));
-//
-// // Mock a call to an `absl::Uniform` distribution within Googletest
-// absl::MockingBitGen bitgen;
-//
-// ON_CALL(absl::MockUniform<int>(), Call(bitgen, testing::_, testing::_))
-// .WillByDefault([] (int low, int high) {
-// return low + (high - low) / 2;
-// });
-//
-// EXPECT_EQ(absl::Uniform<int>(gen, 0, 10), 5);
-// EXPECT_EQ(absl::Uniform<int>(gen, 30, 40), 35);
-//
-// At this time, only mock distributions supplied within the Abseil random
-// library are officially supported.
-//
-// EXPECT_CALL and ON_CALL need to be made within the same DLL component as
-// the call to absl::Uniform and related methods, otherwise mocking will fail
-// since the underlying implementation creates a type-specific pointer which
-// will be distinct across different DLL boundaries.
-//
-class MockingBitGen {
+// Implements MockingBitGen with an option to turn on extra validation.
+template <bool EnableValidation>
+class MockingBitGenImpl {
public:
- MockingBitGen() = default;
- ~MockingBitGen() = default;
+ MockingBitGenImpl() = default;
+ ~MockingBitGenImpl() = default;
// URBG interface
using result_type = absl::BitGen::result_type;
@@ -177,23 +138,25 @@
typename ValidatorT>
auto RegisterMock(SelfT&, base_internal::FastTypeIdType type, ValidatorT)
-> decltype(GetMockFnType(std::declval<ResultT>(),
- std::declval<ArgTupleT>())) & {
+ std::declval<ArgTupleT>()))& {
+ using ActualValidatorT =
+ std::conditional_t<EnableValidation, ValidatorT, NoOpValidator>;
using MockFnType = decltype(GetMockFnType(std::declval<ResultT>(),
std::declval<ArgTupleT>()));
using WrappedFnType = absl::conditional_t<
- std::is_same<SelfT, ::testing::NiceMock<MockingBitGen>>::value,
+ std::is_same<SelfT, ::testing::NiceMock<MockingBitGenImpl>>::value,
::testing::NiceMock<MockFnType>,
absl::conditional_t<
- std::is_same<SelfT, ::testing::NaggyMock<MockingBitGen>>::value,
+ std::is_same<SelfT, ::testing::NaggyMock<MockingBitGenImpl>>::value,
::testing::NaggyMock<MockFnType>,
absl::conditional_t<
std::is_same<SelfT,
- ::testing::StrictMock<MockingBitGen>>::value,
+ ::testing::StrictMock<MockingBitGenImpl>>::value,
::testing::StrictMock<MockFnType>, MockFnType>>>;
using ImplT =
- FunctionHolderImpl<WrappedFnType, ValidatorT, ResultT, ArgTupleT>;
+ FunctionHolderImpl<WrappedFnType, ActualValidatorT, ResultT, ArgTupleT>;
auto& mock = mocks_[type];
if (!mock) {
mock = absl::make_unique<ImplT>();
@@ -233,6 +196,58 @@
// InvokeMock
};
+} // namespace random_internal
+
+// MockingBitGen
+//
+// `absl::MockingBitGen` is a mock Uniform Random Bit Generator (URBG) class
+// which can act in place of an `absl::BitGen` URBG within tests using the
+// Googletest testing framework.
+//
+// Usage:
+//
+// Use an `absl::MockingBitGen` along with a mock distribution object (within
+// mock_distributions.h) inside Googletest constructs such as ON_CALL(),
+// EXPECT_TRUE(), etc. to produce deterministic results conforming to the
+// distribution's API contract.
+//
+// Example:
+//
+// // Mock a call to an `absl::Bernoulli` distribution using Googletest
+// absl::MockingBitGen bitgen;
+//
+// ON_CALL(absl::MockBernoulli(), Call(bitgen, 0.5))
+// .WillByDefault(testing::Return(true));
+// EXPECT_TRUE(absl::Bernoulli(bitgen, 0.5));
+//
+// // Mock a call to an `absl::Uniform` distribution within Googletest
+// absl::MockingBitGen bitgen;
+//
+// ON_CALL(absl::MockUniform<int>(), Call(bitgen, testing::_, testing::_))
+// .WillByDefault([] (int low, int high) {
+// return low + (high - low) / 2;
+// });
+//
+// EXPECT_EQ(absl::Uniform<int>(gen, 0, 10), 5);
+// EXPECT_EQ(absl::Uniform<int>(gen, 30, 40), 35);
+//
+// At this time, only mock distributions supplied within the Abseil random
+// library are officially supported.
+//
+// EXPECT_CALL and ON_CALL need to be made within the same DLL component as
+// the call to absl::Uniform and related methods, otherwise mocking will fail
+// since the underlying implementation creates a type-specific pointer which
+// will be distinct across different DLL boundaries.
+//
+using MockingBitGen = random_internal::MockingBitGenImpl<true>;
+
+// UnvalidatedMockingBitGen
+//
+// UnvalidatedMockingBitGen is a variant of MockingBitGen which does no extra
+// validation.
+using UnvalidatedMockingBitGen ABSL_DEPRECATED("Use MockingBitGen instead") =
+ random_internal::MockingBitGenImpl<false>;
+
ABSL_NAMESPACE_END
} // namespace absl
diff --git a/absl/random/poisson_distribution.h b/absl/random/poisson_distribution.h
index ae2e095..f457308 100644
--- a/absl/random/poisson_distribution.h
+++ b/absl/random/poisson_distribution.h
@@ -17,12 +17,11 @@
#include <cassert>
#include <cmath>
-#include <cstdint>
#include <istream>
#include <limits>
#include <ostream>
+#include <type_traits>
-#include "absl/base/config.h"
#include "absl/random/internal/fast_uniform_bits.h"
#include "absl/random/internal/fastmath.h"
#include "absl/random/internal/generate_real.h"
@@ -49,8 +48,8 @@
// the distribution results are limited to the max() value.
//
// The goals of this implementation are to provide good performance while still
-// being thread-safe: This limits the implementation to not using lgamma
-// provided by <math.h>.
+// beig thread-safe: This limits the implementation to not using lgamma provided
+// by <math.h>.
//
template <typename IntType = int>
class poisson_distribution {
diff --git a/absl/random/poisson_distribution_test.cc b/absl/random/poisson_distribution_test.cc
index 3a1d238..5475596 100644
--- a/absl/random/poisson_distribution_test.cc
+++ b/absl/random/poisson_distribution_test.cc
@@ -106,6 +106,7 @@
0.0), // denorm_max
};
+
constexpr int kCount = 1000;
absl::InsecureBitGen gen;
for (const double m : kParams) {
diff --git a/absl/random/seed_gen_exception.cc b/absl/random/seed_gen_exception.cc
index 6fb4ad3..fdcb54a 100644
--- a/absl/random/seed_gen_exception.cc
+++ b/absl/random/seed_gen_exception.cc
@@ -14,8 +14,9 @@
#include "absl/random/seed_gen_exception.h"
+#include <iostream>
+
#include "absl/base/config.h"
-#include "absl/base/internal/raw_logging.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
@@ -35,7 +36,7 @@
#ifdef ABSL_HAVE_EXCEPTIONS
throw absl::SeedGenException();
#else
- ABSL_RAW_LOG(FATAL, "%s", kExceptionMessage);
+ std::cerr << kExceptionMessage << std::endl;
std::terminate();
#endif
}
diff --git a/absl/random/seed_sequences.h b/absl/random/seed_sequences.h
index dacc5b9..33970be 100644
--- a/absl/random/seed_sequences.h
+++ b/absl/random/seed_sequences.h
@@ -80,7 +80,8 @@
//
template <typename URBG>
SeedSeq CreateSeedSeqFrom(URBG* urbg) {
- SeedSeq::result_type seed_material[random_internal::kEntropyBlocksNeeded];
+ SeedSeq::result_type
+ seed_material[random_internal::kEntropyBlocksNeeded];
if (!random_internal::ReadSeedMaterialFromURBG(
urbg, absl::MakeSpan(seed_material))) {
diff --git a/absl/random/uniform_int_distribution.h b/absl/random/uniform_int_distribution.h
index 0dc7c62..fae8025 100644
--- a/absl/random/uniform_int_distribution.h
+++ b/absl/random/uniform_int_distribution.h
@@ -31,9 +31,8 @@
#include <cassert>
#include <istream>
#include <limits>
-#include <ostream>
+#include <type_traits>
-#include "absl/base/config.h"
#include "absl/base/optimization.h"
#include "absl/random/internal/fast_uniform_bits.h"
#include "absl/random/internal/iostream_state_saver.h"
diff --git a/absl/random/uniform_int_distribution_test.cc b/absl/random/uniform_int_distribution_test.cc
index 8134ab6..b40d618 100644
--- a/absl/random/uniform_int_distribution_test.cc
+++ b/absl/random/uniform_int_distribution_test.cc
@@ -114,8 +114,8 @@
TYPED_TEST(UniformIntDistributionTest, ViolatesPreconditionsDeathTest) {
#if GTEST_HAS_DEATH_TEST
// Hi < Lo
- EXPECT_DEBUG_DEATH(
- { absl::uniform_int_distribution<TypeParam> dist(10, 1); }, "");
+ EXPECT_DEBUG_DEATH({ absl::uniform_int_distribution<TypeParam> dist(10, 1); },
+ "");
#endif // GTEST_HAS_DEATH_TEST
#if defined(NDEBUG)
// opt-mode, for invalid parameters, will generate a garbage value,
diff --git a/absl/random/uniform_real_distribution.h b/absl/random/uniform_real_distribution.h
index 8bef946..1968334 100644
--- a/absl/random/uniform_real_distribution.h
+++ b/absl/random/uniform_real_distribution.h
@@ -37,10 +37,8 @@
#include <cstdint>
#include <istream>
#include <limits>
-#include <ostream>
#include <type_traits>
-#include "absl/base/config.h"
#include "absl/meta/type_traits.h"
#include "absl/random/internal/fast_uniform_bits.h"
#include "absl/random/internal/generate_real.h"
diff --git a/absl/random/uniform_real_distribution_test.cc b/absl/random/uniform_real_distribution_test.cc
index 4d544ca..260aac9 100644
--- a/absl/random/uniform_real_distribution_test.cc
+++ b/absl/random/uniform_real_distribution_test.cc
@@ -190,7 +190,7 @@
#ifdef _MSC_VER
#pragma warning(push)
-#pragma warning(disable : 4756) // Constant arithmetic overflow.
+#pragma warning(disable:4756) // Constant arithmetic overflow.
#endif
TYPED_TEST(UniformRealDistributionTest, ViolatesPreconditionsDeathTest) {
using DistributionType = absl::uniform_real_distribution<TypeParam>;
diff --git a/absl/random/zipf_distribution.h b/absl/random/zipf_distribution.h
index 21e3b70..03497b1 100644
--- a/absl/random/zipf_distribution.h
+++ b/absl/random/zipf_distribution.h
@@ -22,7 +22,6 @@
#include <ostream>
#include <type_traits>
-#include "absl/base/config.h"
#include "absl/random/internal/iostream_state_saver.h"
#include "absl/random/internal/traits.h"
#include "absl/random/uniform_real_distribution.h"
@@ -58,8 +57,8 @@
public:
using distribution_type = zipf_distribution;
- // Preconditions: k >= 0, v > 0, q > 1
- // The preconditions are validated when NDEBUG is not defined via
+ // Preconditions: k > 0, v > 0, q > 1
+ // The precondidtions are validated when NDEBUG is not defined via
// a pair of assert() directives.
// If NDEBUG is defined and either or both of these parameters take invalid
// values, the behavior of the class is undefined.
@@ -153,7 +152,7 @@
: k_(k), q_(q), v_(v), one_minus_q_(1 - q) {
assert(q > 1);
assert(v > 0);
- assert(k >= 0);
+ assert(k > 0);
one_minus_q_inv_ = 1 / one_minus_q_;
// Setup for the ZRI algorithm (pg 17 of the paper).
@@ -222,7 +221,7 @@
const double v = uniform_double(g);
const double u = p.hxm_ + v * p.hx0_minus_hxm_;
const double x = p.hinv(u);
- k = rint(x); // std::floor(x + 0.5);
+ k = rint(x); // std::floor(x + 0.5);
if (k > static_cast<double>(p.k())) continue; // reject k > max_k
if (k - x <= p.s_) break;
const double h = p.h(k + 0.5);
diff --git a/absl/random/zipf_distribution_test.cc b/absl/random/zipf_distribution_test.cc
index 71548ca..801ec4f 100644
--- a/absl/random/zipf_distribution_test.cc
+++ b/absl/random/zipf_distribution_test.cc
@@ -176,15 +176,15 @@
const double x = v_ + i;
// H(n, q-1)
- const double hnqm1 = (q_ == 2.0) ? (1.0 / x)
- : (q_ == 3.0) ? (1.0 / (x * x))
- : std::pow(x, -qm1);
+ const double hnqm1 =
+ (q_ == 2.0) ? (1.0 / x)
+ : (q_ == 3.0) ? (1.0 / (x * x)) : std::pow(x, -qm1);
sum_hnq_m1 += hnqm1;
// H(n, q)
- const double hnq = (q_ == 2.0) ? (1.0 / (x * x))
- : (q_ == 3.0) ? (1.0 / (x * x * x))
- : std::pow(x, -q_);
+ const double hnq =
+ (q_ == 2.0) ? (1.0 / (x * x))
+ : (q_ == 3.0) ? (1.0 / (x * x * x)) : std::pow(x, -q_);
sum_hnq_ += hnq;
hnq_.push_back(hnq);
if (i > 1000 && hnq <= 1e-10) {
diff --git a/absl/status/BUILD.bazel b/absl/status/BUILD.bazel
index b0eb27a..8822e0f 100644
--- a/absl/status/BUILD.bazel
+++ b/absl/status/BUILD.bazel
@@ -58,7 +58,6 @@
"//absl/base:raw_logging_internal",
"//absl/base:strerror",
"//absl/container:inlined_vector",
- "//absl/debugging:leak_check",
"//absl/debugging:stacktrace",
"//absl/debugging:symbolize",
"//absl/functional:function_ref",
@@ -81,8 +80,8 @@
"//absl/strings",
"//absl/strings:cord",
"//absl/strings:str_format",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -127,8 +126,8 @@
"//absl/types:any",
"//absl/types:variant",
"//absl/utility",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -147,7 +146,7 @@
":statusor",
"//absl/base:config",
"//absl/strings:string_view",
- "@googletest//:gtest",
+ "@com_google_googletest//:gtest",
],
)
@@ -162,7 +161,7 @@
":status_matchers",
":statusor",
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
diff --git a/absl/status/CMakeLists.txt b/absl/status/CMakeLists.txt
index e140365..24c01e7 100644
--- a/absl/status/CMakeLists.txt
+++ b/absl/status/CMakeLists.txt
@@ -35,7 +35,6 @@
absl::core_headers
absl::function_ref
absl::inlined_vector
- absl::leak_check
absl::memory
absl::no_destructor
absl::nullability
@@ -43,8 +42,8 @@
absl::raw_logging_internal
absl::span
absl::stacktrace
- absl::str_format
absl::strerror
+ absl::str_format
absl::strings
absl::symbolize
PUBLIC
diff --git a/absl/status/internal/status_internal.cc b/absl/status/internal/status_internal.cc
index 99bf8fa..a915675 100644
--- a/absl/status/internal/status_internal.cc
+++ b/absl/status/internal/status_internal.cc
@@ -28,7 +28,6 @@
#include "absl/base/config.h"
#include "absl/base/macros.h"
#include "absl/base/nullability.h"
-#include "absl/debugging/leak_check.h"
#include "absl/debugging/stacktrace.h"
#include "absl/debugging/symbolize.h"
#include "absl/memory/memory.h"
@@ -235,15 +234,12 @@
}
}
-absl::Nonnull<const char*> MakeCheckFailString(
+absl::Nonnull<std::string*> MakeCheckFailString(
absl::Nonnull<const absl::Status*> status,
absl::Nonnull<const char*> prefix) {
- // There's no need to free this string since the process is crashing.
- return absl::IgnoreLeak(
- new std::string(absl::StrCat(
- prefix, " (",
- status->ToString(StatusToStringMode::kWithEverything), ")")))
- ->c_str();
+ return new std::string(
+ absl::StrCat(prefix, " (",
+ status->ToString(StatusToStringMode::kWithEverything), ")"));
}
} // namespace status_internal
diff --git a/absl/status/internal/status_internal.h b/absl/status/internal/status_internal.h
index fe335b0..c9f4383 100644
--- a/absl/status/internal/status_internal.h
+++ b/absl/status/internal/status_internal.h
@@ -120,7 +120,7 @@
//
// This is an internal implementation detail for Abseil logging.
ABSL_ATTRIBUTE_PURE_FUNCTION
-absl::Nonnull<const char*> MakeCheckFailString(
+absl::Nonnull<std::string*> MakeCheckFailString(
absl::Nonnull<const absl::Status*> status,
absl::Nonnull<const char*> prefix);
diff --git a/absl/status/status.h b/absl/status/status.h
index 02fd296..6cfe49f 100644
--- a/absl/status/status.h
+++ b/absl/status/status.h
@@ -649,7 +649,7 @@
// Converts between StatusRep* and the external uintptr_t representation used
// by rep_. See rep_ for details.
- static uintptr_t PointerToRep(absl::Nonnull<status_internal::StatusRep*> r);
+ static uintptr_t PointerToRep(status_internal::StatusRep* r);
static absl::Nonnull<const status_internal::StatusRep*> RepToPointer(
uintptr_t r);
diff --git a/absl/strings/BUILD.bazel b/absl/strings/BUILD.bazel
index 81b8d89..2cc014e 100644
--- a/absl/strings/BUILD.bazel
+++ b/absl/strings/BUILD.bazel
@@ -146,8 +146,8 @@
visibility = ["//visibility:private"],
deps = [
":strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -166,8 +166,8 @@
"//absl/base:core_headers",
"//absl/container:fixed_array",
"//absl/log:check",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -183,8 +183,8 @@
deps = [
":strings",
"//absl/base:raw_logging_internal",
- "@google_benchmark//:benchmark_main",
- "@googletest//:gtest",
+ "@com_github_google_benchmark//:benchmark_main",
+ "@com_google_googletest//:gtest",
],
)
@@ -197,8 +197,8 @@
deps = [
":strings",
"//absl/types:optional",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -221,8 +221,8 @@
deps = [
":has_ostream_operator",
"//absl/types:optional",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -235,8 +235,8 @@
deps = [
":strings",
"//absl/base:core_headers",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -248,8 +248,8 @@
visibility = ["//visibility:private"],
deps = [
":strings",
- "@google_benchmark//:benchmark_main",
- "@googletest//:gtest",
+ "@com_github_google_benchmark//:benchmark_main",
+ "@com_google_googletest//:gtest",
],
)
@@ -262,8 +262,8 @@
copts = ABSL_TEST_COPTS,
deps = [
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -279,8 +279,8 @@
deps = [
":strings",
"//absl/base:core_headers",
- "@google_benchmark//:benchmark_main",
- "@googletest//:gtest",
+ "@com_github_google_benchmark//:benchmark_main",
+ "@com_google_googletest//:gtest",
],
)
@@ -296,8 +296,8 @@
deps = [
":strings",
"//absl/base:core_headers",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -312,8 +312,8 @@
deps = [
":internal",
"//absl/base:core_headers",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -326,8 +326,8 @@
deps = [
":strings",
"//absl/meta:type_traits",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -342,8 +342,8 @@
":strings",
"//absl/base:core_headers",
"//absl/base:raw_logging_internal",
- "@google_benchmark//:benchmark_main",
- "@googletest//:gtest",
+ "@com_github_google_benchmark//:benchmark_main",
+ "@com_google_googletest//:gtest",
],
)
@@ -359,8 +359,8 @@
"//absl/base:core_headers",
"//absl/base:dynamic_annotations",
"//absl/meta:type_traits",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -378,8 +378,8 @@
deps = [
":charset",
"//absl/log:check",
- "@google_benchmark//:benchmark_main",
- "@googletest//:gtest",
+ "@com_github_google_benchmark//:benchmark_main",
+ "@com_google_googletest//:gtest",
],
)
@@ -392,7 +392,7 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":string_view",
- "//absl/base:config",
+ "//absl/base:core_headers",
],
)
@@ -405,8 +405,8 @@
deps = [
":charset",
":strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -441,13 +441,15 @@
"//absl/base:config",
"//absl/base:core_headers",
"//absl/base:endian",
- "//absl/base:nullability",
"//absl/base:raw_logging_internal",
+ "//absl/base:throw_delegate",
"//absl/container:compressed_tuple",
"//absl/container:container_memory",
"//absl/container:inlined_vector",
+ "//absl/container:layout",
"//absl/crc:crc_cord_state",
"//absl/functional:function_ref",
+ "//absl/meta:type_traits",
"//absl/types:span",
],
)
@@ -463,8 +465,8 @@
":cord_rep_test_util",
":strings",
"//absl/base:config",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -482,8 +484,8 @@
"//absl/base:config",
"//absl/base:raw_logging_internal",
"//absl/cleanup",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -499,8 +501,8 @@
":strings",
"//absl/base:config",
"//absl/base:raw_logging_internal",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -517,8 +519,8 @@
":strings",
"//absl/base:config",
"//absl/base:raw_logging_internal",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -533,8 +535,8 @@
":cord_rep_test_util",
"//absl/base:config",
"//absl/crc:crc_cord_state",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -557,8 +559,8 @@
"//absl/base:config",
"//absl/base:core_headers",
"//absl/synchronization",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -578,11 +580,14 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":cord_internal",
+ ":cordz_functions",
":cordz_info",
+ ":cordz_statistics",
":cordz_update_scope",
":cordz_update_tracker",
":internal",
":strings",
+ "//absl/base",
"//absl/base:config",
"//absl/base:core_headers",
"//absl/base:endian",
@@ -672,8 +677,8 @@
":cordz_update_scope",
":cordz_update_tracker",
"//absl/base:config",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -733,8 +738,8 @@
":cordz_functions",
":cordz_test_helpers",
"//absl/base:config",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -752,8 +757,8 @@
"//absl/synchronization",
"//absl/synchronization:thread_pool",
"//absl/time",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -774,8 +779,8 @@
"//absl/debugging:stacktrace",
"//absl/debugging:symbolize",
"//absl/types:span",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -796,8 +801,8 @@
"//absl/crc:crc_cord_state",
"//absl/synchronization",
"//absl/synchronization:thread_pool",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -818,8 +823,8 @@
"//absl/synchronization",
"//absl/synchronization:thread_pool",
"//absl/time",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -870,7 +875,7 @@
"//absl/base:config",
"//absl/base:core_headers",
"//absl/base:nullability",
- "@googletest//:gtest",
+ "@com_google_googletest//:gtest",
],
)
@@ -887,8 +892,8 @@
":string_view",
"//absl/base:config",
"//absl/types:span",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -922,8 +927,8 @@
"//absl/random",
"//absl/types:compare",
"//absl/types:optional",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -956,8 +961,8 @@
"//absl/base:config",
"//absl/base:core_headers",
"//absl/base:raw_logging_internal",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -970,8 +975,8 @@
deps = [
":strings",
"//absl/base:core_headers",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -984,8 +989,8 @@
deps = [
":strings",
"//absl/base:raw_logging_internal",
- "@google_benchmark//:benchmark_main",
- "@googletest//:gtest",
+ "@com_github_google_benchmark//:benchmark_main",
+ "@com_google_googletest//:gtest",
],
)
@@ -997,8 +1002,8 @@
visibility = ["//visibility:private"],
deps = [
":strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -1014,8 +1019,8 @@
"//absl/container:btree",
"//absl/container:flat_hash_map",
"//absl/container:node_hash_map",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -1028,8 +1033,8 @@
deps = [
":strings",
"//absl/base:raw_logging_internal",
- "@google_benchmark//:benchmark_main",
- "@googletest//:gtest",
+ "@com_github_google_benchmark//:benchmark_main",
+ "@com_google_googletest//:gtest",
],
)
@@ -1041,8 +1046,8 @@
visibility = ["//visibility:private"],
deps = [
":internal",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -1054,8 +1059,8 @@
visibility = ["//visibility:private"],
deps = [
":internal",
- "@google_benchmark//:benchmark_main",
- "@googletest//:gtest",
+ "@com_github_google_benchmark//:benchmark_main",
+ "@com_google_googletest//:gtest",
],
)
@@ -1071,8 +1076,8 @@
deps = [
"//absl/base:core_headers",
"//absl/meta:type_traits",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -1086,8 +1091,8 @@
":strings",
"//absl/base:core_headers",
"//absl/memory",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -1099,8 +1104,8 @@
visibility = ["//visibility:private"],
deps = [
":strings",
- "@google_benchmark//:benchmark_main",
- "@googletest//:gtest",
+ "@com_github_google_benchmark//:benchmark_main",
+ "@com_google_googletest//:gtest",
],
)
@@ -1113,9 +1118,8 @@
deps = [
":str_format",
":strings",
- "//absl/base:config",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -1129,8 +1133,8 @@
":strings",
"//absl/random",
"//absl/random:distributions",
- "@google_benchmark//:benchmark_main",
- "@googletest//:gtest",
+ "@com_github_google_benchmark//:benchmark_main",
+ "@com_google_googletest//:gtest",
],
)
@@ -1152,8 +1156,8 @@
"//absl/numeric:int128",
"//absl/random",
"//absl/random:distributions",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -1168,8 +1172,8 @@
"//absl/base:raw_logging_internal",
"//absl/random",
"//absl/random:distributions",
- "@google_benchmark//:benchmark_main",
- "@googletest//:gtest",
+ "@com_github_google_benchmark//:benchmark_main",
+ "@com_google_googletest//:gtest",
],
)
@@ -1181,8 +1185,8 @@
visibility = ["//visibility:private"],
deps = [
":strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -1194,8 +1198,8 @@
":pow10_helper",
":str_format",
":strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -1210,8 +1214,8 @@
":strings",
"//absl/base:config",
"//absl/log:check",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -1226,8 +1230,8 @@
deps = [
":strings",
"//absl/base:config",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -1241,8 +1245,8 @@
],
deps = [
":strings",
- "@google_benchmark//:benchmark_main",
- "@googletest//:gtest",
+ "@com_github_google_benchmark//:benchmark_main",
+ "@com_google_googletest//:gtest",
],
)
@@ -1315,8 +1319,8 @@
"//absl/base:config",
"//absl/base:core_headers",
"//absl/types:span",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -1331,8 +1335,8 @@
":str_format",
":str_format_internal",
":strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -1345,8 +1349,8 @@
":str_format",
":str_format_internal",
"//absl/base:config",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -1357,8 +1361,8 @@
visibility = ["//visibility:private"],
deps = [
":str_format_internal",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -1369,8 +1373,8 @@
visibility = ["//visibility:private"],
deps = [
":str_format",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -1392,8 +1396,8 @@
"//absl/numeric:int128",
"//absl/types:optional",
"//absl/types:span",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -1405,8 +1409,8 @@
deps = [
":cord",
":str_format_internal",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -1420,8 +1424,8 @@
":string_view",
"//absl/base:config",
"//absl/base:core_headers",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -1443,8 +1447,8 @@
deps = [
":pow10_helper",
":str_format",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -1471,7 +1475,7 @@
deps = [
":str_format",
":strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
diff --git a/absl/strings/CMakeLists.txt b/absl/strings/CMakeLists.txt
index 993d751..3a1619e 100644
--- a/absl/strings/CMakeLists.txt
+++ b/absl/strings/CMakeLists.txt
@@ -100,7 +100,7 @@
COPTS
${ABSL_DEFAULT_COPTS}
DEPS
- absl::config
+ absl::core_headers
absl::string_view
PUBLIC
)
@@ -371,7 +371,6 @@
DEPS
absl::strings
absl::str_format
- absl::config
absl::core_headers
GTest::gmock_main
)
diff --git a/absl/strings/ascii.cc b/absl/strings/ascii.cc
index d15e424..20a696a 100644
--- a/absl/strings/ascii.cc
+++ b/absl/strings/ascii.cc
@@ -19,8 +19,10 @@
#include <cstring>
#include <string>
+#include "absl/base/attributes.h"
#include "absl/base/config.h"
#include "absl/base/nullability.h"
+#include "absl/base/optimization.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
@@ -175,17 +177,10 @@
return static_cast<signed char>(u) < threshold;
}
+// Force-inline so the compiler won't merge the short and long implementations.
template <bool ToUpper>
-constexpr bool AsciiInAZRangeNaive(unsigned char c) {
- constexpr unsigned char a = (ToUpper ? 'a' : 'A');
- constexpr unsigned char z = (ToUpper ? 'z' : 'Z');
- return a <= c && c <= z;
-}
-
-template <bool ToUpper, bool Naive>
-constexpr void AsciiStrCaseFoldImpl(absl::Nonnull<char*> dst,
- absl::Nullable<const char*> src,
- size_t size) {
+ABSL_ATTRIBUTE_ALWAYS_INLINE inline constexpr void AsciiStrCaseFoldImpl(
+ absl::Nonnull<char*> p, size_t size) {
// The upper- and lowercase versions of ASCII characters differ by only 1 bit.
// When we need to flip the case, we can xor with this bit to achieve the
// desired result. Note that the choice of 'a' and 'A' here is arbitrary. We
@@ -194,37 +189,29 @@
constexpr unsigned char kAsciiCaseBitFlip = 'a' ^ 'A';
for (size_t i = 0; i < size; ++i) {
- unsigned char v = static_cast<unsigned char>(src[i]);
- if ABSL_INTERNAL_CONSTEXPR_SINCE_CXX17 (Naive) {
- v ^= AsciiInAZRangeNaive<ToUpper>(v) ? kAsciiCaseBitFlip : 0;
- } else {
- v ^= AsciiInAZRange<ToUpper>(v) ? kAsciiCaseBitFlip : 0;
- }
- dst[i] = static_cast<char>(v);
+ unsigned char v = static_cast<unsigned char>(p[i]);
+ v ^= AsciiInAZRange<ToUpper>(v) ? kAsciiCaseBitFlip : 0;
+ p[i] = static_cast<char>(v);
}
}
+// The string size threshold for starting using the long string version.
+constexpr size_t kCaseFoldThreshold = 16;
+
+// No-inline so the compiler won't merge the short and long implementations.
+template <bool ToUpper>
+ABSL_ATTRIBUTE_NOINLINE constexpr void AsciiStrCaseFoldLong(
+ absl::Nonnull<char*> p, size_t size) {
+ ABSL_ASSUME(size >= kCaseFoldThreshold);
+ AsciiStrCaseFoldImpl<ToUpper>(p, size);
+}
+
// Splitting to short and long strings to allow vectorization decisions
// to be made separately in the long and short cases.
-// Using slightly different implementations so the compiler won't optimize them
-// into the same code (the non-naive version is needed for SIMD, so for short
-// strings it's not important).
-// `src` may be null iff `size` is zero.
template <bool ToUpper>
-constexpr void AsciiStrCaseFold(absl::Nonnull<char*> dst,
- absl::Nullable<const char*> src, size_t size) {
- size < 16 ? AsciiStrCaseFoldImpl<ToUpper, /*Naive=*/true>(dst, src, size)
- : AsciiStrCaseFoldImpl<ToUpper, /*Naive=*/false>(dst, src, size);
-}
-
-void AsciiStrToLower(absl::Nonnull<char*> dst, absl::Nullable<const char*> src,
- size_t n) {
- return AsciiStrCaseFold<false>(dst, src, n);
-}
-
-void AsciiStrToUpper(absl::Nonnull<char*> dst, absl::Nullable<const char*> src,
- size_t n) {
- return AsciiStrCaseFold<true>(dst, src, n);
+constexpr void AsciiStrCaseFold(absl::Nonnull<char*> p, size_t size) {
+ size < kCaseFoldThreshold ? AsciiStrCaseFoldImpl<ToUpper>(p, size)
+ : AsciiStrCaseFoldLong<ToUpper>(p, size);
}
static constexpr size_t ValidateAsciiCasefold() {
@@ -235,8 +222,8 @@
for (unsigned int i = 0; i < num_chars; ++i) {
uppered[i] = lowered[i] = static_cast<char>(i);
}
- AsciiStrCaseFold<false>(&lowered[0], &lowered[0], num_chars);
- AsciiStrCaseFold<true>(&uppered[0], &uppered[0], num_chars);
+ AsciiStrCaseFold<false>(&lowered[0], num_chars);
+ AsciiStrCaseFold<true>(&uppered[0], num_chars);
for (size_t i = 0; i < num_chars; ++i) {
const char ch = static_cast<char>(i),
ch_upper = ('a' <= ch && ch <= 'z' ? 'A' + (ch - 'a') : ch),
@@ -254,13 +241,11 @@
} // namespace ascii_internal
void AsciiStrToLower(absl::Nonnull<std::string*> s) {
- char* p = &(*s)[0];
- return ascii_internal::AsciiStrCaseFold<false>(p, p, s->size());
+ return ascii_internal::AsciiStrCaseFold<false>(&(*s)[0], s->size());
}
void AsciiStrToUpper(absl::Nonnull<std::string*> s) {
- char* p = &(*s)[0];
- return ascii_internal::AsciiStrCaseFold<true>(p, p, s->size());
+ return ascii_internal::AsciiStrCaseFold<true>(&(*s)[0], s->size());
}
void RemoveExtraAsciiWhitespace(absl::Nonnull<std::string*> str) {
diff --git a/absl/strings/ascii.h b/absl/strings/ascii.h
index d9317eb..c238f4d 100644
--- a/absl/strings/ascii.h
+++ b/absl/strings/ascii.h
@@ -55,12 +55,10 @@
#include <algorithm>
#include <cstddef>
#include <string>
-#include <utility>
#include "absl/base/attributes.h"
#include "absl/base/config.h"
#include "absl/base/nullability.h"
-#include "absl/strings/internal/resize_uninitialized.h"
#include "absl/strings/string_view.h"
namespace absl {
@@ -76,12 +74,6 @@
// Declaration for the array of characters to lower-case characters.
ABSL_DLL extern const char kToLower[256];
-void AsciiStrToLower(absl::Nonnull<char*> dst, absl::Nullable<const char*> src,
- size_t n);
-
-void AsciiStrToUpper(absl::Nonnull<char*> dst, absl::Nullable<const char*> src,
- size_t n);
-
} // namespace ascii_internal
// ascii_isalpha()
@@ -139,42 +131,32 @@
//
// Determines whether the given character can be represented as a decimal
// digit character (i.e. {0-9}).
-inline constexpr bool ascii_isdigit(unsigned char c) {
- return c >= '0' && c <= '9';
-}
+inline bool ascii_isdigit(unsigned char c) { return c >= '0' && c <= '9'; }
// ascii_isprint()
//
// Determines whether the given character is printable, including spaces.
-inline constexpr bool ascii_isprint(unsigned char c) {
- return c >= 32 && c < 127;
-}
+inline bool ascii_isprint(unsigned char c) { return c >= 32 && c < 127; }
// ascii_isgraph()
//
// Determines whether the given character has a graphical representation.
-inline constexpr bool ascii_isgraph(unsigned char c) {
- return c > 32 && c < 127;
-}
+inline bool ascii_isgraph(unsigned char c) { return c > 32 && c < 127; }
// ascii_isupper()
//
// Determines whether the given character is uppercase.
-inline constexpr bool ascii_isupper(unsigned char c) {
- return c >= 'A' && c <= 'Z';
-}
+inline bool ascii_isupper(unsigned char c) { return c >= 'A' && c <= 'Z'; }
// ascii_islower()
//
// Determines whether the given character is lowercase.
-inline constexpr bool ascii_islower(unsigned char c) {
- return c >= 'a' && c <= 'z';
-}
+inline bool ascii_islower(unsigned char c) { return c >= 'a' && c <= 'z'; }
// ascii_isascii()
//
// Determines whether the given character is ASCII.
-inline constexpr bool ascii_isascii(unsigned char c) { return c < 128; }
+inline bool ascii_isascii(unsigned char c) { return c < 128; }
// ascii_tolower()
//
@@ -189,18 +171,7 @@
// 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;
- strings_internal::STLStringResizeUninitialized(&result, s.size());
- ascii_internal::AsciiStrToLower(&result[0], s.data(), s.size());
- return result;
-}
-
-// Creates a lowercase string from a given std::string&&.
-//
-// (Template is used to lower priority of this overload.)
-template <int&... DoNotSpecify>
-ABSL_MUST_USE_RESULT inline std::string AsciiStrToLower(std::string&& s) {
- std::string result = std::move(s);
+ std::string result(s);
absl::AsciiStrToLower(&result);
return result;
}
@@ -218,18 +189,7 @@
// 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;
- strings_internal::STLStringResizeUninitialized(&result, s.size());
- ascii_internal::AsciiStrToUpper(&result[0], s.data(), s.size());
- return result;
-}
-
-// Creates an uppercase string from a given std::string&&.
-//
-// (Template is used to lower priority of this overload.)
-template <int&... DoNotSpecify>
-ABSL_MUST_USE_RESULT inline std::string AsciiStrToUpper(std::string&& s) {
- std::string result = std::move(s);
+ std::string result(s);
absl::AsciiStrToUpper(&result);
return result;
}
diff --git a/absl/strings/ascii_benchmark.cc b/absl/strings/ascii_benchmark.cc
index e4d0196..4ae7317 100644
--- a/absl/strings/ascii_benchmark.cc
+++ b/absl/strings/ascii_benchmark.cc
@@ -102,7 +102,7 @@
BENCHMARK_TEMPLATE(BM_Ascii, absl::ascii_toupper);
static void BM_StrToLower(benchmark::State& state) {
- const size_t size = static_cast<size_t>(state.range(0));
+ const int size = state.range(0);
std::string s(size, 'X');
for (auto _ : state) {
benchmark::DoNotOptimize(s);
@@ -116,7 +116,7 @@
->Range(64, 1 << 26);
static void BM_StrToUpper(benchmark::State& state) {
- const size_t size = static_cast<size_t>(state.range(0));
+ const int size = state.range(0);
std::string s(size, 'x');
for (auto _ : state) {
benchmark::DoNotOptimize(s);
@@ -129,32 +129,4 @@
->RangeMultiplier(2)
->Range(64, 1 << 26);
-static void BM_StrToUpperFromRvalref(benchmark::State& state) {
- const size_t size = static_cast<size_t>(state.range(0));
- std::string s(size, 'X');
- for (auto _ : state) {
- benchmark::DoNotOptimize(s);
- std::string res = absl::AsciiStrToUpper(std::string(s));
- benchmark::DoNotOptimize(res);
- }
-}
-BENCHMARK(BM_StrToUpperFromRvalref)
- ->DenseRange(0, 32)
- ->RangeMultiplier(2)
- ->Range(64, 1 << 26);
-
-static void BM_StrToLowerFromRvalref(benchmark::State& state) {
- const size_t size = static_cast<size_t>(state.range(0));
- std::string s(size, 'x');
- for (auto _ : state) {
- benchmark::DoNotOptimize(s);
- std::string res = absl::AsciiStrToLower(std::string(s));
- benchmark::DoNotOptimize(res);
- }
-}
-BENCHMARK(BM_StrToLowerFromRvalref)
- ->DenseRange(0, 32)
- ->RangeMultiplier(2)
- ->Range(64, 1 << 26);
-
} // namespace
diff --git a/absl/strings/ascii_test.cc b/absl/strings/ascii_test.cc
index fe1083a..8885bb1 100644
--- a/absl/strings/ascii_test.cc
+++ b/absl/strings/ascii_test.cc
@@ -192,17 +192,11 @@
const absl::string_view sp(str2);
const std::string long_str("ABCDEFGHIJKLMNOPQRSTUVWXYZ1!a");
std::string mutable_str("_`?@[{AMNOPQRSTUVWXYZ");
- auto fun = []() -> std::string { return "PQRSTU"; };
EXPECT_EQ("abcdef", absl::AsciiStrToLower(buf));
EXPECT_EQ("ghijkl", absl::AsciiStrToLower(str));
EXPECT_EQ("mnopqr", absl::AsciiStrToLower(sp));
EXPECT_EQ("abcdefghijklmnopqrstuvwxyz1!a", absl::AsciiStrToLower(long_str));
- EXPECT_EQ("pqrstu", absl::AsciiStrToLower(fun()));
-
- // An empty `string_view` specifically exercises the case where a null data
- // pointer is passed to internal functions.
- EXPECT_EQ("", absl::AsciiStrToLower(absl::string_view()));
absl::AsciiStrToLower(&mutable_str);
EXPECT_EQ("_`?@[{amnopqrstuvwxyz", mutable_str);
@@ -219,17 +213,11 @@
const std::string str2("_`?@[{amnopqrstuvwxyz");
const absl::string_view sp(str2);
const std::string long_str("abcdefghijklmnopqrstuvwxyz1!A");
- auto fun = []() -> std::string { return "pqrstu"; };
EXPECT_EQ("ABCDEF", absl::AsciiStrToUpper(buf));
EXPECT_EQ("GHIJKL", absl::AsciiStrToUpper(str));
EXPECT_EQ("_`?@[{AMNOPQRSTUVWXYZ", absl::AsciiStrToUpper(sp));
EXPECT_EQ("ABCDEFGHIJKLMNOPQRSTUVWXYZ1!A", absl::AsciiStrToUpper(long_str));
- EXPECT_EQ("PQRSTU", absl::AsciiStrToUpper(fun()));
-
- // An empty `string_view` specifically exercises the case where a null data
- // pointer is passed to internal functions.
- EXPECT_EQ("", absl::AsciiStrToUpper(absl::string_view()));
char mutable_buf[] = "Mutable";
std::transform(mutable_buf, mutable_buf + strlen(mutable_buf),
diff --git a/absl/strings/charconv.cc b/absl/strings/charconv.cc
index 66c12cc..0c9227f 100644
--- a/absl/strings/charconv.cc
+++ b/absl/strings/charconv.cc
@@ -359,13 +359,16 @@
bool HandleEdgeCase(const strings_internal::ParsedFloat& input, bool negative,
absl::Nonnull<FloatType*> value) {
if (input.type == strings_internal::FloatType::kNan) {
- // A bug in gcc would cause the compiler to optimize away the buffer we are
- // building below. Declaring the buffer volatile avoids the issue, and has
- // no measurable performance impact in microbenchmarks.
+ // A bug in both clang < 7 and gcc would cause the compiler to optimize
+ // away the buffer we are building below. Declaring the buffer volatile
+ // avoids the issue, and has no measurable performance impact in
+ // microbenchmarks.
//
+ // https://bugs.llvm.org/show_bug.cgi?id=37778
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86113
constexpr ptrdiff_t kNanBufferSize = 128;
-#if (defined(__GNUC__) && !defined(__clang__))
+#if (defined(__GNUC__) && !defined(__clang__)) || \
+ (defined(__clang__) && __clang_major__ < 7)
volatile char n_char_sequence[kNanBufferSize];
#else
char n_char_sequence[kNanBufferSize];
diff --git a/absl/strings/charset.h b/absl/strings/charset.h
index 04ad459..ff4e81a 100644
--- a/absl/strings/charset.h
+++ b/absl/strings/charset.h
@@ -46,13 +46,15 @@
#ifndef ABSL_STRINGS_CHARSET_H_
#define ABSL_STRINGS_CHARSET_H_
+#include <cstddef>
#include <cstdint>
+#include <cstring>
-#include "absl/base/config.h"
+#include "absl/base/macros.h"
+#include "absl/base/port.h"
#include "absl/strings/string_view.h"
namespace absl {
-ABSL_NAMESPACE_BEGIN
class CharSet {
public:
@@ -157,7 +159,6 @@
uint64_t m_[4];
};
-ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_STRINGS_CHARSET_H_
diff --git a/absl/strings/cord.h b/absl/strings/cord.h
index 1f8aafb..69aa8ef 100644
--- a/absl/strings/cord.h
+++ b/absl/strings/cord.h
@@ -61,7 +61,6 @@
#define ABSL_STRINGS_CORD_H_
#include <algorithm>
-#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstring>
@@ -69,14 +68,16 @@
#include <iterator>
#include <string>
#include <type_traits>
-#include <utility>
#include "absl/base/attributes.h"
#include "absl/base/config.h"
#include "absl/base/internal/endian.h"
+#include "absl/base/internal/per_thread_tls.h"
#include "absl/base/macros.h"
#include "absl/base/nullability.h"
#include "absl/base/optimization.h"
+#include "absl/base/port.h"
+#include "absl/container/inlined_vector.h"
#include "absl/crc/internal/crc_cord_state.h"
#include "absl/functional/function_ref.h"
#include "absl/meta/type_traits.h"
@@ -87,10 +88,12 @@
#include "absl/strings/internal/cord_rep_btree.h"
#include "absl/strings/internal/cord_rep_btree_reader.h"
#include "absl/strings/internal/cord_rep_crc.h"
-#include "absl/strings/internal/cord_rep_flat.h"
+#include "absl/strings/internal/cordz_functions.h"
#include "absl/strings/internal/cordz_info.h"
+#include "absl/strings/internal/cordz_statistics.h"
#include "absl/strings/internal/cordz_update_scope.h"
#include "absl/strings/internal/cordz_update_tracker.h"
+#include "absl/strings/internal/resize_uninitialized.h"
#include "absl/strings/internal/string_constant.h"
#include "absl/strings/string_view.h"
#include "absl/types/compare.h"
@@ -638,6 +641,7 @@
bool operator==(const CharIterator& other) const;
bool operator!=(const CharIterator& other) const;
reference operator*() const;
+ pointer operator->() const;
friend Cord;
@@ -975,9 +979,15 @@
bool IsSame(const InlineRep& other) const { return data_ == other.data_; }
- // Copies the inline contents into `dst`. Assumes the cord is not empty.
void CopyTo(absl::Nonnull<std::string*> dst) const {
- data_.CopyInlineToString(dst);
+ // memcpy is much faster when operating on a known size. On most supported
+ // platforms, the small string optimization is large enough that resizing
+ // to 15 bytes does not cause a memory allocation.
+ absl::strings_internal::STLStringResizeUninitialized(dst, kMaxInline);
+ data_.copy_max_inline_to(&(*dst)[0]);
+ // erase is faster than resize because the logic for memory allocation is
+ // not needed.
+ dst->erase(inline_size());
}
// Copies the inline contents into `dst`. Assumes the cord is not empty.
@@ -1649,6 +1659,10 @@
return *chunk_iterator_->data();
}
+inline Cord::CharIterator::pointer Cord::CharIterator::operator->() const {
+ return chunk_iterator_->data();
+}
+
inline Cord Cord::AdvanceAndRead(absl::Nonnull<CharIterator*> it,
size_t n_bytes) {
assert(it != nullptr);
diff --git a/absl/strings/cord_test.cc b/absl/strings/cord_test.cc
index 993e586..eaf6d71 100644
--- a/absl/strings/cord_test.cc
+++ b/absl/strings/cord_test.cc
@@ -1309,7 +1309,6 @@
absl::Cord c;
c.Append(absl::Cord(std::string(100, 'x')));
absl::Cord other_ref = c; // Prevent inplace appends
- EXPECT_THAT(other_ref, testing::Eq(c));
MaybeHarden(c);
c.Append(absl::Cord(std::string(200, 'y')));
c.RemoveSuffix(200);
@@ -1666,7 +1665,6 @@
auto releaser = [&invoked](absl::string_view) { invoked = true; };
{
auto c = absl::MakeCordFromExternal("", releaser);
- EXPECT_THAT(c, testing::Eq(""));
EXPECT_TRUE(invoked);
}
}
@@ -1681,7 +1679,6 @@
auto releaser = [&invoked](absl::string_view) { invoked = true; };
{
auto c = absl::MakeCordFromExternal(large_dummy, releaser);
- EXPECT_THAT(c, testing::Eq(large_dummy));
EXPECT_FALSE(invoked);
}
EXPECT_TRUE(invoked);
@@ -2170,7 +2167,6 @@
absl::Cord cord;
for (char c : expected) {
absl::Cord shared(cord);
- EXPECT_THAT(cord, testing::Eq(shared));
cord.Append(absl::string_view(&c, 1));
MaybeHarden(cord);
}
@@ -2534,6 +2530,8 @@
EXPECT_EQ(*pre_iter, *post_iter);
EXPECT_EQ(&*pre_iter, &*post_iter);
+ EXPECT_EQ(&*pre_iter, pre_iter.operator->());
+
const char* character_address = &*pre_iter;
absl::Cord::CharIterator copy = pre_iter;
++copy;
@@ -3280,26 +3278,6 @@
EXPECT_EQ(absl::HashOf(c3), absl::HashOf(absl::string_view()));
}
-// This must not be static to avoid aggressive optimizations.
-ABSL_ATTRIBUTE_WEAK
-size_t FalseReport(const absl::Cord& a, bool f);
-
-ABSL_ATTRIBUTE_NOINLINE
-size_t FalseReport(const absl::Cord& a, bool f) {
- absl::Cord b;
- const absl::Cord& ref = f ? b : a;
- // Test that sanitizers report nothing here. Without
- // InlineData::Rep::annotated_this() compiler can unconditionally load
- // poisoned parts, assuming that local variable is fully accessible.
- return ref.size();
-}
-
-TEST(CordSanitizerTest, SanitizesCordFalseReport) {
- absl::Cord c;
- for (int i = 0; i < 1000; ++i) c.Append("a");
- FalseReport(c, false);
-}
-
TEST(CrcCordTest, ChecksummedEmptyCordEstimateMemoryUsage) {
absl::Cord cord;
cord.SetExpectedChecksum(0);
diff --git a/absl/strings/escaping.cc b/absl/strings/escaping.cc
index b70c504..4ffef94 100644
--- a/absl/strings/escaping.cc
+++ b/absl/strings/escaping.cc
@@ -15,7 +15,6 @@
#include "absl/strings/escaping.h"
#include <algorithm>
-#include <array>
#include <cassert>
#include <cstddef>
#include <cstdint>
@@ -25,7 +24,6 @@
#include <utility>
#include "absl/base/config.h"
-#include "absl/base/internal/endian.h"
#include "absl/base/internal/raw_logging.h"
#include "absl/base/internal/unaligned_access.h"
#include "absl/base/nullability.h"
@@ -370,7 +368,7 @@
}
/* clang-format off */
-constexpr std::array<unsigned char, 256> kCEscapedLen = {
+constexpr unsigned char kCEscapedLen[256] = {
4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 4, 4, 2, 4, 4, // \t, \n, \r
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, // ", '
@@ -390,40 +388,6 @@
};
/* clang-format on */
-constexpr uint32_t MakeCEscapedLittleEndianUint32(size_t c) {
- size_t char_len = kCEscapedLen[c];
- if (char_len == 1) {
- return static_cast<uint32_t>(c);
- }
- if (char_len == 2) {
- switch (c) {
- case '\n':
- return '\\' | (static_cast<uint32_t>('n') << 8);
- case '\r':
- return '\\' | (static_cast<uint32_t>('r') << 8);
- case '\t':
- return '\\' | (static_cast<uint32_t>('t') << 8);
- case '\"':
- return '\\' | (static_cast<uint32_t>('\"') << 8);
- case '\'':
- return '\\' | (static_cast<uint32_t>('\'') << 8);
- case '\\':
- return '\\' | (static_cast<uint32_t>('\\') << 8);
- }
- }
- return static_cast<uint32_t>('\\' | (('0' + (c / 64)) << 8) |
- (('0' + ((c % 64) / 8)) << 16) |
- (('0' + (c % 8)) << 24));
-}
-
-template <size_t... indexes>
-inline constexpr std::array<uint32_t, sizeof...(indexes)>
-MakeCEscapedLittleEndianUint32Array(std::index_sequence<indexes...>) {
- return {MakeCEscapedLittleEndianUint32(indexes)...};
-}
-constexpr std::array<uint32_t, 256> kCEscapedLittleEndianUint32Array =
- MakeCEscapedLittleEndianUint32Array(std::make_index_sequence<256>());
-
// Calculates the length of the C-style escaped version of 'src'.
// Assumes that non-printable characters are escaped using octal sequences, and
// that UTF-8 bytes are not handled specially.
@@ -457,31 +421,59 @@
return;
}
- // We keep 3 slop bytes so that we can call `little_endian::Store32`
- // invariably regardless of the length of the escaped character.
- constexpr size_t slop_bytes = 3;
size_t cur_dest_len = dest->size();
- size_t new_dest_len = cur_dest_len + escaped_len + slop_bytes;
- ABSL_INTERNAL_CHECK(new_dest_len > cur_dest_len, "std::string size overflow");
- strings_internal::AppendUninitializedTraits<std::string>::Append(
- dest, escaped_len + slop_bytes);
+ ABSL_INTERNAL_CHECK(
+ cur_dest_len <= std::numeric_limits<size_t>::max() - escaped_len,
+ "std::string size overflow");
+ strings_internal::STLStringResizeUninitialized(dest,
+ cur_dest_len + escaped_len);
char* append_ptr = &(*dest)[cur_dest_len];
for (char c : src) {
- unsigned char uc = static_cast<unsigned char>(c);
- size_t char_len = kCEscapedLen[uc];
- uint32_t little_endian_uint32 = kCEscapedLittleEndianUint32Array[uc];
- little_endian::Store32(append_ptr, little_endian_uint32);
- append_ptr += char_len;
+ size_t char_len = kCEscapedLen[static_cast<unsigned char>(c)];
+ if (char_len == 1) {
+ *append_ptr++ = c;
+ } else if (char_len == 2) {
+ switch (c) {
+ case '\n':
+ *append_ptr++ = '\\';
+ *append_ptr++ = 'n';
+ break;
+ case '\r':
+ *append_ptr++ = '\\';
+ *append_ptr++ = 'r';
+ break;
+ case '\t':
+ *append_ptr++ = '\\';
+ *append_ptr++ = 't';
+ break;
+ case '\"':
+ *append_ptr++ = '\\';
+ *append_ptr++ = '\"';
+ break;
+ case '\'':
+ *append_ptr++ = '\\';
+ *append_ptr++ = '\'';
+ break;
+ case '\\':
+ *append_ptr++ = '\\';
+ *append_ptr++ = '\\';
+ break;
+ }
+ } else {
+ *append_ptr++ = '\\';
+ *append_ptr++ = '0' + static_cast<unsigned char>(c) / 64;
+ *append_ptr++ = '0' + (static_cast<unsigned char>(c) % 64) / 8;
+ *append_ptr++ = '0' + static_cast<unsigned char>(c) % 8;
+ }
}
- dest->resize(new_dest_len - slop_bytes);
}
// Reverses the mapping in Base64EscapeInternal; see that method's
// documentation for details of the mapping.
bool Base64UnescapeInternal(absl::Nullable<const char*> src_param, size_t szsrc,
absl::Nullable<char*> dest, size_t szdest,
- const std::array<signed char, 256>& unbase64,
+ absl::Nonnull<const signed char*> unbase64,
absl::Nonnull<size_t*> len) {
static const char kPad64Equals = '=';
static const char kPad64Dot = '.';
@@ -746,7 +738,7 @@
// where the value of "Base64[]" was replaced by one of k(WebSafe)Base64Chars
// in the internal escaping.cc.
/* clang-format off */
-constexpr std::array<signed char, 256> kUnBase64 = {
+constexpr signed char kUnBase64[] = {
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
@@ -781,7 +773,7 @@
-1, -1, -1, -1, -1, -1, -1, -1
};
-constexpr std::array<signed char, 256> kUnWebSafeBase64 = {
+constexpr signed char kUnWebSafeBase64[] = {
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
@@ -820,7 +812,7 @@
template <typename String>
bool Base64UnescapeInternal(absl::Nullable<const char*> src, size_t slen,
absl::Nonnull<String*> dest,
- const std::array<signed char, 256>& unbase64) {
+ absl::Nonnull<const signed char*> unbase64) {
// Determine the size of the output string. Base64 encodes every 3 bytes into
// 4 characters. Any leftover chars are added directly for good measure.
const size_t dest_len = 3 * (slen / 4) + (slen % 4);
@@ -845,7 +837,7 @@
}
/* clang-format off */
-constexpr std::array<char, 256> kHexValueLenient = {
+constexpr char kHexValueLenient[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -864,7 +856,7 @@
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
-constexpr std::array<signed char, 256> kHexValueStrict = {
+constexpr signed char kHexValueStrict[256] = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
diff --git a/absl/strings/escaping_benchmark.cc b/absl/strings/escaping_benchmark.cc
index 342fd14..f792226 100644
--- a/absl/strings/escaping_benchmark.cc
+++ b/absl/strings/escaping_benchmark.cc
@@ -15,6 +15,8 @@
#include "absl/strings/escaping.h"
#include <cstdint>
+#include <cstdio>
+#include <cstring>
#include <memory>
#include <random>
#include <string>
@@ -23,7 +25,6 @@
#include "absl/base/internal/raw_logging.h"
#include "absl/strings/internal/escaping_test_common.h"
#include "absl/strings/str_cat.h"
-#include "absl/strings/string_view.h"
namespace {
@@ -32,12 +33,9 @@
for (int i = 0; i < 50; i++) {
src += "\\x55";
}
+ std::string dest;
for (auto _ : state) {
- std::string dest;
- benchmark::DoNotOptimize(src);
- bool result = absl::CUnescape(src, &dest);
- benchmark::DoNotOptimize(result);
- benchmark::DoNotOptimize(dest);
+ absl::CUnescape(src, &dest);
}
}
BENCHMARK(BM_CUnescapeHexString);
@@ -49,45 +47,22 @@
raw += std::string(test_set.plaintext);
}
}
+
+ // The actual benchmark loop is tiny...
+ std::string escaped;
for (auto _ : state) {
- std::string escaped;
- benchmark::DoNotOptimize(raw);
absl::WebSafeBase64Escape(raw, &escaped);
- benchmark::DoNotOptimize(escaped);
}
+
+ // We want to be sure the compiler doesn't throw away the loop above,
+ // and the easiest way to ensure that is to round-trip the results and verify
+ // them.
+ std::string round_trip;
+ absl::WebSafeBase64Unescape(escaped, &round_trip);
+ ABSL_RAW_CHECK(round_trip == raw, "");
}
BENCHMARK(BM_WebSafeBase64Escape_string);
-void BM_HexStringToBytes(benchmark::State& state) {
- const int size = state.range(0);
- std::string input, output;
- for (int i = 0; i < size; ++i) input += "1c";
- for (auto _ : state) {
- benchmark::DoNotOptimize(input);
- bool result = absl::HexStringToBytes(input, &output);
- benchmark::DoNotOptimize(result);
- benchmark::DoNotOptimize(output);
- }
-}
-BENCHMARK(BM_HexStringToBytes)->Range(1, 1 << 8);
-
-void BM_HexStringToBytes_Fail(benchmark::State& state) {
- std::string binary;
- absl::string_view hex_input1 = "1c2f003";
- absl::string_view hex_input2 = "1c2f0032f40123456789abcdef**";
- for (auto _ : state) {
- benchmark::DoNotOptimize(hex_input1);
- bool result1 = absl::HexStringToBytes(hex_input1, &binary);
- benchmark::DoNotOptimize(result1);
- benchmark::DoNotOptimize(binary);
- benchmark::DoNotOptimize(hex_input2);
- bool result2 = absl::HexStringToBytes(hex_input2, &binary);
- benchmark::DoNotOptimize(result2);
- benchmark::DoNotOptimize(binary);
- }
-}
-BENCHMARK(BM_HexStringToBytes_Fail);
-
// Used for the CEscape benchmarks
const char kStringValueNoEscape[] = "1234567890";
const char kStringValueSomeEscaped[] = "123\n56789\xA1";
@@ -101,9 +76,7 @@
}
for (auto _ : state) {
- benchmark::DoNotOptimize(src);
- std::string result = absl::CEscape(src);
- benchmark::DoNotOptimize(result);
+ absl::CEscape(src);
}
}
diff --git a/absl/strings/internal/charconv_bigint.h b/absl/strings/internal/charconv_bigint.h
index 2c7a336..cb29767 100644
--- a/absl/strings/internal/charconv_bigint.h
+++ b/absl/strings/internal/charconv_bigint.h
@@ -17,7 +17,7 @@
#include <algorithm>
#include <cstdint>
-#include <ostream>
+#include <iostream>
#include <string>
#include "absl/base/config.h"
diff --git a/absl/strings/internal/cord_internal.h b/absl/strings/internal/cord_internal.h
index b68ec2b..f0060f1 100644
--- a/absl/strings/internal/cord_internal.h
+++ b/absl/strings/internal/cord_internal.h
@@ -19,18 +19,16 @@
#include <cassert>
#include <cstddef>
#include <cstdint>
-#include <cstring>
-#include <string>
+#include <type_traits>
#include "absl/base/attributes.h"
#include "absl/base/config.h"
#include "absl/base/internal/endian.h"
#include "absl/base/internal/invoke.h"
-#include "absl/base/macros.h"
-#include "absl/base/nullability.h"
#include "absl/base/optimization.h"
#include "absl/container/internal/compressed_tuple.h"
#include "absl/container/internal/container_memory.h"
+#include "absl/meta/type_traits.h"
#include "absl/strings/string_view.h"
// We can only add poisoning if we can detect consteval executions.
@@ -637,19 +635,6 @@
poison();
}
- void CopyInlineToString(absl::Nonnull<std::string*> dst) const {
- assert(!is_tree());
- // As Cord can store only 15 bytes it is smaller than std::string's
- // small string optimization buffer size. Therefore we will always trigger
- // the fast assign short path.
- //
- // Copying with a size equal to the maximum allows more efficient, wider
- // stores to be used and no branching.
- dst->assign(rep_.SanitizerSafeCopy().as_chars(), kMaxInline);
- // After the copy we then change the size and put in a 0 byte.
- dst->erase(inline_size());
- }
-
void copy_max_inline_to(char* dst) const {
assert(!is_tree());
memcpy(dst, rep_.SanitizerSafeCopy().as_chars(), kMaxInline);
@@ -728,53 +713,35 @@
GetOrNull(chars, 13),
GetOrNull(chars, 14)} {}
-#ifdef ABSL_INTERNAL_CORD_HAVE_SANITIZER
- // Break compiler optimization for cases when value is allocated on the
- // stack. Compiler assumes that the the variable is fully accessible
- // regardless of our poisoning.
- // Missing report: https://github.com/llvm/llvm-project/issues/100640
- const Rep* self() const {
- const Rep* volatile ptr = this;
- return ptr;
- }
- Rep* self() {
- Rep* volatile ptr = this;
- return ptr;
- }
-#else
- constexpr const Rep* self() const { return this; }
- constexpr Rep* self() { return this; }
-#endif
-
// Disable sanitizer as we must always be able to read `tag`.
ABSL_CORD_INTERNAL_NO_SANITIZE
int8_t tag() const { return reinterpret_cast<const int8_t*>(this)[0]; }
- void set_tag(int8_t rhs) { reinterpret_cast<int8_t*>(self())[0] = rhs; }
+ void set_tag(int8_t rhs) { reinterpret_cast<int8_t*>(this)[0] = rhs; }
- char* as_chars() { return self()->data + 1; }
- const char* as_chars() const { return self()->data + 1; }
+ char* as_chars() { return data + 1; }
+ const char* as_chars() const { return data + 1; }
- bool is_tree() const { return (self()->tag() & 1) != 0; }
+ bool is_tree() const { return (tag() & 1) != 0; }
size_t inline_size() const {
- ABSL_ASSERT(!self()->is_tree());
- return static_cast<size_t>(self()->tag()) >> 1;
+ ABSL_ASSERT(!is_tree());
+ return static_cast<size_t>(tag()) >> 1;
}
void set_inline_size(size_t size) {
ABSL_ASSERT(size <= kMaxInline);
- self()->set_tag(static_cast<int8_t>(size << 1));
+ set_tag(static_cast<int8_t>(size << 1));
}
- CordRep* tree() const { return self()->as_tree.rep; }
- void set_tree(CordRep* rhs) { self()->as_tree.rep = rhs; }
+ CordRep* tree() const { return as_tree.rep; }
+ void set_tree(CordRep* rhs) { as_tree.rep = rhs; }
- cordz_info_t cordz_info() const { return self()->as_tree.cordz_info; }
- void set_cordz_info(cordz_info_t rhs) { self()->as_tree.cordz_info = rhs; }
+ cordz_info_t cordz_info() const { return as_tree.cordz_info; }
+ void set_cordz_info(cordz_info_t rhs) { as_tree.cordz_info = rhs; }
void make_tree(CordRep* tree) {
- self()->as_tree.rep = tree;
- self()->as_tree.cordz_info = kNullCordzInfo;
+ as_tree.rep = tree;
+ as_tree.cordz_info = kNullCordzInfo;
}
#ifdef ABSL_INTERNAL_CORD_HAVE_SANITIZER
diff --git a/absl/strings/internal/str_format/float_conversion.cc b/absl/strings/internal/str_format/float_conversion.cc
index aa31998..8edf520 100644
--- a/absl/strings/internal/str_format/float_conversion.cc
+++ b/absl/strings/internal/str_format/float_conversion.cc
@@ -17,7 +17,6 @@
#include <string.h>
#include <algorithm>
-#include <array>
#include <cassert>
#include <cmath>
#include <limits>
@@ -160,7 +159,7 @@
// See the current block of digits.
absl::string_view CurrentDigits() const {
- return absl::string_view(&digits_[kDigitsPerChunk - size_], size_);
+ return absl::string_view(digits_ + kDigitsPerChunk - size_, size_);
}
// Advance the current view of digits.
@@ -235,7 +234,7 @@
size_t decimal_start_;
size_t decimal_end_;
- std::array<char, kDigitsPerChunk> digits_;
+ char digits_[kDigitsPerChunk];
size_t size_ = 0;
absl::Span<uint32_t> data_;
diff --git a/absl/strings/internal/str_split_internal.h b/absl/strings/internal/str_split_internal.h
index ed1f117..11ea96f 100644
--- a/absl/strings/internal/str_split_internal.h
+++ b/absl/strings/internal/str_split_internal.h
@@ -253,10 +253,6 @@
(std::is_same<First, absl::string_view>::value ||
std::is_same<Second, absl::string_view>::value)>;
-template <typename StringType, typename ElementType, std::size_t Size>
-using ShouldUseLifetimeBoundForArray = std::integral_constant<
- bool, std::is_same<StringType, std::string>::value &&
- std::is_same<ElementType, absl::string_view>::value>;
// This class implements the range that is returned by absl::StrSplit(). This
// class has templated conversion operators that allow it to be implicitly
@@ -348,38 +344,7 @@
return ConvertToPair<First, Second>();
}
- // Returns an array with its elements set to the first few strings returned by
- // the begin() iterator. If there is not a corresponding value the empty
- // string is used.
- template <typename ElementType, std::size_t Size,
- std::enable_if_t<ShouldUseLifetimeBoundForArray<
- StringType, ElementType, Size>::value,
- std::nullptr_t> = nullptr>
- // NOLINTNEXTLINE(google-explicit-constructor)
- operator std::array<ElementType, Size>() const ABSL_ATTRIBUTE_LIFETIME_BOUND {
- return ConvertToArray<ElementType, Size>();
- }
-
- template <typename ElementType, std::size_t Size,
- std::enable_if_t<!ShouldUseLifetimeBoundForArray<
- StringType, ElementType, Size>::value,
- std::nullptr_t> = nullptr>
- // NOLINTNEXTLINE(google-explicit-constructor)
- operator std::array<ElementType, Size>() const {
- return ConvertToArray<ElementType, Size>();
- }
-
private:
- template <typename ElementType, std::size_t Size>
- std::array<ElementType, Size> ConvertToArray() const {
- std::array<ElementType, Size> a;
- auto it = begin();
- for (std::size_t i = 0; i < Size && it != end(); ++i, ++it) {
- a[i] = ElementType(*it);
- }
- return a;
- }
-
template <typename First, typename Second>
std::pair<First, Second> ConvertToPair() const {
absl::string_view first, second;
diff --git a/absl/strings/match.h b/absl/strings/match.h
index ce4fe78..1eeafbb 100644
--- a/absl/strings/match.h
+++ b/absl/strings/match.h
@@ -55,32 +55,22 @@
// StartsWith()
//
// Returns whether a given string `text` begins with `prefix`.
-inline constexpr bool StartsWith(absl::string_view text,
- absl::string_view prefix) noexcept {
- if (prefix.empty()) {
- return true;
- }
- if (text.size() < prefix.size()) {
- return false;
- }
- absl::string_view possible_match = text.substr(0, prefix.size());
-
- return possible_match == prefix;
+inline bool StartsWith(absl::string_view text,
+ absl::string_view prefix) noexcept {
+ return prefix.empty() ||
+ (text.size() >= prefix.size() &&
+ memcmp(text.data(), prefix.data(), prefix.size()) == 0);
}
// EndsWith()
//
// Returns whether a given string `text` ends with `suffix`.
-inline constexpr bool EndsWith(absl::string_view text,
- absl::string_view suffix) noexcept {
- if (suffix.empty()) {
- return true;
- }
- if (text.size() < suffix.size()) {
- return false;
- }
- absl::string_view possible_match = text.substr(text.size() - suffix.size());
- return possible_match == suffix;
+inline bool EndsWith(absl::string_view text,
+ absl::string_view suffix) noexcept {
+ return suffix.empty() ||
+ (text.size() >= suffix.size() &&
+ memcmp(text.data() + (text.size() - suffix.size()), suffix.data(),
+ suffix.size()) == 0);
}
// StrContainsIgnoreCase()
//
diff --git a/absl/strings/numbers.cc b/absl/strings/numbers.cc
index 83ea80b..b57d9e8 100644
--- a/absl/strings/numbers.cc
+++ b/absl/strings/numbers.cc
@@ -18,7 +18,6 @@
#include "absl/strings/numbers.h"
#include <algorithm>
-#include <array>
#include <cassert>
#include <cfloat> // for DBL_DIG and FLT_DIG
#include <cmath> // for HUGE_VAL
@@ -675,7 +674,7 @@
// Represents integer values of digits.
// Uses 36 to indicate an invalid character since we support
// bases up to 36.
-static constexpr std::array<int8_t, 256> kAsciiToInt = {
+static const int8_t kAsciiToInt[256] = {
36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, // 16 36s.
36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 0, 1, 2, 3, 4, 5,
diff --git a/absl/strings/str_cat.h b/absl/strings/str_cat.h
index 1a80662..b98adc0 100644
--- a/absl/strings/str_cat.h
+++ b/absl/strings/str_cat.h
@@ -101,7 +101,6 @@
#include <vector>
#include "absl/base/attributes.h"
-#include "absl/base/config.h"
#include "absl/base/nullability.h"
#include "absl/base/port.h"
#include "absl/meta/type_traits.h"
@@ -111,10 +110,6 @@
#include "absl/strings/numbers.h"
#include "absl/strings/string_view.h"
-#if defined(ABSL_HAVE_STD_STRING_VIEW) && !defined(ABSL_USES_STD_STRING_VIEW)
-#include <string_view>
-#endif
-
namespace absl {
ABSL_NAMESPACE_BEGIN
@@ -366,12 +361,6 @@
ABSL_ATTRIBUTE_LIFETIME_BOUND)
: piece_(pc) {}
-#if defined(ABSL_HAVE_STD_STRING_VIEW) && !defined(ABSL_USES_STD_STRING_VIEW)
- AlphaNum(std::string_view pc // NOLINT(runtime/explicit)
- ABSL_ATTRIBUTE_LIFETIME_BOUND)
- : piece_(pc.data(), pc.size()) {}
-#endif // !ABSL_USES_STD_STRING_VIEW
-
template <typename T, typename = typename std::enable_if<
HasAbslStringify<T>::value>::type>
AlphaNum( // NOLINT(runtime/explicit)
diff --git a/absl/strings/str_cat_test.cc b/absl/strings/str_cat_test.cc
index fb11734..66eddf0 100644
--- a/absl/strings/str_cat_test.cc
+++ b/absl/strings/str_cat_test.cc
@@ -24,14 +24,9 @@
#include <vector>
#include "gtest/gtest.h"
-#include "absl/base/config.h"
#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
-#if defined(ABSL_HAVE_STD_STRING_VIEW)
-#include <string_view>
-#endif
-
#ifdef __ANDROID__
// Android assert messages only go to system log, so death tests cannot inspect
// the message for matching.
@@ -219,14 +214,6 @@
EXPECT_EQ(result, "");
}
-#if defined(ABSL_HAVE_STD_STRING_VIEW)
-TEST(StrCat, StdStringView) {
- std::string_view pieces[] = {"Hello", ", ", "World", "!"};
- EXPECT_EQ(absl::StrCat(pieces[0], pieces[1], pieces[2], pieces[3]),
- "Hello, World!");
-}
-#endif // ABSL_HAVE_STD_STRING_VIEW
-
TEST(StrCat, NullConstCharPtr) {
const char* null = nullptr;
EXPECT_EQ(absl::StrCat("mon", null, "key"), "monkey");
diff --git a/absl/strings/str_format_test.cc b/absl/strings/str_format_test.cc
index 969e1f9..3c52be1 100644
--- a/absl/strings/str_format_test.cc
+++ b/absl/strings/str_format_test.cc
@@ -516,13 +516,7 @@
EXPECT_EQ(result, 17);
EXPECT_EQ(std::string(buffer), "NUMBER: 1234567");
- // The `output` parameter is annotated nonnull, but we want to test that
- // it is never written to if the size is zero.
- // Use a variable instead of passing nullptr directly to avoid a `-Wnonnull`
- // warning.
- char* null_output = nullptr;
- result =
- SNPrintF(null_output, 0, "Just checking the %s of the output.", "size");
+ result = SNPrintF(nullptr, 0, "Just checking the %s of the output.", "size");
EXPECT_EQ(result, 37);
}
@@ -551,13 +545,7 @@
std::string size = "size";
- // The `output` parameter is annotated nonnull, but we want to test that
- // it is never written to if the size is zero.
- // Use a variable instead of passing nullptr directly to avoid a `-Wnonnull`
- // warning.
- char* null_output = nullptr;
- result =
- SNPrintF(null_output, 0, "Just checking the %v of the output.", size);
+ result = SNPrintF(nullptr, 0, "Just checking the %v of the output.", size);
EXPECT_EQ(result, 37);
}
diff --git a/absl/strings/str_split.h b/absl/strings/str_split.h
index 7e8e31c..ba176fc 100644
--- a/absl/strings/str_split.h
+++ b/absl/strings/str_split.h
@@ -444,10 +444,8 @@
// behavior works for:
//
// 1) All standard STL containers including `std::vector`, `std::list`,
-// `std::deque`, `std::set`,`std::multiset`, 'std::map`, and `std::multimap`.
+// `std::deque`, `std::set`,`std::multiset`, 'std::map`, and `std::multimap`
// 2) `std::pair` (which is not actually a container). See below.
-// 3) `std::array`, which is a container but has different behavior due to its
-// fixed size. See below.
//
// Example:
//
@@ -489,21 +487,6 @@
// std::pair<std::string, std::string> p = absl::StrSplit("a,b,c", ',');
// // p.first == "a", p.second == "b" // "c" is omitted.
//
-//
-// Splitting to `std::array` is similar to splitting to `std::pair`, but for
-// N elements instead of two; missing elements are filled with the empty string
-// and extra elements are discarded.
-//
-// Examples:
-//
-// // Stores first two split strings as the elements in a std::array.
-// std::array<std::string, 2> a = absl::StrSplit("a,b,c", ',');
-// // a[0] == "a", a[1] == "b" // "c" is omitted.
-//
-// // The second element is empty.
-// std::array<std::string, 2> a = absl::StrSplit("a,", ',');
-// // a[0] == "a", a[1] == ""
-//
// The `StrSplit()` function can be used multiple times to perform more
// complicated splitting logic, such as intelligently parsing key-value pairs.
//
diff --git a/absl/strings/str_split_test.cc b/absl/strings/str_split_test.cc
index b083975..df6c460 100644
--- a/absl/strings/str_split_test.cc
+++ b/absl/strings/str_split_test.cc
@@ -14,7 +14,6 @@
#include "absl/strings/str_split.h"
-#include <array>
#include <cstddef>
#include <cstdint>
#include <deque>
@@ -398,12 +397,6 @@
EXPECT_EQ(p, (std::pair<FirstType, SecondType>("a", "b")));
}
-template <typename StringType, typename Splitter>
-void TestArrayConversionOperator(const Splitter& splitter) {
- std::array<StringType, 2> a = splitter;
- EXPECT_THAT(a, ElementsAre("a", "b"));
-}
-
TEST(Splitter, ConversionOperator) {
auto splitter = absl::StrSplit("a,b,c,d", ',');
@@ -474,10 +467,6 @@
TestPairConversionOperator<absl::string_view, std::string>(splitter);
TestPairConversionOperator<std::string, absl::string_view>(splitter);
TestPairConversionOperator<std::string, std::string>(splitter);
-
- // Tests conversion to std::array
- TestArrayConversionOperator<std::string>(splitter);
- TestArrayConversionOperator<absl::string_view>(splitter);
}
// A few additional tests for conversion to std::pair. This conversion is
@@ -522,41 +511,6 @@
}
}
-// std::array tests similar to std::pair tests above, testing fewer, exactly,
-// or more elements than the array size.
-TEST(Splitter, ToArray) {
- {
- // Empty string
- std::array<std::string, 2> p = absl::StrSplit("", ',');
- EXPECT_THAT(p, ElementsAre("", ""));
- }
-
- {
- // Only first
- std::array<std::string, 2> p = absl::StrSplit("a", ',');
- EXPECT_THAT(p, ElementsAre("a", ""));
- }
-
- {
- // Only second
- std::array<std::string, 2> p = absl::StrSplit(",b", ',');
- EXPECT_THAT(p, ElementsAre("", "b"));
- }
-
- {
- // First and second.
- std::array<std::string, 2> p = absl::StrSplit("a,b", ',');
- EXPECT_THAT(p, ElementsAre("a", "b"));
- }
-
- {
- // First and second and then more stuff that will be ignored.
- std::array<std::string, 2> p = absl::StrSplit("a,b,c", ',');
- EXPECT_THAT(p, ElementsAre("a", "b"));
- // "c" is omitted.
- }
-}
-
TEST(Splitter, Predicates) {
static const char kTestChars[] = ",a, ,b,";
using absl::AllowEmpty;
diff --git a/absl/strings/string_view.h b/absl/strings/string_view.h
index b461478..ff76001 100644
--- a/absl/strings/string_view.h
+++ b/absl/strings/string_view.h
@@ -159,7 +159,7 @@
//
// absl::string_view() == absl::string_view("", 0)
// absl::string_view(nullptr, 0) == absl::string_view("abcdef"+6, 0)
-class ABSL_ATTRIBUTE_VIEW string_view {
+class ABSL_INTERNAL_ATTRIBUTE_VIEW string_view {
public:
using traits_type = std::char_traits<char>;
using value_type = char;
@@ -200,12 +200,13 @@
absl::Nonnull<const char*> str)
: ptr_(str), length_(str ? StrlenInternal(str) : 0) {}
- // Constructor of a `string_view` from a `const char*` and length.
+ // Implicit constructor of a `string_view` from a `const char*` and length.
constexpr string_view(absl::Nullable<const char*> data, size_type len)
: ptr_(data), length_(CheckLengthInternal(len)) {}
- constexpr string_view(const string_view&) noexcept = default;
- string_view& operator=(const string_view&) noexcept = default;
+ // NOTE: Harmlessly omitted to work around gdb bug.
+ // constexpr string_view(const string_view&) noexcept = default;
+ // string_view& operator=(const string_view&) noexcept = default;
// Iterators
@@ -292,8 +293,7 @@
// Returns the ith element of the `string_view` using the array operator.
// Note that this operator does not perform any bounds checking.
constexpr const_reference operator[](size_type i) const {
- ABSL_HARDENING_ASSERT(i < size());
- return ptr_[i];
+ return ABSL_HARDENING_ASSERT(i < size()), ptr_[i];
}
// string_view::at()
@@ -302,26 +302,25 @@
// and an exception of type `std::out_of_range` will be thrown on invalid
// access.
constexpr const_reference at(size_type i) const {
- if (ABSL_PREDICT_FALSE(i >= size())) {
- base_internal::ThrowStdOutOfRange("absl::string_view::at");
- }
- return ptr_[i];
+ return ABSL_PREDICT_TRUE(i < size())
+ ? ptr_[i]
+ : ((void)base_internal::ThrowStdOutOfRange(
+ "absl::string_view::at"),
+ ptr_[i]);
}
// string_view::front()
//
// Returns the first element of a `string_view`.
constexpr const_reference front() const {
- ABSL_HARDENING_ASSERT(!empty());
- return ptr_[0];
+ return ABSL_HARDENING_ASSERT(!empty()), ptr_[0];
}
// string_view::back()
//
// Returns the last element of a `string_view`.
constexpr const_reference back() const {
- ABSL_HARDENING_ASSERT(!empty());
- return ptr_[size() - 1];
+ return ABSL_HARDENING_ASSERT(!empty()), ptr_[size() - 1];
}
// string_view::data()
@@ -395,10 +394,11 @@
// `pos > size`.
// Use absl::ClippedSubstr if you need a truncating substr operation.
constexpr string_view substr(size_type pos = 0, size_type n = npos) const {
- if (ABSL_PREDICT_FALSE(pos > length_)) {
- base_internal::ThrowStdOutOfRange("absl::string_view::substr");
- }
- return string_view(ptr_ + pos, Min(n, length_ - pos));
+ return ABSL_PREDICT_FALSE(pos > length_)
+ ? (base_internal::ThrowStdOutOfRange(
+ "absl::string_view::substr"),
+ string_view())
+ : string_view(ptr_ + pos, Min(n, length_ - pos));
}
// string_view::compare()
@@ -667,8 +667,7 @@
(std::numeric_limits<difference_type>::max)();
static constexpr size_type CheckLengthInternal(size_type len) {
- ABSL_HARDENING_ASSERT(len <= kMaxSize);
- return len;
+ return ABSL_HARDENING_ASSERT(len <= kMaxSize), len;
}
static constexpr size_type StrlenInternal(absl::Nonnull<const char*> str) {
diff --git a/absl/strings/string_view_test.cc b/absl/strings/string_view_test.cc
index 7064cc7..e978fc3 100644
--- a/absl/strings/string_view_test.cc
+++ b/absl/strings/string_view_test.cc
@@ -894,11 +894,7 @@
EXPECT_EQ(s.size(), 0u);
#ifdef ABSL_HAVE_STRING_VIEW_FROM_NULLPTR
- // The `str` parameter is annotated nonnull, but we want to test the defensive
- // null check. Use a variable instead of passing nullptr directly to avoid a
- // `-Wnonnull` warning.
- char* null_str = nullptr;
- s = absl::string_view(null_str);
+ s = absl::string_view(nullptr);
EXPECT_EQ(s.data(), nullptr);
EXPECT_EQ(s.size(), 0u);
@@ -1080,22 +1076,9 @@
TEST(StringViewTest, ConstexprCompiles) {
constexpr absl::string_view sp;
- // With `-Wnonnull` turned on, there is no way to test the defensive null
- // check in the `string_view(const char*)` constructor in a constexpr context,
- // as the argument needs to be constexpr. The compiler will therefore always
- // know at compile time that the argument is nullptr and complain because the
- // parameter is annotated nonnull. We hence turn the warning off for this
- // test.
-#if defined(__clang__)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wnonnull"
-#endif
#ifdef ABSL_HAVE_STRING_VIEW_FROM_NULLPTR
constexpr absl::string_view cstr(nullptr);
#endif
-#if defined(__clang__)
-#pragma clang diagnostic pop
-#endif
constexpr absl::string_view cstr_len("cstr", 4);
#if defined(ABSL_USES_STD_STRING_VIEW)
@@ -1123,7 +1106,7 @@
#endif
// MSVC 2017+ should be able to construct a constexpr string_view from a cstr.
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) && _MSC_VER >= 1910
#define ABSL_HAVE_CONSTEXPR_STRING_VIEW_FROM_CSTR 1
#endif
@@ -1159,6 +1142,10 @@
#endif
#endif
+#if !defined(__clang__) || 3 < __clang_major__ || \
+ (3 == __clang_major__ && 4 < __clang_minor__)
+ // older clang versions (< 3.5) complain that:
+ // "cannot perform pointer arithmetic on null pointer"
constexpr absl::string_view::iterator const_begin_empty = sp.begin();
constexpr absl::string_view::iterator const_end_empty = sp.end();
EXPECT_EQ(const_begin_empty, const_end_empty);
@@ -1168,6 +1155,7 @@
constexpr absl::string_view::iterator const_end_nullptr = cstr.end();
EXPECT_EQ(const_begin_nullptr, const_end_nullptr);
#endif // ABSL_HAVE_STRING_VIEW_FROM_NULLPTR
+#endif // !defined(__clang__) || ...
constexpr absl::string_view::iterator const_begin = cstr_len.begin();
constexpr absl::string_view::iterator const_end = cstr_len.end();
diff --git a/absl/strings/strip.h b/absl/strings/strip.h
index 8a55375..e3cda5b 100644
--- a/absl/strings/strip.h
+++ b/absl/strings/strip.h
@@ -24,7 +24,6 @@
#include <cstddef>
#include <string>
-#include "absl/base/attributes.h"
#include "absl/base/macros.h"
#include "absl/base/nullability.h"
#include "absl/strings/ascii.h"
@@ -45,8 +44,8 @@
// absl::string_view input("abc");
// EXPECT_TRUE(absl::ConsumePrefix(&input, "a"));
// EXPECT_EQ(input, "bc");
-inline constexpr bool ConsumePrefix(absl::Nonnull<absl::string_view*> str,
- absl::string_view expected) {
+inline bool ConsumePrefix(absl::Nonnull<absl::string_view*> str,
+ absl::string_view expected) {
if (!absl::StartsWith(*str, expected)) return false;
str->remove_prefix(expected.size());
return true;
@@ -62,8 +61,8 @@
// absl::string_view input("abcdef");
// EXPECT_TRUE(absl::ConsumeSuffix(&input, "def"));
// EXPECT_EQ(input, "abc");
-inline constexpr bool ConsumeSuffix(absl::Nonnull<absl::string_view*> str,
- absl::string_view expected) {
+inline bool ConsumeSuffix(absl::Nonnull<absl::string_view*> str,
+ absl::string_view expected) {
if (!absl::EndsWith(*str, expected)) return false;
str->remove_suffix(expected.size());
return true;
@@ -74,9 +73,8 @@
// 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 constexpr absl::string_view StripPrefix(
- absl::string_view str ABSL_ATTRIBUTE_LIFETIME_BOUND,
- absl::string_view prefix) {
+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());
return str;
}
@@ -86,9 +84,8 @@
// 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 constexpr absl::string_view StripSuffix(
- absl::string_view str ABSL_ATTRIBUTE_LIFETIME_BOUND,
- absl::string_view suffix) {
+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());
return str;
}
diff --git a/absl/synchronization/BUILD.bazel b/absl/synchronization/BUILD.bazel
index 867e986..dafeba3 100644
--- a/absl/synchronization/BUILD.bazel
+++ b/absl/synchronization/BUILD.bazel
@@ -85,8 +85,8 @@
"//absl/base:config",
"//absl/random",
"//absl/time",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -124,9 +124,9 @@
],
copts = ABSL_DEFAULT_COPTS,
linkopts = select({
- "@rules_cc//cc/compiler:msvc-cl": [],
- "@rules_cc//cc/compiler:clang-cl": [],
- "@rules_cc//cc/compiler:emscripten": [],
+ "//absl:msvc_compiler": [],
+ "//absl:clang-cl_compiler": [],
+ "//absl:wasm": [],
"//conditions:default": ["-pthread"],
}) + ABSL_DEFAULT_LINKOPTS,
visibility = ["//visibility:public"],
@@ -141,7 +141,6 @@
"//absl/base:dynamic_annotations",
"//absl/base:malloc_internal",
"//absl/base:raw_logging_internal",
- "//absl/base:tracing_internal",
"//absl/debugging:stacktrace",
"//absl/debugging:symbolize",
"//absl/time",
@@ -162,8 +161,8 @@
deps = [
":synchronization",
"//absl/time",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -178,12 +177,9 @@
],
deps = [
":synchronization",
- "//absl/base:config",
- "//absl/base:core_headers",
- "//absl/base:tracing_internal",
"//absl/time",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -198,7 +194,7 @@
":synchronization",
":thread_pool",
"//absl/base:no_destructor",
- "@google_benchmark//:benchmark_main",
+ "@com_github_google_benchmark//:benchmark_main",
],
)
@@ -213,8 +209,8 @@
"//absl/base:core_headers",
"//absl/log",
"//absl/log:check",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -229,8 +225,8 @@
deps = [
":graphcycles_internal",
"//absl/base:raw_logging_internal",
- "@google_benchmark//:benchmark_main",
- "@googletest//:gtest",
+ "@com_github_google_benchmark//:benchmark_main",
+ "@com_google_googletest//:gtest",
],
)
@@ -267,8 +263,8 @@
"//absl/log:check",
"//absl/memory",
"//absl/time",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -280,8 +276,8 @@
deps = [
":synchronization",
"//absl/base:config",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -299,7 +295,7 @@
"//absl/base",
"//absl/base:config",
"//absl/base:no_destructor",
- "@google_benchmark//:benchmark_main",
+ "@com_github_google_benchmark//:benchmark_main",
],
alwayslink = 1,
)
@@ -324,12 +320,9 @@
tags = ["no_test_lexan"],
deps = [
":synchronization",
- "//absl/base:config",
- "//absl/base:core_headers",
- "//absl/base:tracing_internal",
"//absl/time",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -347,7 +340,7 @@
"//absl/base:config",
"//absl/strings",
"//absl/time",
- "@googletest//:gtest",
+ "@com_google_googletest//:gtest",
],
alwayslink = 1,
)
@@ -365,7 +358,7 @@
":synchronization",
"//absl/strings",
"//absl/time",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -382,8 +375,8 @@
"//absl/base:config",
"//absl/random",
"//absl/time",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
diff --git a/absl/synchronization/CMakeLists.txt b/absl/synchronization/CMakeLists.txt
index a745574..a0f64e5 100644
--- a/absl/synchronization/CMakeLists.txt
+++ b/absl/synchronization/CMakeLists.txt
@@ -112,9 +112,7 @@
absl::raw_logging_internal
absl::stacktrace
absl::symbolize
- absl::tracing_internal
absl::time
- absl::tracing_internal
Threads::Threads
PUBLIC
)
@@ -142,7 +140,6 @@
DEPS
absl::synchronization
absl::time
- absl::tracing_internal
GTest::gmock_main
)
@@ -218,12 +215,8 @@
COPTS
${ABSL_TEST_COPTS}
DEPS
- absl::base
- absl::config
- absl::core_headers
absl::synchronization
absl::time
- absl::tracing_internal
GTest::gmock_main
)
diff --git a/absl/synchronization/blocking_counter.cc b/absl/synchronization/blocking_counter.cc
index a530baf..d2f82da 100644
--- a/absl/synchronization/blocking_counter.cc
+++ b/absl/synchronization/blocking_counter.cc
@@ -17,7 +17,6 @@
#include <atomic>
#include "absl/base/internal/raw_logging.h"
-#include "absl/base/internal/tracing.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
@@ -41,7 +40,6 @@
ABSL_RAW_CHECK(count >= 0,
"BlockingCounter::DecrementCount() called too many times");
if (count == 0) {
- base_internal::TraceSignal(this, TraceObjectKind());
MutexLock l(&lock_);
done_ = true;
return true;
@@ -50,23 +48,19 @@
}
void BlockingCounter::Wait() {
- base_internal::TraceWait(this, TraceObjectKind());
- {
- MutexLock l(&this->lock_);
+ MutexLock l(&this->lock_);
- // only one thread may call Wait(). To support more than one thread,
- // implement a counter num_to_exit, like in the Barrier class.
- ABSL_RAW_CHECK(num_waiting_ == 0, "multiple threads called Wait()");
- num_waiting_++;
+ // only one thread may call Wait(). To support more than one thread,
+ // implement a counter num_to_exit, like in the Barrier class.
+ ABSL_RAW_CHECK(num_waiting_ == 0, "multiple threads called Wait()");
+ num_waiting_++;
- this->lock_.Await(Condition(IsDone, &this->done_));
+ this->lock_.Await(Condition(IsDone, &this->done_));
- // At this point, we know that all threads executing DecrementCount
- // will not touch this object again.
- // Therefore, the thread calling this method is free to delete the object
- // after we return from this method.
- }
- base_internal::TraceContinue(this, TraceObjectKind());
+ // At this point, we know that all threads executing DecrementCount
+ // will not touch this object again.
+ // Therefore, the thread calling this method is free to delete the object
+ // after we return from this method.
}
ABSL_NAMESPACE_END
diff --git a/absl/synchronization/blocking_counter.h b/absl/synchronization/blocking_counter.h
index d0504a1..1908fdb 100644
--- a/absl/synchronization/blocking_counter.h
+++ b/absl/synchronization/blocking_counter.h
@@ -22,7 +22,6 @@
#include <atomic>
-#include "absl/base/internal/tracing.h"
#include "absl/base/thread_annotations.h"
#include "absl/synchronization/mutex.h"
@@ -90,11 +89,6 @@
void Wait();
private:
- // Convenience helper to reduce verbosity at call sites.
- static inline constexpr base_internal::ObjectKind TraceObjectKind() {
- return base_internal::ObjectKind::kBlockingCounter;
- }
-
Mutex lock_;
std::atomic<int> count_;
int num_waiting_ ABSL_GUARDED_BY(lock_);
diff --git a/absl/synchronization/blocking_counter_test.cc b/absl/synchronization/blocking_counter_test.cc
index 0c42b56..06885f5 100644
--- a/absl/synchronization/blocking_counter_test.cc
+++ b/absl/synchronization/blocking_counter_test.cc
@@ -15,13 +15,9 @@
#include "absl/synchronization/blocking_counter.h"
#include <thread> // NOLINT(build/c++11)
-#include <tuple>
#include <vector>
#include "gtest/gtest.h"
-#include "absl/base/attributes.h"
-#include "absl/base/config.h"
-#include "absl/base/internal/tracing.h"
#include "absl/time/clock.h"
#include "absl/time/time.h"
@@ -80,67 +76,5 @@
#endif
} // namespace
-
-#if ABSL_HAVE_ATTRIBUTE_WEAK
-
-namespace base_internal {
-
-namespace {
-
-using TraceRecord = std::tuple<const void*, ObjectKind>;
-
-thread_local TraceRecord tls_signal;
-thread_local TraceRecord tls_wait;
-thread_local TraceRecord tls_continue;
-
-} // namespace
-
-// Strong extern "C" implementation.
-extern "C" {
-
-void ABSL_INTERNAL_C_SYMBOL(AbslInternalTraceWait)(const void* object,
- ObjectKind kind) {
- tls_wait = {object, kind};
-}
-
-void ABSL_INTERNAL_C_SYMBOL(AbslInternalTraceContinue)(const void* object,
- ObjectKind kind) {
- tls_continue = {object, kind};
-}
-
-void ABSL_INTERNAL_C_SYMBOL(AbslInternalTraceSignal)(const void* object,
- ObjectKind kind) {
- tls_signal = {object, kind};
-}
-
-} // extern "C"
-
-TEST(BlockingCounterTest, TracesSignal) {
- BlockingCounter counter(2);
-
- tls_signal = {};
- counter.DecrementCount();
- EXPECT_EQ(tls_signal, TraceRecord(nullptr, ObjectKind::kUnknown));
-
- tls_signal = {};
- counter.DecrementCount();
- EXPECT_EQ(tls_signal, TraceRecord(&counter, ObjectKind::kBlockingCounter));
-}
-
-TEST(BlockingCounterTest, TracesWaitContinue) {
- BlockingCounter counter(1);
- counter.DecrementCount();
-
- tls_wait = {};
- tls_continue = {};
- counter.Wait();
- EXPECT_EQ(tls_wait, TraceRecord(&counter, ObjectKind::kBlockingCounter));
- EXPECT_EQ(tls_continue, TraceRecord(&counter, ObjectKind::kBlockingCounter));
-}
-
-} // namespace base_internal
-
-#endif // ABSL_HAVE_ATTRIBUTE_WEAK
-
ABSL_NAMESPACE_END
} // namespace absl
diff --git a/absl/synchronization/internal/create_thread_identity.cc b/absl/synchronization/internal/create_thread_identity.cc
index 93cd376..eacaa28 100644
--- a/absl/synchronization/internal/create_thread_identity.cc
+++ b/absl/synchronization/internal/create_thread_identity.cc
@@ -39,8 +39,7 @@
ABSL_CONST_INIT static base_internal::ThreadIdentity* thread_identity_freelist;
// A per-thread destructor for reclaiming associated ThreadIdentity objects.
-// Since we must preserve their storage, we cache them for re-use instead of
-// truly destructing the object.
+// Since we must preserve their storage we cache them for re-use.
static void ReclaimThreadIdentity(void* v) {
base_internal::ThreadIdentity* identity =
static_cast<base_internal::ThreadIdentity*>(v);
@@ -125,9 +124,6 @@
identity = reinterpret_cast<base_internal::ThreadIdentity*>(
RoundUp(reinterpret_cast<intptr_t>(allocation),
base_internal::PerThreadSynch::kAlignment));
- // Note that *identity is never constructed.
- // TODO(b/357097463): change this "one time init" to be a proper
- // constructor.
OneTimeInitThreadIdentity(identity);
}
ResetThreadIdentityBetweenReuse(identity);
diff --git a/absl/synchronization/internal/waiter_test.cc b/absl/synchronization/internal/waiter_test.cc
index 6e37415..da13896 100644
--- a/absl/synchronization/internal/waiter_test.cc
+++ b/absl/synchronization/internal/waiter_test.cc
@@ -108,10 +108,7 @@
absl::synchronization_internal::KernelTimeout(absl::Seconds(10))));
absl::Duration waited = absl::Now() - start;
EXPECT_GE(waited, WithTolerance(absl::Milliseconds(500)));
-#ifndef _MSC_VER
- // Skip on MSVC due to flakiness.
EXPECT_LT(waited, absl::Seconds(2));
-#endif
}
TYPED_TEST_P(WaiterTest, WaitTimeWoken) {
diff --git a/absl/synchronization/mutex.cc b/absl/synchronization/mutex.cc
index 52ed27f..cb3c7e7 100644
--- a/absl/synchronization/mutex.cc
+++ b/absl/synchronization/mutex.cc
@@ -651,13 +651,6 @@
static const intptr_t kMuLow = 0x00ffL; // mask all mutex bits
static const intptr_t kMuHigh = ~kMuLow; // mask pointer/reader count
-static_assert((0xab & (kMuWriter | kMuReader)) == (kMuWriter | kMuReader),
- "The debug allocator's uninitialized pattern (0xab) must be an "
- "invalid mutex state");
-static_assert((0xcd & (kMuWriter | kMuReader)) == (kMuWriter | kMuReader),
- "The debug allocator's freed pattern (0xcd) must be an invalid "
- "mutex state");
-
// Hack to make constant values available to gdb pretty printer
enum {
kGdbMuSpin = kMuSpin,
@@ -1720,44 +1713,25 @@
// NOTE: optimized out when kDebugMode is false.
bool should_try_cas = ((v & (kMuEvent | kMuWriter)) == kMuWriter &&
(v & (kMuWait | kMuDesig)) != kMuWait);
-
// But, we can use an alternate computation of it, that compilers
// currently don't find on their own. When that changes, this function
// can be simplified.
- //
- // should_try_cas is true iff the bits satisfy the following conditions:
- //
- // Ev Wr Wa De
- // equal to 0 1
- // and not equal to 1 0
- //
- // after xoring by 0 1 0 1, this is equivalent to:
- //
- // equal to 0 0
- // and not equal to 1 1, which is the same as:
- //
- // smaller than 0 0 1 1
- static_assert(kMuEvent > kMuWait, "Needed for should_try_cas_fast");
- static_assert(kMuEvent > kMuDesig, "Needed for should_try_cas_fast");
- static_assert(kMuWriter > kMuWait, "Needed for should_try_cas_fast");
- static_assert(kMuWriter > kMuDesig, "Needed for should_try_cas_fast");
-
- bool should_try_cas_fast =
- ((v ^ (kMuWriter | kMuDesig)) &
- (kMuEvent | kMuWriter | kMuWait | kMuDesig)) < (kMuWait | kMuDesig);
-
- if (kDebugMode && should_try_cas != should_try_cas_fast) {
+ intptr_t x = (v ^ (kMuWriter | kMuWait)) & (kMuWriter | kMuEvent);
+ intptr_t y = (v ^ (kMuWriter | kMuWait)) & (kMuWait | kMuDesig);
+ // Claim: "x == 0 && y > 0" is equal to should_try_cas.
+ // Also, because kMuWriter and kMuEvent exceed kMuDesig and kMuWait,
+ // all possible non-zero values for x exceed all possible values for y.
+ // Therefore, (x == 0 && y > 0) == (x < y).
+ if (kDebugMode && should_try_cas != (x < y)) {
// We would usually use PRIdPTR here, but is not correctly implemented
// within the android toolchain.
ABSL_RAW_LOG(FATAL, "internal logic error %llx %llx %llx\n",
- static_cast<long long>(v),
- static_cast<long long>(should_try_cas),
- static_cast<long long>(should_try_cas_fast));
+ static_cast<long long>(v), static_cast<long long>(x),
+ static_cast<long long>(y));
}
- if (should_try_cas_fast &&
- mu_.compare_exchange_strong(v, v & ~(kMuWrWait | kMuWriter),
- std::memory_order_release,
- std::memory_order_relaxed)) {
+ if (x < y && mu_.compare_exchange_strong(v, v & ~(kMuWrWait | kMuWriter),
+ std::memory_order_release,
+ std::memory_order_relaxed)) {
// fast writer release (writer with no waiters or with designated waker)
} else {
this->UnlockSlow(nullptr /*no waitp*/); // take slow path
diff --git a/absl/synchronization/notification.cc b/absl/synchronization/notification.cc
index a5853ab..165ba66 100644
--- a/absl/synchronization/notification.cc
+++ b/absl/synchronization/notification.cc
@@ -17,7 +17,6 @@
#include <atomic>
#include "absl/base/internal/raw_logging.h"
-#include "absl/base/internal/tracing.h"
#include "absl/synchronization/mutex.h"
#include "absl/time/time.h"
@@ -25,7 +24,6 @@
ABSL_NAMESPACE_BEGIN
void Notification::Notify() {
- base_internal::TraceSignal(this, TraceObjectKind());
MutexLock l(&this->mutex_);
#ifndef NDEBUG
@@ -47,37 +45,31 @@
}
void Notification::WaitForNotification() const {
- base_internal::TraceWait(this, TraceObjectKind());
if (!HasBeenNotifiedInternal(&this->notified_yet_)) {
- this->mutex_.LockWhen(
- Condition(&HasBeenNotifiedInternal, &this->notified_yet_));
+ this->mutex_.LockWhen(Condition(&HasBeenNotifiedInternal,
+ &this->notified_yet_));
this->mutex_.Unlock();
}
- base_internal::TraceContinue(this, TraceObjectKind());
}
bool Notification::WaitForNotificationWithTimeout(
absl::Duration timeout) const {
- base_internal::TraceWait(this, TraceObjectKind());
bool notified = HasBeenNotifiedInternal(&this->notified_yet_);
if (!notified) {
notified = this->mutex_.LockWhenWithTimeout(
Condition(&HasBeenNotifiedInternal, &this->notified_yet_), timeout);
this->mutex_.Unlock();
}
- base_internal::TraceContinue(notified ? this : nullptr, TraceObjectKind());
return notified;
}
bool Notification::WaitForNotificationWithDeadline(absl::Time deadline) const {
- base_internal::TraceWait(this, TraceObjectKind());
bool notified = HasBeenNotifiedInternal(&this->notified_yet_);
if (!notified) {
notified = this->mutex_.LockWhenWithDeadline(
Condition(&HasBeenNotifiedInternal, &this->notified_yet_), deadline);
this->mutex_.Unlock();
}
- base_internal::TraceContinue(notified ? this : nullptr, TraceObjectKind());
return notified;
}
diff --git a/absl/synchronization/notification.h b/absl/synchronization/notification.h
index 78cdf29..8986d9a 100644
--- a/absl/synchronization/notification.h
+++ b/absl/synchronization/notification.h
@@ -53,7 +53,6 @@
#include <atomic>
#include "absl/base/attributes.h"
-#include "absl/base/internal/tracing.h"
#include "absl/synchronization/mutex.h"
#include "absl/time/time.h"
@@ -76,11 +75,7 @@
//
// Returns the value of the notification's internal "notified" state.
ABSL_MUST_USE_RESULT bool HasBeenNotified() const {
- if (HasBeenNotifiedInternal(&this->notified_yet_)) {
- base_internal::TraceObserved(this, TraceObjectKind());
- return true;
- }
- return false;
+ return HasBeenNotifiedInternal(&this->notified_yet_);
}
// Notification::WaitForNotification()
@@ -113,11 +108,6 @@
void Notify();
private:
- // Convenience helper to reduce verbosity at call sites.
- static inline constexpr base_internal::ObjectKind TraceObjectKind() {
- return base_internal::ObjectKind::kNotification;
- }
-
static inline bool HasBeenNotifiedInternal(
const std::atomic<bool>* notified_yet) {
return notified_yet->load(std::memory_order_acquire);
diff --git a/absl/synchronization/notification_test.cc b/absl/synchronization/notification_test.cc
index eedad17..49ce61a 100644
--- a/absl/synchronization/notification_test.cc
+++ b/absl/synchronization/notification_test.cc
@@ -15,15 +15,10 @@
#include "absl/synchronization/notification.h"
#include <thread> // NOLINT(build/c++11)
-#include <tuple>
#include <vector>
#include "gtest/gtest.h"
-#include "absl/base/attributes.h"
-#include "absl/base/config.h"
-#include "absl/base/internal/tracing.h"
#include "absl/synchronization/mutex.h"
-#include "absl/time/time.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
@@ -84,11 +79,7 @@
// Allow for a slight early return, to account for quality of implementation
// issues on various platforms.
- absl::Duration slop = absl::Milliseconds(5);
-#ifdef _MSC_VER
- // Avoid flakiness on MSVC.
- slop = absl::Milliseconds(15);
-#endif
+ const absl::Duration slop = absl::Milliseconds(5);
EXPECT_LE(delay - slop, elapsed)
<< "WaitForNotificationWithTimeout returned " << delay - elapsed
<< " early (with " << slop << " slop), start time was " << start;
@@ -138,93 +129,5 @@
BasicTests(true, &local_notification2);
}
-#if ABSL_HAVE_ATTRIBUTE_WEAK
-
-namespace base_internal {
-
-namespace {
-
-using TraceRecord = std::tuple<const void*, ObjectKind>;
-
-thread_local TraceRecord tls_signal;
-thread_local TraceRecord tls_wait;
-thread_local TraceRecord tls_continue;
-thread_local TraceRecord tls_observed;
-
-} // namespace
-
-// Strong extern "C" implementation.
-extern "C" {
-
-void ABSL_INTERNAL_C_SYMBOL(AbslInternalTraceWait)(const void* object,
- ObjectKind kind) {
- tls_wait = {object, kind};
-}
-
-void ABSL_INTERNAL_C_SYMBOL(AbslInternalTraceContinue)(const void* object,
- ObjectKind kind) {
- tls_continue = {object, kind};
-}
-
-void ABSL_INTERNAL_C_SYMBOL(AbslInternalTraceSignal)(const void* object,
- ObjectKind kind) {
- tls_signal = {object, kind};
-}
-
-void ABSL_INTERNAL_C_SYMBOL(AbslInternalTraceObserved)(const void* object,
- ObjectKind kind) {
- tls_observed = {object, kind};
-}
-
-} // extern "C"
-
-TEST(NotificationTest, TracesNotify) {
- Notification n;
- tls_signal = {};
- n.Notify();
- EXPECT_EQ(tls_signal, TraceRecord(&n, ObjectKind::kNotification));
-}
-
-TEST(NotificationTest, TracesWaitForNotification) {
- Notification n;
- n.Notify();
- tls_wait = tls_continue = {};
- n.WaitForNotification();
- EXPECT_EQ(tls_wait, TraceRecord(&n, ObjectKind::kNotification));
- EXPECT_EQ(tls_continue, TraceRecord(&n, ObjectKind::kNotification));
-}
-
-TEST(NotificationTest, TracesWaitForNotificationWithTimeout) {
- Notification n;
-
- tls_wait = tls_continue = {};
- n.WaitForNotificationWithTimeout(absl::Milliseconds(1));
- EXPECT_EQ(tls_wait, TraceRecord(&n, ObjectKind::kNotification));
- EXPECT_EQ(tls_continue, TraceRecord(nullptr, ObjectKind::kNotification));
-
- n.Notify();
- tls_wait = tls_continue = {};
- n.WaitForNotificationWithTimeout(absl::Milliseconds(1));
- EXPECT_EQ(tls_wait, TraceRecord(&n, ObjectKind::kNotification));
- EXPECT_EQ(tls_continue, TraceRecord(&n, ObjectKind::kNotification));
-}
-
-TEST(NotificationTest, TracesHasBeenNotified) {
- Notification n;
-
- tls_observed = {};
- ASSERT_FALSE(n.HasBeenNotified());
- EXPECT_EQ(tls_observed, TraceRecord(nullptr, ObjectKind::kUnknown));
-
- n.Notify();
- tls_observed = {};
- ASSERT_TRUE(n.HasBeenNotified());
- EXPECT_EQ(tls_observed, TraceRecord(&n, ObjectKind::kNotification));
-}
-
-} // namespace base_internal
-
-#endif // ABSL_HAVE_ATTRIBUTE_WEAK
-
ABSL_NAMESPACE_END
} // namespace absl
diff --git a/absl/time/BUILD.bazel b/absl/time/BUILD.bazel
index 474c18f..05f1f2f 100644
--- a/absl/time/BUILD.bazel
+++ b/absl/time/BUILD.bazel
@@ -90,6 +90,7 @@
],
copts = ABSL_TEST_COPTS,
data = ["//absl/time/internal/cctz:zoneinfo"],
+ env = {"TZDIR": "absl/time/internal/cctz/testdata/zoneinfo"},
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":test_util",
@@ -99,8 +100,8 @@
"//absl/numeric:int128",
"//absl/strings:str_format",
"//absl/time/internal/cctz:time_zone",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -124,8 +125,8 @@
":time",
"//absl/flags:flag",
"//absl/flags:reflection",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -140,6 +141,7 @@
],
copts = ABSL_TEST_COPTS,
data = ["//absl/time/internal/cctz:zoneinfo"],
+ env = {"TZDIR": "absl/time/internal/cctz/testdata/zoneinfo"},
linkopts = ABSL_DEFAULT_LINKOPTS,
tags = [
"benchmark",
@@ -151,6 +153,6 @@
"//absl/base:core_headers",
"//absl/flags:flag",
"//absl/hash",
- "@google_benchmark//:benchmark_main",
+ "@com_github_google_benchmark//:benchmark_main",
],
)
diff --git a/absl/time/duration.cc b/absl/time/duration.cc
index 1940708..8d0b66f 100644
--- a/absl/time/duration.cc
+++ b/absl/time/duration.cc
@@ -549,6 +549,50 @@
//
// Conversion to other duration types.
//
+
+int64_t ToInt64Nanoseconds(Duration d) {
+ if (time_internal::GetRepHi(d) >= 0 &&
+ time_internal::GetRepHi(d) >> 33 == 0) {
+ return (time_internal::GetRepHi(d) * 1000 * 1000 * 1000) +
+ (time_internal::GetRepLo(d) / kTicksPerNanosecond);
+ }
+ return d / Nanoseconds(1);
+}
+int64_t ToInt64Microseconds(Duration d) {
+ if (time_internal::GetRepHi(d) >= 0 &&
+ time_internal::GetRepHi(d) >> 43 == 0) {
+ return (time_internal::GetRepHi(d) * 1000 * 1000) +
+ (time_internal::GetRepLo(d) / (kTicksPerNanosecond * 1000));
+ }
+ return d / Microseconds(1);
+}
+int64_t ToInt64Milliseconds(Duration d) {
+ if (time_internal::GetRepHi(d) >= 0 &&
+ time_internal::GetRepHi(d) >> 53 == 0) {
+ return (time_internal::GetRepHi(d) * 1000) +
+ (time_internal::GetRepLo(d) / (kTicksPerNanosecond * 1000 * 1000));
+ }
+ return d / Milliseconds(1);
+}
+int64_t ToInt64Seconds(Duration d) {
+ int64_t hi = time_internal::GetRepHi(d);
+ if (time_internal::IsInfiniteDuration(d)) return hi;
+ if (hi < 0 && time_internal::GetRepLo(d) != 0) ++hi;
+ return hi;
+}
+int64_t ToInt64Minutes(Duration d) {
+ int64_t hi = time_internal::GetRepHi(d);
+ if (time_internal::IsInfiniteDuration(d)) return hi;
+ if (hi < 0 && time_internal::GetRepLo(d) != 0) ++hi;
+ return hi / 60;
+}
+int64_t ToInt64Hours(Duration d) {
+ int64_t hi = time_internal::GetRepHi(d);
+ if (time_internal::IsInfiniteDuration(d)) return hi;
+ if (hi < 0 && time_internal::GetRepLo(d) != 0) ++hi;
+ return hi / (60 * 60);
+}
+
double ToDoubleNanoseconds(Duration d) {
return FDivDuration(d, Nanoseconds(1));
}
@@ -674,12 +718,13 @@
int prec;
double pow10;
};
-constexpr DisplayUnit kDisplayNano = {"ns", 2, 1e2};
-constexpr DisplayUnit kDisplayMicro = {"us", 5, 1e5};
-constexpr DisplayUnit kDisplayMilli = {"ms", 8, 1e8};
-constexpr DisplayUnit kDisplaySec = {"s", 11, 1e11};
-constexpr DisplayUnit kDisplayMin = {"m", -1, 0.0}; // prec ignored
-constexpr DisplayUnit kDisplayHour = {"h", -1, 0.0}; // prec ignored
+ABSL_CONST_INIT const DisplayUnit kDisplayNano = {"ns", 2, 1e2};
+ABSL_CONST_INIT const DisplayUnit kDisplayMicro = {"us", 5, 1e5};
+ABSL_CONST_INIT const DisplayUnit kDisplayMilli = {"ms", 8, 1e8};
+ABSL_CONST_INIT const DisplayUnit kDisplaySec = {"s", 11, 1e11};
+ABSL_CONST_INIT const DisplayUnit kDisplayMin = {"m", -1, 0.0}; // prec ignored
+ABSL_CONST_INIT const DisplayUnit kDisplayHour = {"h", -1,
+ 0.0}; // prec ignored
void AppendNumberUnit(std::string* out, int64_t n, DisplayUnit unit) {
char buf[sizeof("2562047788015216")]; // hours in max duration
diff --git a/absl/time/duration_test.cc b/absl/time/duration_test.cc
index 573a76a..4c801a8 100644
--- a/absl/time/duration_test.cc
+++ b/absl/time/duration_test.cc
@@ -16,19 +16,14 @@
#include <winsock2.h> // for timeval
#endif
-#include "absl/base/config.h"
-
-// For feature testing and determining which headers can be included.
-#if ABSL_INTERNAL_CPLUSPLUS_LANG >= 202002L
-#include <version>
-#endif
-
#include <array>
#include <cfloat>
#include <chrono> // NOLINT(build/c++11)
-#ifdef __cpp_lib_three_way_comparison
+
+#ifdef __cpp_impl_three_way_comparison
#include <compare>
-#endif // __cpp_lib_three_way_comparison
+#endif // __cpp_impl_three_way_comparison
+
#include <cmath>
#include <cstdint>
#include <ctime>
@@ -36,7 +31,6 @@
#include <limits>
#include <random>
#include <string>
-#include <type_traits>
#include "gmock/gmock.h"
#include "gtest/gtest.h"
@@ -75,8 +69,6 @@
}
TEST(Duration, ConstExpr) {
- static_assert(std::is_trivially_destructible<absl::Duration>::value,
- "Duration is documented as being trivially destructible");
constexpr absl::Duration d0 = absl::ZeroDuration();
static_assert(d0 == absl::ZeroDuration(), "ZeroDuration()");
constexpr absl::Duration d1 = absl::Seconds(1);
@@ -445,14 +437,14 @@
EXPECT_LT(-inf, inf);
EXPECT_GT(inf, -inf);
-#ifdef ABSL_INTERNAL_TIME_HAS_THREE_WAY_COMPARISON
+#ifdef __cpp_impl_three_way_comparison
EXPECT_EQ(inf <=> inf, std::strong_ordering::equal);
EXPECT_EQ(-inf <=> -inf, std::strong_ordering::equal);
EXPECT_EQ(-inf <=> inf, std::strong_ordering::less);
EXPECT_EQ(inf <=> -inf, std::strong_ordering::greater);
EXPECT_EQ(any_dur <=> inf, std::strong_ordering::less);
EXPECT_EQ(any_dur <=> -inf, std::strong_ordering::greater);
-#endif // ABSL_INTERNAL_TIME_HAS_THREE_WAY_COMPARISON
+#endif // __cpp_impl_three_way_comparison
}
TEST(Duration, InfinityAddition) {
@@ -519,18 +511,18 @@
absl::Duration almost_neg_inf = sec_min;
EXPECT_LT(-inf, almost_neg_inf);
-#ifdef ABSL_INTERNAL_TIME_HAS_THREE_WAY_COMPARISON
+#ifdef __cpp_impl_three_way_comparison
EXPECT_EQ(-inf <=> almost_neg_inf, std::strong_ordering::less);
EXPECT_EQ(almost_neg_inf <=> -inf, std::strong_ordering::greater);
-#endif // ABSL_INTERNAL_TIME_HAS_THREE_WAY_COMPARISON
+#endif // __cpp_impl_three_way_comparison
almost_neg_inf -= -absl::Nanoseconds(1);
EXPECT_LT(-inf, almost_neg_inf);
-#ifdef ABSL_INTERNAL_TIME_HAS_THREE_WAY_COMPARISON
+#ifdef __cpp_impl_three_way_comparison
EXPECT_EQ(-inf <=> almost_neg_inf, std::strong_ordering::less);
EXPECT_EQ(almost_neg_inf <=> -inf, std::strong_ordering::greater);
-#endif // ABSL_INTERNAL_TIME_HAS_THREE_WAY_COMPARISON
+#endif // __cpp_impl_three_way_comparison
// For reference: IEEE 754 behavior
const double dbl_inf = std::numeric_limits<double>::infinity();
@@ -891,7 +883,7 @@
EXPECT_LT(neg_full_range, full_range);
EXPECT_EQ(neg_full_range, -full_range);
-#ifdef ABSL_INTERNAL_TIME_HAS_THREE_WAY_COMPARISON
+#ifdef __cpp_impl_three_way_comparison
EXPECT_EQ(range_future <=> absl::InfiniteDuration(),
std::strong_ordering::less);
EXPECT_EQ(range_past <=> -absl::InfiniteDuration(),
@@ -904,7 +896,7 @@
std::strong_ordering::greater);
EXPECT_EQ(neg_full_range <=> full_range, std::strong_ordering::less);
EXPECT_EQ(neg_full_range <=> -full_range, std::strong_ordering::equal);
-#endif // ABSL_INTERNAL_TIME_HAS_THREE_WAY_COMPARISON
+#endif // __cpp_impl_three_way_comparison
}
TEST(Duration, RelationalOperators) {
@@ -928,7 +920,8 @@
#undef TEST_REL_OPS
}
-#ifdef ABSL_INTERNAL_TIME_HAS_THREE_WAY_COMPARISON
+
+#ifdef __cpp_impl_three_way_comparison
TEST(Duration, SpaceshipOperators) {
#define TEST_REL_OPS(UNIT) \
@@ -946,7 +939,7 @@
#undef TEST_REL_OPS
}
-#endif // ABSL_INTERNAL_TIME_HAS_THREE_WAY_COMPARISON
+#endif // __cpp_impl_three_way_comparison
TEST(Duration, Addition) {
#define TEST_ADD_OPS(UNIT) \
diff --git a/absl/time/internal/cctz/BUILD.bazel b/absl/time/internal/cctz/BUILD.bazel
index da30a0f..0b43bb1 100644
--- a/absl/time/internal/cctz/BUILD.bazel
+++ b/absl/time/internal/cctz/BUILD.bazel
@@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-load("//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", "ABSL_DEFAULT_LINKOPTS", "ABSL_TEST_COPTS")
-
package(features = [
"header_modules",
"layering_check",
@@ -30,8 +28,6 @@
hdrs = [
"include/cctz/civil_time.h",
],
- copts = ABSL_DEFAULT_COPTS,
- linkopts = ABSL_DEFAULT_LINKOPTS,
textual_hdrs = ["include/cctz/civil_time_detail.h"],
visibility = ["//visibility:public"],
deps = ["//absl/base:config"],
@@ -61,8 +57,7 @@
"include/cctz/time_zone.h",
"include/cctz/zone_info_source.h",
],
- copts = ABSL_DEFAULT_COPTS,
- linkopts = ABSL_DEFAULT_LINKOPTS + select({
+ linkopts = select({
"@platforms//os:osx": ["-Wl,-framework,CoreFoundation"],
"@platforms//os:ios": ["-Wl,-framework,CoreFoundation"],
"//conditions:default": [],
@@ -89,13 +84,11 @@
name = "civil_time_test",
size = "small",
srcs = ["src/civil_time_test.cc"],
- copts = ABSL_TEST_COPTS,
- linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":civil_time",
"//absl/base:config",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -103,9 +96,8 @@
name = "time_zone_format_test",
size = "small",
srcs = ["src/time_zone_format_test.cc"],
- copts = ABSL_TEST_COPTS,
data = [":zoneinfo"],
- linkopts = ABSL_DEFAULT_LINKOPTS,
+ env = {"TZDIR": "absl/time/internal/cctz/testdata/zoneinfo"},
tags = [
"no_test_android_arm",
"no_test_android_arm64",
@@ -116,8 +108,8 @@
":civil_time",
":time_zone",
"//absl/base:config",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -126,9 +118,8 @@
size = "small",
timeout = "moderate",
srcs = ["src/time_zone_lookup_test.cc"],
- copts = ABSL_TEST_COPTS,
data = [":zoneinfo"],
- linkopts = ABSL_DEFAULT_LINKOPTS,
+ env = {"TZDIR": "absl/time/internal/cctz/testdata/zoneinfo"},
tags = [
"no_test_android_arm",
"no_test_android_arm64",
@@ -139,8 +130,8 @@
":civil_time",
":time_zone",
"//absl/base:config",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -155,24 +146,22 @@
"src/time_zone_info.h",
"src/tzfile.h",
],
- copts = ABSL_TEST_COPTS,
- linkopts = ABSL_DEFAULT_LINKOPTS,
linkstatic = 1,
tags = ["benchmark"],
deps = [
":civil_time",
":time_zone",
"//absl/base:config",
- "@google_benchmark//:benchmark_main",
+ "@com_github_google_benchmark//:benchmark_main",
],
)
-### examples
-
-### binaries
-
filegroup(
name = "zoneinfo",
srcs = glob(["testdata/zoneinfo/**"]),
visibility = ["//absl/time:__subpackages__"],
)
+
+### examples
+
+### binaries
diff --git a/absl/time/internal/cctz/src/cctz_benchmark.cc b/absl/time/internal/cctz/src/cctz_benchmark.cc
index 4a5ac1b..11f9ba6 100644
--- a/absl/time/internal/cctz/src/cctz_benchmark.cc
+++ b/absl/time/internal/cctz/src/cctz_benchmark.cc
@@ -23,7 +23,7 @@
#include "benchmark/benchmark.h"
#include "absl/time/internal/cctz/include/cctz/civil_time.h"
#include "absl/time/internal/cctz/include/cctz/time_zone.h"
-#include "absl/time/internal/cctz/src/time_zone_impl.h"
+#include "time_zone_impl.h"
namespace {
diff --git a/absl/time/internal/cctz/src/time_zone_fixed.cc b/absl/time/internal/cctz/src/time_zone_fixed.cc
index ed7f9cb..e09654e 100644
--- a/absl/time/internal/cctz/src/time_zone_fixed.cc
+++ b/absl/time/internal/cctz/src/time_zone_fixed.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "absl/time/internal/cctz/src/time_zone_fixed.h"
+#include "time_zone_fixed.h"
#include <algorithm>
#include <cassert>
diff --git a/absl/time/internal/cctz/src/time_zone_format.cc b/absl/time/internal/cctz/src/time_zone_format.cc
index 0e5f32f..e7e30a2 100644
--- a/absl/time/internal/cctz/src/time_zone_format.cc
+++ b/absl/time/internal/cctz/src/time_zone_format.cc
@@ -46,7 +46,7 @@
#endif
#include "absl/time/internal/cctz/include/cctz/civil_time.h"
-#include "absl/time/internal/cctz/src/time_zone_if.h"
+#include "time_zone_if.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
diff --git a/absl/time/internal/cctz/src/time_zone_if.cc b/absl/time/internal/cctz/src/time_zone_if.cc
index 09f83e8..0e65cd9 100644
--- a/absl/time/internal/cctz/src/time_zone_if.cc
+++ b/absl/time/internal/cctz/src/time_zone_if.cc
@@ -12,11 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "absl/time/internal/cctz/src/time_zone_if.h"
+#include "time_zone_if.h"
#include "absl/base/config.h"
-#include "absl/time/internal/cctz/src/time_zone_info.h"
-#include "absl/time/internal/cctz/src/time_zone_libc.h"
+#include "time_zone_info.h"
+#include "time_zone_libc.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
diff --git a/absl/time/internal/cctz/src/time_zone_impl.cc b/absl/time/internal/cctz/src/time_zone_impl.cc
index 5f2f49e..aadbb77 100644
--- a/absl/time/internal/cctz/src/time_zone_impl.cc
+++ b/absl/time/internal/cctz/src/time_zone_impl.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "absl/time/internal/cctz/src/time_zone_impl.h"
+#include "time_zone_impl.h"
#include <deque>
#include <memory>
@@ -22,7 +22,7 @@
#include <utility>
#include "absl/base/config.h"
-#include "absl/time/internal/cctz/src/time_zone_fixed.h"
+#include "time_zone_fixed.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
diff --git a/absl/time/internal/cctz/src/time_zone_impl.h b/absl/time/internal/cctz/src/time_zone_impl.h
index da3aec5..8308a3b 100644
--- a/absl/time/internal/cctz/src/time_zone_impl.h
+++ b/absl/time/internal/cctz/src/time_zone_impl.h
@@ -21,8 +21,8 @@
#include "absl/base/config.h"
#include "absl/time/internal/cctz/include/cctz/civil_time.h"
#include "absl/time/internal/cctz/include/cctz/time_zone.h"
-#include "absl/time/internal/cctz/src/time_zone_if.h"
-#include "absl/time/internal/cctz/src/time_zone_info.h"
+#include "time_zone_if.h"
+#include "time_zone_info.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
diff --git a/absl/time/internal/cctz/src/time_zone_info.cc b/absl/time/internal/cctz/src/time_zone_info.cc
index f8484c9..b7178a6 100644
--- a/absl/time/internal/cctz/src/time_zone_info.cc
+++ b/absl/time/internal/cctz/src/time_zone_info.cc
@@ -30,7 +30,7 @@
// Note that we assume the proleptic Gregorian calendar and 60-second
// minutes throughout.
-#include "absl/time/internal/cctz/src/time_zone_info.h"
+#include "time_zone_info.h"
#include <algorithm>
#include <cassert>
@@ -49,8 +49,8 @@
#include "absl/base/config.h"
#include "absl/time/internal/cctz/include/cctz/civil_time.h"
-#include "absl/time/internal/cctz/src/time_zone_fixed.h"
-#include "absl/time/internal/cctz/src/time_zone_posix.h"
+#include "time_zone_fixed.h"
+#include "time_zone_posix.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
diff --git a/absl/time/internal/cctz/src/time_zone_info.h b/absl/time/internal/cctz/src/time_zone_info.h
index efe2f9c..689df6f 100644
--- a/absl/time/internal/cctz/src/time_zone_info.h
+++ b/absl/time/internal/cctz/src/time_zone_info.h
@@ -26,8 +26,8 @@
#include "absl/time/internal/cctz/include/cctz/civil_time.h"
#include "absl/time/internal/cctz/include/cctz/time_zone.h"
#include "absl/time/internal/cctz/include/cctz/zone_info_source.h"
-#include "absl/time/internal/cctz/src/time_zone_if.h"
-#include "absl/time/internal/cctz/src/tzfile.h"
+#include "time_zone_if.h"
+#include "tzfile.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
diff --git a/absl/time/internal/cctz/src/time_zone_libc.cc b/absl/time/internal/cctz/src/time_zone_libc.cc
index 362da1a..b509402 100644
--- a/absl/time/internal/cctz/src/time_zone_libc.cc
+++ b/absl/time/internal/cctz/src/time_zone_libc.cc
@@ -16,7 +16,7 @@
#define _CRT_SECURE_NO_WARNINGS 1
#endif
-#include "absl/time/internal/cctz/src/time_zone_libc.h"
+#include "time_zone_libc.h"
#include <chrono>
#include <ctime>
diff --git a/absl/time/internal/cctz/src/time_zone_libc.h b/absl/time/internal/cctz/src/time_zone_libc.h
index f1ed5cd..ae21073 100644
--- a/absl/time/internal/cctz/src/time_zone_libc.h
+++ b/absl/time/internal/cctz/src/time_zone_libc.h
@@ -19,7 +19,7 @@
#include <string>
#include "absl/base/config.h"
-#include "absl/time/internal/cctz/src/time_zone_if.h"
+#include "time_zone_if.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
diff --git a/absl/time/internal/cctz/src/time_zone_lookup.cc b/absl/time/internal/cctz/src/time_zone_lookup.cc
index 80f7319..8979174 100644
--- a/absl/time/internal/cctz/src/time_zone_lookup.cc
+++ b/absl/time/internal/cctz/src/time_zone_lookup.cc
@@ -47,7 +47,6 @@
#include <wchar.h>
#include <windows.globalization.h>
#include <windows.h>
-#include <winstring.h>
#endif
#endif
@@ -55,8 +54,8 @@
#include <cstring>
#include <string>
-#include "absl/time/internal/cctz/src/time_zone_fixed.h"
-#include "absl/time/internal/cctz/src/time_zone_impl.h"
+#include "time_zone_fixed.h"
+#include "time_zone_impl.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
diff --git a/absl/time/internal/cctz/src/time_zone_lookup_test.cc b/absl/time/internal/cctz/src/time_zone_lookup_test.cc
index 22c0eb6..6f7e5cf 100644
--- a/absl/time/internal/cctz/src/time_zone_lookup_test.cc
+++ b/absl/time/internal/cctz/src/time_zone_lookup_test.cc
@@ -1330,24 +1330,35 @@
ExpectTime(tp, tz, 1983, 12, 31, 23, 59, 59, -5 * 3600, false, "EST");
}
-TEST(TimeZoneEdgeCase, EuropeLisbon) {
- // Cover a non-existent time within a forward transition.
- const time_zone tz = LoadZone("Europe/Lisbon");
+TEST(TimeZoneEdgeCase, WET) {
+ // Cover some non-existent times within forward transitions.
+ const time_zone tz = LoadZone("WET");
- // Over a forward transition.
- // 354671999 == Sat, 28 Mar 1981 23:59:59 +0000 (WET)
- // 354672000 == Sun, 29 Mar 1981 01:00:00 +0100 (WEST)
- auto tp = convert(civil_second(1981, 3, 28, 23, 59, 59), tz);
- ExpectTime(tp, tz, 1981, 3, 28, 23, 59, 59, 0, false, "WET");
+ // Before the first transition.
+ auto tp = convert(civil_second(1977, 1, 1, 0, 0, 0), tz);
+ ExpectTime(tp, tz, 1977, 1, 1, 0, 0, 0, 0, false, "WET");
+
+ // Over the first transition.
+ // 228877199 == Sun, 3 Apr 1977 00:59:59 +0000 (WET)
+ // 228877200 == Sun, 3 Apr 1977 02:00:00 +0100 (WEST)
+ tp = convert(civil_second(1977, 4, 3, 0, 59, 59), tz);
+ ExpectTime(tp, tz, 1977, 4, 3, 0, 59, 59, 0, false, "WET");
tp += absl::time_internal::cctz::seconds(1);
- ExpectTime(tp, tz, 1981, 3, 29, 1, 0, 0, 1 * 3600, true, "WEST");
+ ExpectTime(tp, tz, 1977, 4, 3, 2, 0, 0, 1 * 3600, true, "WEST");
- // A non-existent time within the transition.
- time_zone::civil_lookup cl1 = tz.lookup(civil_second(1981, 3, 29, 0, 15, 0));
+ // A non-existent time within the first transition.
+ time_zone::civil_lookup cl1 = tz.lookup(civil_second(1977, 4, 3, 1, 15, 0));
EXPECT_EQ(time_zone::civil_lookup::SKIPPED, cl1.kind);
- ExpectTime(cl1.pre, tz, 1981, 3, 29, 1, 15, 0, 1 * 3600, true, "WEST");
- ExpectTime(cl1.trans, tz, 1981, 3, 29, 1, 0, 0, 1 * 3600, true, "WEST");
- ExpectTime(cl1.post, tz, 1981, 3, 28, 23, 15, 0, 0 * 3600, false, "WET");
+ ExpectTime(cl1.pre, tz, 1977, 4, 3, 2, 15, 0, 1 * 3600, true, "WEST");
+ ExpectTime(cl1.trans, tz, 1977, 4, 3, 2, 0, 0, 1 * 3600, true, "WEST");
+ ExpectTime(cl1.post, tz, 1977, 4, 3, 0, 15, 0, 0 * 3600, false, "WET");
+
+ // A non-existent time within the second forward transition.
+ time_zone::civil_lookup cl2 = tz.lookup(civil_second(1978, 4, 2, 1, 15, 0));
+ EXPECT_EQ(time_zone::civil_lookup::SKIPPED, cl2.kind);
+ ExpectTime(cl2.pre, tz, 1978, 4, 2, 2, 15, 0, 1 * 3600, true, "WEST");
+ ExpectTime(cl2.trans, tz, 1978, 4, 2, 2, 0, 0, 1 * 3600, true, "WEST");
+ ExpectTime(cl2.post, tz, 1978, 4, 2, 0, 15, 0, 0 * 3600, false, "WET");
}
TEST(TimeZoneEdgeCase, FixedOffsets) {
diff --git a/absl/time/internal/cctz/src/time_zone_posix.cc b/absl/time/internal/cctz/src/time_zone_posix.cc
index efea080..5cdd09e 100644
--- a/absl/time/internal/cctz/src/time_zone_posix.cc
+++ b/absl/time/internal/cctz/src/time_zone_posix.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "absl/time/internal/cctz/src/time_zone_posix.h"
+#include "time_zone_posix.h"
#include <cstddef>
#include <cstring>
diff --git a/absl/time/internal/cctz/src/tzfile.h b/absl/time/internal/cctz/src/tzfile.h
index 6281438..2be3bb8 100644
--- a/absl/time/internal/cctz/src/tzfile.h
+++ b/absl/time/internal/cctz/src/tzfile.h
@@ -25,7 +25,7 @@
#define TZDEFRULES "posixrules"
#endif /* !defined TZDEFRULES */
-/* See Internet RFC 9636 for more details about the following format. */
+/* See Internet RFC 8536 for more details about the following format. */
/*
** Each file begins with. . .
@@ -75,16 +75,14 @@
** If tzh_version is '2' or greater, the above is followed by a second instance
** of tzhead and a second instance of the data in which each coded transition
** time uses 8 rather than 4 chars,
-** then a POSIX.1-2017 proleptic TZ string for use in handling
+** then a POSIX-TZ-environment-variable-style string for use in handling
** instants after the last transition time stored in the file
** (with nothing between the newlines if there is no POSIX.1-2017
** representation for such instants).
**
-** If tz_version is '3' or greater, the TZ string can be any POSIX.1-2024
-** proleptic TZ string, which means the above is extended as follows.
+** If tz_version is '3' or greater, the above is extended as follows.
** First, the TZ string's hour offset may range from -167
-** through 167 as compared to the range 0 through 24 required
-** by POSIX.1-2017 and earlier.
+** through 167 as compared to the POSIX-required 0 through 24.
** Second, its DST start time may be January 1 at 00:00 and its stop
** time December 31 at 24:00 plus the difference between DST and
** standard time, indicating DST all year.
diff --git a/absl/time/internal/cctz/testdata/version b/absl/time/internal/cctz/testdata/version
index 0846b7f..04fe674 100644
--- a/absl/time/internal/cctz/testdata/version
+++ b/absl/time/internal/cctz/testdata/version
@@ -1 +1 @@
-2025a
+2024a
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/Africa/Maputo b/absl/time/internal/cctz/testdata/zoneinfo/Africa/Maputo
index 581bb0e..651e5cf 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/Africa/Maputo
+++ b/absl/time/internal/cctz/testdata/zoneinfo/Africa/Maputo
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/America/Asuncion b/absl/time/internal/cctz/testdata/zoneinfo/America/Asuncion
index f056047..6225036 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/America/Asuncion
+++ b/absl/time/internal/cctz/testdata/zoneinfo/America/Asuncion
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/America/Bahia_Banderas b/absl/time/internal/cctz/testdata/zoneinfo/America/Bahia_Banderas
index 882400b..48faea2 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/America/Bahia_Banderas
+++ b/absl/time/internal/cctz/testdata/zoneinfo/America/Bahia_Banderas
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/America/Cancun b/absl/time/internal/cctz/testdata/zoneinfo/America/Cancun
index 3110cdf..640b259 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/America/Cancun
+++ b/absl/time/internal/cctz/testdata/zoneinfo/America/Cancun
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/America/Chihuahua b/absl/time/internal/cctz/testdata/zoneinfo/America/Chihuahua
index f65bb1c..5e0a54f 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/America/Chihuahua
+++ b/absl/time/internal/cctz/testdata/zoneinfo/America/Chihuahua
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/America/Ciudad_Juarez b/absl/time/internal/cctz/testdata/zoneinfo/America/Ciudad_Juarez
index 5f865ea..f636ee6 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/America/Ciudad_Juarez
+++ b/absl/time/internal/cctz/testdata/zoneinfo/America/Ciudad_Juarez
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/America/Ensenada b/absl/time/internal/cctz/testdata/zoneinfo/America/Ensenada
index 18d0d14..42087af 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/America/Ensenada
+++ b/absl/time/internal/cctz/testdata/zoneinfo/America/Ensenada
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/America/Hermosillo b/absl/time/internal/cctz/testdata/zoneinfo/America/Hermosillo
index ba7b147..5c92e29 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/America/Hermosillo
+++ b/absl/time/internal/cctz/testdata/zoneinfo/America/Hermosillo
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/America/Mazatlan b/absl/time/internal/cctz/testdata/zoneinfo/America/Mazatlan
index 5aa6039..97d4d36 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/America/Mazatlan
+++ b/absl/time/internal/cctz/testdata/zoneinfo/America/Mazatlan
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/America/Merida b/absl/time/internal/cctz/testdata/zoneinfo/America/Merida
index e5c7d8c..e5de113 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/America/Merida
+++ b/absl/time/internal/cctz/testdata/zoneinfo/America/Merida
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/America/Mexico_City b/absl/time/internal/cctz/testdata/zoneinfo/America/Mexico_City
index 1811234..80a415c 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/America/Mexico_City
+++ b/absl/time/internal/cctz/testdata/zoneinfo/America/Mexico_City
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/America/Monterrey b/absl/time/internal/cctz/testdata/zoneinfo/America/Monterrey
index c1e0546..a5822e2 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/America/Monterrey
+++ b/absl/time/internal/cctz/testdata/zoneinfo/America/Monterrey
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/America/Ojinaga b/absl/time/internal/cctz/testdata/zoneinfo/America/Ojinaga
index 1dd08b1..f7e40c0 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/America/Ojinaga
+++ b/absl/time/internal/cctz/testdata/zoneinfo/America/Ojinaga
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/America/Santa_Isabel b/absl/time/internal/cctz/testdata/zoneinfo/America/Santa_Isabel
index 18d0d14..42087af 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/America/Santa_Isabel
+++ b/absl/time/internal/cctz/testdata/zoneinfo/America/Santa_Isabel
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/America/Tijuana b/absl/time/internal/cctz/testdata/zoneinfo/America/Tijuana
index 18d0d14..42087af 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/America/Tijuana
+++ b/absl/time/internal/cctz/testdata/zoneinfo/America/Tijuana
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/Asia/Choibalsan b/absl/time/internal/cctz/testdata/zoneinfo/Asia/Choibalsan
index 6f5d3a1..0a948c2 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/Asia/Choibalsan
+++ b/absl/time/internal/cctz/testdata/zoneinfo/Asia/Choibalsan
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/Asia/Dili b/absl/time/internal/cctz/testdata/zoneinfo/Asia/Dili
index 22e705c..bb7be9f 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/Asia/Dili
+++ b/absl/time/internal/cctz/testdata/zoneinfo/Asia/Dili
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/Asia/Manila b/absl/time/internal/cctz/testdata/zoneinfo/Asia/Manila
index 145bb6f..3c3584e 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/Asia/Manila
+++ b/absl/time/internal/cctz/testdata/zoneinfo/Asia/Manila
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/Atlantic/Azores b/absl/time/internal/cctz/testdata/zoneinfo/Atlantic/Azores
index cda1c1d..e6e2616 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/Atlantic/Azores
+++ b/absl/time/internal/cctz/testdata/zoneinfo/Atlantic/Azores
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/Atlantic/Madeira b/absl/time/internal/cctz/testdata/zoneinfo/Atlantic/Madeira
index 21e8457..cf965c3 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/Atlantic/Madeira
+++ b/absl/time/internal/cctz/testdata/zoneinfo/Atlantic/Madeira
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/CET b/absl/time/internal/cctz/testdata/zoneinfo/CET
index 3197327..546748d 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/CET
+++ b/absl/time/internal/cctz/testdata/zoneinfo/CET
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/CST6CDT b/absl/time/internal/cctz/testdata/zoneinfo/CST6CDT
index b016880..d931558 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/CST6CDT
+++ b/absl/time/internal/cctz/testdata/zoneinfo/CST6CDT
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/EET b/absl/time/internal/cctz/testdata/zoneinfo/EET
index 231bf9c..378919e 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/EET
+++ b/absl/time/internal/cctz/testdata/zoneinfo/EET
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/EST b/absl/time/internal/cctz/testdata/zoneinfo/EST
index 9154643..3ae9691 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/EST
+++ b/absl/time/internal/cctz/testdata/zoneinfo/EST
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/EST5EDT b/absl/time/internal/cctz/testdata/zoneinfo/EST5EDT
index 2b6c2ee..50c95e0 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/EST5EDT
+++ b/absl/time/internal/cctz/testdata/zoneinfo/EST5EDT
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/Europe/Lisbon b/absl/time/internal/cctz/testdata/zoneinfo/Europe/Lisbon
index 7e9aae7..f0c70b6 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/Europe/Lisbon
+++ b/absl/time/internal/cctz/testdata/zoneinfo/Europe/Lisbon
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/HST b/absl/time/internal/cctz/testdata/zoneinfo/HST
index 40e3d49..160a53e 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/HST
+++ b/absl/time/internal/cctz/testdata/zoneinfo/HST
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/MET b/absl/time/internal/cctz/testdata/zoneinfo/MET
index 3197327..6f0558c 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/MET
+++ b/absl/time/internal/cctz/testdata/zoneinfo/MET
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/MST b/absl/time/internal/cctz/testdata/zoneinfo/MST
index c2bd2f9..a0953d1 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/MST
+++ b/absl/time/internal/cctz/testdata/zoneinfo/MST
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/MST7MDT b/absl/time/internal/cctz/testdata/zoneinfo/MST7MDT
index 09e54e5..137867c 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/MST7MDT
+++ b/absl/time/internal/cctz/testdata/zoneinfo/MST7MDT
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/Mexico/BajaNorte b/absl/time/internal/cctz/testdata/zoneinfo/Mexico/BajaNorte
index 18d0d14..42087af 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/Mexico/BajaNorte
+++ b/absl/time/internal/cctz/testdata/zoneinfo/Mexico/BajaNorte
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/Mexico/BajaSur b/absl/time/internal/cctz/testdata/zoneinfo/Mexico/BajaSur
index 5aa6039..97d4d36 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/Mexico/BajaSur
+++ b/absl/time/internal/cctz/testdata/zoneinfo/Mexico/BajaSur
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/Mexico/General b/absl/time/internal/cctz/testdata/zoneinfo/Mexico/General
index 1811234..80a415c 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/Mexico/General
+++ b/absl/time/internal/cctz/testdata/zoneinfo/Mexico/General
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/PST8PDT b/absl/time/internal/cctz/testdata/zoneinfo/PST8PDT
index aaf0778..fde4833 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/PST8PDT
+++ b/absl/time/internal/cctz/testdata/zoneinfo/PST8PDT
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/Portugal b/absl/time/internal/cctz/testdata/zoneinfo/Portugal
index 7e9aae7..f0c70b6 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/Portugal
+++ b/absl/time/internal/cctz/testdata/zoneinfo/Portugal
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/WET b/absl/time/internal/cctz/testdata/zoneinfo/WET
index 7e9aae7..423c6c2 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/WET
+++ b/absl/time/internal/cctz/testdata/zoneinfo/WET
Binary files differ
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/zone1970.tab b/absl/time/internal/cctz/testdata/zoneinfo/zone1970.tab
index 5ded056..abd9489 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/zone1970.tab
+++ b/absl/time/internal/cctz/testdata/zoneinfo/zone1970.tab
@@ -183,7 +183,7 @@
IT,SM,VA +4154+01229 Europe/Rome
JM +175805-0764736 America/Jamaica
JO +3157+03556 Asia/Amman
-JP,AU +353916+1394441 Asia/Tokyo Eyre Bird Observatory
+JP +353916+1394441 Asia/Tokyo
KE,DJ,ER,ET,KM,MG,SO,TZ,UG,YT -0117+03649 Africa/Nairobi
KG +4254+07436 Asia/Bishkek
KI,MH,TV,UM,WF +0125+17300 Pacific/Tarawa Gilberts, Marshalls, Wake
@@ -209,7 +209,8 @@
MH +0905+16720 Pacific/Kwajalein Kwajalein
MM,CC +1647+09610 Asia/Yangon
MN +4755+10653 Asia/Ulaanbaatar most of Mongolia
-MN +4801+09139 Asia/Hovd Bayan-Ölgii, Hovd, Uvs
+MN +4801+09139 Asia/Hovd Bayan-Ölgii, Govi-Altai, Hovd, Uvs, Zavkhan
+MN +4804+11430 Asia/Choibalsan Dornod, Sükhbaatar
MO +221150+1133230 Asia/Macau
MQ +1436-06105 America/Martinique
MT +3554+01431 Europe/Malta
@@ -246,7 +247,7 @@
PF -2308-13457 Pacific/Gambier Gambier Islands
PG,AQ,FM -0930+14710 Pacific/Port_Moresby Papua New Guinea (most areas), Chuuk, Yap, Dumont d'Urville
PG -0613+15534 Pacific/Bougainville Bougainville
-PH +143512+1205804 Asia/Manila
+PH +1435+12100 Asia/Manila
PK +2452+06703 Asia/Karachi
PL +5215+02100 Europe/Warsaw
PM +4703-05620 America/Miquelon
@@ -293,7 +294,7 @@
SA,AQ,KW,YE +2438+04643 Asia/Riyadh Syowa
SB,FM -0932+16012 Pacific/Guadalcanal Pohnpei
SD +1536+03232 Africa/Khartoum
-SG,AQ,MY +0117+10351 Asia/Singapore peninsular Malaysia, Concordia
+SG,MY +0117+10351 Asia/Singapore peninsular Malaysia
SR +0550-05510 America/Paramaribo
SS +0451+03137 Africa/Juba
ST +0020+00644 Africa/Sao_Tome
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/zonenow.tab b/absl/time/internal/cctz/testdata/zoneinfo/zonenow.tab
index d2c1e48..b6f2910 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/zonenow.tab
+++ b/absl/time/internal/cctz/testdata/zoneinfo/zonenow.tab
@@ -5,7 +5,7 @@
# From Paul Eggert (2023-12-18):
# This file contains a table where each row stands for a timezone
# where civil timestamps are predicted to agree from now on.
-# This file is like zone1970.tab (see zone1970.tab's comments),
+# This file is like zone1970.tab (see zone1970.tab's coments),
# but with the following changes:
#
# 1. Each timezone corresponds to a set of clocks that are planned
@@ -97,6 +97,9 @@
# -04/-03 (Chile DST)
XX -3327-07040 America/Santiago most of Chile
#
+# -04/-03 (Paraguay DST)
+XX -2516-05740 America/Asuncion Paraguay
+#
# -04/-03 - AST/ADT (North America DST)
XX +4439-06336 America/Halifax Atlantic ("AST/ADT") - Canada; Bermuda
#
@@ -120,6 +123,8 @@
#
# -01/+00 (EU DST)
XX +3744-02540 Atlantic/Azores Azores
+# -01/+00 (EU DST) until 2024-03-31; then -02/-01 (EU DST)
+XX +7029-02158 America/Scoresbysund Ittoqqortoormiit
#
# +00 - GMT
XX +0519-00402 Africa/Abidjan far western Africa; Iceland ("GMT")
@@ -194,7 +199,7 @@
XX +3431+06912 Asia/Kabul Afghanistan
#
# +05
-XX +4120+06918 Asia/Tashkent Russia; Kazakhstan; Tajikistan; Turkmenistan; Uzbekistan; Maldives
+XX +4120+06918 Asia/Tashkent Russia; west Kazakhstan; Tajikistan; Turkmenistan; Uzbekistan; Maldives
#
# +05 - PKT
XX +2452+06703 Asia/Karachi Pakistan ("PKT")
@@ -210,6 +215,8 @@
#
# +06
XX +2343+09025 Asia/Dhaka Russia; Kyrgyzstan; Bhutan; Bangladesh; Chagos
+# +06 until 2024-03-01; then +05
+XX +4315+07657 Asia/Almaty Kazakhstan (except western areas)
#
# +06:30
XX +1647+09610 Asia/Yangon Myanmar; Cocos
@@ -221,7 +228,7 @@
XX -0610+10648 Asia/Jakarta Indonesia ("WIB")
#
# +08
-XX +0117+10351 Asia/Singapore Russia; Brunei; Malaysia; Singapore; Concordia
+XX +0117+10351 Asia/Singapore Russia; Brunei; Malaysia; Singapore
#
# +08 - AWST
XX -3157+11551 Australia/Perth Western Australia ("AWST")
@@ -233,7 +240,7 @@
XX +2217+11409 Asia/Hong_Kong Hong Kong ("HKT")
#
# +08 - PHT
-XX +143512+1205804 Asia/Manila Philippines ("PHT")
+XX +1435+12100 Asia/Manila Philippines ("PHT")
#
# +08 - WITA
XX -0507+11924 Asia/Makassar Indonesia ("WITA")
@@ -245,7 +252,7 @@
XX +5203+11328 Asia/Chita Russia; Palau; East Timor
#
# +09 - JST
-XX +353916+1394441 Asia/Tokyo Japan ("JST"); Eyre Bird Observatory
+XX +353916+1394441 Asia/Tokyo Japan ("JST")
#
# +09 - KST
XX +3733+12658 Asia/Seoul Korea ("KST")
diff --git a/absl/time/time.h b/absl/time/time.h
index d73a204..f133c2d 100644
--- a/absl/time/time.h
+++ b/absl/time/time.h
@@ -74,19 +74,13 @@
// including 'windows.h' so we are picking the lesser of two evils here.
struct timeval;
#endif
-
-#include "absl/base/config.h"
-
-// For feature testing and determining which headers can be included.
-#if ABSL_INTERNAL_CPLUSPLUS_LANG >= 202002L
-#include <version>
-#endif
-
#include <chrono> // NOLINT(build/c++11)
-#include <cmath>
-#ifdef __cpp_lib_three_way_comparison
+
+#ifdef __cpp_impl_three_way_comparison
#include <compare>
-#endif // __cpp_lib_three_way_comparison
+#endif // __cpp_impl_three_way_comparison
+
+#include <cmath>
#include <cstdint>
#include <ctime>
#include <limits>
@@ -97,16 +91,12 @@
#include <utility>
#include "absl/base/attributes.h"
+#include "absl/base/config.h"
#include "absl/base/macros.h"
#include "absl/strings/string_view.h"
#include "absl/time/civil_time.h"
#include "absl/time/internal/cctz/include/cctz/time_zone.h"
-#if defined(__cpp_impl_three_way_comparison) && \
- defined(__cpp_lib_three_way_comparison)
-#define ABSL_INTERNAL_TIME_HAS_THREE_WAY_COMPARISON 1
-#endif
-
namespace absl {
ABSL_NAMESPACE_BEGIN
@@ -148,8 +138,7 @@
// the result of subtracting one `absl::Time` from another. Durations behave
// like unit-safe integers and they support all the natural integer-like
// arithmetic operations. Arithmetic overflows and saturates at +/- infinity.
-// `Duration` is trivially destructible and should be passed by value rather
-// than const reference.
+// `Duration` should be passed by value rather than const reference.
//
// Factory functions `Nanoseconds()`, `Microseconds()`, `Milliseconds()`,
// `Seconds()`, `Minutes()`, `Hours()` and `InfiniteDuration()` allow for
@@ -324,12 +313,12 @@
// Relational Operators
-#ifdef ABSL_INTERNAL_TIME_HAS_THREE_WAY_COMPARISON
+#ifdef __cpp_impl_three_way_comparison
ABSL_ATTRIBUTE_CONST_FUNCTION constexpr std::strong_ordering operator<=>(
Duration lhs, Duration rhs);
-#endif // ABSL_INTERNAL_TIME_HAS_THREE_WAY_COMPARISON
+#endif // __cpp_impl_three_way_comparison
ABSL_ATTRIBUTE_CONST_FUNCTION constexpr bool operator<(Duration lhs,
Duration rhs);
@@ -620,12 +609,12 @@
//
// absl::Duration d = absl::Milliseconds(1500);
// int64_t isec = absl::ToInt64Seconds(d); // isec == 1
-ABSL_ATTRIBUTE_CONST_FUNCTION inline int64_t ToInt64Nanoseconds(Duration d);
-ABSL_ATTRIBUTE_CONST_FUNCTION inline int64_t ToInt64Microseconds(Duration d);
-ABSL_ATTRIBUTE_CONST_FUNCTION inline int64_t ToInt64Milliseconds(Duration d);
-ABSL_ATTRIBUTE_CONST_FUNCTION inline int64_t ToInt64Seconds(Duration d);
-ABSL_ATTRIBUTE_CONST_FUNCTION inline int64_t ToInt64Minutes(Duration d);
-ABSL_ATTRIBUTE_CONST_FUNCTION inline int64_t ToInt64Hours(Duration d);
+ABSL_ATTRIBUTE_CONST_FUNCTION int64_t ToInt64Nanoseconds(Duration d);
+ABSL_ATTRIBUTE_CONST_FUNCTION int64_t ToInt64Microseconds(Duration d);
+ABSL_ATTRIBUTE_CONST_FUNCTION int64_t ToInt64Milliseconds(Duration d);
+ABSL_ATTRIBUTE_CONST_FUNCTION int64_t ToInt64Seconds(Duration d);
+ABSL_ATTRIBUTE_CONST_FUNCTION int64_t ToInt64Minutes(Duration d);
+ABSL_ATTRIBUTE_CONST_FUNCTION int64_t ToInt64Hours(Duration d);
// ToDoubleNanoseconds()
// ToDoubleMicroseconds()
@@ -749,9 +738,8 @@
// are provided for naturally expressing time calculations. Instances are
// created using `absl::Now()` and the `absl::From*()` factory functions that
// accept the gamut of other time representations. Formatting and parsing
-// functions are provided for conversion to and from strings. `absl::Time` is
-// trivially destructible and should be passed by value rather than const
-// reference.
+// functions are provided for conversion to and from strings. `absl::Time`
+// should be passed by value rather than const reference.
//
// `absl::Time` assumes there are 60 seconds in a minute, which means the
// underlying time scales must be "smeared" to eliminate leap seconds.
@@ -865,9 +853,9 @@
friend constexpr Time time_internal::FromUnixDuration(Duration d);
friend constexpr Duration time_internal::ToUnixDuration(Time t);
-#ifdef ABSL_INTERNAL_TIME_HAS_THREE_WAY_COMPARISON
+#ifdef __cpp_impl_three_way_comparison
friend constexpr std::strong_ordering operator<=>(Time lhs, Time rhs);
-#endif // ABSL_INTERNAL_TIME_HAS_THREE_WAY_COMPARISON
+#endif // __cpp_impl_three_way_comparison
friend constexpr bool operator<(Time lhs, Time rhs);
friend constexpr bool operator==(Time lhs, Time rhs);
@@ -880,14 +868,14 @@
};
// Relational Operators
-#ifdef ABSL_INTERNAL_TIME_HAS_THREE_WAY_COMPARISON
+#ifdef __cpp_impl_three_way_comparison
ABSL_ATTRIBUTE_CONST_FUNCTION constexpr std::strong_ordering operator<=>(
Time lhs, Time rhs) {
return lhs.rep_ <=> rhs.rep_;
}
-#endif // ABSL_INTERNAL_TIME_HAS_THREE_WAY_COMPARISON
+#endif // __cpp_impl_three_way_comparison
ABSL_ATTRIBUTE_CONST_FUNCTION constexpr bool operator<(Time lhs, Time rhs) {
return lhs.rep_ < rhs.rep_;
@@ -1764,7 +1752,8 @@
: time_internal::GetRepLo(lhs) < time_internal::GetRepLo(rhs);
}
-#ifdef ABSL_INTERNAL_TIME_HAS_THREE_WAY_COMPARISON
+
+#ifdef __cpp_impl_three_way_comparison
ABSL_ATTRIBUTE_CONST_FUNCTION constexpr std::strong_ordering operator<=>(
Duration lhs, Duration rhs) {
@@ -1780,7 +1769,7 @@
: lhs_lo <=> rhs_lo;
}
-#endif // ABSL_INTERNAL_TIME_HAS_THREE_WAY_COMPARISON
+#endif // __cpp_impl_three_way_comparison
ABSL_ATTRIBUTE_CONST_FUNCTION constexpr bool operator==(Duration lhs,
Duration rhs) {
@@ -1864,56 +1853,6 @@
return time_internal::FromUnixDuration(Seconds(t));
}
-ABSL_ATTRIBUTE_CONST_FUNCTION inline int64_t ToInt64Nanoseconds(Duration d) {
- if (time_internal::GetRepHi(d) >= 0 &&
- time_internal::GetRepHi(d) >> 33 == 0) {
- return (time_internal::GetRepHi(d) * 1000 * 1000 * 1000) +
- (time_internal::GetRepLo(d) / time_internal::kTicksPerNanosecond);
- }
- return d / Nanoseconds(1);
-}
-
-ABSL_ATTRIBUTE_CONST_FUNCTION inline int64_t ToInt64Microseconds(Duration d) {
- if (time_internal::GetRepHi(d) >= 0 &&
- time_internal::GetRepHi(d) >> 43 == 0) {
- return (time_internal::GetRepHi(d) * 1000 * 1000) +
- (time_internal::GetRepLo(d) /
- (time_internal::kTicksPerNanosecond * 1000));
- }
- return d / Microseconds(1);
-}
-
-ABSL_ATTRIBUTE_CONST_FUNCTION inline int64_t ToInt64Milliseconds(Duration d) {
- if (time_internal::GetRepHi(d) >= 0 &&
- time_internal::GetRepHi(d) >> 53 == 0) {
- return (time_internal::GetRepHi(d) * 1000) +
- (time_internal::GetRepLo(d) /
- (time_internal::kTicksPerNanosecond * 1000 * 1000));
- }
- return d / Milliseconds(1);
-}
-
-ABSL_ATTRIBUTE_CONST_FUNCTION inline int64_t ToInt64Seconds(Duration d) {
- int64_t hi = time_internal::GetRepHi(d);
- if (time_internal::IsInfiniteDuration(d)) return hi;
- if (hi < 0 && time_internal::GetRepLo(d) != 0) ++hi;
- return hi;
-}
-
-ABSL_ATTRIBUTE_CONST_FUNCTION inline int64_t ToInt64Minutes(Duration d) {
- int64_t hi = time_internal::GetRepHi(d);
- if (time_internal::IsInfiniteDuration(d)) return hi;
- if (hi < 0 && time_internal::GetRepLo(d) != 0) ++hi;
- return hi / 60;
-}
-
-ABSL_ATTRIBUTE_CONST_FUNCTION inline int64_t ToInt64Hours(Duration d) {
- int64_t hi = time_internal::GetRepHi(d);
- if (time_internal::IsInfiniteDuration(d)) return hi;
- if (hi < 0 && time_internal::GetRepLo(d) != 0) ++hi;
- return hi / (60 * 60);
-}
-
ABSL_NAMESPACE_END
} // namespace absl
diff --git a/absl/time/time_test.cc b/absl/time/time_test.cc
index 6f21008..71f54d6 100644
--- a/absl/time/time_test.cc
+++ b/absl/time/time_test.cc
@@ -13,31 +13,27 @@
// limitations under the License.
#include "absl/time/time.h"
+
+#include <cstdint>
+#include <ios>
+
#include "absl/time/civil_time.h"
#if defined(_MSC_VER)
#include <winsock2.h> // for timeval
#endif
-#include "absl/base/config.h"
-
-// For feature testing and determining which headers can be included.
-#if ABSL_INTERNAL_CPLUSPLUS_LANG >= 202002L
-#include <version>
-#endif
-
#include <chrono> // NOLINT(build/c++11)
-#ifdef __cpp_lib_three_way_comparison
+
+#ifdef __cpp_impl_three_way_comparison
#include <compare>
-#endif // __cpp_lib_three_way_comparison
-#include <cstdint>
+#endif // __cpp_impl_three_way_comparison
+
#include <cstring>
#include <ctime>
#include <iomanip>
-#include <ios>
#include <limits>
#include <string>
-#include <type_traits>
#include "gmock/gmock.h"
#include "gtest/gtest.h"
@@ -90,8 +86,6 @@
}
TEST(Time, ConstExpr) {
- static_assert(std::is_trivially_destructible<absl::Time>::value,
- "Time is documented as being trivially destructible");
constexpr absl::Time t0 = absl::UnixEpoch();
static_assert(t0 == absl::UnixEpoch(), "UnixEpoch");
constexpr absl::Time t1 = absl::InfiniteFuture();
@@ -219,7 +213,7 @@
static_assert(t1 >= t1, "");
static_assert(t3 >= t1, "");
-#ifdef ABSL_INTERNAL_TIME_HAS_THREE_WAY_COMPARISON
+#ifdef __cpp_impl_three_way_comparison
static_assert((t1 <=> t1) == std::strong_ordering::equal, "");
static_assert((t2 <=> t2) == std::strong_ordering::equal, "");
@@ -233,7 +227,7 @@
static_assert((t3 <=> t2) == std::strong_ordering::greater, "");
static_assert((t3 <=> t1) == std::strong_ordering::greater, "");
-#endif // ABSL_INTERNAL_TIME_HAS_THREE_WAY_COMPARISON
+#endif // __cpp_impl_three_way_comparison
}
TEST(Time, Infinity) {
@@ -245,14 +239,14 @@
static_assert(ipast < ifuture, "");
static_assert(ifuture > ipast, "");
-#ifdef ABSL_INTERNAL_TIME_HAS_THREE_WAY_COMPARISON
+#ifdef __cpp_impl_three_way_comparison
static_assert((ifuture <=> ifuture) == std::strong_ordering::equal, "");
static_assert((ipast <=> ipast) == std::strong_ordering::equal, "");
static_assert((ipast <=> ifuture) == std::strong_ordering::less, "");
static_assert((ifuture <=> ipast) == std::strong_ordering::greater, "");
-#endif // ABSL_INTERNAL_TIME_HAS_THREE_WAY_COMPARISON
+#endif // __cpp_impl_three_way_comparison
// Arithmetic saturates
EXPECT_EQ(ifuture, ifuture + absl::Seconds(1));
@@ -269,14 +263,14 @@
static_assert(t < ifuture, "");
static_assert(t > ipast, "");
-#ifdef ABSL_INTERNAL_TIME_HAS_THREE_WAY_COMPARISON
+#ifdef __cpp_impl_three_way_comparison
static_assert((t <=> ifuture) == std::strong_ordering::less, "");
static_assert((t <=> ipast) == std::strong_ordering::greater, "");
static_assert((ipast <=> t) == std::strong_ordering::less, "");
static_assert((ifuture <=> t) == std::strong_ordering::greater, "");
-#endif // ABSL_INTERNAL_TIME_HAS_THREE_WAY_COMPARISON
+#endif // __cpp_impl_three_way_comparison
EXPECT_EQ(ifuture, t + absl::InfiniteDuration());
EXPECT_EQ(ipast, t - absl::InfiniteDuration());
diff --git a/absl/types/BUILD.bazel b/absl/types/BUILD.bazel
index 532afa6..a86e2c1 100644
--- a/absl/types/BUILD.bazel
+++ b/absl/types/BUILD.bazel
@@ -86,8 +86,8 @@
"//absl/base:exception_testing",
"//absl/container:test_instance_tracker",
"//absl/log",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -100,8 +100,8 @@
":any",
"//absl/base:config",
"//absl/base:exception_safety_testing",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -117,7 +117,6 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
"//absl/algorithm",
- "//absl/base:config",
"//absl/base:core_headers",
"//absl/base:nullability",
"//absl/base:throw_delegate",
@@ -141,8 +140,8 @@
"//absl/hash:hash_testing",
"//absl/meta:type_traits",
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -202,8 +201,8 @@
"//absl/log",
"//absl/meta:type_traits",
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -218,8 +217,8 @@
":optional",
"//absl/base:config",
"//absl/base:exception_safety_testing",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -252,8 +251,8 @@
"//absl/memory",
"//absl/meta:type_traits",
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -268,8 +267,8 @@
deps = [
":variant",
"//absl/utility",
- "@google_benchmark//:benchmark_main",
- "@googletest//:gtest",
+ "@com_github_google_benchmark//:benchmark_main",
+ "@com_google_googletest//:gtest",
],
)
@@ -286,8 +285,8 @@
"//absl/base:config",
"//absl/base:exception_safety_testing",
"//absl/memory",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -313,7 +312,7 @@
deps = [
":compare",
"//absl/base",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
diff --git a/absl/types/CMakeLists.txt b/absl/types/CMakeLists.txt
index 400b49a..fed532f 100644
--- a/absl/types/CMakeLists.txt
+++ b/absl/types/CMakeLists.txt
@@ -114,7 +114,6 @@
${ABSL_DEFAULT_COPTS}
DEPS
absl::algorithm
- absl::config
absl::core_headers
absl::nullability
absl::throw_delegate
diff --git a/absl/types/internal/span.h b/absl/types/internal/span.h
index 1039f61..ab89ba3 100644
--- a/absl/types/internal/span.h
+++ b/absl/types/internal/span.h
@@ -22,7 +22,6 @@
#include <type_traits>
#include "absl/algorithm/algorithm.h"
-#include "absl/base/config.h"
#include "absl/base/internal/throw_delegate.h"
#include "absl/meta/type_traits.h"
@@ -87,13 +86,13 @@
typename std::enable_if<!std::is_const<T>::value, int>::type;
template <template <typename> class SpanT, typename T>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool EqualImpl(SpanT<T> a, SpanT<T> b) {
+bool EqualImpl(SpanT<T> a, SpanT<T> b) {
static_assert(std::is_const<T>::value, "");
return std::equal(a.begin(), a.end(), b.begin(), b.end());
}
template <template <typename> class SpanT, typename T>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool LessThanImpl(SpanT<T> a, SpanT<T> b) {
+bool LessThanImpl(SpanT<T> a, SpanT<T> b) {
// We can't use value_type since that is remove_cv_t<T>, so we go the long way
// around.
static_assert(std::is_const<T>::value, "");
diff --git a/absl/types/optional.h b/absl/types/optional.h
index 0d8f870..cf7249c 100644
--- a/absl/types/optional.h
+++ b/absl/types/optional.h
@@ -429,16 +429,14 @@
// Accesses the underlying `T` value of an `optional`. If the `optional` is
// empty, behavior is undefined.
constexpr const T& operator*() const& ABSL_ATTRIBUTE_LIFETIME_BOUND {
- ABSL_HARDENING_ASSERT(this->engaged_);
- return reference();
+ return ABSL_HARDENING_ASSERT(this->engaged_), reference();
}
T& operator*() & ABSL_ATTRIBUTE_LIFETIME_BOUND {
ABSL_HARDENING_ASSERT(this->engaged_);
return reference();
}
constexpr const T&& operator*() const&& ABSL_ATTRIBUTE_LIFETIME_BOUND {
- ABSL_HARDENING_ASSERT(this->engaged_);
- return std::move(reference());
+ return ABSL_HARDENING_ASSERT(this->engaged_), std::move(reference());
}
T&& operator*() && ABSL_ATTRIBUTE_LIFETIME_BOUND {
ABSL_HARDENING_ASSERT(this->engaged_);
diff --git a/absl/types/span.h b/absl/types/span.h
index 33904a9..a0f8027 100644
--- a/absl/types/span.h
+++ b/absl/types/span.h
@@ -61,7 +61,6 @@
#include <utility>
#include "absl/base/attributes.h"
-#include "absl/base/config.h"
#include "absl/base/internal/throw_delegate.h"
#include "absl/base/macros.h"
#include "absl/base/nullability.h"
@@ -73,33 +72,6 @@
namespace absl {
ABSL_NAMESPACE_BEGIN
-template <typename T>
-class Span;
-
-ABSL_NAMESPACE_END
-} // namespace absl
-
-// If std::ranges is available, mark Span as satisfying the `view` and
-// `borrowed_range` concepts, just like std::span.
-#if !defined(__has_include)
-#define __has_include(header) 0
-#endif
-#if __has_include(<version>)
-#include <version> // NOLINT(misc-include-cleaner)
-#endif
-#if defined(__cpp_lib_ranges) && __cpp_lib_ranges >= 201911L
-#include <ranges> // NOLINT(build/c++20)
-template <typename T>
- // NOLINTNEXTLINE(build/c++20)
-inline constexpr bool std::ranges::enable_view<absl::Span<T>> = true;
-template <typename T>
- // NOLINTNEXTLINE(build/c++20)
-inline constexpr bool std::ranges::enable_borrowed_range<absl::Span<T>> = true;
-#endif
-
-namespace absl {
-ABSL_NAMESPACE_BEGIN
-
//------------------------------------------------------------------------------
// Span
//------------------------------------------------------------------------------
@@ -179,7 +151,7 @@
// int* my_array = new int[10];
// MyRoutine(absl::Span<const int>(my_array, 10));
template <typename T>
-class ABSL_ATTRIBUTE_VIEW Span {
+class ABSL_INTERNAL_ATTRIBUTE_VIEW Span {
private:
// Used to determine whether a Span can be constructed from a container of
// type C.
@@ -215,18 +187,15 @@
using difference_type = ptrdiff_t;
using absl_internal_is_view = std::true_type;
- // NOLINTNEXTLINE
static const size_type npos = ~(size_type(0));
constexpr Span() noexcept : Span(nullptr, 0) {}
- constexpr Span(pointer array ABSL_ATTRIBUTE_LIFETIME_BOUND,
- size_type length) noexcept
+ constexpr Span(pointer array, size_type length) noexcept
: ptr_(array), len_(length) {}
// Implicit conversion constructors
template <size_t N>
- constexpr Span(T( // NOLINT(google-explicit-constructor)
- &a ABSL_ATTRIBUTE_LIFETIME_BOUND)[N]) noexcept
+ constexpr Span(T (&a)[N]) noexcept // NOLINT(runtime/explicit)
: Span(a, N) {}
// Explicit reference constructor for a mutable `Span<T>` type. Can be
@@ -243,8 +212,9 @@
template <typename V, typename = EnableIfConvertibleFrom<V>,
typename = EnableIfValueIsConst<V>,
typename = span_internal::EnableIfNotIsView<V>>
- // NOLINTNEXTLINE(google-explicit-constructor)
- constexpr Span(const V& v ABSL_ATTRIBUTE_LIFETIME_BOUND) noexcept
+ constexpr Span(
+ const V& v
+ ABSL_ATTRIBUTE_LIFETIME_BOUND) noexcept // NOLINT(runtime/explicit)
: Span(span_internal::GetData(v), v.size()) {}
// Overloads of the above two functions that are only enabled for view types.
@@ -259,7 +229,7 @@
template <typename V, typename = EnableIfConvertibleFrom<V>,
typename = EnableIfValueIsConst<V>,
span_internal::EnableIfIsView<V> = 0>
- constexpr Span(const V& v) noexcept // NOLINT(google-explicit-constructor)
+ constexpr Span(const V& v) noexcept // NOLINT(runtime/explicit)
: Span(span_internal::GetData(v), v.size()) {}
// Implicit constructor from an initializer list, making it possible to pass a
@@ -330,8 +300,7 @@
//
// Returns a reference to the i'th element of this span.
constexpr reference operator[](size_type i) const noexcept {
- ABSL_HARDENING_ASSERT(i < size());
- return ptr_[i];
+ return ABSL_HARDENING_ASSERT(i < size()), ptr_[i];
}
// Span::at()
@@ -350,8 +319,7 @@
// Returns a reference to the first element of this span. The span must not
// be empty.
constexpr reference front() const noexcept {
- ABSL_HARDENING_ASSERT(size() > 0);
- return *data();
+ return ABSL_HARDENING_ASSERT(size() > 0), *data();
}
// Span::back()
@@ -359,8 +327,7 @@
// Returns a reference to the last element of this span. The span must not
// be empty.
constexpr reference back() const noexcept {
- ABSL_HARDENING_ASSERT(size() > 0);
- return *(data() + size() - 1);
+ return ABSL_HARDENING_ASSERT(size() > 0), *(data() + size() - 1);
}
// Span::begin()
@@ -525,165 +492,157 @@
// operator==
template <typename T>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator==(Span<T> a, Span<T> b) {
+bool operator==(Span<T> a, Span<T> b) {
return span_internal::EqualImpl<Span, const T>(a, b);
}
template <typename T>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator==(Span<const T> a,
- Span<T> b) {
+bool operator==(Span<const T> a, Span<T> b) {
return span_internal::EqualImpl<Span, const T>(a, b);
}
template <typename T>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator==(Span<T> a,
- Span<const T> b) {
+bool operator==(Span<T> a, Span<const T> b) {
return span_internal::EqualImpl<Span, const T>(a, b);
}
template <
typename T, typename U,
typename = span_internal::EnableIfConvertibleTo<U, absl::Span<const T>>>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator==(const U& a, Span<T> b) {
+bool operator==(const U& a, Span<T> b) {
return span_internal::EqualImpl<Span, const T>(a, b);
}
template <
typename T, typename U,
typename = span_internal::EnableIfConvertibleTo<U, absl::Span<const T>>>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator==(Span<T> a, const U& b) {
+bool operator==(Span<T> a, const U& b) {
return span_internal::EqualImpl<Span, const T>(a, b);
}
// operator!=
template <typename T>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator!=(Span<T> a, Span<T> b) {
+bool operator!=(Span<T> a, Span<T> b) {
return !(a == b);
}
template <typename T>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator!=(Span<const T> a,
- Span<T> b) {
+bool operator!=(Span<const T> a, Span<T> b) {
return !(a == b);
}
template <typename T>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator!=(Span<T> a,
- Span<const T> b) {
+bool operator!=(Span<T> a, Span<const T> b) {
return !(a == b);
}
template <
typename T, typename U,
typename = span_internal::EnableIfConvertibleTo<U, absl::Span<const T>>>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator!=(const U& a, Span<T> b) {
+bool operator!=(const U& a, Span<T> b) {
return !(a == b);
}
template <
typename T, typename U,
typename = span_internal::EnableIfConvertibleTo<U, absl::Span<const T>>>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator!=(Span<T> a, const U& b) {
+bool operator!=(Span<T> a, const U& b) {
return !(a == b);
}
// operator<
template <typename T>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator<(Span<T> a, Span<T> b) {
+bool operator<(Span<T> a, Span<T> b) {
return span_internal::LessThanImpl<Span, const T>(a, b);
}
template <typename T>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator<(Span<const T> a, Span<T> b) {
+bool operator<(Span<const T> a, Span<T> b) {
return span_internal::LessThanImpl<Span, const T>(a, b);
}
template <typename T>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator<(Span<T> a, Span<const T> b) {
+bool operator<(Span<T> a, Span<const T> b) {
return span_internal::LessThanImpl<Span, const T>(a, b);
}
template <
typename T, typename U,
typename = span_internal::EnableIfConvertibleTo<U, absl::Span<const T>>>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator<(const U& a, Span<T> b) {
+bool operator<(const U& a, Span<T> b) {
return span_internal::LessThanImpl<Span, const T>(a, b);
}
template <
typename T, typename U,
typename = span_internal::EnableIfConvertibleTo<U, absl::Span<const T>>>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator<(Span<T> a, const U& b) {
+bool operator<(Span<T> a, const U& b) {
return span_internal::LessThanImpl<Span, const T>(a, b);
}
// operator>
template <typename T>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator>(Span<T> a, Span<T> b) {
+bool operator>(Span<T> a, Span<T> b) {
return b < a;
}
template <typename T>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator>(Span<const T> a, Span<T> b) {
+bool operator>(Span<const T> a, Span<T> b) {
return b < a;
}
template <typename T>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator>(Span<T> a, Span<const T> b) {
+bool operator>(Span<T> a, Span<const T> b) {
return b < a;
}
template <
typename T, typename U,
typename = span_internal::EnableIfConvertibleTo<U, absl::Span<const T>>>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator>(const U& a, Span<T> b) {
+bool operator>(const U& a, Span<T> b) {
return b < a;
}
template <
typename T, typename U,
typename = span_internal::EnableIfConvertibleTo<U, absl::Span<const T>>>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator>(Span<T> a, const U& b) {
+bool operator>(Span<T> a, const U& b) {
return b < a;
}
// operator<=
template <typename T>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator<=(Span<T> a, Span<T> b) {
+bool operator<=(Span<T> a, Span<T> b) {
return !(b < a);
}
template <typename T>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator<=(Span<const T> a,
- Span<T> b) {
+bool operator<=(Span<const T> a, Span<T> b) {
return !(b < a);
}
template <typename T>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator<=(Span<T> a,
- Span<const T> b) {
+bool operator<=(Span<T> a, Span<const T> b) {
return !(b < a);
}
template <
typename T, typename U,
typename = span_internal::EnableIfConvertibleTo<U, absl::Span<const T>>>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator<=(const U& a, Span<T> b) {
+bool operator<=(const U& a, Span<T> b) {
return !(b < a);
}
template <
typename T, typename U,
typename = span_internal::EnableIfConvertibleTo<U, absl::Span<const T>>>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator<=(Span<T> a, const U& b) {
+bool operator<=(Span<T> a, const U& b) {
return !(b < a);
}
// operator>=
template <typename T>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator>=(Span<T> a, Span<T> b) {
+bool operator>=(Span<T> a, Span<T> b) {
return !(a < b);
}
template <typename T>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator>=(Span<const T> a,
- Span<T> b) {
+bool operator>=(Span<const T> a, Span<T> b) {
return !(a < b);
}
template <typename T>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator>=(Span<T> a,
- Span<const T> b) {
+bool operator>=(Span<T> a, Span<const T> b) {
return !(a < b);
}
template <
typename T, typename U,
typename = span_internal::EnableIfConvertibleTo<U, absl::Span<const T>>>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator>=(const U& a, Span<T> b) {
+bool operator>=(const U& a, Span<T> b) {
return !(a < b);
}
template <
typename T, typename U,
typename = span_internal::EnableIfConvertibleTo<U, absl::Span<const T>>>
-ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator>=(Span<T> a, const U& b) {
+bool operator>=(Span<T> a, const U& b) {
return !(a < b);
}
@@ -730,8 +689,8 @@
template <int&... ExplicitArgumentBarrier, typename T>
Span<T> MakeSpan(absl::Nullable<T*> begin, absl::Nullable<T*> end) noexcept {
- ABSL_HARDENING_ASSERT(begin <= end);
- return Span<T>(begin, static_cast<size_t>(end - begin));
+ return ABSL_HARDENING_ASSERT(begin <= end),
+ Span<T>(begin, static_cast<size_t>(end - begin));
}
template <int&... ExplicitArgumentBarrier, typename C>
@@ -778,8 +737,7 @@
template <int&... ExplicitArgumentBarrier, typename T>
Span<const T> MakeConstSpan(absl::Nullable<T*> begin,
absl::Nullable<T*> end) noexcept {
- ABSL_HARDENING_ASSERT(begin <= end);
- return Span<const T>(begin, end - begin);
+ return ABSL_HARDENING_ASSERT(begin <= end), Span<const T>(begin, end - begin);
}
template <int&... ExplicitArgumentBarrier, typename C>
diff --git a/absl/types/span_test.cc b/absl/types/span_test.cc
index a1a207f..e24144d 100644
--- a/absl/types/span_test.cc
+++ b/absl/types/span_test.cc
@@ -787,9 +787,9 @@
template <int i>
struct ConstexprTester {};
-#define ABSL_TEST_CONSTEXPR(expr) \
- do { \
- ABSL_ATTRIBUTE_UNUSED ConstexprTester<(static_cast<void>(expr), 1)> t; \
+#define ABSL_TEST_CONSTEXPR(expr) \
+ do { \
+ ABSL_ATTRIBUTE_UNUSED ConstexprTester<(expr, 1)> t; \
} while (0)
struct ContainerWithConstexprMethods {
@@ -826,41 +826,6 @@
ABSL_TEST_CONSTEXPR(span[0]);
}
-#if defined(ABSL_INTERNAL_CPLUSPLUS_LANG) && \
- ABSL_INTERNAL_CPLUSPLUS_LANG >= 202002L
-
-TEST(ConstIntSpan, ConstexprRelOpsTest) {
- static constexpr int lhs_data[] = {1, 2, 3};
- static constexpr int rhs_data[] = {1, 2, 3};
-
- constexpr absl::Span<const int> lhs = absl::MakeConstSpan(lhs_data, 3);
- constexpr absl::Span<const int> rhs = absl::MakeConstSpan(rhs_data, 3);
-
- ABSL_TEST_CONSTEXPR(lhs_data == rhs);
- ABSL_TEST_CONSTEXPR(lhs_data != rhs);
- ABSL_TEST_CONSTEXPR(lhs_data < rhs);
- ABSL_TEST_CONSTEXPR(lhs_data <= rhs);
- ABSL_TEST_CONSTEXPR(lhs_data > rhs);
- ABSL_TEST_CONSTEXPR(lhs_data >= rhs);
-
- ABSL_TEST_CONSTEXPR(lhs == rhs);
- ABSL_TEST_CONSTEXPR(lhs != rhs);
- ABSL_TEST_CONSTEXPR(lhs < rhs);
- ABSL_TEST_CONSTEXPR(lhs <= rhs);
- ABSL_TEST_CONSTEXPR(lhs > rhs);
- ABSL_TEST_CONSTEXPR(lhs >= rhs);
-
- ABSL_TEST_CONSTEXPR(lhs == rhs_data);
- ABSL_TEST_CONSTEXPR(lhs != rhs_data);
- ABSL_TEST_CONSTEXPR(lhs < rhs_data);
- ABSL_TEST_CONSTEXPR(lhs <= rhs_data);
- ABSL_TEST_CONSTEXPR(lhs > rhs_data);
- ABSL_TEST_CONSTEXPR(lhs >= rhs_data);
-}
-
-#endif // defined(ABSL_INTERNAL_CPLUSPLUS_LANG) &&
- // ABSL_INTERNAL_CPLUSPLUS_LANG >= 202002L
-
struct BigStruct {
char bytes[10000];
};
diff --git a/absl/utility/BUILD.bazel b/absl/utility/BUILD.bazel
index 0b6ce3b..1c01fc1 100644
--- a/absl/utility/BUILD.bazel
+++ b/absl/utility/BUILD.bazel
@@ -56,8 +56,8 @@
"//absl/base:core_headers",
"//absl/memory",
"//absl/strings",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
@@ -80,7 +80,7 @@
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":if_constexpr",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
+ "@com_google_googletest//:gtest",
+ "@com_google_googletest//:gtest_main",
],
)
diff --git a/ci/linux_docker_containers.sh b/ci/linux_docker_containers.sh
index cb4893a..fefef92 100644
--- a/ci/linux_docker_containers.sh
+++ b/ci/linux_docker_containers.sh
@@ -16,7 +16,7 @@
# Test scripts should source this file to get the identifiers.
readonly LINUX_ALPINE_CONTAINER="gcr.io/google.com/absl-177019/alpine:20230612"
-readonly LINUX_CLANG_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20241218"
+readonly LINUX_CLANG_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20240523"
readonly LINUX_ARM_CLANG_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_arm_hybrid-latest:20231219"
-readonly LINUX_GCC_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20241218"
-readonly LINUX_GCC_FLOOR_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-floor:20241218"
+readonly LINUX_GCC_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20240523"
+readonly LINUX_GCC_FLOOR_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-floor:20240717"
diff --git a/ci/linux_gcc-floor_libstdcxx_bazel.sh b/ci/linux_gcc-floor_libstdcxx_bazel.sh
index ef1bb54..b2d8c1d 100755
--- a/ci/linux_gcc-floor_libstdcxx_bazel.sh
+++ b/ci/linux_gcc-floor_libstdcxx_bazel.sh
@@ -78,6 +78,7 @@
--copt="-DGTEST_REMOVE_LEGACY_TEST_CASEAPI_=1" \
--copt=-Werror \
--define="absl=1" \
+ --distdir="/bazel-distdir" \
--enable_bzlmod=false \
--features=external_include_paths \
--keep_going \
diff --git a/ci/macos_xcode_bazel.sh b/ci/macos_xcode_bazel.sh
index fe4e2eb..bb8fb4b 100755
--- a/ci/macos_xcode_bazel.sh
+++ b/ci/macos_xcode_bazel.sh
@@ -24,7 +24,7 @@
fi
# If we are running on Kokoro, check for a versioned Bazel binary.
-KOKORO_GFILE_BAZEL_BIN="bazel-8.0.0-darwin-x86_64"
+KOKORO_GFILE_BAZEL_BIN="bazel-7.0.0-darwin-x86_64"
if [[ ${KOKORO_GFILE_DIR:-} ]] && [[ -f ${KOKORO_GFILE_DIR}/${KOKORO_GFILE_BAZEL_BIN} ]]; then
BAZEL_BIN="${KOKORO_GFILE_DIR}/${KOKORO_GFILE_BAZEL_BIN}"
chmod +x ${BAZEL_BIN}
@@ -52,9 +52,6 @@
cp ${ALTERNATE_OPTIONS:-} absl/base/options.h || exit 1
fi
-# Avoid using the system version of google-benchmark.
-brew uninstall google-benchmark
-
${BAZEL_BIN} test ... \
--copt="-DGTEST_REMOVE_LEGACY_TEST_CASEAPI_=1" \
--copt="-Werror" \
diff --git a/ci/windows_clangcl_bazel.bat b/ci/windows_clangcl_bazel.bat
index 93ac028..b031c30 100755
--- a/ci/windows_clangcl_bazel.bat
+++ b/ci/windows_clangcl_bazel.bat
@@ -39,7 +39,7 @@
:: /google/data/rw/teams/absl/kokoro/windows.
::
:: TODO(absl-team): Remove -Wno-microsoft-cast
-%KOKORO_GFILE_DIR%\bazel-8.0.0-windows-x86_64.exe ^
+%KOKORO_GFILE_DIR%\bazel-7.0.0-windows-x86_64.exe ^
test ... ^
--compilation_mode=%COMPILATION_MODE% ^
--compiler=clang-cl ^
diff --git a/ci/windows_msvc_bazel.bat b/ci/windows_msvc_bazel.bat
index 78ce28f..e2acf5f 100755
--- a/ci/windows_msvc_bazel.bat
+++ b/ci/windows_msvc_bazel.bat
@@ -34,7 +34,7 @@
:: To upgrade Bazel, first download a new binary from
:: https://github.com/bazelbuild/bazel/releases and copy it to
:: /google/data/rw/teams/absl/kokoro/windows.
-%KOKORO_GFILE_DIR%\bazel-8.0.0-windows-x86_64.exe ^
+%KOKORO_GFILE_DIR%\bazel-7.0.0-windows-x86_64.exe ^
test ... ^
--compilation_mode=%COMPILATION_MODE% ^
--copt=/WX ^