diff --git a/CMake/AbseilDll.cmake b/CMake/AbseilDll.cmake index 8abab5d..2e3a2f2 100644 --- a/CMake/AbseilDll.cmake +++ b/CMake/AbseilDll.cmake
@@ -22,7 +22,6 @@ "base/internal/dynamic_annotations.h" "base/internal/endian.h" "base/internal/errno_saver.h" - "base/internal/hardening.cc" "base/internal/hardening.h" "base/internal/hide_ptr.h" "base/internal/iterator_traits.h"
diff --git a/absl/algorithm/BUILD.bazel b/absl/algorithm/BUILD.bazel index 337f035..10b9400 100644 --- a/absl/algorithm/BUILD.bazel +++ b/absl/algorithm/BUILD.bazel
@@ -88,7 +88,6 @@ "//absl/base", "//absl/base:config", "//absl/base:core_headers", - "//absl/base:hardening", "//absl/memory", "//absl/meta:type_traits", "//absl/random",
diff --git a/absl/algorithm/CMakeLists.txt b/absl/algorithm/CMakeLists.txt index eb20132..cd7fa22 100644 --- a/absl/algorithm/CMakeLists.txt +++ b/absl/algorithm/CMakeLists.txt
@@ -37,7 +37,6 @@ DEPS absl::algorithm absl::config - absl::hardening GTest::gmock_main )
diff --git a/absl/algorithm/container.h b/absl/algorithm/container.h index a6b60cb..9d2b48e 100644 --- a/absl/algorithm/container.h +++ b/absl/algorithm/container.h
@@ -218,7 +218,7 @@ // types that satisfy std::ranges::borrowed_range. template <typename C> using IsPermissibleDestinationRange = - std::conditional_t<std::is_lvalue_reference<C>::value, std::true_type, + std::conditional_t<std::is_lvalue_reference_v<C>, std::true_type, IsSpan<C>>; template <typename C, typename OutputRange>
diff --git a/absl/algorithm/container_test.cc b/absl/algorithm/container_test.cc index 7778dce..e025382 100644 --- a/absl/algorithm/container_test.cc +++ b/absl/algorithm/container_test.cc
@@ -36,7 +36,6 @@ #include "gtest/gtest.h" #include "absl/base/casts.h" #include "absl/base/config.h" -#include "absl/base/internal/hardening.h" #include "absl/base/macros.h" #include "absl/memory/memory.h" #include "absl/meta/type_traits.h" @@ -873,7 +872,6 @@ (void)actual; #if GTEST_HAS_DEATH_TEST if (IsHardened()) { - absl::base_internal::ScopedSetAbslHardeningForTesting hardener(true); EXPECT_DEATH(absl::c_copy(input, actual), ""); } #endif @@ -885,7 +883,6 @@ (void)actual; #if GTEST_HAS_DEATH_TEST if (IsHardened()) { - absl::base_internal::ScopedSetAbslHardeningForTesting hardener(true); EXPECT_DEATH(absl::c_copy_n(input, 3, actual), ""); } #endif @@ -897,7 +894,6 @@ (void)actual; #if GTEST_HAS_DEATH_TEST if (IsHardened()) { - absl::base_internal::ScopedSetAbslHardeningForTesting hardener(true); EXPECT_DEATH(absl::c_copy_n(input, 4, actual), ""); } #endif @@ -908,7 +904,6 @@ std::list<int> actual = {0, 0, 0}; #if GTEST_HAS_DEATH_TEST if (IsHardened()) { - absl::base_internal::ScopedSetAbslHardeningForTesting hardener(true); EXPECT_DEATH(absl::c_copy(input, actual), ""); } #endif @@ -919,7 +914,6 @@ std::vector<int> actual = {0, 0, 0, 0}; #if GTEST_HAS_DEATH_TEST if (IsHardened()) { - absl::base_internal::ScopedSetAbslHardeningForTesting hardener(true); EXPECT_DEATH(absl::c_copy_n(input, 4, actual), ""); } #endif @@ -930,7 +924,6 @@ std::vector<int> actual = {0, 0}; #if GTEST_HAS_DEATH_TEST if (IsHardened()) { - absl::base_internal::ScopedSetAbslHardeningForTesting hardener(true); EXPECT_DEATH(absl::c_copy_n(input, 3, actual), ""); } #endif @@ -941,7 +934,6 @@ std::forward_list<int> actual = {0, 0, 0}; #if GTEST_HAS_DEATH_TEST if (IsHardened()) { - absl::base_internal::ScopedSetAbslHardeningForTesting hardener(true); EXPECT_DEATH(absl::c_copy(input, actual), ""); } #endif @@ -952,7 +944,6 @@ std::forward_list<int> actual = {0, 0, 0, 0}; #if GTEST_HAS_DEATH_TEST if (IsHardened()) { - absl::base_internal::ScopedSetAbslHardeningForTesting hardener(true); EXPECT_DEATH(absl::c_copy_n(input, 4, actual), ""); } #endif @@ -963,7 +954,6 @@ std::forward_list<int> actual = {0, 0}; #if GTEST_HAS_DEATH_TEST if (IsHardened()) { - absl::base_internal::ScopedSetAbslHardeningForTesting hardener(true); EXPECT_DEATH(absl::c_copy_n(input, 3, actual), ""); } #endif @@ -1117,7 +1107,6 @@ (void)actual; #if GTEST_HAS_DEATH_TEST if (IsHardened()) { - absl::base_internal::ScopedSetAbslHardeningForTesting hardener(true); EXPECT_DEATH(absl::c_move(input, actual), ""); } #endif @@ -1128,7 +1117,6 @@ std::list<int> actual = {0, 0, 0}; #if GTEST_HAS_DEATH_TEST if (IsHardened()) { - absl::base_internal::ScopedSetAbslHardeningForTesting hardener(true); EXPECT_DEATH(absl::c_move(input, actual), ""); } #endif @@ -1139,7 +1127,6 @@ std::forward_list<int> actual = {0, 0, 0}; #if GTEST_HAS_DEATH_TEST if (IsHardened()) { - absl::base_internal::ScopedSetAbslHardeningForTesting hardener(true); EXPECT_DEATH(absl::c_move(input, actual), ""); } #endif @@ -1243,7 +1230,6 @@ (void)actual; #if GTEST_HAS_DEATH_TEST if (IsHardened()) { - absl::base_internal::ScopedSetAbslHardeningForTesting hardener(true); EXPECT_DEATH(absl::c_transform(input, actual, [](int x) { return x * 2; }), ""); } @@ -1257,7 +1243,6 @@ (void)actual; #if GTEST_HAS_DEATH_TEST if (IsHardened()) { - absl::base_internal::ScopedSetAbslHardeningForTesting hardener(true); EXPECT_DEATH(absl::c_transform(input1, input2, actual, std::plus<int>()), ""); } @@ -1269,7 +1254,6 @@ std::list<int> actual = {0, 0, 0}; #if GTEST_HAS_DEATH_TEST if (IsHardened()) { - absl::base_internal::ScopedSetAbslHardeningForTesting hardener(true); EXPECT_DEATH(absl::c_transform(input, actual, [](int x) { return x * 2; }), ""); } @@ -1282,7 +1266,6 @@ std::vector<int> actual = {0, 0, 0}; #if GTEST_HAS_DEATH_TEST if (IsHardened()) { - absl::base_internal::ScopedSetAbslHardeningForTesting hardener(true); EXPECT_DEATH(absl::c_transform(input1, input2, actual, std::plus<int>()), ""); } @@ -1295,7 +1278,6 @@ std::vector<int> actual = {0}; #if GTEST_HAS_DEATH_TEST if (IsHardened()) { - absl::base_internal::ScopedSetAbslHardeningForTesting hardener(true); EXPECT_DEATH(absl::c_transform(input1, input2, actual, std::plus<int>()), ""); } @@ -1308,7 +1290,6 @@ std::vector<int> actual = {0}; #if GTEST_HAS_DEATH_TEST if (IsHardened()) { - absl::base_internal::ScopedSetAbslHardeningForTesting hardener(true); EXPECT_DEATH(absl::c_transform(input1, input2, actual, std::plus<int>()), ""); }
diff --git a/absl/base/BUILD.bazel b/absl/base/BUILD.bazel index 6bbddd4..059f43b 100644 --- a/absl/base/BUILD.bazel +++ b/absl/base/BUILD.bazel
@@ -79,7 +79,6 @@ cc_library( name = "hardening", - srcs = ["internal/hardening.cc"], hdrs = [ "internal/hardening.h", ],
diff --git a/absl/base/CMakeLists.txt b/absl/base/CMakeLists.txt index 2a20d74..73eea03 100644 --- a/absl/base/CMakeLists.txt +++ b/absl/base/CMakeLists.txt
@@ -61,8 +61,6 @@ hardening HDRS "internal/hardening.h" - SRCS - "internal/hardening.cc" DEPS absl::config absl::core_headers
diff --git a/absl/base/attributes.h b/absl/base/attributes.h index 6ec0446..53e440e 100644 --- a/absl/base/attributes.h +++ b/absl/base/attributes.h
@@ -782,22 +782,20 @@ // ABSL_CONST_INIT // -// A variable declaration annotated with the `ABSL_CONST_INIT` attribute will -// not compile (on supported platforms) unless the variable has a constant -// initializer. This is useful for variables with static and thread storage -// duration, because it guarantees that they will not suffer from the so-called -// "static init order fiasco". +// A variable declared with `ABSL_CONST_INIT` will not compile (on supported +// platforms) unless the variable has a constant initializer. This is useful for +// variables with static and thread storage duration, because it guarantees that +// they will not suffer from the so-called "static init order fiasco". // -// This attribute must be placed on the initializing declaration of the -// variable. Some compilers will give a -Wmissing-constinit warning when this -// attribute is placed on some other declaration but missing from the -// initializing declaration. +// `ABSL_CONST_INIT` must be placed on the initializing declaration +// (i.e. definition) of the variable. Some compilers will give a +// `-Wmissing-constinit` warning when it is placed on some other +// declaration but missing from the initializing declaration. // -// In some cases (notably with thread_local variables), `ABSL_CONST_INIT` can -// also be used in a non-initializing declaration to tell the compiler that a -// variable is already initialized, reducing overhead that would otherwise be -// incurred by a hidden guard variable. Thus annotating all declarations with -// this attribute is recommended to potentially enhance optimization. +// For thread_local variables, placing `ABSL_CONST_INIT` on the non-initializing +// declaration tells the compiler that the variable is already initialized, +// reducing overhead that would otherwise be incurred by a hidden guard +// variable. // // Example: // @@ -809,9 +807,10 @@ // ABSL_CONST_INIT MyType MyClass::my_var = MakeMyType(...); // // For code or headers that are assured to only build with C++20 and up, prefer -// just using the standard `constinit` keyword directly over this macro. +// using the standard `constinit` keyword directly over this macro. // -// Note that this attribute is redundant if the variable is declared constexpr. +// Note that `ABSL_CONST_INIT` must not be used on a variable declared +// constexpr. #if defined(__cpp_constinit) && __cpp_constinit >= 201907L #define ABSL_CONST_INIT constinit #elif ABSL_HAVE_CPP_ATTRIBUTE(clang::require_constant_initialization)
diff --git a/absl/base/internal/cycleclock.cc b/absl/base/internal/cycleclock.cc index 9946601..af6babf 100644 --- a/absl/base/internal/cycleclock.cc +++ b/absl/base/internal/cycleclock.cc
@@ -28,6 +28,7 @@ #include "absl/base/attributes.h" #include "absl/base/config.h" #include "absl/base/internal/unscaledcycleclock.h" +#include "absl/base/internal/unscaledcycleclock_config.h" namespace absl { ABSL_NAMESPACE_BEGIN
diff --git a/absl/base/internal/cycleclock.h b/absl/base/internal/cycleclock.h index cbfdf57..5abffa5 100644 --- a/absl/base/internal/cycleclock.h +++ b/absl/base/internal/cycleclock.h
@@ -49,6 +49,7 @@ #include "absl/base/config.h" #include "absl/base/internal/cycleclock_config.h" #include "absl/base/internal/unscaledcycleclock.h" +#include "absl/base/internal/unscaledcycleclock_config.h" namespace absl { ABSL_NAMESPACE_BEGIN
diff --git a/absl/base/internal/direct_mmap.h b/absl/base/internal/direct_mmap.h index 1beb2ee..f56ba23 100644 --- a/absl/base/internal/direct_mmap.h +++ b/absl/base/internal/direct_mmap.h
@@ -35,8 +35,10 @@ #include <linux/unistd.h> #include <unistd.h> + #include <cerrno> #include <cstdarg> +#include <cstddef> #include <cstdint> #ifdef __mips__
diff --git a/absl/base/internal/endian_test.cc b/absl/base/internal/endian_test.cc index a1691b1..0671951 100644 --- a/absl/base/internal/endian_test.cc +++ b/absl/base/internal/endian_test.cc
@@ -15,13 +15,16 @@ #include "absl/base/internal/endian.h" #include <algorithm> +#include <cstddef> #include <cstdint> +#include <ios> #include <limits> #include <random> #include <vector> #include "gtest/gtest.h" #include "absl/base/config.h" +#include "absl/base/internal/unaligned_access.h" namespace absl { ABSL_NAMESPACE_BEGIN
diff --git a/absl/base/internal/errno_saver_test.cc b/absl/base/internal/errno_saver_test.cc index e9b742c..06be720 100644 --- a/absl/base/internal/errno_saver_test.cc +++ b/absl/base/internal/errno_saver_test.cc
@@ -15,6 +15,7 @@ #include "absl/base/internal/errno_saver.h" #include <cerrno> +#include <ostream> #include "gmock/gmock.h" #include "gtest/gtest.h"
diff --git a/absl/base/internal/hardening.cc b/absl/base/internal/hardening.cc deleted file mode 100644 index 9b11b99..0000000 --- a/absl/base/internal/hardening.cc +++ /dev/null
@@ -1,34 +0,0 @@ -// -// Copyright 2026 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/hardening.h" - -#include <atomic> - -#include "absl/base/config.h" -#include "absl/base/macros.h" - -namespace absl { -ABSL_NAMESPACE_BEGIN - -namespace base_internal { - -void SetAbslHardeningEnabled([[maybe_unused]] bool enabled) { -} - -} // namespace base_internal - -ABSL_NAMESPACE_END -} // namespace absl
diff --git a/absl/base/internal/hardening.h b/absl/base/internal/hardening.h index ef6d327..26957a3 100644 --- a/absl/base/internal/hardening.h +++ b/absl/base/internal/hardening.h
@@ -34,8 +34,6 @@ namespace base_internal { -void SetAbslHardeningEnabled(bool enabled); - // `HardeningAssert` performs runtime checks when Abseil Hardening is enabled, // even if `NDEBUG` is defined. // @@ -132,20 +130,6 @@ #endif } -class ScopedSetAbslHardeningForTesting { - private: - bool prev_state_; - - public: - explicit ScopedSetAbslHardeningForTesting([[maybe_unused]] bool enabled) { - prev_state_ = false; - SetAbslHardeningEnabled(enabled); - } - ~ScopedSetAbslHardeningForTesting() { - absl::base_internal::SetAbslHardeningEnabled(prev_state_); - } -}; - } // namespace base_internal ABSL_NAMESPACE_END
diff --git a/absl/base/internal/hardening_test.cc b/absl/base/internal/hardening_test.cc index f819331..cffa87c 100644 --- a/absl/base/internal/hardening_test.cc +++ b/absl/base/internal/hardening_test.cc
@@ -42,28 +42,14 @@ return hardened; } -class HardeningTest : public testing::Test { - public: - ~HardeningTest() override { - absl::base_internal::SetAbslHardeningEnabled(true); - } -}; - -class HardeningDeathTest : public testing::Test { - public: - ~HardeningDeathTest() override { - absl::base_internal::SetAbslHardeningEnabled(true); - } -}; - -TEST_F(HardeningTest, HardeningAssertSlow) { +TEST(HardeningTest, HardeningAssertSlow) { absl::base_internal::HardeningAssertSlow(true); if (!IsHardenedSlow()) { absl::base_internal::HardeningAssertSlow(false); } } -TEST_F(HardeningDeathTest, HardeningAssertSlow) { +TEST(HardeningDeathTest, HardeningAssertSlow) { #if GTEST_HAS_DEATH_TEST if (IsHardenedSlow()) { // The underlying mechanism of termination varies, and may include SIGILL @@ -73,114 +59,107 @@ #endif } -TEST_F(HardeningTest, HardeningAssertGT) { +TEST(HardeningTest, HardeningAssertGT) { absl::base_internal::HardeningAssertGT(1, 0); } -TEST_F(HardeningDeathTest, HardeningAssertGT) { +TEST(HardeningDeathTest, HardeningAssertGT) { #if GTEST_HAS_DEATH_TEST if (IsHardened()) { // The underlying mechanism of termination varies, and may include SIGILL // or SIGABRT. - absl::base_internal::SetAbslHardeningEnabled(true); EXPECT_DEATH(absl::base_internal::HardeningAssertGT(1, 1), ""); EXPECT_DEATH(absl::base_internal::HardeningAssertGT(0, 1), ""); } #endif } -TEST_F(HardeningTest, HardeningAssertGE) { +TEST(HardeningTest, HardeningAssertGE) { absl::base_internal::HardeningAssertGE(1, 0); absl::base_internal::HardeningAssertGE(1, 1); } -TEST_F(HardeningDeathTest, HardeningAssertGE) { +TEST(HardeningDeathTest, HardeningAssertGE) { #if GTEST_HAS_DEATH_TEST if (IsHardened()) { // The underlying mechanism of termination varies, and may include SIGILL // or SIGABRT. - absl::base_internal::SetAbslHardeningEnabled(true); EXPECT_DEATH(absl::base_internal::HardeningAssertGE(0, 1), ""); } #endif } -TEST_F(HardeningTest, HardeningAssertLT) { +TEST(HardeningTest, HardeningAssertLT) { absl::base_internal::HardeningAssertLT(0, 1); } -TEST_F(HardeningDeathTest, HardeningAssertLT) { +TEST(HardeningDeathTest, HardeningAssertLT) { #if GTEST_HAS_DEATH_TEST if (IsHardened()) { // The underlying mechanism of termination varies, and may include SIGILL // or SIGABRT. - absl::base_internal::SetAbslHardeningEnabled(true); EXPECT_DEATH(absl::base_internal::HardeningAssertLT(1, 1), ""); EXPECT_DEATH(absl::base_internal::HardeningAssertLT(1, 0), ""); } #endif } -TEST_F(HardeningTest, HardeningAssertLE) { +TEST(HardeningTest, HardeningAssertLE) { absl::base_internal::HardeningAssertLE(0, 1); absl::base_internal::HardeningAssertLE(1, 1); } -TEST_F(HardeningDeathTest, HardeningAssertLE) { +TEST(HardeningDeathTest, HardeningAssertLE) { #if GTEST_HAS_DEATH_TEST if (IsHardened()) { // The underlying mechanism of termination varies, and may include SIGILL // or SIGABRT. - absl::base_internal::SetAbslHardeningEnabled(true); EXPECT_DEATH(absl::base_internal::HardeningAssertLE(1, 0), ""); } #endif } -TEST_F(HardeningTest, HardeningAssertInBounds) { +TEST(HardeningTest, HardeningAssertInBounds) { absl::base_internal::HardeningAssertInBounds(0, 10); } -TEST_F(HardeningDeathTest, HardeningAssertInBounds) { +TEST(HardeningDeathTest, HardeningAssertInBounds) { #if GTEST_HAS_DEATH_TEST if (IsHardened()) { // The underlying mechanism of termination varies, and may include SIGILL // or SIGABRT. - absl::base_internal::SetAbslHardeningEnabled(true); EXPECT_DEATH(absl::base_internal::HardeningAssertInBounds(10, 10), ""); } #endif } -TEST_F(HardeningTest, HardeningAssertNonEmpty) { +TEST(HardeningTest, HardeningAssertNonEmpty) { std::vector<int> v = {1}; absl::base_internal::HardeningAssertNonEmpty(v); } -TEST_F(HardeningDeathTest, HardeningAssertNonEmpty) { +TEST(HardeningDeathTest, HardeningAssertNonEmpty) { #if GTEST_HAS_DEATH_TEST if (IsHardened()) { // The underlying mechanism of termination varies, and may include SIGILL // or SIGABRT. std::vector<int> v = {}; - absl::base_internal::SetAbslHardeningEnabled(true); EXPECT_DEATH(absl::base_internal::HardeningAssertNonEmpty(v), ""); } #endif } -TEST_F(HardeningTest, HardeningAssertNonNull) { +TEST(HardeningTest, HardeningAssertNonNull) { int x = 1; absl::base_internal::HardeningAssertNonNull(&x); } -TEST_F(HardeningDeathTest, HardeningAssertNonNull) { +TEST(HardeningDeathTest, HardeningAssertNonNull) { #if GTEST_HAS_DEATH_TEST if (IsHardened()) { // The underlying mechanism of termination varies, and may include SIGILL // or SIGABRT. int *x = nullptr; - absl::base_internal::SetAbslHardeningEnabled(true); EXPECT_DEATH(absl::base_internal::HardeningAssertNonNull(x), ""); } #endif
diff --git a/absl/base/internal/low_level_alloc_test.cc b/absl/base/internal/low_level_alloc_test.cc index 8fdec09..3282076 100644 --- a/absl/base/internal/low_level_alloc_test.cc +++ b/absl/base/internal/low_level_alloc_test.cc
@@ -17,16 +17,17 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> + #include <thread> // NOLINT(build/c++11) #include <unordered_map> #include <utility> +#include "absl/container/node_hash_map.h" + #ifdef __EMSCRIPTEN__ #include <emscripten.h> #endif -#include "absl/container/node_hash_map.h" - namespace absl { ABSL_NAMESPACE_BEGIN namespace base_internal {
diff --git a/absl/base/internal/low_level_scheduling.h b/absl/base/internal/low_level_scheduling.h index bba27ef..04e44e9 100644 --- a/absl/base/internal/low_level_scheduling.h +++ b/absl/base/internal/low_level_scheduling.h
@@ -19,6 +19,7 @@ #define ABSL_BASE_INTERNAL_LOW_LEVEL_SCHEDULING_H_ #include <atomic> +#include <cstdint> #include "absl/base/internal/raw_logging.h" #include "absl/base/internal/scheduling_mode.h"
diff --git a/absl/base/internal/raw_logging.cc b/absl/base/internal/raw_logging.cc index 8537f3e..7c39f6d 100644 --- a/absl/base/internal/raw_logging.cc +++ b/absl/base/internal/raw_logging.cc
@@ -21,16 +21,16 @@ #include <cstring> #include <string> -#ifdef __EMSCRIPTEN__ -#include <emscripten/console.h> -#endif - #include "absl/base/attributes.h" #include "absl/base/config.h" #include "absl/base/internal/atomic_hook.h" #include "absl/base/internal/errno_saver.h" #include "absl/base/log_severity.h" +#ifdef __EMSCRIPTEN__ +#include <emscripten/console.h> +#endif + // We know how to perform low-level writes to stderr in POSIX and Windows. For // these platforms, we define the token ABSL_LOW_LEVEL_WRITE_SUPPORTED. // Much of raw_logging.cc becomes a no-op when we can't output messages,
diff --git a/absl/base/internal/raw_logging.h b/absl/base/internal/raw_logging.h index d7cfbc5..8637030 100644 --- a/absl/base/internal/raw_logging.h +++ b/absl/base/internal/raw_logging.h
@@ -19,6 +19,7 @@ #ifndef ABSL_BASE_INTERNAL_RAW_LOGGING_H_ #define ABSL_BASE_INTERNAL_RAW_LOGGING_H_ +#include <cstddef> #include <string> #include "absl/base/attributes.h"
diff --git a/absl/base/internal/scoped_set_env.cc b/absl/base/internal/scoped_set_env.cc index 8a934cb..b13e7a2 100644 --- a/absl/base/internal/scoped_set_env.cc +++ b/absl/base/internal/scoped_set_env.cc
@@ -14,14 +14,14 @@ #include "absl/base/internal/scoped_set_env.h" -#ifdef _WIN32 -#include <windows.h> -#endif - #include <cstdlib> #include "absl/base/internal/raw_logging.h" +#ifdef _WIN32 +#include <windows.h> +#endif + namespace absl { ABSL_NAMESPACE_BEGIN namespace base_internal {
diff --git a/absl/base/internal/scoped_set_env_test.cc b/absl/base/internal/scoped_set_env_test.cc index 5cbad24..6d6775a 100644 --- a/absl/base/internal/scoped_set_env_test.cc +++ b/absl/base/internal/scoped_set_env_test.cc
@@ -12,13 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "absl/base/internal/scoped_set_env.h" + +#include <cstdlib> +#include <string> + +#include "gtest/gtest.h" + #ifdef _WIN32 #include <windows.h> #endif -#include "gtest/gtest.h" -#include "absl/base/internal/scoped_set_env.h" - namespace { using absl::base_internal::ScopedSetEnv;
diff --git a/absl/base/internal/sysinfo.cc b/absl/base/internal/sysinfo.cc index b103f49..1f380bc 100644 --- a/absl/base/internal/sysinfo.cc +++ b/absl/base/internal/sysinfo.cc
@@ -14,7 +14,26 @@ #include "absl/base/internal/sysinfo.h" +#include <string.h> + +#include <cassert> +#include <cerrno> +#include <cstdint> +#include <cstdio> +#include <cstdlib> +#include <ctime> +#include <limits> +#include <thread> // NOLINT(build/c++11) +#include <utility> +#include <vector> + #include "absl/base/attributes.h" +#include "absl/base/call_once.h" +#include "absl/base/config.h" +#include "absl/base/internal/raw_logging.h" +#include "absl/base/internal/spinlock.h" +#include "absl/base/internal/unscaledcycleclock.h" +#include "absl/base/thread_annotations.h" #ifdef _WIN32 #include <windows.h> @@ -50,26 +69,6 @@ #include <zircon/process.h> #endif -#include <string.h> - -#include <cassert> -#include <cerrno> -#include <cstdint> -#include <cstdio> -#include <cstdlib> -#include <ctime> -#include <limits> -#include <thread> // NOLINT(build/c++11) -#include <utility> -#include <vector> - -#include "absl/base/call_once.h" -#include "absl/base/config.h" -#include "absl/base/internal/raw_logging.h" -#include "absl/base/internal/spinlock.h" -#include "absl/base/internal/unscaledcycleclock.h" -#include "absl/base/thread_annotations.h" - namespace absl { ABSL_NAMESPACE_BEGIN namespace base_internal {
diff --git a/absl/base/internal/sysinfo.h b/absl/base/internal/sysinfo.h index 119cf1f..94df348 100644 --- a/absl/base/internal/sysinfo.h +++ b/absl/base/internal/sysinfo.h
@@ -24,15 +24,15 @@ #ifndef ABSL_BASE_INTERNAL_SYSINFO_H_ #define ABSL_BASE_INTERNAL_SYSINFO_H_ -#ifndef _WIN32 -#include <sys/types.h> -#endif - #include <cstdint> #include "absl/base/config.h" #include "absl/base/port.h" +#ifndef _WIN32 +#include <sys/types.h> +#endif + namespace absl { ABSL_NAMESPACE_BEGIN namespace base_internal {
diff --git a/absl/base/internal/sysinfo_test.cc b/absl/base/internal/sysinfo_test.cc index b4c75f5..7248fde 100644 --- a/absl/base/internal/sysinfo_test.cc +++ b/absl/base/internal/sysinfo_test.cc
@@ -14,11 +14,6 @@ #include "absl/base/internal/sysinfo.h" -#ifndef _WIN32 -#include <sys/types.h> -#include <unistd.h> -#endif - #include <thread> // NOLINT(build/c++11) #include <unordered_set> #include <vector> @@ -27,6 +22,11 @@ #include "absl/synchronization/barrier.h" #include "absl/synchronization/mutex.h" +#ifndef _WIN32 +#include <sys/types.h> +#include <unistd.h> +#endif + namespace absl { ABSL_NAMESPACE_BEGIN namespace base_internal {
diff --git a/absl/base/internal/thread_identity.cc b/absl/base/internal/thread_identity.cc index 0471a25..27b5816 100644 --- a/absl/base/internal/thread_identity.cc +++ b/absl/base/internal/thread_identity.cc
@@ -14,15 +14,6 @@ #include "absl/base/internal/thread_identity.h" -#if !defined(_WIN32) || defined(__MINGW32__) -#include <pthread.h> -#ifndef __wasi__ -// WASI does not provide this header, either way we disable use -// of signals with it below. -#include <signal.h> -#endif -#endif - #include <atomic> #include <cassert> #include <memory> @@ -32,6 +23,15 @@ #include "absl/base/internal/raw_logging.h" #include "absl/base/internal/spinlock.h" +#if !defined(_WIN32) || defined(__MINGW32__) +#include <pthread.h> +#ifndef __wasi__ +// WASI does not provide this header, either way we disable use +// of signals with it below. +#include <signal.h> +#endif +#endif + namespace absl { ABSL_NAMESPACE_BEGIN namespace base_internal {
diff --git a/absl/base/internal/thread_identity.h b/absl/base/internal/thread_identity.h index 0c2d619..a9f26d0 100644 --- a/absl/base/internal/thread_identity.h +++ b/absl/base/internal/thread_identity.h
@@ -20,6 +20,15 @@ #ifndef ABSL_BASE_INTERNAL_THREAD_IDENTITY_H_ #define ABSL_BASE_INTERNAL_THREAD_IDENTITY_H_ +#include <atomic> +#include <cstddef> +#include <cstdint> + +#include "absl/base/attributes.h" +#include "absl/base/config.h" +#include "absl/base/internal/per_thread_tls.h" +#include "absl/base/optimization.h" + #ifndef _WIN32 #include <pthread.h> // Defines __GOOGLE_GRTE_VERSION__ (via glibc-specific features.h) when @@ -27,13 +36,6 @@ #include <unistd.h> #endif -#include <atomic> -#include <cstdint> - -#include "absl/base/config.h" -#include "absl/base/internal/per_thread_tls.h" -#include "absl/base/optimization.h" - namespace absl { ABSL_NAMESPACE_BEGIN
diff --git a/absl/base/internal/thread_identity_test.cc b/absl/base/internal/thread_identity_test.cc index 3ef2ffe..94beaa8 100644 --- a/absl/base/internal/thread_identity_test.cc +++ b/absl/base/internal/thread_identity_test.cc
@@ -14,6 +14,7 @@ #include "absl/base/internal/thread_identity.h" +#include <cstdint> #include <thread> // NOLINT(build/c++11) #include <vector> @@ -22,6 +23,7 @@ #include "absl/base/internal/spinlock.h" #include "absl/base/macros.h" #include "absl/base/thread_annotations.h" +#include "absl/synchronization/internal/create_thread_identity.h" #include "absl/synchronization/internal/per_thread_sem.h" #include "absl/synchronization/mutex.h"
diff --git a/absl/base/internal/unscaledcycleclock.cc b/absl/base/internal/unscaledcycleclock.cc index 73e4145..9e93180 100644 --- a/absl/base/internal/unscaledcycleclock.cc +++ b/absl/base/internal/unscaledcycleclock.cc
@@ -14,6 +14,8 @@ #include "absl/base/internal/unscaledcycleclock.h" +#include "absl/base/internal/unscaledcycleclock_config.h" + #if ABSL_USE_UNSCALED_CYCLECLOCK #if defined(_WIN32)
diff --git a/absl/base/internal/unscaledcycleclock.h b/absl/base/internal/unscaledcycleclock.h index fb5751b..c8a4e4b 100644 --- a/absl/base/internal/unscaledcycleclock.h +++ b/absl/base/internal/unscaledcycleclock.h
@@ -38,13 +38,13 @@ #include <cstdint> +#include "absl/base/config.h" +#include "absl/base/internal/unscaledcycleclock_config.h" + #if defined(__APPLE__) #include <TargetConditionals.h> #endif -#include "absl/base/config.h" -#include "absl/base/internal/unscaledcycleclock_config.h" - #if ABSL_USE_UNSCALED_CYCLECLOCK namespace gloop_do_not_use {
diff --git a/absl/base/log_severity_test.cc b/absl/base/log_severity_test.cc index 3394ecd..7b92b4f 100644 --- a/absl/base/log_severity_test.cc +++ b/absl/base/log_severity_test.cc
@@ -27,6 +27,7 @@ #include "absl/flags/internal/flag.h" #include "absl/flags/marshalling.h" #include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" namespace { using ::testing::Eq;
diff --git a/absl/base/macros.h b/absl/base/macros.h index 69463f3..0d7a048 100644 --- a/absl/base/macros.h +++ b/absl/base/macros.h
@@ -160,12 +160,12 @@ // 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) - #define ABSL_HARDENING_ASSERT(expr) \ - do { \ - if (!ABSL_PREDICT_TRUE((expr))) { \ - ABSL_INTERNAL_HARDENING_ABORT(); \ - } \ - } while (false) +#define ABSL_HARDENING_ASSERT(expr) \ + do { \ + if (!ABSL_PREDICT_TRUE((expr))) { \ + ABSL_INTERNAL_HARDENING_ABORT(); \ + } \ + } while (false) #else #define ABSL_HARDENING_ASSERT(expr) ABSL_ASSERT(expr) #endif @@ -245,7 +245,7 @@ // Note: go/cpp-inliner is Google-internal service for automated refactoring. // While open-source users do not have access to this service, the macro is // provided for compatibility. -#if ABSL_HAVE_CPP_ATTRIBUTE(clang::annotate) +#if ABSL_HAVE_CPP_ATTRIBUTE(clang::annotate) && !defined(__NVCC__) #define ABSL_REFACTOR_INLINE \ _Pragma("clang diagnostic push") /* Avoid errors on using-declarations */ \ _Pragma("clang diagnostic ignored \"-Wcxx-attribute-extension\"") \
diff --git a/absl/base/port.h b/absl/base/port.h index 5bc4d6c..485d2c0 100644 --- a/absl/base/port.h +++ b/absl/base/port.h
@@ -15,6 +15,8 @@ // This files is a forwarding header for other headers containing various // portability macros and functions. +// SKIP_ABSL_INLINE_NAMESPACE_CHECK + #ifndef ABSL_BASE_PORT_H_ #define ABSL_BASE_PORT_H_
diff --git a/absl/base/prefetch_test.cc b/absl/base/prefetch_test.cc index ee21989..4e50bd1 100644 --- a/absl/base/prefetch_test.cc +++ b/absl/base/prefetch_test.cc
@@ -14,6 +14,7 @@ #include "absl/base/prefetch.h" +#include <cstring> #include <memory> #include "gtest/gtest.h"
diff --git a/absl/base/raw_logging_test.cc b/absl/base/raw_logging_test.cc index f4f3445..48158c0 100644 --- a/absl/base/raw_logging_test.cc +++ b/absl/base/raw_logging_test.cc
@@ -18,6 +18,7 @@ #include "absl/base/internal/raw_logging.h" +#include <string> #include <tuple> #include "gtest/gtest.h"
diff --git a/absl/base/spinlock_test_common.cc b/absl/base/spinlock_test_common.cc index 411150a..e198faf 100644 --- a/absl/base/spinlock_test_common.cc +++ b/absl/base/spinlock_test_common.cc
@@ -16,6 +16,7 @@ // spinlock. If the spinlock is working properly, all elements of the // array should be equal at the end of the test. +#include <cstddef> #include <cstdint> #include <limits> #include <mutex> // NOLINT(build/c++11)
diff --git a/absl/base/throw_delegate.cc b/absl/base/throw_delegate.cc index b960edd..3ac399c 100644 --- a/absl/base/throw_delegate.cc +++ b/absl/base/throw_delegate.cc
@@ -18,6 +18,7 @@ #include <functional> #include <new> #include <stdexcept> +#include <string> #include "absl/base/config.h" #include "absl/base/internal/raw_logging.h"
diff --git a/absl/base/throw_delegate_test.cc b/absl/base/throw_delegate_test.cc index 3cbc171..c8fc1cd 100644 --- a/absl/base/throw_delegate_test.cc +++ b/absl/base/throw_delegate_test.cc
@@ -17,6 +17,7 @@ #include <functional> #include <new> #include <stdexcept> +#include <string> #include "gtest/gtest.h" #include "absl/base/config.h"
diff --git a/absl/container/BUILD.bazel b/absl/container/BUILD.bazel index 4138d99..f9b0c5c 100644 --- a/absl/container/BUILD.bazel +++ b/absl/container/BUILD.bazel
@@ -91,7 +91,6 @@ ":test_allocator", "//absl/base:config", "//absl/base:exception_testing", - "//absl/base:hardening", "//absl/base:iterator_traits_test_helper", "//absl/hash:hash_testing", "//absl/memory", @@ -184,7 +183,6 @@ "//absl/base:config", "//absl/base:core_headers", "//absl/base:exception_testing", - "//absl/base:hardening", "//absl/base:iterator_traits_test_helper", "//absl/hash:hash_testing", "//absl/log:check", @@ -1425,7 +1423,6 @@ ":chunked_queue", ":test_allocator", "//absl/base:core_headers", - "//absl/base:hardening", "//absl/base:throw_delegate", "//absl/strings", "@googletest//:gtest",
diff --git a/absl/container/CMakeLists.txt b/absl/container/CMakeLists.txt index 2f89efe..effe790 100644 --- a/absl/container/CMakeLists.txt +++ b/absl/container/CMakeLists.txt
@@ -149,7 +149,6 @@ absl::fixed_array absl::config absl::exception_testing - absl::hardening absl::hash_testing absl::iterator_traits_test_helper_internal absl::memory @@ -236,7 +235,6 @@ absl::config absl::core_headers absl::exception_testing - absl::hardening absl::hash_testing absl::inlined_vector absl::memory @@ -1238,7 +1236,6 @@ absl::chunked_queue absl::config absl::core_headers - absl::hardening absl::strings absl::test_allocator absl::throw_delegate
diff --git a/absl/container/chunked_queue_test.cc b/absl/container/chunked_queue_test.cc index 9540ff9..22ce944 100644 --- a/absl/container/chunked_queue_test.cc +++ b/absl/container/chunked_queue_test.cc
@@ -31,7 +31,6 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -#include "absl/base/internal/hardening.h" #include "absl/base/macros.h" #include "absl/base/throw_delegate.h" #include "absl/container/internal/test_allocator.h" @@ -804,7 +803,6 @@ GTEST_SKIP() << "Not a hardened build"; } - absl::base_internal::ScopedSetAbslHardeningForTesting hardener(true); absl::chunked_queue<int> q; EXPECT_DEATH_IF_SUPPORTED(q.front(), ""); EXPECT_DEATH_IF_SUPPORTED(q.back(), "");
diff --git a/absl/container/fixed_array_test.cc b/absl/container/fixed_array_test.cc index da2f170..71c6819 100644 --- a/absl/container/fixed_array_test.cc +++ b/absl/container/fixed_array_test.cc
@@ -32,7 +32,6 @@ #include "gtest/gtest.h" #include "absl/base/config.h" #include "absl/base/internal/exception_testing.h" -#include "absl/base/internal/hardening.h" #include "absl/base/internal/iterator_traits_test_helper.h" #include "absl/base/options.h" #include "absl/container/internal/test_allocator.h" @@ -198,7 +197,6 @@ TEST(FixedArrayTest, Hardened) { #if !defined(NDEBUG) || ABSL_OPTION_HARDENED - absl::base_internal::ScopedSetAbslHardeningForTesting hardener(true); absl::FixedArray<int> a = {1, 2, 3}; EXPECT_EQ(a[2], 3); EXPECT_DEATH_IF_SUPPORTED(a[3], "");
diff --git a/absl/container/flat_hash_map.h b/absl/container/flat_hash_map.h index b434a47..e11d7e2 100644 --- a/absl/container/flat_hash_map.h +++ b/absl/container/flat_hash_map.h
@@ -686,10 +686,10 @@ std::forward<Args>(args)...); } - template <class Hash, bool kIsDefault> + template <class Hash, bool kIsDefault, size_t kSeedShift> static constexpr HashSlotFn get_hash_slot_fn() { return memory_internal::IsLayoutCompatible<K, V>::value - ? &TypeErasedApplyToSlotFn<Hash, K, kIsDefault> + ? &TypeErasedApplyToSlotFn<Hash, K, kIsDefault, kSeedShift> : nullptr; }
diff --git a/absl/container/flat_hash_set.h b/absl/container/flat_hash_set.h index bd24dde..ed97743 100644 --- a/absl/container/flat_hash_set.h +++ b/absl/container/flat_hash_set.h
@@ -588,9 +588,9 @@ static size_t space_used(const T*) { return 0; } - template <class Hash, bool kIsDefault> + template <class Hash, bool kIsDefault, size_t kSeedShift> static constexpr HashSlotFn get_hash_slot_fn() { - return &TypeErasedApplyToSlotFn<Hash, T, kIsDefault>; + return &TypeErasedApplyToSlotFn<Hash, T, kIsDefault, kSeedShift>; } }; } // namespace container_internal
diff --git a/absl/container/inlined_vector_test.cc b/absl/container/inlined_vector_test.cc index a175ea5..73584ed 100644 --- a/absl/container/inlined_vector_test.cc +++ b/absl/container/inlined_vector_test.cc
@@ -32,7 +32,6 @@ #include "gtest/gtest.h" #include "absl/base/attributes.h" #include "absl/base/internal/exception_testing.h" -#include "absl/base/internal/hardening.h" #include "absl/base/internal/iterator_traits_test_helper.h" #include "absl/base/macros.h" #include "absl/base/options.h" @@ -295,7 +294,6 @@ Fill(&v, 10); EXPECT_EQ(v[9], 9); #if !defined(NDEBUG) || ABSL_OPTION_HARDENED - absl::base_internal::ScopedSetAbslHardeningForTesting hardener(true); EXPECT_DEATH_IF_SUPPORTED(v[10], ""); EXPECT_DEATH_IF_SUPPORTED(v[static_cast<size_t>(-1)], ""); #endif
diff --git a/absl/container/internal/container_memory.h b/absl/container/internal/container_memory.h index 1d361f5..fceb4eb 100644 --- a/absl/container/internal/container_memory.h +++ b/absl/container/internal/container_memory.h
@@ -144,10 +144,10 @@ template <class T> auto TupleRef(T&& t) -> decltype(TupleRefImpl( std::forward<T>(t), - std::make_index_sequence<std::tuple_size<std::decay_t<T>>::value>())) { + std::make_index_sequence<std::tuple_size_v<std::decay_t<T>>>())) { return TupleRefImpl( std::forward<T>(t), - std::make_index_sequence<std::tuple_size<std::decay_t<T>>::value>()); + std::make_index_sequence<std::tuple_size_v<std::decay_t<T>>>()); } template <class F, class K, class V> @@ -167,7 +167,7 @@ void ConstructFromTuple(Alloc* alloc, T* ptr, Tuple&& t) { memory_internal::ConstructFromTupleImpl( alloc, ptr, std::forward<Tuple>(t), - std::make_index_sequence<std::tuple_size<std::decay_t<Tuple>>::value>()); + std::make_index_sequence<std::tuple_size_v<std::decay_t<Tuple>>>()); } // Constructs T using the args specified in the tuple and calls F with the @@ -177,7 +177,7 @@ F&& f) { return memory_internal::WithConstructedImpl<T>( std::forward<Tuple>(t), - std::make_index_sequence<std::tuple_size<std::decay_t<Tuple>>::value>(), + std::make_index_sequence<std::tuple_size_v<std::decay_t<Tuple>>>(), std::forward<F>(f)); } @@ -486,9 +486,9 @@ // Variadic arguments hash function that ignore the rest of the arguments. // Useful for usage with policy traits. -template <class Hash, bool kIsDefault> +template <class Hash, bool kIsDefault, size_t kSeedShift> struct HashElement { - HashElement(const Hash& h, size_t s) : hash(h), seed(s) {} + HashElement(const Hash& h, size_t s) : hash(h), seed(s >> kSeedShift) {} template <class K, class... Args> size_t operator()(const K& key, Args&&...) const { @@ -506,12 +506,12 @@ }; // No arguments function hash function for a specific key. -template <class Hash, class Key, bool kIsDefault> +template <class Hash, class Key, bool kIsDefault, size_t kSeedShift> struct HashKey { HashKey(const Hash& h, const Key& k) : hash(h), key(k) {} size_t operator()(size_t seed) const { - return HashElement<Hash, kIsDefault>{hash, seed}(key); + return HashElement<Hash, kIsDefault, kSeedShift>{hash, seed}(key); } const Hash& hash; const Key& key; @@ -534,30 +534,31 @@ // Type erased function to apply `Fn` to data inside of the `slot`. // The data is expected to have type `T`. -template <class Fn, class T, bool kIsDefault> +template <class Fn, class T, bool kIsDefault, size_t kSeedShift> size_t TypeErasedApplyToSlotFn(const void* fn, void* slot, size_t seed) { const auto* f = static_cast<const Fn*>(fn); - return HashElement<Fn, kIsDefault>{*f, seed}(*static_cast<const T*>(slot)); + return HashElement<Fn, kIsDefault, kSeedShift>{ + *f, seed}(*static_cast<const T*>(slot)); } // Type erased function to apply `Fn` to data inside of the `*slot_ptr`. // The data is expected to have type `T`. -template <class Fn, class T, bool kIsDefault> +template <class Fn, class T, bool kIsDefault, size_t kSeedShift> size_t TypeErasedDerefAndApplyToSlotFn(const void* fn, void* slot_ptr, size_t seed) { const auto* f = static_cast<const Fn*>(fn); const T* slot = *static_cast<T**>(slot_ptr); - return HashElement<Fn, kIsDefault>{*f, seed}(*slot); + return HashElement<Fn, kIsDefault, kSeedShift>{*f, seed}(*slot); } // Type erased function to apply `Fn` to data inside of the `slot_ptr->first`. // The data is expected to have type `T`. -template <class Fn, class T, bool kIsDefault> +template <class Fn, class T, bool kIsDefault, size_t kSeedShift> size_t TypeErasedDerefAndApplyToSlotFirstFn(const void* fn, void* slot_ptr, size_t seed) { const auto* f = static_cast<const Fn*>(fn); const T* slot = *static_cast<T**>(slot_ptr); - return HashElement<Fn, kIsDefault>{*f, seed}(slot->first); + return HashElement<Fn, kIsDefault, kSeedShift>{*f, seed}(slot->first); } } // namespace container_internal
diff --git a/absl/container/internal/container_memory_test.cc b/absl/container/internal/container_memory_test.cc index 9a8ba67..1aa459c 100644 --- a/absl/container/internal/container_memory_test.cc +++ b/absl/container/internal/container_memory_test.cc
@@ -313,10 +313,10 @@ size_t x = 7; size_t seed = 100; auto fn = [](size_t v) { return v * 2; }; - EXPECT_EQ( - (TypeErasedApplyToSlotFn<decltype(fn), size_t, /*kIsDefault=*/false>( - &fn, &x, seed)), - (HashElement<decltype(fn), /*kIsDefault=*/false>(fn, seed)(x))); + EXPECT_EQ((TypeErasedApplyToSlotFn<decltype(fn), size_t, /*kIsDefault=*/false, + /*kSeedShift=*/0>(&fn, &x, seed)), + (HashElement<decltype(fn), /*kIsDefault=*/false, /*kSeedShift=*/0>( + fn, seed)(x))); } TEST(ApplyTest, TypeErasedDerefAndApplyToSlotFn) { @@ -324,10 +324,12 @@ size_t seed = 100; auto fn = [](size_t v) { return v * 2; }; size_t* x_ptr = &x; - EXPECT_EQ((TypeErasedDerefAndApplyToSlotFn<decltype(fn), size_t, - /*kIsDefault=*/false>(&fn, &x_ptr, - seed)), - (HashElement<decltype(fn), /*kIsDefault=*/false>(fn, seed)(x))); + EXPECT_EQ( + (TypeErasedDerefAndApplyToSlotFn<decltype(fn), size_t, + /*kIsDefault=*/false, + /*kSeedShift=*/0>(&fn, &x_ptr, seed)), + (HashElement<decltype(fn), /*kIsDefault=*/false, /*kSeedShift=*/0>( + fn, seed)(x))); } TEST(HashElement, DefaultHash) { @@ -339,7 +341,8 @@ return v * 2 + seed * 3; } } hash; - EXPECT_EQ((HashElement<HashWithSeed, /*kIsDefault=*/true>(hash, seed)(x)), + EXPECT_EQ((HashElement<HashWithSeed, /*kIsDefault=*/true, + /*kSeedShift=*/0>(hash, seed)(x)), hash.hash_with_seed(x, seed)); } @@ -348,11 +351,21 @@ size_t seed = 100; auto fn = [](size_t v) { return v * 2; }; EXPECT_EQ( - (HashElement<decltype(fn), /*kIsDefault=*/false>( + (HashElement<decltype(fn), /*kIsDefault=*/false, /*kSeedShift=*/0>( fn, seed)(x)), fn(x) ^ seed); } +TEST(HashElement, NonDefaultHashWithSeedShift) { + size_t x = 7; + size_t seed = 100; + auto fn = [](size_t v) { return v * 2; }; + EXPECT_EQ( + (HashElement<decltype(fn), /*kIsDefault=*/false, /*kSeedShift=*/1>( + fn, seed)(x)), + fn(x) ^ (seed >> 1)); +} + } // namespace } // namespace container_internal ABSL_NAMESPACE_END
diff --git a/absl/container/internal/hash_policy_traits.h b/absl/container/internal/hash_policy_traits.h index e469d71..beed150 100644 --- a/absl/container/internal/hash_policy_traits.h +++ b/absl/container/internal/hash_policy_traits.h
@@ -146,7 +146,7 @@ return P::value(elem); } - template <class Hash, bool kIsDefault> + template <class Hash, bool kIsDefault, size_t kSeedShift> static constexpr HashSlotFn get_hash_slot_fn() { // get_hash_slot_fn may return nullptr to signal that non type erased function // should be used. GCC warns against comparing function address with nullptr. @@ -155,9 +155,11 @@ // silent error: the address of * will never be NULL [-Werror=address] #pragma GCC diagnostic ignored "-Waddress" #endif - return Policy::template get_hash_slot_fn<Hash, kIsDefault>() == nullptr - ? &hash_slot_fn_non_type_erased<Hash, kIsDefault> - : Policy::template get_hash_slot_fn<Hash, kIsDefault>(); + return Policy::template get_hash_slot_fn<Hash, kIsDefault, kSeedShift>() == + nullptr + ? &hash_slot_fn_non_type_erased<Hash, kIsDefault, kSeedShift> + : Policy::template get_hash_slot_fn<Hash, kIsDefault, + kSeedShift>(); #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic pop #endif @@ -167,11 +169,12 @@ static constexpr bool soo_enabled() { return soo_enabled_impl(Rank1{}); } private: - template <class Hash, bool kIsDefault> + template <class Hash, bool kIsDefault, size_t kSeedShift> static size_t hash_slot_fn_non_type_erased(const void* hash_fn, void* slot, size_t seed) { return Policy::apply( - HashElement<Hash, kIsDefault>{*static_cast<const Hash*>(hash_fn), seed}, + HashElement<Hash, kIsDefault, kSeedShift>{ + *static_cast<const Hash*>(hash_fn), seed}, Policy::element(static_cast<slot_type*>(slot))); }
diff --git a/absl/container/internal/hash_policy_traits_test.cc b/absl/container/internal/hash_policy_traits_test.cc index 03de132..8d498e0 100644 --- a/absl/container/internal/hash_policy_traits_test.cc +++ b/absl/container/internal/hash_policy_traits_test.cc
@@ -45,7 +45,7 @@ static std::function<int(int)> apply_impl; static std::function<Slot&(Slot*)> value; - template <class Hash, bool kIsDefault> + template <class Hash, bool kIsDefault, size_t kSeedShift> static constexpr HashSlotFn get_hash_slot_fn() { return nullptr; } @@ -99,7 +99,7 @@ return fn(v); } - template <class Hash, bool kIsDefault> + template <class Hash, bool kIsDefault, size_t kSeedShift> static constexpr HashSlotFn get_hash_slot_fn() { return nullptr; } @@ -108,9 +108,9 @@ size_t* PolicyNoHashFn::apply_called_count; struct PolicyCustomHashFn : PolicyNoHashFn { - template <class Hash, bool kIsDefault> + template <class Hash, bool kIsDefault, size_t kSeedShift> static constexpr HashSlotFn get_hash_slot_fn() { - return &TypeErasedApplyToSlotFn<Hash, int, kIsDefault>; + return &TypeErasedApplyToSlotFn<Hash, int, kIsDefault, kSeedShift>; } }; @@ -121,10 +121,11 @@ Hash hasher; Slot value = 7; auto* fn = hash_policy_traits<PolicyNoHashFn>::get_hash_slot_fn< - Hash, /*kIsDefault=*/false>(); + Hash, /*kIsDefault=*/false, /*kSeedShift=*/6>(); EXPECT_NE(fn, nullptr); EXPECT_EQ(fn(&hasher, &value, 100), - (HashElement<Hash, /*kIsDefault=*/false>(hasher, 100)(value))); + (HashElement<Hash, /*kIsDefault=*/false, /*kSeedShift=*/6>( + hasher, 100)(value))); EXPECT_EQ(apply_called_count, 1); } @@ -135,11 +136,13 @@ Hash hasher; Slot value = 7; auto* fn = hash_policy_traits<PolicyCustomHashFn>::get_hash_slot_fn< - Hash, /*kIsDefault=*/false>(); - EXPECT_EQ( - fn, (PolicyCustomHashFn::get_hash_slot_fn<Hash, /*kIsDefault=*/false>())); + Hash, /*kIsDefault=*/false, /*kSeedShift=*/6>(); + EXPECT_EQ(fn, + (PolicyCustomHashFn::get_hash_slot_fn<Hash, /*kIsDefault=*/false, + /*kSeedShift=*/6>())); EXPECT_EQ(fn(&hasher, &value, 100), - (HashElement<Hash, /*kIsDefault=*/false>(hasher, 100)(value))); + (HashElement<Hash, /*kIsDefault=*/false, /*kSeedShift=*/6>( + hasher, 100)(value))); EXPECT_EQ(apply_called_count, 0); }
diff --git a/absl/container/internal/hashtable_control_bytes.h b/absl/container/internal/hashtable_control_bytes.h index b0faec3..b70ac8c 100644 --- a/absl/container/internal/hashtable_control_bytes.h +++ b/absl/container/internal/hashtable_control_bytes.h
@@ -24,6 +24,9 @@ #include <type_traits> #include "absl/base/config.h" +#include "absl/base/internal/endian.h" +#include "absl/base/optimization.h" +#include "absl/numeric/bits.h" #ifdef ABSL_INTERNAL_HAVE_SSE2 #include <emmintrin.h> @@ -41,10 +44,6 @@ #include <arm_neon.h> #endif -#include "absl/base/optimization.h" -#include "absl/numeric/bits.h" -#include "absl/base/internal/endian.h" - namespace absl { ABSL_NAMESPACE_BEGIN namespace container_internal {
diff --git a/absl/container/internal/layout.h b/absl/container/internal/layout.h index a4cfe59..0f9084c 100644 --- a/absl/container/internal/layout.h +++ b/absl/container/internal/layout.h
@@ -386,7 +386,7 @@ template <size_t N> using ElementAlignment = - AlignOf<typename std::tuple_element<N, std::tuple<Elements...>>::type>; + AlignOf<std::tuple_element_t<N, std::tuple<Elements...>>>; public: // Element types of all arrays packed in a tuple. @@ -394,7 +394,7 @@ // Element type of the Nth array. template <size_t N> - using ElementType = typename std::tuple_element<N, ElementTypes>::type; + using ElementType = std::tuple_element_t<N, ElementTypes>; constexpr explicit LayoutImpl(IntToSize<RuntimeSizeSeq>... sizes) : size_{sizes...} {}
diff --git a/absl/container/internal/layout_test.cc b/absl/container/internal/layout_test.cc index d2d1196..12039e9 100644 --- a/absl/container/internal/layout_test.cc +++ b/absl/container/internal/layout_test.cc
@@ -1435,9 +1435,9 @@ template <typename Tuple> bool MatchAndExplain(const Tuple& p, testing::MatchResultListener* /* listener */) const { - static_assert(std::tuple_size<Tuple>::value == sizeof...(M)); + static_assert(std::tuple_size_v<Tuple> == sizeof...(M)); return MatchAndExplainImpl( - p, std::make_index_sequence<std::tuple_size<Tuple>::value>{}); + p, std::make_index_sequence<std::tuple_size_v<Tuple>>{}); } // For the matcher concept. Left empty as we don't really need the diagnostics @@ -1450,8 +1450,7 @@ bool MatchAndExplainImpl(const Tuple& p, std::index_sequence<Is...>) const { // Using std::min as a simple variadic "and". return std::min( - {true, testing::SafeMatcherCast< - const typename std::tuple_element<Is, Tuple>::type&>( + {true, testing::SafeMatcherCast<const std::tuple_element_t<Is, Tuple>&>( std::get<Is>(matchers_)) .Matches(std::get<Is>(p))...}); }
diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h index 0531300..ad416cd 100644 --- a/absl/container/internal/raw_hash_set.h +++ b/absl/container/internal/raw_hash_set.h
@@ -655,8 +655,8 @@ // 1) one bit that stores whether we have infoz. // 2) kBlockedElementsBitCount bits that stores number of blocked elements in // the table. -// 3) PerTableSeed::kBitCount bits for the seed. (For SOO tables, the lowest -// bit of the seed is repurposed to track if sampling has been tried). +// 3) kSeedBitCount bits for the seed. (For SOO tables, the lowest bit of the +// seed is repurposed to track if sampling has been tried). template <HashtableCapacityStorageMode StorageMode> class HashtableInlineDataImpl { // The number of bits in the seed. It is big enough to ensure @@ -2274,6 +2274,15 @@ constexpr static bool kIsDefaultHash = std::is_same_v<hasher, absl::Hash<key_type>> || std::is_same_v<hasher, absl::container_internal::StringHash>; + // For non-default hashers it is required to have low bits entropy because + // (a) in such cases, the seed is xor'ed with the hash value rather than being + // used as a seed for the hash function, (b) the seed has low bits that are + // all 0s, and (c) we require random iteration order for small tables. + // In ToPublicSeed we shift the seed by kCapacityBitStoredInDataCount as + // performance optimization for default hashers. For non-default hashers, we + // shift it back. + constexpr static size_t kSeedShift = + kIsDefaultHash ? 0 : HashtableInlineData::kCapacityBitStoredInDataCount; // TODO(b/289225379): we could add extra SOO space inside raw_hash_set // after CommonFields to allow inlining larger slot_types (e.g. std::string), @@ -3505,12 +3514,13 @@ } template <class K> ABSL_ATTRIBUTE_ALWAYS_INLINE size_t hash_of(const K& key) const { - return HashElement<hasher, kIsDefaultHash>{hash_ref(), - common().seed().seed()}(key); + return HashElement<hasher, kIsDefaultHash, kSeedShift>{ + hash_ref(), common().seed().seed()}(key); } ABSL_ATTRIBUTE_ALWAYS_INLINE size_t hash_of(slot_type* slot) const { return PolicyTraits::apply( - HashElement<hasher, kIsDefaultHash>{hash_ref(), common().seed().seed()}, + HashElement<hasher, kIsDefaultHash, kSeedShift>{hash_ref(), + common().seed().seed()}, PolicyTraits::element(slot)); } @@ -3649,9 +3659,10 @@ GrowSooTableToNextCapacityAndPrepareInsert< kUseMemcpy ? OptimalMemcpySizeForSooSlotTransfer(sizeof(slot_type)) : 0, - kUseMemcpy>(common(), GetPolicyFunctions(), - HashKey<hasher, K, kIsDefaultHash>{hash_ref(), key}, - force_sampling)); + kUseMemcpy>( + common(), GetPolicyFunctions(), + HashKey<hasher, K, kIsDefaultHash, kSeedShift>{hash_ref(), key}, + force_sampling)); return {slot, true}; } @@ -3667,10 +3678,11 @@ return {single_slot(), false}; } } - return {to_slot(PrepareInsertSmallNonSoo( - common(), GetPolicyFunctions(), - HashKey<hasher, K, kIsDefaultHash>{hash_ref(), key})), - true}; + return { + to_slot(PrepareInsertSmallNonSoo( + common(), GetPolicyFunctions(), + HashKey<hasher, K, kIsDefaultHash, kSeedShift>{hash_ref(), key})), + true}; } template <class K> @@ -3698,15 +3710,15 @@ auto mask_empty = g.MaskEmpty(); if (ABSL_PREDICT_TRUE(mask_empty)) { size_t target_group_offset = seq.offset(); - void* slot = - SwisstableGenerationsEnabled() - ? PrepareInsertLargeGenerationsEnabled( - common(), GetPolicyFunctions(), hash, mask_empty, - FindInfo{target_group_offset, seq.index()}, - HashKey<hasher, K, kIsDefaultHash>{hash_ref(), key}) - : PrepareInsertLarge( - common(), GetPolicyFunctions(), hash, mask_empty, - FindInfo{target_group_offset, seq.index()}); + void* slot = SwisstableGenerationsEnabled() + ? PrepareInsertLargeGenerationsEnabled( + common(), GetPolicyFunctions(), hash, mask_empty, + FindInfo{target_group_offset, seq.index()}, + HashKey<hasher, K, kIsDefaultHash, kSeedShift>{ + hash_ref(), key}) + : PrepareInsertLarge( + common(), GetPolicyFunctions(), hash, mask_empty, + FindInfo{target_group_offset, seq.index()}); return {to_slot(slot), true}; } seq.next(); @@ -4007,7 +4019,8 @@ // for standard layout and alignof(Hash) <= alignof(CommonFields). std::is_empty_v<hasher> ? &GetRefForEmptyClass : &raw_hash_set::get_hash_ref_fn, - PolicyTraits::template get_hash_slot_fn<hasher, kIsDefaultHash>(), + PolicyTraits::template get_hash_slot_fn<hasher, kIsDefaultHash, + kSeedShift>(), PolicyTraits::transfer_uses_memcpy() ? TransferNRelocatable<sizeof(slot_type)> : &raw_hash_set::transfer_n_slots_fn,
diff --git a/absl/container/internal/raw_hash_set_allocator_test.cc b/absl/container/internal/raw_hash_set_allocator_test.cc index 22a916b..eaee003 100644 --- a/absl/container/internal/raw_hash_set_allocator_test.cc +++ b/absl/container/internal/raw_hash_set_allocator_test.cc
@@ -184,7 +184,7 @@ static slot_type& element(slot_type* slot) { return *slot; } - template <class Hash, bool kIsDefault> + template <class Hash, bool kIsDefault, size_t kSeedShift> static constexpr HashSlotFn get_hash_slot_fn() { return nullptr; }
diff --git a/absl/container/internal/raw_hash_set_benchmark.cc b/absl/container/internal/raw_hash_set_benchmark.cc index 5cbaf5c..4c0a78a 100644 --- a/absl/container/internal/raw_hash_set_benchmark.cc +++ b/absl/container/internal/raw_hash_set_benchmark.cc
@@ -69,7 +69,7 @@ return std::forward<F>(f)(x, x); } - template <class Hash, bool kIsDefault> + template <class Hash, bool kIsDefault, size_t kSeedShift> static constexpr HashSlotFn get_hash_slot_fn() { return nullptr; } @@ -136,7 +136,7 @@ PairArgs(std::forward<Args>(args)...)); } - template <class Hash, bool kIsDefault> + template <class Hash, bool kIsDefault, size_t kSeedShift> static constexpr HashSlotFn get_hash_slot_fn() { return nullptr; }
diff --git a/absl/container/internal/raw_hash_set_probe_benchmark.cc b/absl/container/internal/raw_hash_set_probe_benchmark.cc index dcd1596..fee9531 100644 --- a/absl/container/internal/raw_hash_set_probe_benchmark.cc +++ b/absl/container/internal/raw_hash_set_probe_benchmark.cc
@@ -81,7 +81,7 @@ return std::forward<F>(f)(arg, arg); } - template <class Hash, bool kIsDefault> + template <class Hash, bool kIsDefault, size_t kSeedShift> static constexpr auto get_hash_slot_fn() { return nullptr; }
diff --git a/absl/container/internal/raw_hash_set_test.cc b/absl/container/internal/raw_hash_set_test.cc index c52c692..ec5ec30 100644 --- a/absl/container/internal/raw_hash_set_test.cc +++ b/absl/container/internal/raw_hash_set_test.cc
@@ -1015,7 +1015,7 @@ std::forward<F>(f), std::forward<Args>(args)...); } - template <class Hash, bool kIsDefault> + template <class Hash, bool kIsDefault, size_t kSeedShift> static constexpr HashSlotFn get_hash_slot_fn() { return nullptr; } @@ -1169,7 +1169,7 @@ PairArgs(std::forward<Args>(args)...)); } - template <class Hash, bool kIsDefault> + template <class Hash, bool kIsDefault, size_t kSeedShift> static constexpr HashSlotFn get_hash_slot_fn() { return nullptr; } @@ -2342,11 +2342,24 @@ } } +template <class TableType> +class IterationOrderTest : public testing::Test {}; + +struct CustomHashIntTable + : raw_hash_set<IntPolicy, std::hash<int64_t>> { + using Base = typename CustomHashIntTable::raw_hash_set; + using Base::Base; +}; + +using IterationOrderTypes = + ::testing::Types<SooIntTable, NonSooIntTable, CustomHashIntTable>; +TYPED_TEST_SUITE(IterationOrderTest, IterationOrderTypes); + // These IterationOrderChanges tests depend on non-deterministic behavior. // We are injecting non-determinism to the table. // We have to retry enough times to make sure that the seed changes in bits that // matter for the iteration order. -TYPED_TEST(SooTest, IterationOrderChangesByInstance) { +TYPED_TEST(IterationOrderTest, IterationOrderChangesByInstance) { DisableSampling(); // We do not want test to pass only because of sampling. for (bool do_reserve : {false, true}) { for (size_t size : {2u, 6u, 12u, 20u}) { @@ -2367,7 +2380,7 @@ } } -TYPED_TEST(SooTest, IterationOrderChangesOnRehash) { +TYPED_TEST(IterationOrderTest, IterationOrderChangesOnRehash) { DisableSampling(); // We do not want test to pass only because of sampling. // We test different sizes with many small numbers, because small table @@ -2831,7 +2844,7 @@ return std::forward<F>(f)(x, x); } - template <class Hash, bool kIsDefault> + template <class Hash, bool kIsDefault, size_t kSeedShift> static constexpr HashSlotFn get_hash_slot_fn() { return nullptr; }
diff --git a/absl/container/internal/tracked.h b/absl/container/internal/tracked.h index 29f5829..6962eb8 100644 --- a/absl/container/internal/tracked.h +++ b/absl/container/internal/tracked.h
@@ -50,12 +50,14 @@ num_moves_ = that.num_moves_; num_copies_ = that.num_copies_; ++(*num_copies_); + return *this; } Tracked& operator=(Tracked&& that) { val_ = std::move(that.val_); num_moves_ = std::move(that.num_moves_); num_copies_ = std::move(that.num_copies_); ++(*num_moves_); + return *this; } const T& val() const { return val_; } @@ -67,8 +69,8 @@ return !(a == b); } - size_t num_copies() { return *num_copies_; } - size_t num_moves() { return *num_moves_; } + size_t num_copies() const { return *num_copies_; } + size_t num_moves() const { return *num_moves_; } private: T val_;
diff --git a/absl/container/node_hash_map.h b/absl/container/node_hash_map.h index bd2f426..75fc0cc 100644 --- a/absl/container/node_hash_map.h +++ b/absl/container/node_hash_map.h
@@ -681,11 +681,11 @@ static Value& value(value_type* elem) { return elem->second; } static const Value& value(const value_type* elem) { return elem->second; } - template <class Hash, bool kIsDefault> + template <class Hash, bool kIsDefault, size_t kSeedShift> static constexpr HashSlotFn get_hash_slot_fn() { return memory_internal::IsLayoutCompatible<Key, Value>::value ? &TypeErasedDerefAndApplyToSlotFirstFn<Hash, value_type, - kIsDefault> + kIsDefault, kSeedShift> : nullptr; } };
diff --git a/absl/container/node_hash_set.h b/absl/container/node_hash_set.h index 55568b7..9da52e7 100644 --- a/absl/container/node_hash_set.h +++ b/absl/container/node_hash_set.h
@@ -582,9 +582,9 @@ static size_t element_space_used(const T*) { return sizeof(T); } - template <class Hash, bool kIsDefault> + template <class Hash, bool kIsDefault, size_t kSeedShift> static constexpr HashSlotFn get_hash_slot_fn() { - return &TypeErasedDerefAndApplyToSlotFn<Hash, T, kIsDefault>; + return &TypeErasedDerefAndApplyToSlotFn<Hash, T, kIsDefault, kSeedShift>; } }; } // namespace container_internal
diff --git a/absl/crc/crc32c.cc b/absl/crc/crc32c.cc index 9b1ef7e..9020563 100644 --- a/absl/crc/crc32c.cc +++ b/absl/crc/crc32c.cc
@@ -14,6 +14,7 @@ #include "absl/crc/crc32c.h" +#include <cstddef> #include <cstdint> #include "absl/crc/internal/crc.h"
diff --git a/absl/crc/crc32c.h b/absl/crc/crc32c.h index 5ecc6b3..4ce941d 100644 --- a/absl/crc/crc32c.h +++ b/absl/crc/crc32c.h
@@ -25,6 +25,7 @@ #ifndef ABSL_CRC_CRC32C_H_ #define ABSL_CRC_CRC32C_H_ +#include <cstddef> #include <cstdint> #include <ostream>
diff --git a/absl/crc/crc32c_benchmark.cc b/absl/crc/crc32c_benchmark.cc index 0ac9225..fb226a2 100644 --- a/absl/crc/crc32c_benchmark.cc +++ b/absl/crc/crc32c_benchmark.cc
@@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include <cstddef> +#include <cstdint> #include <memory> #include <string>
diff --git a/absl/crc/internal/crc.h b/absl/crc/internal/crc.h index 4efdd03..90e05f1 100644 --- a/absl/crc/internal/crc.h +++ b/absl/crc/internal/crc.h
@@ -15,6 +15,7 @@ #ifndef ABSL_CRC_INTERNAL_CRC_H_ #define ABSL_CRC_INTERNAL_CRC_H_ +#include <cstddef> #include <cstdint> #include "absl/base/config.h"
diff --git a/absl/crc/internal/crc32_x86_arm_combined_simd.h b/absl/crc/internal/crc32_x86_arm_combined_simd.h index 9c287b5..c50a301 100644 --- a/absl/crc/internal/crc32_x86_arm_combined_simd.h +++ b/absl/crc/internal/crc32_x86_arm_combined_simd.h
@@ -20,6 +20,10 @@ #include "absl/base/config.h" +#ifdef __SSE4_2__ +#include <immintrin.h> +#endif + // ------------------------------------------------------------------------- // Many x86 and ARM machines have CRC acceleration hardware. // We can do a faster version of Extend() on such machines.
diff --git a/absl/crc/internal/crc32c.h b/absl/crc/internal/crc32c.h index 34027c5..20e9b73 100644 --- a/absl/crc/internal/crc32c.h +++ b/absl/crc/internal/crc32c.h
@@ -15,6 +15,8 @@ #ifndef ABSL_CRC_INTERNAL_CRC32C_H_ #define ABSL_CRC_INTERNAL_CRC32C_H_ +#include <cstddef> + #include "absl/base/config.h" #include "absl/crc/crc32c.h"
diff --git a/absl/crc/internal/crc32c_inline.h b/absl/crc/internal/crc32c_inline.h index 6236c10..e117c86 100644 --- a/absl/crc/internal/crc32c_inline.h +++ b/absl/crc/internal/crc32c_inline.h
@@ -15,6 +15,7 @@ #ifndef ABSL_CRC_INTERNAL_CRC32C_INLINE_H_ #define ABSL_CRC_INTERNAL_CRC32C_INLINE_H_ +#include <cstddef> #include <cstdint> #include "absl/base/config.h"
diff --git a/absl/crc/internal/crc_cord_state.cc b/absl/crc/internal/crc_cord_state.cc index 303a555..cccd0b0 100644 --- a/absl/crc/internal/crc_cord_state.cc +++ b/absl/crc/internal/crc_cord_state.cc
@@ -14,10 +14,14 @@ #include "absl/crc/internal/crc_cord_state.h" +#include <atomic> #include <cassert> +#include <cstddef> +#include <cstdint> #include "absl/base/config.h" #include "absl/base/no_destructor.h" +#include "absl/crc/crc32c.h" #include "absl/numeric/bits.h" namespace absl {
diff --git a/absl/crc/internal/crc_cord_state.h b/absl/crc/internal/crc_cord_state.h index fbbb8c0..a68e0b3 100644 --- a/absl/crc/internal/crc_cord_state.h +++ b/absl/crc/internal/crc_cord_state.h
@@ -16,7 +16,9 @@ #define ABSL_CRC_INTERNAL_CRC_CORD_STATE_H_ #include <atomic> +#include <cassert> #include <cstddef> +#include <cstdint> #include <deque> #include "absl/base/config.h"
diff --git a/absl/crc/internal/crc_internal.h b/absl/crc/internal/crc_internal.h index 0447858..ac9c38d 100644 --- a/absl/crc/internal/crc_internal.h +++ b/absl/crc/internal/crc_internal.h
@@ -15,11 +15,13 @@ #ifndef ABSL_CRC_INTERNAL_CRC_INTERNAL_H_ #define ABSL_CRC_INTERNAL_CRC_INTERNAL_H_ +#include <cstddef> #include <cstdint> #include <memory> #include <vector> #include "absl/base/internal/raw_logging.h" +#include "absl/base/optimization.h" #include "absl/crc/internal/crc.h" namespace absl {
diff --git a/absl/crc/internal/crc_memcpy_x86_arm_combined.cc b/absl/crc/internal/crc_memcpy_x86_arm_combined.cc index fd3ce60..dac0446 100644 --- a/absl/crc/internal/crc_memcpy_x86_arm_combined.cc +++ b/absl/crc/internal/crc_memcpy_x86_arm_combined.cc
@@ -38,14 +38,6 @@ // using 3 CRCs over fixed-size blocks where the zero-extensions required for // CRC32C::Concat can be precomputed. -#ifdef __SSE4_2__ -#include <immintrin.h> -#endif - -#ifdef _MSC_VER -#include <intrin.h> -#endif - #include <array> #include <cstddef> #include <cstdint>
diff --git a/absl/crc/internal/non_temporal_memcpy.h b/absl/crc/internal/non_temporal_memcpy.h index 5d3e4e3..96eb178 100644 --- a/absl/crc/internal/non_temporal_memcpy.h +++ b/absl/crc/internal/non_temporal_memcpy.h
@@ -15,6 +15,15 @@ #ifndef ABSL_CRC_INTERNAL_NON_TEMPORAL_MEMCPY_H_ #define ABSL_CRC_INTERNAL_NON_TEMPORAL_MEMCPY_H_ +#include <algorithm> +#include <cassert> +#include <cstdint> +#include <cstring> + +#include "absl/base/attributes.h" +#include "absl/base/config.h" +#include "absl/base/optimization.h" + #ifdef _MSC_VER #include <intrin.h> #endif @@ -28,15 +37,6 @@ #include "absl/crc/internal/non_temporal_arm_intrinsics.h" #endif -#include <algorithm> -#include <cassert> -#include <cstdint> -#include <cstring> - -#include "absl/base/attributes.h" -#include "absl/base/config.h" -#include "absl/base/optimization.h" - namespace absl { ABSL_NAMESPACE_BEGIN namespace crc_internal {
diff --git a/absl/crc/internal/non_temporal_memcpy_test.cc b/absl/crc/internal/non_temporal_memcpy_test.cc index b2b19d3..179998e 100644 --- a/absl/crc/internal/non_temporal_memcpy_test.cc +++ b/absl/crc/internal/non_temporal_memcpy_test.cc
@@ -15,6 +15,7 @@ #include "absl/crc/internal/non_temporal_memcpy.h" #include <algorithm> +#include <cstddef> #include <cstdint> #include <iostream> #include <vector>
diff --git a/absl/debugging/BUILD.bazel b/absl/debugging/BUILD.bazel index 556ab9c..d3eb74d 100644 --- a/absl/debugging/BUILD.bazel +++ b/absl/debugging/BUILD.bazel
@@ -202,6 +202,7 @@ ":failure_signal_handler", ":stacktrace", ":symbolize", + "//absl/base:core_headers", "//absl/base:raw_logging_internal", "//absl/log:check", "//absl/strings",
diff --git a/absl/debugging/failure_signal_handler.cc b/absl/debugging/failure_signal_handler.cc index 745f773..e15d49d 100644 --- a/absl/debugging/failure_signal_handler.cc +++ b/absl/debugging/failure_signal_handler.cc
@@ -16,7 +16,20 @@ #include "absl/debugging/failure_signal_handler.h" +#include <algorithm> +#include <atomic> +#include <cerrno> +#include <csignal> +#include <cstdio> +#include <cstring> +#include <ctime> + +#include "absl/base/attributes.h" #include "absl/base/config.h" +#include "absl/base/internal/raw_logging.h" +#include "absl/base/internal/sysinfo.h" +#include "absl/debugging/internal/examine_stack.h" +#include "absl/debugging/stacktrace.h" #ifdef _WIN32 #include <windows.h> @@ -41,20 +54,6 @@ #include <sys/prctl.h> #endif -#include <algorithm> -#include <atomic> -#include <cerrno> -#include <csignal> -#include <cstdio> -#include <cstring> -#include <ctime> - -#include "absl/base/attributes.h" -#include "absl/base/internal/raw_logging.h" -#include "absl/base/internal/sysinfo.h" -#include "absl/debugging/internal/examine_stack.h" -#include "absl/debugging/stacktrace.h" - #if !defined(_WIN32) && !defined(__wasi__) #define ABSL_HAVE_SIGACTION // Apple WatchOS and TVOS don't allow sigaltstack
diff --git a/absl/debugging/failure_signal_handler_test.cc b/absl/debugging/failure_signal_handler_test.cc index 72816a3..7a84e38 100644 --- a/absl/debugging/failure_signal_handler_test.cc +++ b/absl/debugging/failure_signal_handler_test.cc
@@ -21,9 +21,11 @@ #include <cstdlib> #include <cstring> #include <fstream> +#include <string> #include "gmock/gmock.h" #include "gtest/gtest.h" +#include "absl/base/attributes.h" #include "absl/base/internal/raw_logging.h" #include "absl/debugging/stacktrace.h" #include "absl/debugging/symbolize.h"
diff --git a/absl/debugging/internal/address_is_readable.cc b/absl/debugging/internal/address_is_readable.cc index be17a10..e9be2ca 100644 --- a/absl/debugging/internal/address_is_readable.cc +++ b/absl/debugging/internal/address_is_readable.cc
@@ -17,6 +17,8 @@ #include "absl/debugging/internal/address_is_readable.h" +#include <cerrno> + #if !defined(__linux__) || defined(__ANDROID__) namespace absl {
diff --git a/absl/debugging/internal/demangle.cc b/absl/debugging/internal/demangle.cc index c82274f..e97a8ff 100644 --- a/absl/debugging/internal/demangle.cc +++ b/absl/debugging/internal/demangle.cc
@@ -1645,7 +1645,11 @@ return false; } MaybeAppend(state, "_Float"); - MaybeAppendDecimal(state, number); + if (number >= 0) { + MaybeAppendDecimal(state, number); + } else { + MaybeAppend(state, "?"); // the best we can do for an invalid width + } if (ParseOneCharToken(state, 'x')) { MaybeAppend(state, "x"); return true;
diff --git a/absl/debugging/internal/demangle.h b/absl/debugging/internal/demangle.h index cb0aba1..93193a9 100644 --- a/absl/debugging/internal/demangle.h +++ b/absl/debugging/internal/demangle.h
@@ -15,7 +15,9 @@ #ifndef ABSL_DEBUGGING_INTERNAL_DEMANGLE_H_ #define ABSL_DEBUGGING_INTERNAL_DEMANGLE_H_ +#include <cstddef> #include <string> + #include "absl/base/config.h" namespace absl {
diff --git a/absl/debugging/internal/demangle_test.cc b/absl/debugging/internal/demangle_test.cc index 50e4359..3023c5c 100644 --- a/absl/debugging/internal/demangle_test.cc +++ b/absl/debugging/internal/demangle_test.cc
@@ -705,6 +705,18 @@ EXPECT_STREQ("S::operator _Float128x()", tmp); } +TEST(Demangle, InvalidFloatNWidth) { + char tmp[80]; + + // A negative or overflowed _FloatN width is not printable, so render it as + // "?" like the sibling _BitInt path instead of emitting garbage bytes. + EXPECT_TRUE(Demangle("_ZNK1ScvDFn3_Ev", tmp, sizeof(tmp))); + EXPECT_STREQ("S::operator _Float?()", tmp); + + EXPECT_TRUE(Demangle("_ZNK1ScvDF2147483648_Ev", tmp, sizeof(tmp))); + EXPECT_STREQ("S::operator _Float?()", tmp); +} + TEST(Demangle, Bfloat16) { char tmp[80];
diff --git a/absl/debugging/internal/elf_mem_image.h b/absl/debugging/internal/elf_mem_image.h index c8a1036..4d31a47 100644 --- a/absl/debugging/internal/elf_mem_image.h +++ b/absl/debugging/internal/elf_mem_image.h
@@ -22,6 +22,7 @@ // Including this will define the __GLIBC__ macro if glibc is being // used. #include <climits> +#include <cstddef> #include <cstdint> #include "absl/base/config.h"
diff --git a/absl/debugging/internal/examine_stack.cc b/absl/debugging/internal/examine_stack.cc index cf18a51..9869c18 100644 --- a/absl/debugging/internal/examine_stack.cc +++ b/absl/debugging/internal/examine_stack.cc
@@ -16,14 +16,22 @@ #include "absl/debugging/internal/examine_stack.h" +#include <csignal> +#include <cstdint> +#include <cstdio> #include <iterator> +#include "absl/base/attributes.h" +#include "absl/base/config.h" +#include "absl/base/internal/raw_logging.h" +#include "absl/base/macros.h" +#include "absl/debugging/stacktrace.h" +#include "absl/debugging/symbolize.h" + #ifndef _WIN32 #include <unistd.h> #endif -#include "absl/base/config.h" - #ifdef ABSL_HAVE_MMAP #include <sys/mman.h> #if defined(MAP_ANON) && !defined(MAP_ANONYMOUS) @@ -35,15 +43,6 @@ #include <sys/ucontext.h> #endif -#include <csignal> -#include <cstdio> - -#include "absl/base/attributes.h" -#include "absl/base/internal/raw_logging.h" -#include "absl/base/macros.h" -#include "absl/debugging/stacktrace.h" -#include "absl/debugging/symbolize.h" - namespace absl { ABSL_NAMESPACE_BEGIN namespace debugging_internal {
diff --git a/absl/debugging/internal/stacktrace_aarch64-inl.inc b/absl/debugging/internal/stacktrace_aarch64-inl.inc index 0010644..79d6858 100644 --- a/absl/debugging/internal/stacktrace_aarch64-inl.inc +++ b/absl/debugging/internal/stacktrace_aarch64-inl.inc
@@ -3,13 +3,6 @@ // Generate stack tracer for aarch64 -#if defined(__linux__) -#include <signal.h> -#include <sys/mman.h> -#include <ucontext.h> -#include <unistd.h> -#endif - #include <atomic> #include <cassert> #include <cstddef> @@ -23,6 +16,13 @@ #include "absl/debugging/internal/vdso_support.h" // a no-op on non-elf or non-glibc systems #include "absl/debugging/stacktrace.h" +#if defined(__linux__) +#include <signal.h> +#include <sys/mman.h> +#include <ucontext.h> +#include <unistd.h> +#endif + static const size_t kUnknownFrameSize = 0; // Stack end to use when we don't know the actual stack end // (effectively just the end of address space).
diff --git a/absl/debugging/internal/stacktrace_powerpc-inl.inc b/absl/debugging/internal/stacktrace_powerpc-inl.inc index f446655..f23c29c 100644 --- a/absl/debugging/internal/stacktrace_powerpc-inl.inc +++ b/absl/debugging/internal/stacktrace_powerpc-inl.inc
@@ -21,13 +21,8 @@ #ifndef ABSL_DEBUGGING_INTERNAL_STACKTRACE_POWERPC_INL_H_ #define ABSL_DEBUGGING_INTERNAL_STACKTRACE_POWERPC_INL_H_ -#include "absl/debugging/internal/addresses.h" -#if defined(__linux__) -#include <asm/ptrace.h> // for PT_NIP. -#include <ucontext.h> // for ucontext_t -#endif - #include <unistd.h> + #include <cassert> #include <cstdint> #include <cstdio> @@ -35,9 +30,15 @@ #include "absl/base/attributes.h" #include "absl/base/optimization.h" #include "absl/base/port.h" -#include "absl/debugging/stacktrace.h" #include "absl/debugging/internal/address_is_readable.h" +#include "absl/debugging/internal/addresses.h" #include "absl/debugging/internal/vdso_support.h" // a no-op on non-elf or non-glibc systems +#include "absl/debugging/stacktrace.h" + +#if defined(__linux__) +#include <asm/ptrace.h> // for PT_NIP. +#include <ucontext.h> // for ucontext_t +#endif // Given a stack pointer, return the saved link register value. // Note that this is the link register for a callee.
diff --git a/absl/debugging/internal/stacktrace_riscv-inl.inc b/absl/debugging/internal/stacktrace_riscv-inl.inc index a4fb383..e950e76 100644 --- a/absl/debugging/internal/stacktrace_riscv-inl.inc +++ b/absl/debugging/internal/stacktrace_riscv-inl.inc
@@ -19,14 +19,6 @@ #include <sys/ucontext.h> -#include "absl/base/config.h" -#include "absl/debugging/internal/addresses.h" -#if defined(__linux__) -#include <sys/mman.h> -#include <ucontext.h> -#include <unistd.h> -#endif - #include <atomic> #include <cassert> #include <cstdint> @@ -35,8 +27,16 @@ #include <utility> #include "absl/base/attributes.h" +#include "absl/base/config.h" +#include "absl/debugging/internal/addresses.h" #include "absl/debugging/stacktrace.h" +#if defined(__linux__) +#include <sys/mman.h> +#include <ucontext.h> +#include <unistd.h> +#endif + static constexpr ptrdiff_t kUnknownFrameSize = 0; // Compute the size of a stack frame in [low..high). We assume that low < high.
diff --git a/absl/debugging/internal/stacktrace_x86-inl.inc b/absl/debugging/internal/stacktrace_x86-inl.inc index 6aa3146..55cf29a 100644 --- a/absl/debugging/internal/stacktrace_x86-inl.inc +++ b/absl/debugging/internal/stacktrace_x86-inl.inc
@@ -17,16 +17,8 @@ #ifndef ABSL_DEBUGGING_INTERNAL_STACKTRACE_X86_INL_INC_ #define ABSL_DEBUGGING_INTERNAL_STACKTRACE_X86_INL_INC_ -#include <cstddef> -#if defined(__linux__) && (defined(__i386__) || defined(__x86_64__)) -#include <ucontext.h> // for ucontext_t -#endif - -#if !defined(_WIN32) -#include <unistd.h> -#endif - #include <cassert> +#include <cstddef> #include <cstdint> #include <limits> @@ -38,6 +30,14 @@ #include "absl/debugging/internal/vdso_support.h" // a no-op on non-elf or non-glibc systems #include "absl/debugging/stacktrace.h" +#if defined(__linux__) && (defined(__i386__) || defined(__x86_64__)) +#include <ucontext.h> // for ucontext_t +#endif + +#if !defined(_WIN32) +#include <unistd.h> +#endif + using absl::debugging_internal::AddressIsReadable; #if defined(__linux__) && defined(__i386__)
diff --git a/absl/debugging/internal/symbolize.h b/absl/debugging/internal/symbolize.h index 3360af5..fd65544 100644 --- a/absl/debugging/internal/symbolize.h +++ b/absl/debugging/internal/symbolize.h
@@ -22,6 +22,7 @@ #include <cstddef> #include <cstdint> +#include <functional> #include <memory> #include "absl/base/config.h" @@ -35,7 +36,6 @@ #include <elf.h> #include <link.h> // For ElfW() macro. -#include <functional> namespace absl { ABSL_NAMESPACE_BEGIN
diff --git a/absl/debugging/internal/vdso_support.cc b/absl/debugging/internal/vdso_support.cc index d9dfccb..9d96f3b 100644 --- a/absl/debugging/internal/vdso_support.cc +++ b/absl/debugging/internal/vdso_support.cc
@@ -17,7 +17,11 @@ // VDSOSupport -- a class representing kernel VDSO (if present). #include "absl/debugging/internal/vdso_support.h" + +#include <atomic> + #include "absl/base/attributes.h" +#include "absl/debugging/internal/elf_mem_image.h" #ifdef ABSL_HAVE_VDSO_SUPPORT // defined in vdso_support.h
diff --git a/absl/debugging/symbolize_test.cc b/absl/debugging/symbolize_test.cc index d216f26..2cb1638 100644 --- a/absl/debugging/symbolize_test.cc +++ b/absl/debugging/symbolize_test.cc
@@ -13,23 +13,14 @@ // limitations under the License. #include "absl/debugging/symbolize.h" + #include <cstddef> - -#include "absl/debugging/internal/symbolize.h" -#include "absl/strings/str_format.h" - -#ifdef __EMSCRIPTEN__ -#include <emscripten.h> -#endif - -#ifndef _WIN32 -#include <fcntl.h> -#include <sys/mman.h> -#endif - +#include <cstdint> #include <cstring> #include <iostream> #include <memory> +#include <string> +#include <vector> #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -41,11 +32,22 @@ #include "absl/base/optimization.h" #include "absl/cleanup/cleanup.h" #include "absl/debugging/internal/stack_consumption.h" +#include "absl/debugging/internal/symbolize.h" #include "absl/log/check.h" #include "absl/log/log.h" #include "absl/memory/memory.h" +#include "absl/strings/str_format.h" #include "absl/strings/string_view.h" +#ifdef __EMSCRIPTEN__ +#include <emscripten.h> +#endif + +#ifndef _WIN32 +#include <fcntl.h> +#include <sys/mman.h> +#endif + #if defined(MAP_ANON) && !defined(MAP_ANONYMOUS) #define MAP_ANONYMOUS MAP_ANON #endif
diff --git a/absl/flags/config_test.cc b/absl/flags/config_test.cc index 6389986..5c74d76 100644 --- a/absl/flags/config_test.cc +++ b/absl/flags/config_test.cc
@@ -13,13 +13,12 @@ // limitations under the License. #include "absl/flags/config.h" +#include "gtest/gtest.h" #ifdef __APPLE__ #include <TargetConditionals.h> #endif -#include "gtest/gtest.h" - #ifndef ABSL_FLAGS_STRIP_NAMES #error ABSL_FLAGS_STRIP_NAMES is not defined #endif
diff --git a/absl/flags/parse.cc b/absl/flags/parse.cc index 736dc8b..940bf56 100644 --- a/absl/flags/parse.cc +++ b/absl/flags/parse.cc
@@ -29,10 +29,6 @@ #include <utility> #include <vector> -#ifdef _WIN32 -#include <windows.h> -#endif - #include "absl/algorithm/container.h" #include "absl/base/attributes.h" #include "absl/base/config.h" @@ -58,6 +54,10 @@ #include "absl/strings/strip.h" #include "absl/synchronization/mutex.h" +#ifdef _WIN32 +#include <windows.h> +#endif + // -------------------------------------------------------------------- namespace absl {
diff --git a/absl/hash/BUILD.bazel b/absl/hash/BUILD.bazel index 9f12e9a..41d7d68 100644 --- a/absl/hash/BUILD.bazel +++ b/absl/hash/BUILD.bazel
@@ -98,6 +98,7 @@ "//absl/memory", "//absl/meta:type_traits", "//absl/numeric:bits", + "//absl/strings:cord", "//absl/strings:cord_test_helpers", "//absl/strings:string_view", "@googletest//:gtest",
diff --git a/absl/hash/hash_benchmark.cc b/absl/hash/hash_benchmark.cc index a6b0e81..978b5bc 100644 --- a/absl/hash/hash_benchmark.cc +++ b/absl/hash/hash_benchmark.cc
@@ -196,7 +196,7 @@ 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); + static_assert(std::tuple_size_v<decltype(t6)> == 32); return t6; }
diff --git a/absl/hash/hash_test.cc b/absl/hash/hash_test.cc index c8d8235..4198102 100644 --- a/absl/hash/hash_test.cc +++ b/absl/hash/hash_test.cc
@@ -49,6 +49,7 @@ #include "absl/memory/memory.h" #include "absl/meta/type_traits.h" #include "absl/numeric/bits.h" +#include "absl/strings/cord.h" #include "absl/strings/cord_test_helpers.h" #include "absl/strings/string_view.h" @@ -1308,7 +1309,11 @@ // These sizes cover the different hashing cases. for (size_t size : {8u, 16u, 32u, 64u, 128u}) { for (size_t b = 0; b < size - 1; ++b) { - absl::flat_hash_set<std::string> set; + // Pre-reserve table capacity so the test measures hash distribution + // quality under standard load factors, avoiding probe length spikes + // caused by near-maximum load factors right before incremental resizing. + absl::flat_hash_set<std::string> set( + size_t{kMaxChar - kMinChar} * size_t{kMaxChar - kMinChar}); std::string s(size, '\0'); for (char c1 = kMinChar; c1 < kMaxChar; ++c1) { for (char c2 = kMinChar; c2 < kMaxChar; ++c2) { @@ -1329,8 +1334,12 @@ TEST(SwisstableCollisions, LowEntropyInts) { constexpr int kSizeTBits = sizeof(size_t) * 8; for (int bit = 0; bit < kSizeTBits; ++bit) { - absl::flat_hash_set<size_t> set; - for (size_t i = 0; i < 128 * 1024; ++i) { + // Pre-reserve table capacity so the test measures hash distribution + // quality under standard load factors, avoiding probe length spikes + // caused by near-maximum load factors right before incremental resizing. + const size_t kNumElements = 128 * 1024; + absl::flat_hash_set<size_t> set(kNumElements); + for (size_t i = 0; i < kNumElements; ++i) { size_t v = absl::rotl(i, bit); set.insert(v); ASSERT_LT(HashtableDebugAccess<decltype(set)>::GetNumProbes(set, v), 48)
diff --git a/absl/hash/internal/city.cc b/absl/hash/internal/city.cc index 416beed..bc2999a 100644 --- a/absl/hash/internal/city.cc +++ b/absl/hash/internal/city.cc
@@ -22,6 +22,9 @@ #include "absl/hash/internal/city.h" #include <algorithm> +#include <cstddef> +#include <cstdint> +#include <utility> #include "absl/base/config.h" #include "absl/base/internal/endian.h"
diff --git a/absl/hash/internal/city_test.cc b/absl/hash/internal/city_test.cc index 1bbf02e..822b399 100644 --- a/absl/hash/internal/city_test.cc +++ b/absl/hash/internal/city_test.cc
@@ -15,8 +15,11 @@ #include "absl/hash/internal/city.h" #include <string.h> + +#include <cstdint> #include <cstdio> #include <iostream> + #include "gtest/gtest.h" namespace absl {
diff --git a/absl/hash/internal/hash.h b/absl/hash/internal/hash.h index b17c574..a7dc74c 100644 --- a/absl/hash/internal/hash.h +++ b/absl/hash/internal/hash.h
@@ -19,11 +19,6 @@ #ifndef ABSL_HASH_INTERNAL_HASH_H_ #define ABSL_HASH_INTERNAL_HASH_H_ -#ifdef __APPLE__ -#include <Availability.h> -#include <TargetConditionals.h> -#endif - // We include config.h here to make sure that ABSL_INTERNAL_CPLUSPLUS_LANG is // defined. #include "absl/base/config.h" @@ -90,6 +85,11 @@ #include "absl/types/variant.h" #include "absl/utility/utility.h" +#ifdef __APPLE__ +#include <Availability.h> +#include <TargetConditionals.h> +#endif + #if defined(__cpp_lib_filesystem) && __cpp_lib_filesystem >= 201703L && \ !defined(__XTENSA__) #include <filesystem> // NOLINT
diff --git a/absl/hash/internal/hash_test.h b/absl/hash/internal/hash_test.h index 9963dc0..962a996 100644 --- a/absl/hash/internal/hash_test.h +++ b/absl/hash/internal/hash_test.h
@@ -18,6 +18,7 @@ #ifndef ABSL_HASH_INTERNAL_HASH_TEST_H_ #define ABSL_HASH_INTERNAL_HASH_TEST_H_ +#include <initializer_list> #include <type_traits> #include <utility>
diff --git a/absl/hash/internal/print_hash_of.cc b/absl/hash/internal/print_hash_of.cc index c392125..883cf99 100644 --- a/absl/hash/internal/print_hash_of.cc +++ b/absl/hash/internal/print_hash_of.cc
@@ -12,6 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +// SKIP_ABSL_INLINE_NAMESPACE_CHECK + +#include <cstdio> #include <cstdlib> #include "absl/hash/hash.h"
diff --git a/absl/hash/internal/spy_hash_state.h b/absl/hash/internal/spy_hash_state.h index 9217ec1..543e719 100644 --- a/absl/hash/internal/spy_hash_state.h +++ b/absl/hash/internal/spy_hash_state.h
@@ -23,6 +23,7 @@ #include <ostream> #include <string> #include <type_traits> +#include <utility> #include <vector> #include "absl/hash/hash.h"
diff --git a/absl/log/BUILD.bazel b/absl/log/BUILD.bazel index 5008d88..1881866 100644 --- a/absl/log/BUILD.bazel +++ b/absl/log/BUILD.bazel
@@ -510,8 +510,10 @@ deps = [ ":check", ":log", + ":log_entry", ":scoped_mock_log", "//absl/base:config", + "//absl/base:core_headers", "//absl/log/internal:test_matchers", "//absl/strings", "//absl/strings:str_format", @@ -550,10 +552,12 @@ ], deps = [ ":log", + ":log_entry", ":log_sink", ":log_sink_registry", ":scoped_mock_log", "//absl/base:core_headers", + "//absl/base:log_severity", "//absl/log/internal:test_actions", "//absl/log/internal:test_helpers", "//absl/log/internal:test_matchers", @@ -594,8 +598,10 @@ linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":log", + ":log_entry", ":log_sink", ":scoped_mock_log", + "//absl/base:log_severity", "//absl/log/internal:test_actions", "//absl/log/internal:test_helpers", "//absl/log/internal:test_matchers", @@ -622,6 +628,7 @@ deps = [ ":globals", ":log", + ":log_entry", ":scoped_mock_log", "//absl/base:core_headers", "//absl/base:log_severity",
diff --git a/absl/log/internal/conditions.h b/absl/log/internal/conditions.h index 3325a31..8be029d 100644 --- a/absl/log/internal/conditions.h +++ b/absl/log/internal/conditions.h
@@ -23,11 +23,6 @@ #ifndef ABSL_LOG_INTERNAL_CONDITIONS_H_ #define ABSL_LOG_INTERNAL_CONDITIONS_H_ -#if defined(_WIN32) || defined(__hexagon__) -#include <cstdlib> -#else -#include <unistd.h> -#endif #include <stdlib.h> #include <atomic> @@ -37,6 +32,12 @@ #include "absl/base/config.h" #include "absl/log/internal/voidify.h" +#if defined(_WIN32) || defined(__hexagon__) +#include <cstdlib> +#else +#include <unistd.h> +#endif + // `ABSL_LOG_INTERNAL_CONDITION` prefixes another macro that expands to a // temporary `LogMessage` instantiation followed by zero or more streamed // expressions. This definition is tricky to read correctly. It evaluates to
diff --git a/absl/log/internal/globals.cc b/absl/log/internal/globals.cc index 51b7245..658ebfd 100644 --- a/absl/log/internal/globals.cc +++ b/absl/log/internal/globals.cc
@@ -17,10 +17,6 @@ #include <atomic> #include <cstdio> -#if defined(__EMSCRIPTEN__) -#include <emscripten/console.h> -#endif - #include "absl/base/attributes.h" #include "absl/base/config.h" #include "absl/base/internal/raw_logging.h" @@ -29,6 +25,10 @@ #include "absl/strings/strip.h" // IWYU pragma: keep #include "absl/time/time.h" +#if defined(__EMSCRIPTEN__) +#include <emscripten/console.h> +#endif + namespace absl { ABSL_NAMESPACE_BEGIN namespace log_internal {
diff --git a/absl/log/internal/log_format.cc b/absl/log/internal/log_format.cc index c7bb3ec..ac33021 100644 --- a/absl/log/internal/log_format.cc +++ b/absl/log/internal/log_format.cc
@@ -17,12 +17,6 @@ #include <string.h> -#ifdef _MSC_VER -#include <winsock2.h> // For timeval -#else -#include <sys/time.h> -#endif - #include <cstddef> #include <cstdint> #include <limits> @@ -42,6 +36,12 @@ #include "absl/time/time.h" #include "absl/types/span.h" +#ifdef _MSC_VER +#include <winsock2.h> // For timeval +#else +#include <sys/time.h> +#endif + namespace absl { ABSL_NAMESPACE_BEGIN namespace log_internal {
diff --git a/absl/log/internal/log_message.cc b/absl/log/internal/log_message.cc index 673bd8d..8ac81df 100644 --- a/absl/log/internal/log_message.cc +++ b/absl/log/internal/log_message.cc
@@ -20,10 +20,6 @@ #include <stdlib.h> #include <string.h> -#ifndef _WIN32 -#include <unistd.h> -#endif - #include <algorithm> #include <array> #include <atomic> @@ -59,6 +55,10 @@ #include "absl/time/time.h" #include "absl/types/span.h" +#ifndef _WIN32 +#include <unistd.h> +#endif + extern "C" ABSL_ATTRIBUTE_WEAK void ABSL_INTERNAL_C_SYMBOL( AbslInternalOnFatalLogMessage)(const absl::LogEntry&) { // Default - Do nothing
diff --git a/absl/log/internal/log_sink_set.cc b/absl/log/internal/log_sink_set.cc index c4c7e5f..8f0eb22 100644 --- a/absl/log/internal/log_sink_set.cc +++ b/absl/log/internal/log_sink_set.cc
@@ -15,18 +15,6 @@ #include "absl/log/internal/log_sink_set.h" -#ifndef ABSL_HAVE_THREAD_LOCAL -#include <pthread.h> -#endif - -#ifdef __ANDROID__ -#include <android/log.h> -#endif - -#ifdef _WIN32 -#include <windows.h> -#endif - #include <algorithm> #include <vector> @@ -47,6 +35,18 @@ #include "absl/synchronization/mutex.h" #include "absl/types/span.h" +#ifndef ABSL_HAVE_THREAD_LOCAL +#include <pthread.h> +#endif + +#ifdef __ANDROID__ +#include <android/log.h> +#endif + +#ifdef _WIN32 +#include <windows.h> +#endif + namespace absl { ABSL_NAMESPACE_BEGIN namespace log_internal {
diff --git a/absl/log/internal/nullstream.h b/absl/log/internal/nullstream.h index 4eae52e..f582a05 100644 --- a/absl/log/internal/nullstream.h +++ b/absl/log/internal/nullstream.h
@@ -23,11 +23,6 @@ #ifndef ABSL_LOG_INTERNAL_NULLSTREAM_H_ #define ABSL_LOG_INTERNAL_NULLSTREAM_H_ -#ifdef _WIN32 -#include <cstdlib> -#else -#include <unistd.h> -#endif #include <ios> #include <ostream> @@ -36,6 +31,12 @@ #include "absl/base/log_severity.h" #include "absl/strings/string_view.h" +#ifdef _WIN32 +#include <cstdlib> +#else +#include <unistd.h> +#endif + namespace absl { ABSL_NAMESPACE_BEGIN namespace log_internal {
diff --git a/absl/log/internal/test_helpers.cc b/absl/log/internal/test_helpers.cc index 9abcd87..4a79664 100644 --- a/absl/log/internal/test_helpers.cc +++ b/absl/log/internal/test_helpers.cc
@@ -16,6 +16,13 @@ #include <csignal> +#include "gtest/gtest.h" +#include "absl/base/config.h" +#include "absl/base/log_severity.h" +#include "absl/log/globals.h" +#include "absl/log/initialize.h" +#include "absl/log/internal/globals.h" + #ifdef __Fuchsia__ #include <zircon/syscalls.h> #endif @@ -24,13 +31,6 @@ #include <signal.h> #endif -#include "gtest/gtest.h" -#include "absl/base/config.h" -#include "absl/base/log_severity.h" -#include "absl/log/globals.h" -#include "absl/log/initialize.h" -#include "absl/log/internal/globals.h" - namespace absl { ABSL_NAMESPACE_BEGIN namespace log_internal {
diff --git a/absl/log/log_format_test.cc b/absl/log/log_format_test.cc index aa520e4..eb7585c 100644 --- a/absl/log/log_format_test.cc +++ b/absl/log/log_format_test.cc
@@ -26,16 +26,14 @@ #include <string_view> #include <type_traits> -#ifdef __ANDROID__ -#include <android/api-level.h> -#endif - #include "gmock/gmock.h" #include "gtest/gtest.h" +#include "absl/base/attributes.h" #include "absl/base/config.h" #include "absl/log/check.h" #include "absl/log/internal/test_matchers.h" #include "absl/log/log.h" +#include "absl/log/log_entry.h" #include "absl/log/scoped_mock_log.h" #include "absl/strings/match.h" #include "absl/strings/str_cat.h" @@ -43,6 +41,10 @@ #include "absl/strings/string_view.h" #include "absl/types/source_location.h" +#ifdef __ANDROID__ +#include <android/api-level.h> +#endif + namespace { using ::absl::log_internal::AsString; using ::absl::log_internal::MatchesOstream;
diff --git a/absl/log/log_modifier_methods_test.cc b/absl/log/log_modifier_methods_test.cc index 1c7c35d..42a5147 100644 --- a/absl/log/log_modifier_methods_test.cc +++ b/absl/log/log_modifier_methods_test.cc
@@ -19,10 +19,12 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" +#include "absl/base/log_severity.h" #include "absl/log/internal/test_actions.h" #include "absl/log/internal/test_helpers.h" #include "absl/log/internal/test_matchers.h" #include "absl/log/log.h" +#include "absl/log/log_entry.h" #include "absl/log/log_sink.h" #include "absl/log/scoped_mock_log.h" #include "absl/strings/match.h"
diff --git a/absl/log/log_sink_test.cc b/absl/log/log_sink_test.cc index fa74306..cbb5a53 100644 --- a/absl/log/log_sink_test.cc +++ b/absl/log/log_sink_test.cc
@@ -18,10 +18,12 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" #include "absl/base/attributes.h" +#include "absl/base/log_severity.h" #include "absl/log/internal/test_actions.h" #include "absl/log/internal/test_helpers.h" #include "absl/log/internal/test_matchers.h" #include "absl/log/log.h" +#include "absl/log/log_entry.h" #include "absl/log/log_sink_registry.h" #include "absl/log/scoped_mock_log.h" #include "absl/strings/string_view.h"
diff --git a/absl/log/scoped_mock_log_test.cc b/absl/log/scoped_mock_log_test.cc index fd7c10b..6f1d8fb 100644 --- a/absl/log/scoped_mock_log_test.cc +++ b/absl/log/scoped_mock_log_test.cc
@@ -27,6 +27,7 @@ #include "absl/log/internal/test_helpers.h" #include "absl/log/internal/test_matchers.h" #include "absl/log/log.h" +#include "absl/log/log_entry.h" #include "absl/memory/memory.h" #include "absl/strings/match.h" #include "absl/strings/string_view.h"
diff --git a/absl/log/stripping_test.cc b/absl/log/stripping_test.cc index 20231b9..b0f718c 100644 --- a/absl/log/stripping_test.cc +++ b/absl/log/stripping_test.cc
@@ -33,14 +33,9 @@ #include <stdio.h> -#if defined(__APPLE__) -#include <mach-o/dyld.h> -#elif defined(_WIN32) -#include <Windows.h> -#include <tchar.h> -#endif - #include <algorithm> +#include <cerrno> +#include <cstring> #include <functional> #include <memory> #include <ostream> @@ -56,9 +51,17 @@ #include "absl/log/log.h" #include "absl/status/status.h" #include "absl/strings/escaping.h" +#include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" +#if defined(__APPLE__) +#include <mach-o/dyld.h> +#elif defined(_WIN32) +#include <Windows.h> +#include <tchar.h> +#endif + // Set a flag that controls whether we actually execute fatal statements, but // prevent the compiler from optimizing it out. static volatile bool kReallyDie = false;
diff --git a/absl/memory/memory.h b/absl/memory/memory.h index d364df8..cbc9812 100644 --- a/absl/memory/memory.h +++ b/absl/memory/memory.h
@@ -29,6 +29,7 @@ #include <new> #include <type_traits> #include <utility> +#include <version> #include "absl/base/macros.h" #include "absl/meta/type_traits.h"
diff --git a/absl/memory/memory_test.cc b/absl/memory/memory_test.cc index 8ed14c6..3ef6830 100644 --- a/absl/memory/memory_test.cc +++ b/absl/memory/memory_test.cc
@@ -19,6 +19,7 @@ #include <sys/types.h> #include <cstddef> +#include <cstring> #include <memory> #include <string> #include <type_traits>
diff --git a/absl/meta/type_traits.h b/absl/meta/type_traits.h index 11701e2..0bccd0b 100644 --- a/absl/meta/type_traits.h +++ b/absl/meta/type_traits.h
@@ -54,9 +54,13 @@ #include <span> // NOLINT(build/c++20) #endif -// Defines the default alignment. `__STDCPP_DEFAULT_NEW_ALIGNMENT__` is -// predefined by every C++17 implementation. +// Defines the default alignment. `__STDCPP_DEFAULT_NEW_ALIGNMENT__` is a C++17 +// feature, but GCC leaves it undefined under -fno-aligned-new. +#if defined(__STDCPP_DEFAULT_NEW_ALIGNMENT__) #define ABSL_INTERNAL_DEFAULT_NEW_ALIGNMENT __STDCPP_DEFAULT_NEW_ALIGNMENT__ +#else // defined(__STDCPP_DEFAULT_NEW_ALIGNMENT__) +#define ABSL_INTERNAL_DEFAULT_NEW_ALIGNMENT alignof(std::max_align_t) +#endif // defined(__STDCPP_DEFAULT_NEW_ALIGNMENT__) namespace absl { ABSL_NAMESPACE_BEGIN
diff --git a/absl/numeric/bits.h b/absl/numeric/bits.h index 47e9901..8eca392 100644 --- a/absl/numeric/bits.h +++ b/absl/numeric/bits.h
@@ -41,6 +41,7 @@ #include <cstdint> #include <limits> #include <type_traits> +#include <version> #include "absl/base/config.h"
diff --git a/absl/numeric/bits_benchmark.cc b/absl/numeric/bits_benchmark.cc index 429b4ca..3f8bed0 100644 --- a/absl/numeric/bits_benchmark.cc +++ b/absl/numeric/bits_benchmark.cc
@@ -12,7 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include <cstddef> #include <cstdint> +#include <limits> #include <vector> #include "absl/base/optimization.h"
diff --git a/absl/numeric/bits_test.cc b/absl/numeric/bits_test.cc index 8cf2378..30b5967 100644 --- a/absl/numeric/bits_test.cc +++ b/absl/numeric/bits_test.cc
@@ -20,6 +20,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" +#include "absl/numeric/internal/bits.h" #include "absl/random/random.h" namespace absl {
diff --git a/absl/numeric/int128.cc b/absl/numeric/int128.cc index 5dfc5ea..dc01c0f 100644 --- a/absl/numeric/int128.cc +++ b/absl/numeric/int128.cc
@@ -17,12 +17,16 @@ #include <stddef.h> #include <cassert> +#include <cstdint> #include <iomanip> +#include <ios> +#include <limits> #include <ostream> // NOLINT(readability/streams) #include <sstream> #include <string> #include <type_traits> +#include "absl/base/attributes.h" #include "absl/base/optimization.h" #include "absl/numeric/bits.h"
diff --git a/absl/numeric/int128.h b/absl/numeric/int128.h index 32603b0..0078ab0 100644 --- a/absl/numeric/int128.h +++ b/absl/numeric/int128.h
@@ -35,6 +35,7 @@ #include <string> #include <utility> +#include "absl/base/attributes.h" #include "absl/base/config.h" #include "absl/base/macros.h" #include "absl/base/port.h"
diff --git a/absl/numeric/int128_stream_test.cc b/absl/numeric/int128_stream_test.cc index 1b058e1..f8eb431 100644 --- a/absl/numeric/int128_stream_test.cc +++ b/absl/numeric/int128_stream_test.cc
@@ -12,12 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "absl/numeric/int128.h" - +#include <cstddef> +#include <cstdint> +#include <ios> +#include <limits> #include <sstream> #include <string> +#include <vector> #include "gtest/gtest.h" +#include "absl/numeric/int128.h" #include "absl/strings/str_cat.h" namespace {
diff --git a/absl/numeric/int128_test.cc b/absl/numeric/int128_test.cc index 9c140f0..93f0d73 100644 --- a/absl/numeric/int128_test.cc +++ b/absl/numeric/int128_test.cc
@@ -15,6 +15,8 @@ #include "absl/numeric/int128.h" #include <algorithm> +#include <cmath> +#include <cstdint> #include <limits> #include <random> #include <tuple>
diff --git a/absl/numeric/internal/bits.h b/absl/numeric/internal/bits.h index 82c577d..5835186 100644 --- a/absl/numeric/internal/bits.h +++ b/absl/numeric/internal/bits.h
@@ -19,15 +19,15 @@ #include <limits> #include <type_traits> +#include "absl/base/attributes.h" +#include "absl/base/config.h" + // Clang on Windows has __builtin_clzll; otherwise we need to use the // windows intrinsic functions. #if defined(_MSC_VER) && !defined(__clang__) #include <intrin.h> #endif -#include "absl/base/attributes.h" -#include "absl/base/config.h" - #if defined(__GNUC__) && !defined(__clang__) // GCC #define ABSL_NUMERIC_INTERNAL_HAVE_BUILTIN_OR_GCC(x) 1
diff --git a/absl/profiling/BUILD.bazel b/absl/profiling/BUILD.bazel index b88fc84..e958307 100644 --- a/absl/profiling/BUILD.bazel +++ b/absl/profiling/BUILD.bazel
@@ -93,6 +93,7 @@ visibility = ["//visibility:private"], deps = [ ":exponential_biased", + "//absl/base:core_headers", "//absl/strings", "@googletest//:gtest", "@googletest//:gtest_main", @@ -159,6 +160,7 @@ "//absl/base:raw_logging_internal", "//absl/container:btree", "//absl/container:flat_hash_map", + "//absl/container:hash_container_defaults", "//absl/strings", "//absl/strings:str_format", "//absl/types:span", @@ -176,6 +178,7 @@ ], deps = [ ":profile_builder", + "//absl/base", "//absl/base:config", "//absl/container:hashtablez_sampler", "//absl/status:statusor",
diff --git a/absl/profiling/hashtable.cc b/absl/profiling/hashtable.cc index f1dbe32..7e5e4ea 100644 --- a/absl/profiling/hashtable.cc +++ b/absl/profiling/hashtable.cc
@@ -22,6 +22,7 @@ #include <utility> #include <vector> +#include "absl/base/casts.h" #include "absl/base/config.h" #include "absl/container/internal/hashtablez_sampler.h" #include "absl/profiling/internal/profile_builder.h"
diff --git a/absl/profiling/internal/exponential_biased_test.cc b/absl/profiling/internal/exponential_biased_test.cc index 3dcf105..103b7d5 100644 --- a/absl/profiling/internal/exponential_biased_test.cc +++ b/absl/profiling/internal/exponential_biased_test.cc
@@ -16,12 +16,16 @@ #include <stddef.h> +#include <algorithm> #include <cmath> #include <cstdint> +#include <cstdio> +#include <string> #include <vector> #include "gmock/gmock.h" #include "gtest/gtest.h" +#include "absl/base/attributes.h" #include "absl/strings/str_cat.h" using ::testing::Ge;
diff --git a/absl/profiling/internal/periodic_sampler.cc b/absl/profiling/internal/periodic_sampler.cc index a738a82..3e0fc2f 100644 --- a/absl/profiling/internal/periodic_sampler.cc +++ b/absl/profiling/internal/periodic_sampler.cc
@@ -15,7 +15,9 @@ #include "absl/profiling/internal/periodic_sampler.h" #include <atomic> +#include <cstdint> +#include "absl/base/optimization.h" #include "absl/profiling/internal/exponential_biased.h" namespace absl {
diff --git a/absl/profiling/internal/periodic_sampler_benchmark.cc b/absl/profiling/internal/periodic_sampler_benchmark.cc index 8f0e557..2d6beca 100644 --- a/absl/profiling/internal/periodic_sampler_benchmark.cc +++ b/absl/profiling/internal/periodic_sampler_benchmark.cc
@@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "absl/base/optimization.h" #include "absl/profiling/internal/periodic_sampler.h" #include "benchmark/benchmark.h"
diff --git a/absl/profiling/internal/periodic_sampler_test.cc b/absl/profiling/internal/periodic_sampler_test.cc index ef986f3..d89b217 100644 --- a/absl/profiling/internal/periodic_sampler_test.cc +++ b/absl/profiling/internal/periodic_sampler_test.cc
@@ -14,6 +14,7 @@ #include "absl/profiling/internal/periodic_sampler.h" +#include <cstdint> #include <thread> // NOLINT(build/c++11) #include "gmock/gmock.h"
diff --git a/absl/profiling/internal/profile_builder.cc b/absl/profiling/internal/profile_builder.cc index 54170c4..6dc0677 100644 --- a/absl/profiling/internal/profile_builder.cc +++ b/absl/profiling/internal/profile_builder.cc
@@ -15,11 +15,6 @@ #include "absl/profiling/internal/profile_builder.h" -#ifdef __linux__ -#include <elf.h> -#include <link.h> -#endif // __linux__ - #include <cassert> #include <cstdint> #include <cstring> @@ -33,8 +28,14 @@ #include "absl/strings/escaping.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" #include "absl/types/span.h" +#ifdef __linux__ +#include <elf.h> +#include <link.h> +#endif // __linux__ + namespace absl { ABSL_NAMESPACE_BEGIN namespace debugging_internal {
diff --git a/absl/profiling/internal/profile_builder.h b/absl/profiling/internal/profile_builder.h index e4f2909..243b927 100644 --- a/absl/profiling/internal/profile_builder.h +++ b/absl/profiling/internal/profile_builder.h
@@ -18,11 +18,14 @@ #include <cstddef> #include <cstdint> +#include <memory> #include <string> +#include <utility> #include <vector> #include "absl/container/btree_map.h" #include "absl/container/flat_hash_map.h" +#include "absl/container/hash_container_defaults.h" #include "absl/strings/string_view.h" #include "absl/types/span.h"
diff --git a/absl/profiling/internal/sample_recorder.h b/absl/profiling/internal/sample_recorder.h index c0e4ebc..0d14027 100644 --- a/absl/profiling/internal/sample_recorder.h +++ b/absl/profiling/internal/sample_recorder.h
@@ -26,6 +26,7 @@ #include <atomic> #include <cstddef> +#include <cstdint> #include <functional> #include "absl/base/config.h"
diff --git a/absl/profiling/internal/sample_recorder_test.cc b/absl/profiling/internal/sample_recorder_test.cc index 31c72ed..2401149 100644 --- a/absl/profiling/internal/sample_recorder_test.cc +++ b/absl/profiling/internal/sample_recorder_test.cc
@@ -14,6 +14,7 @@ #include "absl/profiling/internal/sample_recorder.h" +#include <algorithm> #include <atomic> #include <cassert> #include <cstddef>
diff --git a/absl/random/BUILD.bazel b/absl/random/BUILD.bazel index ab0312a..7d62fa5 100644 --- a/absl/random/BUILD.bazel +++ b/absl/random/BUILD.bazel
@@ -263,6 +263,7 @@ deps = [ ":distributions", ":random", + "//absl/numeric:int128", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -282,6 +283,7 @@ deps = [ ":distributions", ":random", + "//absl/base:core_headers", "//absl/log", "//absl/random/internal:distribution_test_util", "//absl/random/internal:pcg_engine",
diff --git a/absl/random/bernoulli_distribution_test.cc b/absl/random/bernoulli_distribution_test.cc index b250f87..9c04bf6 100644 --- a/absl/random/bernoulli_distribution_test.cc +++ b/absl/random/bernoulli_distribution_test.cc
@@ -16,8 +16,10 @@ #include <cmath> #include <cstddef> +#include <limits> #include <random> #include <sstream> +#include <string> #include <utility> #include "gtest/gtest.h"
diff --git a/absl/random/beta_distribution_test.cc b/absl/random/beta_distribution_test.cc index 6839d5c..7e06cb2 100644 --- a/absl/random/beta_distribution_test.cc +++ b/absl/random/beta_distribution_test.cc
@@ -16,14 +16,18 @@ #include <algorithm> #include <cfloat> +#include <cmath> #include <cstddef> #include <cstdint> +#include <cstdlib> #include <iterator> +#include <limits> #include <random> #include <sstream> #include <string> #include <type_traits> #include <unordered_map> +#include <utility> #include <vector> #include "gmock/gmock.h"
diff --git a/absl/random/discrete_distribution_test.cc b/absl/random/discrete_distribution_test.cc index f82ef84..9d961f7 100644 --- a/absl/random/discrete_distribution_test.cc +++ b/absl/random/discrete_distribution_test.cc
@@ -22,6 +22,7 @@ #include <random> #include <sstream> #include <string> +#include <utility> #include <vector> #include "gmock/gmock.h"
diff --git a/absl/random/examples_test.cc b/absl/random/examples_test.cc index 29c27f1..25c673f 100644 --- a/absl/random/examples_test.cc +++ b/absl/random/examples_test.cc
@@ -12,7 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include <algorithm> #include <cinttypes> +#include <cstddef> +#include <cstdint> +#include <iostream> +#include <ostream> #include <random> #include <sstream> #include <vector>
diff --git a/absl/random/exponential_distribution.h b/absl/random/exponential_distribution.h index 67ab866..21a0279 100644 --- a/absl/random/exponential_distribution.h +++ b/absl/random/exponential_distribution.h
@@ -17,8 +17,10 @@ #include <cassert> #include <cmath> +#include <cstdint> #include <istream> #include <limits> +#include <ostream> #include <type_traits> #include "absl/base/config.h"
diff --git a/absl/random/gaussian_distribution_test.cc b/absl/random/gaussian_distribution_test.cc index 4d076bb..65fd85a 100644 --- a/absl/random/gaussian_distribution_test.cc +++ b/absl/random/gaussian_distribution_test.cc
@@ -17,9 +17,12 @@ #include <algorithm> #include <cmath> #include <cstddef> +#include <cstdint> #include <ios> #include <iterator> +#include <limits> #include <random> +#include <sstream> #include <string> #include <type_traits> #include <vector>
diff --git a/absl/random/generators_test.cc b/absl/random/generators_test.cc index c367567..3217a42 100644 --- a/absl/random/generators_test.cc +++ b/absl/random/generators_test.cc
@@ -18,6 +18,7 @@ #include <vector> #include "gtest/gtest.h" +#include "absl/numeric/int128.h" #include "absl/random/distributions.h" #include "absl/random/random.h"
diff --git a/absl/random/internal/pcg_engine.h b/absl/random/internal/pcg_engine.h index 96295b0..f85a1ac 100644 --- a/absl/random/internal/pcg_engine.h +++ b/absl/random/internal/pcg_engine.h
@@ -15,6 +15,12 @@ #ifndef ABSL_RANDOM_INTERNAL_PCG_ENGINE_H_ #define ABSL_RANDOM_INTERNAL_PCG_ENGINE_H_ +#include <cstddef> +#include <cstdint> +#include <ios> +#include <istream> +#include <limits> +#include <ostream> #include <type_traits> #include "absl/base/config.h"
diff --git a/absl/random/internal/randen_detect.cc b/absl/random/internal/randen_detect.cc index fc77b1c..83bde75 100644 --- a/absl/random/internal/randen_detect.cc +++ b/absl/random/internal/randen_detect.cc
@@ -19,6 +19,11 @@ #include "absl/random/internal/randen_detect.h" +#include <optional> // IWYU pragma: keep + +#include "absl/base/config.h" +#include "absl/random/internal/platform.h" + #if defined(__APPLE__) && defined(__aarch64__) #if __has_include(<arm/cpu_capabilities_public.h>) #include <arm/cpu_capabilities_public.h> @@ -27,11 +32,6 @@ #include <sys/types.h> #endif -#include <optional> // IWYU pragma: keep - -#include "absl/base/config.h" -#include "absl/random/internal/platform.h" - #if !defined(__UCLIBC__) && defined(__GLIBC__) && \ (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16)) #define ABSL_HAVE_GETAUXVAL
diff --git a/absl/random/internal/randen_engine.h b/absl/random/internal/randen_engine.h index 525d40a..a33736e 100644 --- a/absl/random/internal/randen_engine.h +++ b/absl/random/internal/randen_engine.h
@@ -17,7 +17,9 @@ #include <algorithm> #include <cinttypes> +#include <cstdint> #include <cstdlib> +#include <cstring> #include <istream> #include <iterator> #include <limits>
diff --git a/absl/random/internal/seed_material.cc b/absl/random/internal/seed_material.cc index 60607cf..75b9e29 100644 --- a/absl/random/internal/seed_material.cc +++ b/absl/random/internal/seed_material.cc
@@ -16,12 +16,6 @@ #include <fcntl.h> -#ifndef _WIN32 -#include <unistd.h> -#else -#include <io.h> -#endif - #include <algorithm> #include <cassert> #include <cerrno> @@ -39,6 +33,12 @@ #include "absl/strings/string_view.h" #include "absl/types/span.h" +#ifndef _WIN32 +#include <unistd.h> +#else +#include <io.h> +#endif + #if defined(_WIN32) #include <windows.h>
diff --git a/absl/random/internal/sequence_urbg.h b/absl/random/internal/sequence_urbg.h index bc96a12..a7acd9e 100644 --- a/absl/random/internal/sequence_urbg.h +++ b/absl/random/internal/sequence_urbg.h
@@ -17,6 +17,7 @@ #include <cstdint> #include <cstring> +#include <initializer_list> #include <limits> #include <type_traits> #include <vector>
diff --git a/absl/random/internal/traits.h b/absl/random/internal/traits.h index 8bde0ce..8404d93 100644 --- a/absl/random/internal/traits.h +++ b/absl/random/internal/traits.h
@@ -15,6 +15,7 @@ #ifndef ABSL_RANDOM_INTERNAL_TRAITS_H_ #define ABSL_RANDOM_INTERNAL_TRAITS_H_ +#include <cstddef> #include <cstdint> #include <limits> #include <type_traits>
diff --git a/absl/random/internal/wide_multiply.h b/absl/random/internal/wide_multiply.h index f2a5033..9cf17a9 100644 --- a/absl/random/internal/wide_multiply.h +++ b/absl/random/internal/wide_multiply.h
@@ -15,21 +15,22 @@ #ifndef ABSL_RANDOM_INTERNAL_WIDE_MULTIPLY_H_ #define ABSL_RANDOM_INTERNAL_WIDE_MULTIPLY_H_ +#include <cstddef> #include <cstdint> #include <limits> #include <type_traits> +#include "absl/base/config.h" +#include "absl/numeric/bits.h" +#include "absl/numeric/int128.h" +#include "absl/random/internal/traits.h" + #if (defined(_WIN32) || defined(_WIN64)) && defined(_M_IA64) #include <intrin.h> // NOLINT(build/include_order) #pragma intrinsic(_umul128) #define ABSL_INTERNAL_USE_UMUL128 1 #endif -#include "absl/base/config.h" -#include "absl/numeric/bits.h" -#include "absl/numeric/int128.h" -#include "absl/random/internal/traits.h" - namespace absl { ABSL_NAMESPACE_BEGIN namespace random_internal {
diff --git a/absl/random/log_uniform_int_distribution_test.cc b/absl/random/log_uniform_int_distribution_test.cc index 2530c9e..591b5b3 100644 --- a/absl/random/log_uniform_int_distribution_test.cc +++ b/absl/random/log_uniform_int_distribution_test.cc
@@ -14,9 +14,12 @@ #include "absl/random/log_uniform_int_distribution.h" +#include <algorithm> +#include <cmath> #include <cstddef> #include <cstdint> #include <iterator> +#include <limits> #include <random> #include <sstream> #include <string> @@ -24,6 +27,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" +#include "absl/base/macros.h" #include "absl/log/log.h" #include "absl/random/internal/chi_square.h" #include "absl/random/internal/distribution_test_util.h"
diff --git a/absl/random/poisson_distribution_test.cc b/absl/random/poisson_distribution_test.cc index 3a1d238..e8ee364 100644 --- a/absl/random/poisson_distribution_test.cc +++ b/absl/random/poisson_distribution_test.cc
@@ -15,9 +15,11 @@ #include "absl/random/poisson_distribution.h" #include <algorithm> +#include <cmath> #include <cstddef> #include <cstdint> #include <iterator> +#include <limits> #include <random> #include <sstream> #include <string>
diff --git a/absl/random/seed_gen_exception.cc b/absl/random/seed_gen_exception.cc index 6fb4ad3..2b6f090 100644 --- a/absl/random/seed_gen_exception.cc +++ b/absl/random/seed_gen_exception.cc
@@ -14,6 +14,8 @@ #include "absl/random/seed_gen_exception.h" +#include <exception> + #include "absl/base/config.h" #include "absl/base/internal/raw_logging.h"
diff --git a/absl/random/seed_sequences.h b/absl/random/seed_sequences.h index dacc5b9..a8d953b 100644 --- a/absl/random/seed_sequences.h +++ b/absl/random/seed_sequences.h
@@ -26,6 +26,7 @@ #define ABSL_RANDOM_SEED_SEQUENCES_H_ #include <iterator> +#include <ostream> #include <random> #include "absl/base/config.h"
diff --git a/absl/random/seed_sequences_test.cc b/absl/random/seed_sequences_test.cc index fe1100b..1a218a7 100644 --- a/absl/random/seed_sequences_test.cc +++ b/absl/random/seed_sequences_test.cc
@@ -14,8 +14,12 @@ #include "absl/random/seed_sequences.h" +#include <cstddef> +#include <cstdint> +#include <iostream> #include <iterator> #include <random> +#include <vector> #include "gmock/gmock.h" #include "gtest/gtest.h"
diff --git a/absl/random/uniform_int_distribution_test.cc b/absl/random/uniform_int_distribution_test.cc index 98da12b..b055833 100644 --- a/absl/random/uniform_int_distribution_test.cc +++ b/absl/random/uniform_int_distribution_test.cc
@@ -15,8 +15,10 @@ #include "absl/random/uniform_int_distribution.h" #include <cmath> +#include <cstddef> #include <cstdint> #include <iterator> +#include <limits> #include <random> #include <sstream> #include <string>
diff --git a/absl/random/uniform_real_distribution_test.cc b/absl/random/uniform_real_distribution_test.cc index 5193b8c..11e1d65 100644 --- a/absl/random/uniform_real_distribution_test.cc +++ b/absl/random/uniform_real_distribution_test.cc
@@ -16,8 +16,10 @@ #include <cfloat> #include <cmath> +#include <cstddef> #include <cstdint> #include <iterator> +#include <limits> #include <random> #include <sstream> #include <string>
diff --git a/absl/random/zipf_distribution_test.cc b/absl/random/zipf_distribution_test.cc index 71548ca..f29aca5 100644 --- a/absl/random/zipf_distribution_test.cc +++ b/absl/random/zipf_distribution_test.cc
@@ -15,10 +15,14 @@ #include "absl/random/zipf_distribution.h" #include <algorithm> +#include <cassert> +#include <cmath> #include <cstddef> #include <cstdint> #include <iterator> +#include <limits> #include <random> +#include <sstream> #include <string> #include <utility> #include <vector>
diff --git a/absl/status/internal/status_internal.h b/absl/status/internal/status_internal.h index 81f6ce4..1cc87ab 100644 --- a/absl/status/internal/status_internal.h +++ b/absl/status/internal/status_internal.h
@@ -29,6 +29,7 @@ #include "absl/base/config.h" #include "absl/base/nullability.h" #include "absl/container/inlined_vector.h" +#include "absl/functional/function_ref.h" #include "absl/strings/cord.h" #include "absl/strings/string_view.h" #include "absl/types/optional.h" @@ -147,6 +148,8 @@ StatusRep* absl_nonnull CloneAndUnref() const; private: + friend class absl::Status; + mutable std::atomic<int32_t> ref_; absl::StatusCode code_;
diff --git a/absl/status/internal/statusor_internal.h b/absl/status/internal/statusor_internal.h index 9327681..b086233 100644 --- a/absl/status/internal/statusor_internal.h +++ b/absl/status/internal/statusor_internal.h
@@ -20,6 +20,7 @@ #include "absl/base/attributes.h" #include "absl/base/nullability.h" +#include "absl/base/optimization.h" #include "absl/meta/type_traits.h" #include "absl/status/status.h" #include "absl/strings/string_view.h"
diff --git a/absl/status/status.cc b/absl/status/status.cc index 555ae42..80e8479 100644 --- a/absl/status/status.cc +++ b/absl/status/status.cc
@@ -147,6 +147,17 @@ return PointerToRep(rep_ptr); } +uintptr_t Status::WithContextImpl(uintptr_t rep, absl::string_view context) { + if (context.empty()) return rep; + status_internal::StatusRep* rep_ptr = PrepareToModify(rep); + if (rep_ptr->message_.empty()) { + rep_ptr->message_ = std::string(context); + } else { + absl::StrAppend(&rep_ptr->message_, "; ", context); + } + return PointerToRep(rep_ptr); +} + status_internal::StatusRep* absl_nonnull Status::PrepareToModify( uintptr_t rep) { if (IsInlined(rep)) { @@ -179,7 +190,6 @@ // If we add more error code, we need to add their values on this list. // Using ints here instead of static_cast<int>(StatusCode::kFoo) makes it easier // to see that the list is complete. -template Status MakeErrorStringViewImpl<0>(string_view, SourceLocation); template Status MakeErrorStringViewImpl<1>(string_view, SourceLocation); template Status MakeErrorStringViewImpl<2>(string_view, SourceLocation); template Status MakeErrorStringViewImpl<3>(string_view, SourceLocation); @@ -209,7 +219,6 @@ // If we add more error code, we need to add their values on this list. // Using ints here instead of static_cast<int>(StatusCode::kFoo) makes it easier // to see that the list is complete. -template Status MakeErrorStringRvalueImpl<0>(std::string&&, SourceLocation); template Status MakeErrorStringRvalueImpl<1>(std::string&&, SourceLocation); template Status MakeErrorStringRvalueImpl<2>(std::string&&, SourceLocation); template Status MakeErrorStringRvalueImpl<3>(std::string&&, SourceLocation);
diff --git a/absl/status/status.h b/absl/status/status.h index f86065a..4158de1 100644 --- a/absl/status/status.h +++ b/absl/status/status.h
@@ -771,6 +771,7 @@ // An out-of-line AddSourceLocation that mutates rep directly. static uintptr_t AddSourceLocationImpl(uintptr_t rep, absl::SourceLocation loc); + static uintptr_t WithContextImpl(uintptr_t rep, absl::string_view context); static void Ref(uintptr_t rep); static void Unref(uintptr_t rep); @@ -1276,7 +1277,6 @@ Status MakeErrorStringViewImpl(string_view message, SourceLocation loc); // Make the instantiations extern to reduce bloat on callers. #ifndef SWIG -extern template Status MakeErrorStringViewImpl<0>(string_view, SourceLocation); extern template Status MakeErrorStringViewImpl<1>(string_view, SourceLocation); extern template Status MakeErrorStringViewImpl<2>(string_view, SourceLocation); extern template Status MakeErrorStringViewImpl<3>(string_view, SourceLocation); @@ -1297,6 +1297,7 @@ template <StatusCode error_code> Status MakeErrorFromStringView(string_view message, SourceLocation loc) { + static_assert(error_code != StatusCode::kOk, "expecting non-OK code"); Status out = MakeErrorStringViewImpl<static_cast<int>(error_code)>(message, loc); // -Wassume warning complains about potential side effects of `ok()`, so use a @@ -1312,8 +1313,6 @@ template <int error_code> Status MakeErrorStringRvalueImpl(std::string&& message, SourceLocation loc); // Make the instantiations extern to reduce bloat on callers. -extern template Status MakeErrorStringRvalueImpl<0>(std::string&&, - SourceLocation); extern template Status MakeErrorStringRvalueImpl<1>(std::string&&, SourceLocation); extern template Status MakeErrorStringRvalueImpl<2>(std::string&&, @@ -1349,6 +1348,7 @@ template <StatusCode error_code, typename String> Status MakeErrorFromStringRvalue(String&& message, SourceLocation loc) { + static_assert(error_code != StatusCode::kOk, "expecting non-OK code"); static_assert(std::is_same_v<String&&, std::string&&>, "`message` should be std::string&&"); Status out = MakeErrorStringRvalueImpl<static_cast<int>(error_code)>(
diff --git a/absl/strings/BUILD.bazel b/absl/strings/BUILD.bazel index 15c13f1..7f8ca5f 100644 --- a/absl/strings/BUILD.bazel +++ b/absl/strings/BUILD.bazel
@@ -594,6 +594,7 @@ "//absl/base:config", "//absl/base:raw_logging_internal", "//absl/cleanup", + "//absl/types:span", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -644,6 +645,7 @@ ":cord_internal", ":cord_rep_test_util", "//absl/base:config", + "//absl/crc:crc32c", "//absl/crc:crc_cord_state", "@googletest//:gtest", "@googletest//:gtest_main", @@ -727,6 +729,7 @@ visibility = ["//absl:__subpackages__"], deps = [ "//absl/base:config", + "//absl/base:core_headers", "//absl/base:no_destructor", "//absl/base:raw_logging_internal", "//absl/synchronization", @@ -907,10 +910,12 @@ ":cordz_statistics", ":cordz_update_scope", ":cordz_update_tracker", + ":string_view", "//absl/base:config", "//absl/crc:crc_cord_state", "//absl/synchronization", "//absl/synchronization:thread_pool", + "//absl/time", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -927,6 +932,7 @@ ":cordz_info", ":cordz_sample_token", ":cordz_test_helpers", + ":cordz_update_tracker", "//absl/base:config", "//absl/memory", "//absl/random", @@ -966,6 +972,7 @@ ":strings", "//absl/base:config", "//absl/base:raw_logging_internal", + "//absl/types:span", ], ) @@ -981,6 +988,7 @@ deps = [ ":cord", ":cord_internal", + ":cordz_functions", ":cordz_info", ":cordz_sample_token", ":cordz_statistics", @@ -1005,7 +1013,6 @@ ":cord_rep_test_util", ":string_view", "//absl/base:config", - "//absl/base:hardening", "//absl/types:span", "@googletest//:gtest", "@googletest//:gtest_main", @@ -1032,7 +1039,6 @@ "//absl/base:config", "//absl/base:core_headers", "//absl/base:endian", - "//absl/base:hardening", "//absl/base:no_destructor", "//absl/container:fixed_array", "//absl/functional:function_ref", @@ -1451,6 +1457,7 @@ deps = [ ":cord", ":str_format", + ":str_format_internal", ":strings", "//absl/base:config", "//absl/base:core_headers", @@ -1498,6 +1505,8 @@ visibility = ["//visibility:private"], deps = [ ":str_format_internal", + ":string_view", + "//absl/types:span", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -1510,6 +1519,7 @@ visibility = ["//visibility:private"], deps = [ ":str_format", + ":string_view", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -1526,10 +1536,12 @@ ":str_format", ":str_format_internal", ":strings", + "//absl/base", "//absl/base:config", "//absl/base:core_headers", "//absl/base:raw_logging_internal", "//absl/log", + "//absl/log:absl_check", "//absl/numeric:int128", "//absl/types:span", "@googletest//:gtest",
diff --git a/absl/strings/CMakeLists.txt b/absl/strings/CMakeLists.txt index a9fa1f9..3ea24fe 100644 --- a/absl/strings/CMakeLists.txt +++ b/absl/strings/CMakeLists.txt
@@ -1165,7 +1165,6 @@ absl::endian absl::fixed_array absl::function_ref - absl::hardening absl::hash absl::hash_testing absl::no_destructor
diff --git a/absl/strings/cord_buffer.h b/absl/strings/cord_buffer.h index a2d1b32..c3803eb 100644 --- a/absl/strings/cord_buffer.h +++ b/absl/strings/cord_buffer.h
@@ -37,6 +37,7 @@ #include "absl/numeric/bits.h" #include "absl/strings/internal/cord_internal.h" #include "absl/strings/internal/cord_rep_flat.h" +#include "absl/strings/string_view.h" #include "absl/types/span.h" namespace absl {
diff --git a/absl/strings/cord_buffer_test.cc b/absl/strings/cord_buffer_test.cc index ab62808..c1b2396 100644 --- a/absl/strings/cord_buffer_test.cc +++ b/absl/strings/cord_buffer_test.cc
@@ -14,7 +14,6 @@ #include "absl/strings/cord_buffer.h" - #include <algorithm> #include <cstring> #include <limits>
diff --git a/absl/strings/cord_test.cc b/absl/strings/cord_test.cc index 7a2c936..1ff172e 100644 --- a/absl/strings/cord_test.cc +++ b/absl/strings/cord_test.cc
@@ -38,7 +38,6 @@ #include "absl/base/attributes.h" #include "absl/base/config.h" #include "absl/base/internal/endian.h" -#include "absl/base/internal/hardening.h" #include "absl/base/macros.h" #include "absl/base/no_destructor.h" #include "absl/base/options.h" @@ -2816,7 +2815,6 @@ }()); if (!test_hardening) return; - absl::base_internal::ScopedSetAbslHardeningForTesting hardener(true); EXPECT_DEATH_IF_SUPPORTED(cord[5], ""); EXPECT_DEATH_IF_SUPPORTED(*cord.chunk_end(), ""); EXPECT_DEATH_IF_SUPPORTED(static_cast<void>(cord.chunk_end()->empty()), ""); @@ -3414,69 +3412,3 @@ std::strong_ordering::greater); #endif } - -#if defined(GTEST_HAS_DEATH_TEST) && defined(ABSL_INTERNAL_CORD_HAVE_SANITIZER) - -// Returns an expected poison / uninitialized death message expression. -const char* MASanDeathExpr() { - return "(use-after-poison|use-of-uninitialized-value)"; -} - -TEST(CordSanitizerTest, SanitizesEmptyCord) { - absl::Cord cord; - const char* data = cord.Flatten().data(); - EXPECT_DEATH(EXPECT_EQ(data[0], 0), MASanDeathExpr()); -} - -TEST(CordSanitizerTest, SanitizesSmallCord) { - absl::Cord cord("Hello"); - const char* data = cord.Flatten().data(); - EXPECT_DEATH(EXPECT_EQ(data[5], 0), MASanDeathExpr()); -} - -TEST(CordSanitizerTest, SanitizesCordOnSetSSOValue) { - absl::Cord cord("String that is too big to be an SSO value"); - cord = "Hello"; - const char* data = cord.Flatten().data(); - EXPECT_DEATH(EXPECT_EQ(data[5], 0), MASanDeathExpr()); -} - -TEST(CordSanitizerTest, SanitizesCordOnCopyCtor) { - absl::Cord src("hello"); - absl::Cord dst(src); - const char* data = dst.Flatten().data(); - EXPECT_DEATH(EXPECT_EQ(data[5], 0), MASanDeathExpr()); -} - -TEST(CordSanitizerTest, SanitizesCordOnMoveCtor) { - absl::Cord src("hello"); - absl::Cord dst(std::move(src)); - const char* data = dst.Flatten().data(); - EXPECT_DEATH(EXPECT_EQ(data[5], 0), MASanDeathExpr()); -} - -TEST(CordSanitizerTest, SanitizesCordOnAssign) { - absl::Cord src("hello"); - absl::Cord dst; - dst = src; - const char* data = dst.Flatten().data(); - EXPECT_DEATH(EXPECT_EQ(data[5], 0), MASanDeathExpr()); -} - -TEST(CordSanitizerTest, SanitizesCordOnMoveAssign) { - absl::Cord src("hello"); - absl::Cord dst; - dst = std::move(src); - const char* data = dst.Flatten().data(); - EXPECT_DEATH(EXPECT_EQ(data[5], 0), MASanDeathExpr()); -} - -TEST(CordSanitizerTest, SanitizesCordOnSsoAssign) { - absl::Cord src("hello"); - absl::Cord dst("String that is too big to be an SSO value"); - dst = src; - const char* data = dst.Flatten().data(); - EXPECT_DEATH(EXPECT_EQ(data[5], 0), MASanDeathExpr()); -} - -#endif // GTEST_HAS_DEATH_TEST && ABSL_INTERNAL_CORD_HAVE_SANITIZER
diff --git a/absl/strings/cord_test_helpers.h b/absl/strings/cord_test_helpers.h index ca52240..715e980 100644 --- a/absl/strings/cord_test_helpers.h +++ b/absl/strings/cord_test_helpers.h
@@ -17,13 +17,16 @@ #ifndef ABSL_STRINGS_CORD_TEST_HELPERS_H_ #define ABSL_STRINGS_CORD_TEST_HELPERS_H_ +#include <cstddef> #include <cstdint> +#include <initializer_list> #include <iostream> #include <string> #include "absl/base/config.h" #include "absl/strings/cord.h" #include "absl/strings/internal/cord_internal.h" +#include "absl/strings/internal/cord_rep_flat.h" #include "absl/strings/string_view.h" namespace absl {
diff --git a/absl/strings/cordz_test_helpers.h b/absl/strings/cordz_test_helpers.h index 66232db..6a29030 100644 --- a/absl/strings/cordz_test_helpers.h +++ b/absl/strings/cordz_test_helpers.h
@@ -15,6 +15,8 @@ #ifndef ABSL_STRINGS_CORDZ_TEST_HELPERS_H_ #define ABSL_STRINGS_CORDZ_TEST_HELPERS_H_ +#include <cstdint> +#include <cstring> #include <utility> #include "gmock/gmock.h" @@ -24,6 +26,7 @@ #include "absl/base/nullability.h" #include "absl/strings/cord.h" #include "absl/strings/internal/cord_internal.h" +#include "absl/strings/internal/cordz_functions.h" #include "absl/strings/internal/cordz_info.h" #include "absl/strings/internal/cordz_sample_token.h" #include "absl/strings/internal/cordz_statistics.h"
diff --git a/absl/strings/escaping.h b/absl/strings/escaping.h index 3dbaa5b..0b0f8b2 100644 --- a/absl/strings/escaping.h +++ b/absl/strings/escaping.h
@@ -23,6 +23,7 @@ #ifndef ABSL_STRINGS_ESCAPING_H_ #define ABSL_STRINGS_ESCAPING_H_ +#include <cassert> #include <cstddef> #include <optional> #include <string>
diff --git a/absl/strings/has_absl_stringify.h b/absl/strings/has_absl_stringify.h index 45843ae..5bc8791 100644 --- a/absl/strings/has_absl_stringify.h +++ b/absl/strings/has_absl_stringify.h
@@ -15,6 +15,7 @@ #ifndef ABSL_STRINGS_HAS_ABSL_STRINGIFY_H_ #define ABSL_STRINGS_HAS_ABSL_STRINGIFY_H_ +#include <cstddef> #include <type_traits> #include <utility>
diff --git a/absl/strings/internal/charconv_bigint.cc b/absl/strings/internal/charconv_bigint.cc index 9185f1f..e91e90b 100644 --- a/absl/strings/internal/charconv_bigint.cc +++ b/absl/strings/internal/charconv_bigint.cc
@@ -16,8 +16,12 @@ #include <algorithm> #include <cassert> +#include <cstdint> +#include <iterator> #include <string> +#include "absl/strings/internal/charconv_parse.h" + namespace absl { ABSL_NAMESPACE_BEGIN namespace strings_internal {
diff --git a/absl/strings/internal/charconv_bigint_test.cc b/absl/strings/internal/charconv_bigint_test.cc index 7bbf16d..8d9f62d 100644 --- a/absl/strings/internal/charconv_bigint_test.cc +++ b/absl/strings/internal/charconv_bigint_test.cc
@@ -14,6 +14,8 @@ #include "absl/strings/internal/charconv_bigint.h" +#include <cstdint> +#include <limits> #include <string> #include "gtest/gtest.h"
diff --git a/absl/strings/internal/charconv_parse_test.cc b/absl/strings/internal/charconv_parse_test.cc index 2b7b082..c10b77b 100644 --- a/absl/strings/internal/charconv_parse_test.cc +++ b/absl/strings/internal/charconv_parse_test.cc
@@ -14,13 +14,16 @@ #include "absl/strings/internal/charconv_parse.h" +#include <cstdint> #include <string> #include <utility> #include "gmock/gmock.h" #include "gtest/gtest.h" #include "absl/log/check.h" +#include "absl/strings/charconv.h" #include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" using absl::chars_format; using absl::strings_internal::FloatType;
diff --git a/absl/strings/internal/cord_data_edge_test.cc b/absl/strings/internal/cord_data_edge_test.cc index 8fce3bc..58046fe 100644 --- a/absl/strings/internal/cord_data_edge_test.cc +++ b/absl/strings/internal/cord_data_edge_test.cc
@@ -18,6 +18,7 @@ #include "gtest/gtest.h" #include "absl/strings/internal/cord_internal.h" #include "absl/strings/internal/cord_rep_test_util.h" +#include "absl/strings/string_view.h" namespace absl { ABSL_NAMESPACE_BEGIN
diff --git a/absl/strings/internal/cord_internal.cc b/absl/strings/internal/cord_internal.cc index becfc6a..79e4461 100644 --- a/absl/strings/internal/cord_internal.cc +++ b/absl/strings/internal/cord_internal.cc
@@ -17,6 +17,7 @@ #include <cassert> #include <memory> +#include "absl/base/attributes.h" #include "absl/base/internal/raw_logging.h" #include "absl/container/inlined_vector.h" #include "absl/strings/internal/cord_rep_btree.h"
diff --git a/absl/strings/internal/cord_internal.h b/absl/strings/internal/cord_internal.h index 650f514..cf45907 100644 --- a/absl/strings/internal/cord_internal.h +++ b/absl/strings/internal/cord_internal.h
@@ -22,6 +22,7 @@ #include <cstring> #include <limits> #include <string> +#include <type_traits> #include "absl/base/attributes.h" #include "absl/base/config.h" @@ -34,19 +35,6 @@ #include "absl/container/internal/container_memory.h" #include "absl/strings/string_view.h" -// We can only add poisoning if we can detect consteval executions. -// -// TODO(b/548049702): attempt to turn this back on. It's disabled because asan -// interacts poorly with trivial ABIs (http://b/546331925). -#if 0 && defined(ABSL_HAVE_CONSTANT_EVALUATED) && \ - (defined(ABSL_HAVE_ADDRESS_SANITIZER) || \ - defined(ABSL_HAVE_MEMORY_SANITIZER)) -#define ABSL_INTERNAL_CORD_HAVE_SANITIZER 1 -#endif - -#define ABSL_CORD_INTERNAL_NO_SANITIZE \ - ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS ABSL_ATTRIBUTE_NO_SANITIZE_MEMORY - namespace absl { ABSL_NAMESPACE_BEGIN namespace cord_internal { @@ -498,18 +486,9 @@ // is actively inspected and used by gdb pretty printing code. static constexpr size_t kTagOffset = 0; - // Implement `~InlineData()` conditionally: we only need this destructor to - // unpoison poisoned instances under *SAN, and it will only compile correctly - // if the current compiler supports `absl::is_constant_evaluated()`. -#ifdef ABSL_INTERNAL_CORD_HAVE_SANITIZER - ~InlineData() noexcept { unpoison(); } -#endif + InlineData() = default; - constexpr InlineData() noexcept { poison_this(); } - - explicit InlineData(DefaultInitType) noexcept : rep_(kDefaultInit) { - poison_this(); - } + explicit InlineData(DefaultInitType) noexcept : rep_(kDefaultInit) {} explicit InlineData(CordRep* rep) noexcept : rep_(rep) { ABSL_ASSERT(rep != nullptr); @@ -519,37 +498,20 @@ // value. Creates an inlined SSO value if `rep` is null, otherwise // creates a tree instance value. constexpr InlineData(absl::string_view sv, CordRep* rep) noexcept - : rep_(rep != nullptr ? Rep(rep) : Rep(sv)) { - poison(); - } + : rep_(rep != nullptr ? Rep(rep) : Rep(sv)) {} - constexpr InlineData(const InlineData& rhs) noexcept; - InlineData& operator=(const InlineData& rhs) noexcept; + constexpr InlineData(const InlineData& rhs) noexcept = default; + InlineData& operator=(const InlineData& rhs) noexcept = default; friend void swap(InlineData& lhs, InlineData& rhs) noexcept; friend bool operator==(const InlineData& lhs, const InlineData& rhs) { -#ifdef ABSL_INTERNAL_CORD_HAVE_SANITIZER - const Rep l = lhs.rep_.SanitizerSafeCopy(); - const Rep r = rhs.rep_.SanitizerSafeCopy(); - return memcmp(&l, &r, sizeof(l)) == 0; -#else return memcmp(&lhs, &rhs, sizeof(lhs)) == 0; -#endif } + friend bool operator!=(const InlineData& lhs, const InlineData& rhs) { return !operator==(lhs, rhs); } - // Poisons the unused inlined SSO data if the current instance - // is inlined, else un-poisons the entire instance. - constexpr void poison(); - - // Un-poisons this instance. - constexpr void unpoison(); - - // Poisons the current instance. This is used on default initialization. - constexpr void poison_this(); - // Returns true if the current instance is empty. // The 'empty value' is an inlined data value of zero length. bool is_empty() const { return rep_.tag() == 0; } @@ -634,10 +596,8 @@ void set_inline_data(const char* data, size_t n) { ABSL_ASSERT(n <= kMaxInline); - unpoison(); rep_.set_tag(static_cast<int8_t>(n << 1)); SmallMemmove<true>(rep_.as_chars(), data, n); - poison(); } void CopyInlineToString(std::string* dst) const { @@ -661,7 +621,6 @@ // Initialize this instance to holding the tree value `rep`, // initializing the cordz_info to null, i.e.: 'not profiled'. void make_tree(CordRep* rep) { - unpoison(); rep_.make_tree(rep); } @@ -681,9 +640,7 @@ // Requires `size` to be <= kMaxInline. // See the documentation on 'as_chars()' for more information and examples. void set_inline_size(size_t size) { - unpoison(); rep_.set_inline_size(size); - poison(); } // Compares 'this' inlined data with rhs. The comparison is a straightforward @@ -731,73 +688,36 @@ 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 this->data + 1; } + const char* as_chars() const { return this->data + 1; } - bool is_tree() const { return (self()->tag() & 1) != 0; } + bool is_tree() const { return (this->tag() & 1) != 0; } size_t inline_size() const { - ABSL_ASSERT(!self()->is_tree()); - return static_cast<size_t>(self()->tag()) >> 1; + ABSL_ASSERT(!this->is_tree()); + return static_cast<size_t>(this->tag()) >> 1; } void set_inline_size(size_t size) { ABSL_ASSERT(size <= kMaxInline); - self()->set_tag(static_cast<int8_t>(size << 1)); + this->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 this->as_tree.rep; } + void set_tree(CordRep* rhs) { this->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 this->as_tree.cordz_info; } + void set_cordz_info(cordz_info_t rhs) { this->as_tree.cordz_info = rhs; } void make_tree(CordRep* tree) { - self()->as_tree.rep = tree; - self()->as_tree.cordz_info = kNullCordzInfo; + this->as_tree.rep = tree; + this->as_tree.cordz_info = kNullCordzInfo; } -#ifdef ABSL_INTERNAL_CORD_HAVE_SANITIZER - constexpr Rep SanitizerSafeCopy() const { - if (!absl::is_constant_evaluated()) { - Rep res; - if (is_tree()) { - res = *this; - } else { - res.set_tag(tag()); - memcpy(res.as_chars(), as_chars(), inline_size()); - } - return res; - } else { - return *this; - } - } -#else constexpr const Rep& SanitizerSafeCopy() const { return *this; } -#endif // If the data has length <= kMaxInline, we store it in `data`, and // store the size in the first char of `data` shifted left + 1. @@ -838,58 +758,6 @@ static_assert(sizeof(InlineData) == kMaxInline + 1); -#ifdef ABSL_INTERNAL_CORD_HAVE_SANITIZER - -constexpr InlineData::InlineData(const InlineData& rhs) noexcept - : rep_(rhs.rep_.SanitizerSafeCopy()) { - poison(); -} - -inline InlineData& InlineData::operator=(const InlineData& rhs) noexcept { - unpoison(); - rep_ = rhs.rep_.SanitizerSafeCopy(); - poison(); - return *this; -} - -constexpr void InlineData::poison_this() { - if (!absl::is_constant_evaluated()) { - container_internal::SanitizerPoisonObject(this); - } -} - -constexpr void InlineData::unpoison() { - if (!absl::is_constant_evaluated()) { - container_internal::SanitizerUnpoisonObject(this); - } -} - -constexpr void InlineData::poison() { - if (!absl::is_constant_evaluated()) { - if (is_tree()) { - container_internal::SanitizerUnpoisonObject(this); - } else if (const size_t size = inline_size()) { - if (size < kMaxInline) { - const char* end = rep_.as_chars() + size; - container_internal::SanitizerPoisonMemoryRegion(end, kMaxInline - size); - } - } else { - container_internal::SanitizerPoisonObject(this); - } - } -} - -#else // ABSL_INTERNAL_CORD_HAVE_SANITIZER - -constexpr InlineData::InlineData(const InlineData&) noexcept = default; -inline InlineData& InlineData::operator=(const InlineData&) noexcept = default; - -constexpr void InlineData::poison_this() {} -constexpr void InlineData::unpoison() {} -constexpr void InlineData::poison() {} - -#endif // ABSL_INTERNAL_CORD_HAVE_SANITIZER - inline CordRepSubstring* CordRep::substring() { assert(IsSubstring()); return static_cast<CordRepSubstring*>(this); @@ -926,16 +794,12 @@ } inline void swap(InlineData& lhs, InlineData& rhs) noexcept { - lhs.unpoison(); - rhs.unpoison(); // TODO(b/145829486): `std::swap(lhs.rep_, rhs.rep_)` results in bad codegen // on clang, spilling the temporary swap value on the stack. Since `Rep` is // trivial, we can make clang DTRT by calling a hand-rolled `SwapValue` where // we pass `rhs` both by value (register allocated) and by reference. The IR // then folds and inlines correctly into an optimized swap without spill. lhs.rep_.SwapValue(rhs.rep_, rhs.rep_); - rhs.poison(); - lhs.poison(); } } // namespace cord_internal
diff --git a/absl/strings/internal/cord_rep_btree.cc b/absl/strings/internal/cord_rep_btree.cc index d816522..7de2a13 100644 --- a/absl/strings/internal/cord_rep_btree.cc +++ b/absl/strings/internal/cord_rep_btree.cc
@@ -14,9 +14,12 @@ #include "absl/strings/internal/cord_rep_btree.h" +#include <algorithm> #include <atomic> #include <cassert> +#include <cstddef> #include <cstdint> +#include <cstring> #include <iostream> #include <ostream> #include <string> @@ -31,6 +34,7 @@ #include "absl/strings/internal/cord_rep_flat.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" +#include "absl/types/span.h" namespace absl { ABSL_NAMESPACE_BEGIN
diff --git a/absl/strings/internal/cord_rep_btree.h b/absl/strings/internal/cord_rep_btree.h index 852cc17..f653735 100644 --- a/absl/strings/internal/cord_rep_btree.h +++ b/absl/strings/internal/cord_rep_btree.h
@@ -15,8 +15,11 @@ #ifndef ABSL_STRINGS_INTERNAL_CORD_REP_BTREE_H_ #define ABSL_STRINGS_INTERNAL_CORD_REP_BTREE_H_ +#include <algorithm> #include <cassert> +#include <cstddef> #include <cstdint> +#include <cstring> #include <iosfwd> #include "absl/base/config.h"
diff --git a/absl/strings/internal/cord_rep_btree_navigator.cc b/absl/strings/internal/cord_rep_btree_navigator.cc index 6ed20c2..707e5c8 100644 --- a/absl/strings/internal/cord_rep_btree_navigator.cc +++ b/absl/strings/internal/cord_rep_btree_navigator.cc
@@ -15,6 +15,8 @@ #include "absl/strings/internal/cord_rep_btree_navigator.h" #include <cassert> +#include <cstddef> +#include <cstdint> #include "absl/strings/internal/cord_data_edge.h" #include "absl/strings/internal/cord_internal.h"
diff --git a/absl/strings/internal/cord_rep_btree_navigator.h b/absl/strings/internal/cord_rep_btree_navigator.h index 3d581c8..1024525 100644 --- a/absl/strings/internal/cord_rep_btree_navigator.h +++ b/absl/strings/internal/cord_rep_btree_navigator.h
@@ -16,8 +16,11 @@ #define ABSL_STRINGS_INTERNAL_CORD_REP_BTREE_NAVIGATOR_H_ #include <cassert> +#include <cstddef> +#include <cstdint> #include <iostream> +#include "absl/base/optimization.h" #include "absl/strings/internal/cord_internal.h" #include "absl/strings/internal/cord_rep_btree.h"
diff --git a/absl/strings/internal/cord_rep_btree_navigator_test.cc b/absl/strings/internal/cord_rep_btree_navigator_test.cc index bed7550..6e4a79b 100644 --- a/absl/strings/internal/cord_rep_btree_navigator_test.cc +++ b/absl/strings/internal/cord_rep_btree_navigator_test.cc
@@ -14,6 +14,7 @@ #include "absl/strings/internal/cord_rep_btree_navigator.h" +#include <cstddef> #include <string> #include <vector>
diff --git a/absl/strings/internal/cord_rep_btree_reader.cc b/absl/strings/internal/cord_rep_btree_reader.cc index 0d0e860..660f240 100644 --- a/absl/strings/internal/cord_rep_btree_reader.cc +++ b/absl/strings/internal/cord_rep_btree_reader.cc
@@ -15,6 +15,7 @@ #include "absl/strings/internal/cord_rep_btree_reader.h" #include <cassert> +#include <cstddef> #include "absl/base/config.h" #include "absl/strings/internal/cord_data_edge.h" @@ -22,6 +23,7 @@ #include "absl/strings/internal/cord_rep_btree.h" #include "absl/strings/internal/cord_rep_btree_navigator.h" #include "absl/strings/internal/cord_rep_flat.h" +#include "absl/strings/string_view.h" namespace absl { ABSL_NAMESPACE_BEGIN
diff --git a/absl/strings/internal/cord_rep_btree_reader.h b/absl/strings/internal/cord_rep_btree_reader.h index 8db8f8d..46ed352 100644 --- a/absl/strings/internal/cord_rep_btree_reader.h +++ b/absl/strings/internal/cord_rep_btree_reader.h
@@ -16,13 +16,16 @@ #define ABSL_STRINGS_INTERNAL_CORD_REP_BTREE_READER_H_ #include <cassert> +#include <cstddef> #include "absl/base/config.h" +#include "absl/base/optimization.h" #include "absl/strings/internal/cord_data_edge.h" #include "absl/strings/internal/cord_internal.h" #include "absl/strings/internal/cord_rep_btree.h" #include "absl/strings/internal/cord_rep_btree_navigator.h" #include "absl/strings/internal/cord_rep_flat.h" +#include "absl/strings/string_view.h" namespace absl { ABSL_NAMESPACE_BEGIN
diff --git a/absl/strings/internal/cord_rep_btree_reader_test.cc b/absl/strings/internal/cord_rep_btree_reader_test.cc index b4cdd8e..684da35 100644 --- a/absl/strings/internal/cord_rep_btree_reader_test.cc +++ b/absl/strings/internal/cord_rep_btree_reader_test.cc
@@ -14,6 +14,8 @@ #include "absl/strings/internal/cord_rep_btree_reader.h" +#include <algorithm> +#include <cstddef> #include <iostream> #include <random> #include <string>
diff --git a/absl/strings/internal/cord_rep_btree_test.cc b/absl/strings/internal/cord_rep_btree_test.cc index 0950617..6b8e628 100644 --- a/absl/strings/internal/cord_rep_btree_test.cc +++ b/absl/strings/internal/cord_rep_btree_test.cc
@@ -14,9 +14,14 @@ #include "absl/strings/internal/cord_rep_btree.h" +#include <cassert> #include <cmath> +#include <cstddef> +#include <cstdint> #include <deque> #include <iostream> +#include <random> +#include <sstream> #include <string> #include <vector> @@ -27,9 +32,11 @@ #include "absl/cleanup/cleanup.h" #include "absl/strings/internal/cord_data_edge.h" #include "absl/strings/internal/cord_internal.h" +#include "absl/strings/internal/cord_rep_flat.h" #include "absl/strings/internal/cord_rep_test_util.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" +#include "absl/types/span.h" namespace absl { ABSL_NAMESPACE_BEGIN
diff --git a/absl/strings/internal/cord_rep_consume.cc b/absl/strings/internal/cord_rep_consume.cc index db7d4fe..8b6af15 100644 --- a/absl/strings/internal/cord_rep_consume.cc +++ b/absl/strings/internal/cord_rep_consume.cc
@@ -15,6 +15,7 @@ #include "absl/strings/internal/cord_rep_consume.h" #include <array> +#include <cstddef> #include <utility> #include "absl/container/inlined_vector.h"
diff --git a/absl/strings/internal/cord_rep_consume.h b/absl/strings/internal/cord_rep_consume.h index bece187..cdb06ba 100644 --- a/absl/strings/internal/cord_rep_consume.h +++ b/absl/strings/internal/cord_rep_consume.h
@@ -15,6 +15,7 @@ #ifndef ABSL_STRINGS_INTERNAL_CORD_REP_CONSUME_H_ #define ABSL_STRINGS_INTERNAL_CORD_REP_CONSUME_H_ +#include <cstddef> #include <functional> #include "absl/functional/function_ref.h"
diff --git a/absl/strings/internal/cord_rep_crc.cc b/absl/strings/internal/cord_rep_crc.cc index dbe54cc..50e1cb9 100644 --- a/absl/strings/internal/cord_rep_crc.cc +++ b/absl/strings/internal/cord_rep_crc.cc
@@ -19,6 +19,7 @@ #include <utility> #include "absl/base/config.h" +#include "absl/crc/internal/crc_cord_state.h" #include "absl/strings/internal/cord_internal.h" namespace absl {
diff --git a/absl/strings/internal/cord_rep_crc_test.cc b/absl/strings/internal/cord_rep_crc_test.cc index 3d27c33..feeaac6 100644 --- a/absl/strings/internal/cord_rep_crc_test.cc +++ b/absl/strings/internal/cord_rep_crc_test.cc
@@ -14,9 +14,12 @@ #include "absl/strings/internal/cord_rep_crc.h" +#include <cstdint> + #include "gmock/gmock.h" #include "gtest/gtest.h" #include "absl/base/config.h" +#include "absl/crc/crc32c.h" #include "absl/crc/internal/crc_cord_state.h" #include "absl/strings/internal/cord_internal.h" #include "absl/strings/internal/cord_rep_test_util.h"
diff --git a/absl/strings/internal/cord_rep_flat.h b/absl/strings/internal/cord_rep_flat.h index 3cdeca6..34da171 100644 --- a/absl/strings/internal/cord_rep_flat.h +++ b/absl/strings/internal/cord_rep_flat.h
@@ -15,9 +15,11 @@ #ifndef ABSL_STRINGS_INTERNAL_CORD_REP_FLAT_H_ #define ABSL_STRINGS_INTERNAL_CORD_REP_FLAT_H_ +#include <algorithm> #include <cassert> #include <cstddef> #include <cstdint> +#include <cstring> #include <memory> #include "absl/base/config.h"
diff --git a/absl/strings/internal/cord_rep_test_util.h b/absl/strings/internal/cord_rep_test_util.h index 18a0a19..9a6744c 100644 --- a/absl/strings/internal/cord_rep_test_util.h +++ b/absl/strings/internal/cord_rep_test_util.h
@@ -16,6 +16,8 @@ #define ABSL_STRINGS_INTERNAL_CORD_REP_TEST_UTIL_H_ #include <cassert> +#include <cstddef> +#include <cstring> #include <memory> #include <random> #include <string> @@ -27,6 +29,7 @@ #include "absl/strings/internal/cord_rep_btree.h" #include "absl/strings/internal/cord_rep_flat.h" #include "absl/strings/string_view.h" +#include "absl/types/span.h" namespace absl { ABSL_NAMESPACE_BEGIN
diff --git a/absl/strings/internal/cordz_functions.cc b/absl/strings/internal/cordz_functions.cc index 6033d04..5094817 100644 --- a/absl/strings/internal/cordz_functions.cc +++ b/absl/strings/internal/cordz_functions.cc
@@ -16,6 +16,7 @@ #include <atomic> #include <cmath> +#include <cstdint> #include <limits> #include <random>
diff --git a/absl/strings/internal/cordz_functions_test.cc b/absl/strings/internal/cordz_functions_test.cc index 8fb93d5..3949bf3 100644 --- a/absl/strings/internal/cordz_functions_test.cc +++ b/absl/strings/internal/cordz_functions_test.cc
@@ -14,6 +14,7 @@ #include "absl/strings/internal/cordz_functions.h" +#include <cstdint> #include <thread> // NOLINT we need real clean new threads #include "gmock/gmock.h"
diff --git a/absl/strings/internal/cordz_handle.cc b/absl/strings/internal/cordz_handle.cc index a4f47f0..4fa8183 100644 --- a/absl/strings/internal/cordz_handle.cc +++ b/absl/strings/internal/cordz_handle.cc
@@ -14,9 +14,13 @@ #include "absl/strings/internal/cordz_handle.h" #include <atomic> +#include <cassert> +#include <vector> #include "absl/base/internal/raw_logging.h" // For ABSL_RAW_CHECK +#include "absl/base/macros.h" #include "absl/base/no_destructor.h" +#include "absl/base/thread_annotations.h" #include "absl/synchronization/mutex.h" namespace absl {
diff --git a/absl/strings/internal/cordz_handle_test.cc b/absl/strings/internal/cordz_handle_test.cc index fd68e06..f2deea2 100644 --- a/absl/strings/internal/cordz_handle_test.cc +++ b/absl/strings/internal/cordz_handle_test.cc
@@ -13,7 +13,9 @@ // limitations under the License. #include "absl/strings/internal/cordz_handle.h" +#include <atomic> #include <random> +#include <vector> #include "gmock/gmock.h" #include "gtest/gtest.h"
diff --git a/absl/strings/internal/cordz_info.cc b/absl/strings/internal/cordz_info.cc index 38fb473..321d15d 100644 --- a/absl/strings/internal/cordz_info.cc +++ b/absl/strings/internal/cordz_info.cc
@@ -14,11 +14,18 @@ #include "absl/strings/internal/cordz_info.h" +#include <atomic> +#include <cassert> +#include <cstddef> #include <cstdint> +#include <cstring> #include "absl/base/config.h" #include "absl/base/const_init.h" +#include "absl/base/macros.h" #include "absl/base/no_destructor.h" +#include "absl/base/optimization.h" +#include "absl/base/thread_annotations.h" #include "absl/container/inlined_vector.h" #include "absl/debugging/stacktrace.h" #include "absl/strings/internal/cord_internal.h"
diff --git a/absl/strings/internal/cordz_info.h b/absl/strings/internal/cordz_info.h index ccbe414..04609cd 100644 --- a/absl/strings/internal/cordz_info.h +++ b/absl/strings/internal/cordz_info.h
@@ -16,12 +16,15 @@ #define ABSL_STRINGS_INTERNAL_CORDZ_INFO_H_ #include <atomic> +#include <cstddef> #include <cstdint> #include <functional> +#include "absl/base/attributes.h" #include "absl/base/config.h" #include "absl/base/const_init.h" #include "absl/base/internal/raw_logging.h" +#include "absl/base/optimization.h" #include "absl/base/thread_annotations.h" #include "absl/strings/internal/cord_internal.h" #include "absl/strings/internal/cordz_functions.h" @@ -29,6 +32,7 @@ #include "absl/strings/internal/cordz_statistics.h" #include "absl/strings/internal/cordz_update_tracker.h" #include "absl/synchronization/mutex.h" +#include "absl/time/time.h" #include "absl/types/span.h" namespace absl {
diff --git a/absl/strings/internal/cordz_info_statistics_test.cc b/absl/strings/internal/cordz_info_statistics_test.cc index 3e6a8a0..859bb20 100644 --- a/absl/strings/internal/cordz_info_statistics_test.cc +++ b/absl/strings/internal/cordz_info_statistics_test.cc
@@ -12,6 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include <cassert> +#include <cstddef> +#include <cstdint> #include <iostream> #include <random> #include <vector> @@ -30,8 +33,11 @@ #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/string_view.h" #include "absl/synchronization/internal/thread_pool.h" #include "absl/synchronization/notification.h" +#include "absl/time/clock.h" +#include "absl/time/time.h" namespace absl { ABSL_NAMESPACE_BEGIN
diff --git a/absl/strings/internal/cordz_info_test.cc b/absl/strings/internal/cordz_info_test.cc index 81ecce2..10de80b 100644 --- a/absl/strings/internal/cordz_info_test.cc +++ b/absl/strings/internal/cordz_info_test.cc
@@ -14,6 +14,9 @@ #include "absl/strings/internal/cordz_info.h" +#include <cstddef> +#include <memory> +#include <string> #include <vector> #include "gmock/gmock.h" @@ -22,6 +25,7 @@ #include "absl/debugging/stacktrace.h" #include "absl/debugging/symbolize.h" #include "absl/strings/cordz_test_helpers.h" +#include "absl/strings/internal/cord_internal.h" #include "absl/strings/internal/cord_rep_flat.h" #include "absl/strings/internal/cordz_handle.h" #include "absl/strings/internal/cordz_statistics.h"
diff --git a/absl/strings/internal/cordz_sample_token.h b/absl/strings/internal/cordz_sample_token.h index 2a86bc3..aaf260e 100644 --- a/absl/strings/internal/cordz_sample_token.h +++ b/absl/strings/internal/cordz_sample_token.h
@@ -12,6 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include <cstddef> +#include <iterator> + #include "absl/base/config.h" #include "absl/strings/internal/cordz_handle.h" #include "absl/strings/internal/cordz_info.h"
diff --git a/absl/strings/internal/cordz_sample_token_test.cc b/absl/strings/internal/cordz_sample_token_test.cc index ccb28d0..8386b2c 100644 --- a/absl/strings/internal/cordz_sample_token_test.cc +++ b/absl/strings/internal/cordz_sample_token_test.cc
@@ -14,6 +14,8 @@ #include "absl/strings/internal/cordz_sample_token.h" +#include <cstddef> +#include <iterator> #include <memory> #include <type_traits> #include <vector> @@ -26,6 +28,7 @@ #include "absl/strings/internal/cord_rep_flat.h" #include "absl/strings/internal/cordz_handle.h" #include "absl/strings/internal/cordz_info.h" +#include "absl/strings/internal/cordz_update_tracker.h" #include "absl/synchronization/internal/thread_pool.h" #include "absl/synchronization/notification.h" #include "absl/time/clock.h"
diff --git a/absl/strings/internal/cordz_statistics.h b/absl/strings/internal/cordz_statistics.h index 9f558df..c024d11 100644 --- a/absl/strings/internal/cordz_statistics.h +++ b/absl/strings/internal/cordz_statistics.h
@@ -15,6 +15,7 @@ #ifndef ABSL_STRINGS_INTERNAL_CORDZ_STATISTICS_H_ #define ABSL_STRINGS_INTERNAL_CORDZ_STATISTICS_H_ +#include <cstddef> #include <cstdint> #include "absl/base/config.h"
diff --git a/absl/strings/internal/cordz_update_tracker_test.cc b/absl/strings/internal/cordz_update_tracker_test.cc index 9b1f798..fb89a37 100644 --- a/absl/strings/internal/cordz_update_tracker_test.cc +++ b/absl/strings/internal/cordz_update_tracker_test.cc
@@ -15,6 +15,7 @@ #include "absl/strings/internal/cordz_update_tracker.h" #include <array> +#include <cstdint> #include <thread> // NOLINT #include "gmock/gmock.h"
diff --git a/absl/strings/internal/damerau_levenshtein_distance_benchmark.cc b/absl/strings/internal/damerau_levenshtein_distance_benchmark.cc index 76d6db4..e10c055 100644 --- a/absl/strings/internal/damerau_levenshtein_distance_benchmark.cc +++ b/absl/strings/internal/damerau_levenshtein_distance_benchmark.cc
@@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include <cstddef> #include <string> #include "absl/strings/internal/damerau_levenshtein_distance.h"
diff --git a/absl/strings/internal/damerau_levenshtein_distance_test.cc b/absl/strings/internal/damerau_levenshtein_distance_test.cc index 49dd105..4d6674d 100644 --- a/absl/strings/internal/damerau_levenshtein_distance_test.cc +++ b/absl/strings/internal/damerau_levenshtein_distance_test.cc
@@ -15,6 +15,7 @@ #include "absl/strings/internal/damerau_levenshtein_distance.h" #include <cstdint> +#include <string> #include "gmock/gmock.h" #include "gtest/gtest.h"
diff --git a/absl/strings/internal/escaping.cc b/absl/strings/internal/escaping.cc index a70b5dc..3c206b4 100644 --- a/absl/strings/internal/escaping.cc +++ b/absl/strings/internal/escaping.cc
@@ -14,6 +14,7 @@ #include "absl/strings/internal/escaping.h" +#include <cstddef> #include <limits> #include "absl/base/internal/endian.h"
diff --git a/absl/strings/internal/generic_printer.cc b/absl/strings/internal/generic_printer.cc index 6535e1c..267213a 100644 --- a/absl/strings/internal/generic_printer.cc +++ b/absl/strings/internal/generic_printer.cc
@@ -16,6 +16,7 @@ #include <cstddef> #include <cstdlib> +#include <limits> #include <ostream> #include <string> @@ -24,6 +25,7 @@ #include "absl/strings/escaping.h" #include "absl/strings/numbers.h" #include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" namespace absl { ABSL_NAMESPACE_BEGIN
diff --git a/absl/strings/internal/generic_printer_test.cc b/absl/strings/internal/generic_printer_test.cc index be6e003..e7ecc09 100644 --- a/absl/strings/internal/generic_printer_test.cc +++ b/absl/strings/internal/generic_printer_test.cc
@@ -17,6 +17,8 @@ #include <array> #include <cinttypes> #include <clocale> +#include <cmath> +#include <cstddef> #include <cstdint> #include <limits> #include <map> @@ -25,6 +27,7 @@ #include <ostream> #include <sstream> #include <string> +#include <tuple> #include <type_traits> #include <utility> #include <variant> @@ -40,6 +43,7 @@ #include "absl/status/statusor.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" #include "absl/strings/substitute.h" namespace generic_logging_test {
diff --git a/absl/strings/internal/memutil_benchmark.cc b/absl/strings/internal/memutil_benchmark.cc index 1186752..fb4f21f 100644 --- a/absl/strings/internal/memutil_benchmark.cc +++ b/absl/strings/internal/memutil_benchmark.cc
@@ -13,6 +13,7 @@ // limitations under the License. #include <algorithm> +#include <cstdint> #include <cstdlib> #include "absl/strings/ascii.h"
diff --git a/absl/strings/internal/pow10_helper_test.cc b/absl/strings/internal/pow10_helper_test.cc index a4ff76d..4e1f34b 100644 --- a/absl/strings/internal/pow10_helper_test.cc +++ b/absl/strings/internal/pow10_helper_test.cc
@@ -15,6 +15,7 @@ #include "absl/strings/internal/pow10_helper.h" #include <cmath> +#include <cstdint> #include "gtest/gtest.h" #include "absl/strings/str_format.h"
diff --git a/absl/strings/internal/resize_uninitialized.h b/absl/strings/internal/resize_uninitialized.h index ff2009b..a2fcab1 100644 --- a/absl/strings/internal/resize_uninitialized.h +++ b/absl/strings/internal/resize_uninitialized.h
@@ -18,6 +18,7 @@ #define ABSL_STRINGS_INTERNAL_RESIZE_UNINITIALIZED_H_ #include <algorithm> +#include <cstddef> #include <string> #include <type_traits> #include <utility>
diff --git a/absl/strings/internal/resize_uninitialized_test.cc b/absl/strings/internal/resize_uninitialized_test.cc index dd5547c..d7d22ca 100644 --- a/absl/strings/internal/resize_uninitialized_test.cc +++ b/absl/strings/internal/resize_uninitialized_test.cc
@@ -16,6 +16,7 @@ #include <cstddef> #include <limits> +#include <string> #include "gtest/gtest.h"
diff --git a/absl/strings/internal/str_format/bind.h b/absl/strings/internal/str_format/bind.h index 075a9d5..1c87e1e 100644 --- a/absl/strings/internal/str_format/bind.h +++ b/absl/strings/internal/str_format/bind.h
@@ -19,6 +19,7 @@ #include <cstdio> #include <ostream> #include <string> +#include <utility> #include "absl/base/config.h" #include "absl/container/inlined_vector.h"
diff --git a/absl/strings/internal/str_format/bind_test.cc b/absl/strings/internal/str_format/bind_test.cc index 1eef9c4..c4fb200 100644 --- a/absl/strings/internal/str_format/bind_test.cc +++ b/absl/strings/internal/str_format/bind_test.cc
@@ -15,9 +15,14 @@ #include "absl/strings/internal/str_format/bind.h" #include <string.h> + #include <limits> #include "gtest/gtest.h" +#include "absl/strings/internal/str_format/arg.h" +#include "absl/strings/internal/str_format/constexpr_parser.h" +#include "absl/strings/string_view.h" +#include "absl/types/span.h" namespace absl { ABSL_NAMESPACE_BEGIN
diff --git a/absl/strings/internal/str_format/checker.h b/absl/strings/internal/str_format/checker.h index ee3df26..14e9a23 100644 --- a/absl/strings/internal/str_format/checker.h +++ b/absl/strings/internal/str_format/checker.h
@@ -16,11 +16,14 @@ #define ABSL_STRINGS_INTERNAL_STR_FORMAT_CHECKER_H_ #include <algorithm> +#include <cstddef> #include "absl/base/attributes.h" +#include "absl/base/const_init.h" #include "absl/strings/internal/str_format/arg.h" #include "absl/strings/internal/str_format/constexpr_parser.h" #include "absl/strings/internal/str_format/extension.h" +#include "absl/strings/string_view.h" // Compile time check support for entry points.
diff --git a/absl/strings/internal/str_format/checker_test.cc b/absl/strings/internal/str_format/checker_test.cc index a86bed3..21f1a7f 100644 --- a/absl/strings/internal/str_format/checker_test.cc +++ b/absl/strings/internal/str_format/checker_test.cc
@@ -17,6 +17,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" #include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" namespace absl { ABSL_NAMESPACE_BEGIN
diff --git a/absl/strings/internal/str_format/convert_test.cc b/absl/strings/internal/str_format/convert_test.cc index 5e86016..46b8588 100644 --- a/absl/strings/internal/str_format/convert_test.cc +++ b/absl/strings/internal/str_format/convert_test.cc
@@ -20,6 +20,7 @@ #include <algorithm> #include <climits> #include <cmath> +#include <cstdint> #include <cstdlib> #include <cstring> #include <cwctype> @@ -37,6 +38,7 @@ #include "gtest/gtest.h" #include "absl/base/attributes.h" #include "absl/base/internal/raw_logging.h" +#include "absl/log/absl_check.h" #include "absl/log/log.h" #include "absl/numeric/int128.h" #include "absl/strings/ascii.h" @@ -315,14 +317,17 @@ TEST_F(FormatConvertTest, BasicString) { TestStringConvert("hello"); // As char array. - TestStringConvert(L"hello"); TestStringConvert(static_cast<const char*>("hello")); - TestStringConvert(static_cast<const wchar_t*>(L"hello")); TestStringConvert(std::string("hello")); - TestStringConvert(std::wstring(L"hello")); TestStringConvert(string_view("hello")); TestStringConvert(std::string_view("hello")); + +#if GTEST_HAS_STD_WSTRING + TestStringConvert(L"hello"); + TestStringConvert(static_cast<const wchar_t*>(L"hello")); + TestStringConvert(std::wstring(L"hello")); TestStringConvert(std::wstring_view(L"hello")); +#endif // GTEST_HAS_STD_WSTRING } TEST_F(FormatConvertTest, NullString) { @@ -330,9 +335,11 @@ UntypedFormatSpecImpl format("%s"); EXPECT_EQ("", FormatPack(format, {FormatArgImpl(p)})); +#if GTEST_HAS_STD_WSTRING const wchar_t* wp = nullptr; UntypedFormatSpecImpl wformat("%ls"); EXPECT_EQ("", FormatPack(wformat, {FormatArgImpl(wp)})); +#endif // GTEST_HAS_STD_WSTRING } TEST_F(FormatConvertTest, StringPrecision) { @@ -342,19 +349,23 @@ UntypedFormatSpecImpl format("%.1s"); EXPECT_EQ("a", FormatPack(format, {FormatArgImpl(p)})); + // We cap at the NUL-terminator. + p = "ABC"; + UntypedFormatSpecImpl format2("%.10s"); + EXPECT_EQ("ABC", FormatPack(format2, {FormatArgImpl(p)})); + +#if GTEST_HAS_STD_WSTRING + // We cap at the precision. wchar_t wc = L'a'; const wchar_t* wp = &wc; UntypedFormatSpecImpl wformat("%.1ls"); EXPECT_EQ("a", FormatPack(wformat, {FormatArgImpl(wp)})); // We cap at the NUL-terminator. - p = "ABC"; - UntypedFormatSpecImpl format2("%.10s"); - EXPECT_EQ("ABC", FormatPack(format2, {FormatArgImpl(p)})); - wp = L"ABC"; UntypedFormatSpecImpl wformat2("%.10ls"); EXPECT_EQ("ABC", FormatPack(wformat2, {FormatArgImpl(wp)})); +#endif // GTEST_HAS_STD_WSTRING } TEST_F(FormatConvertTest, WideStringUnpairedSurrogate) { @@ -411,29 +422,38 @@ TEST_F(FormatConvertTest, Pointer) { static int x = 0; const int *xp = &x; + const int* inil = nullptr; + + using VoidF = void (*)(); + VoidF fp = [] {}; + VoidF fnil = nullptr; + char c = 'h'; char *mcp = &c; const char *cp = "hi"; const char *cnil = nullptr; + volatile char vc; + volatile char* vcp = &vc; + volatile char* vcnil = nullptr; + +#if GTEST_HAS_STD_WSTRING wchar_t wc = L'h'; wchar_t *mwcp = &wc; const wchar_t *wcp = L"hi"; const wchar_t *wcnil = nullptr; - const int *inil = nullptr; - using VoidF = void (*)(); - VoidF fp = [] {}, fnil = nullptr; - volatile char vc; - volatile char *vcp = &vc; - volatile char *vcnil = nullptr; volatile wchar_t vwc; volatile wchar_t *vwcp = &vwc; volatile wchar_t *vwcnil = nullptr; +#endif // GTEST_HAS_STD_WSTRING + const FormatArgImpl args_array[] = { - FormatArgImpl(xp), FormatArgImpl(cp), FormatArgImpl(wcp), - FormatArgImpl(inil), FormatArgImpl(cnil), FormatArgImpl(wcnil), - FormatArgImpl(mcp), FormatArgImpl(mwcp), FormatArgImpl(fp), - FormatArgImpl(fnil), FormatArgImpl(vcp), FormatArgImpl(vwcp), - FormatArgImpl(vcnil), FormatArgImpl(vwcnil), + FormatArgImpl(xp), FormatArgImpl(inil), FormatArgImpl(fp), + FormatArgImpl(fnil), FormatArgImpl(mcp), FormatArgImpl(cp), + FormatArgImpl(cnil), FormatArgImpl(vcp), FormatArgImpl(vcnil), +#if GTEST_HAS_STD_WSTRING + FormatArgImpl(mwcp), FormatArgImpl(wcp), FormatArgImpl(wcnil), + FormatArgImpl(vwcp), FormatArgImpl(vwcnil), +#endif // GTEST_HAS_STD_WSTRING }; auto args = absl::MakeConstSpan(args_array); @@ -462,47 +482,52 @@ // const int* EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%1$p"), args), MatchesPointerString(xp)); - // const char* - EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%2$p"), args), - MatchesPointerString(cp)); - // const wchar_t* - EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%3$p"), args), - MatchesPointerString(wcp)); // null const int* + EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%2$p"), args), + MatchesPointerString(nullptr)); + + // function pointer + EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%3$p"), args), + MatchesPointerString(reinterpret_cast<const void*>(fp))); + // null function pointer EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%4$p"), args), MatchesPointerString(nullptr)); - // null const char* - EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%5$p"), args), - MatchesPointerString(nullptr)); - // null const wchar_t* - EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%6$p"), args), - MatchesPointerString(nullptr)); + // nonconst char* - EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%7$p"), args), + EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%5$p"), args), MatchesPointerString(mcp)); - // nonconst wchar_t* - EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%8$p"), args), - MatchesPointerString(mwcp)); - // function pointer - EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%9$p"), args), - MatchesPointerString(reinterpret_cast<const void *>(fp))); - // null function pointer - EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%10$p"), args), + // const char* + EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%6$p"), args), + MatchesPointerString(cp)); + // null const char* + EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%7$p"), args), MatchesPointerString(nullptr)); // volatile char* EXPECT_THAT( - FormatPack(UntypedFormatSpecImpl("%11$p"), args), - MatchesPointerString(reinterpret_cast<volatile const void *>(vcp))); + FormatPack(UntypedFormatSpecImpl("%8$p"), args), + MatchesPointerString(reinterpret_cast<volatile const void*>(vcp))); + // null volatile char* + EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%9$p"), args), + MatchesPointerString(nullptr)); + +#if GTEST_HAS_STD_WSTRING + // nonconst wchar_t* + EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%10$p"), args), + MatchesPointerString(mwcp)); + // const wchar_t* + EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%11$p"), args), + MatchesPointerString(wcp)); + // null const wchar_t* + EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%12$p"), args), + MatchesPointerString(nullptr)); // volatile wchar_t* EXPECT_THAT( - FormatPack(UntypedFormatSpecImpl("%12$p"), args), + FormatPack(UntypedFormatSpecImpl("%13$p"), args), MatchesPointerString(reinterpret_cast<volatile const void *>(vwcp))); - // null volatile char* - EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%13$p"), args), - MatchesPointerString(nullptr)); // null volatile wchar_t* EXPECT_THAT(FormatPack(UntypedFormatSpecImpl("%14$p"), args), MatchesPointerString(nullptr)); +#endif // GTEST_HAS_STD_WSTRING } struct Cardinal { @@ -741,6 +766,7 @@ FormatArgImpl(cv[0]), FormatArgImpl(cv[1])}))); } +#if GTEST_HAS_STD_WSTRING TEST_F(FormatConvertTest, UnicodeWideString) { // StrFormat() should be able to convert wide strings containing Unicode // characters (to UTF-8). @@ -757,6 +783,7 @@ EXPECT_EQ(output, FormatPack(UntypedFormatSpecImpl("%ls"), absl::MakeSpan(args))); } +#endif // GTEST_HAS_STD_WSTRING TEST_F(FormatConvertTest, Int128) { absl::int128 positive = static_cast<absl::int128>(0x1234567890abcdef) * 1979;
diff --git a/absl/strings/internal/str_format/extension.cc b/absl/strings/internal/str_format/extension.cc index 2d441c2..5b16a86 100644 --- a/absl/strings/internal/str_format/extension.cc +++ b/absl/strings/internal/str_format/extension.cc
@@ -16,9 +16,13 @@ #include "absl/strings/internal/str_format/extension.h" #include <errno.h> + #include <algorithm> +#include <cstddef> #include <string> +#include "absl/strings/string_view.h" + namespace absl { ABSL_NAMESPACE_BEGIN namespace str_format_internal {
diff --git a/absl/strings/internal/str_format/output.cc b/absl/strings/internal/str_format/output.cc index 068091c..1e61d19 100644 --- a/absl/strings/internal/str_format/output.cc +++ b/absl/strings/internal/str_format/output.cc
@@ -15,8 +15,13 @@ #include "absl/strings/internal/str_format/output.h" #include <errno.h> + +#include <algorithm> +#include <cstdio> #include <cstring> +#include "absl/strings/string_view.h" + namespace absl { ABSL_NAMESPACE_BEGIN namespace str_format_internal {
diff --git a/absl/strings/internal/str_format/output_test.cc b/absl/strings/internal/str_format/output_test.cc index ce2e91a..83c9589 100644 --- a/absl/strings/internal/str_format/output_test.cc +++ b/absl/strings/internal/str_format/output_test.cc
@@ -14,6 +14,7 @@ #include "absl/strings/internal/str_format/output.h" +#include <algorithm> #include <sstream> #include <string>
diff --git a/absl/strings/internal/str_format/parser.cc b/absl/strings/internal/str_format/parser.cc index 5aaab69..475d221 100644 --- a/absl/strings/internal/str_format/parser.cc +++ b/absl/strings/internal/str_format/parser.cc
@@ -17,16 +17,21 @@ #include <assert.h> #include <string.h> #include <wchar.h> -#include <cctype> -#include <cstdint> #include <algorithm> +#include <cctype> +#include <cstdint> #include <initializer_list> #include <limits> #include <ostream> #include <string> #include <unordered_set> +#include "absl/base/attributes.h" +#include "absl/strings/internal/str_format/constexpr_parser.h" +#include "absl/strings/internal/str_format/extension.h" +#include "absl/strings/string_view.h" + namespace absl { ABSL_NAMESPACE_BEGIN namespace str_format_internal {
diff --git a/absl/strings/internal/str_split_internal.h b/absl/strings/internal/str_split_internal.h index 4e29790..b36eac1 100644 --- a/absl/strings/internal/str_split_internal.h +++ b/absl/strings/internal/str_split_internal.h
@@ -34,11 +34,13 @@ #include <cstddef> #include <initializer_list> #include <iterator> +#include <string> #include <tuple> #include <type_traits> #include <utility> #include <vector> +#include "absl/base/attributes.h" #include "absl/base/macros.h" #include "absl/base/port.h" #include "absl/meta/type_traits.h"
diff --git a/absl/strings/internal/string_constant_test.cc b/absl/strings/internal/string_constant_test.cc index 86914d6..9743c52 100644 --- a/absl/strings/internal/string_constant_test.cc +++ b/absl/strings/internal/string_constant_test.cc
@@ -18,6 +18,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" +#include "absl/strings/string_view.h" namespace {
diff --git a/absl/strings/internal/stringify_sink.cc b/absl/strings/internal/stringify_sink.cc index 7c6995a..4efe80f 100644 --- a/absl/strings/internal/stringify_sink.cc +++ b/absl/strings/internal/stringify_sink.cc
@@ -13,6 +13,10 @@ // limitations under the License. #include "absl/strings/internal/stringify_sink.h" + +#include <cstddef> + +#include "absl/strings/string_view.h" namespace absl { ABSL_NAMESPACE_BEGIN namespace strings_internal {
diff --git a/absl/strings/internal/stringify_sink.h b/absl/strings/internal/stringify_sink.h index 6478ea5..b2e75d9 100644 --- a/absl/strings/internal/stringify_sink.h +++ b/absl/strings/internal/stringify_sink.h
@@ -16,6 +16,7 @@ #define ABSL_STRINGS_INTERNAL_STRINGIFY_SINK_H_ #include <array> +#include <cstddef> #include <string> #include <type_traits> #include <utility>
diff --git a/absl/strings/numbers.h b/absl/strings/numbers.h index 7e9c6bb..87d146b 100644 --- a/absl/strings/numbers.h +++ b/absl/strings/numbers.h
@@ -23,14 +23,6 @@ #ifndef ABSL_STRINGS_NUMBERS_H_ #define ABSL_STRINGS_NUMBERS_H_ -#ifdef __SSSE3__ -#include <tmmintrin.h> -#endif - -#ifdef _MSC_VER -#include <intrin.h> -#endif - #include <cstddef> #include <cstdint> #include <cstdlib> @@ -50,6 +42,14 @@ #include "absl/numeric/int128.h" #include "absl/strings/string_view.h" +#ifdef __SSSE3__ +#include <tmmintrin.h> +#endif + +#ifdef _MSC_VER +#include <intrin.h> +#endif + namespace absl { ABSL_NAMESPACE_BEGIN
diff --git a/absl/strings/str_cat.h b/absl/strings/str_cat.h index d682cea..3ae1197 100644 --- a/absl/strings/str_cat.h +++ b/absl/strings/str_cat.h
@@ -109,6 +109,7 @@ #include "absl/base/attributes.h" #include "absl/base/config.h" +#include "absl/base/macros.h" #include "absl/base/nullability.h" #include "absl/base/port.h" #include "absl/meta/type_traits.h"
diff --git a/absl/strings/str_format_test.cc b/absl/strings/str_format_test.cc index a0db73f..cbe5ff9 100644 --- a/absl/strings/str_format_test.cc +++ b/absl/strings/str_format_test.cc
@@ -28,6 +28,7 @@ #include "absl/base/config.h" #include "absl/base/macros.h" #include "absl/strings/cord.h" +#include "absl/strings/internal/str_format/constexpr_parser.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "absl/types/span.h"
diff --git a/absl/strings/str_replace.h b/absl/strings/str_replace.h index 4106c24..ac1dcac 100644 --- a/absl/strings/str_replace.h +++ b/absl/strings/str_replace.h
@@ -38,6 +38,8 @@ #ifndef ABSL_STRINGS_STR_REPLACE_H_ #define ABSL_STRINGS_STR_REPLACE_H_ +#include <cstddef> +#include <initializer_list> #include <string> #include <utility> #include <vector>
diff --git a/absl/strings/str_split.h b/absl/strings/str_split.h index a0931a8..b72b446 100644 --- a/absl/strings/str_split.h +++ b/absl/strings/str_split.h
@@ -40,11 +40,13 @@ #include <map> #include <set> #include <string> +#include <type_traits> #include <utility> #include <vector> #include "absl/base/internal/raw_logging.h" #include "absl/base/macros.h" +#include "absl/strings/ascii.h" #include "absl/strings/internal/str_split_internal.h" #include "absl/strings/string_view.h" #include "absl/strings/strip.h"
diff --git a/absl/strings/strip_test.cc b/absl/strings/strip_test.cc index e4e00cb..b5cda6c 100644 --- a/absl/strings/strip_test.cc +++ b/absl/strings/strip_test.cc
@@ -20,9 +20,11 @@ #include <cassert> #include <cstdio> #include <cstring> +#include <string> #include "gmock/gmock.h" #include "gtest/gtest.h" +#include "absl/strings/ascii.h" #include "absl/strings/string_view.h" namespace {
diff --git a/absl/strings/substitute.h b/absl/strings/substitute.h index 7461c2f..accf26e 100644 --- a/absl/strings/substitute.h +++ b/absl/strings/substitute.h
@@ -83,6 +83,7 @@ #include "absl/base/port.h" #include "absl/strings/ascii.h" #include "absl/strings/escaping.h" +#include "absl/strings/has_absl_stringify.h" #include "absl/strings/internal/stringify_sink.h" #include "absl/strings/numbers.h" #include "absl/strings/str_cat.h"
diff --git a/absl/synchronization/internal/create_thread_identity.h b/absl/synchronization/internal/create_thread_identity.h index 4cfde09..f8bfbe9 100644 --- a/absl/synchronization/internal/create_thread_identity.h +++ b/absl/synchronization/internal/create_thread_identity.h
@@ -26,6 +26,7 @@ #define ABSL_SYNCHRONIZATION_INTERNAL_CREATE_THREAD_IDENTITY_H_ #include "absl/base/internal/thread_identity.h" +#include "absl/base/optimization.h" #include "absl/base/port.h" namespace absl {
diff --git a/absl/synchronization/internal/futex.h b/absl/synchronization/internal/futex.h index 573c01b..b4a0cf4 100644 --- a/absl/synchronization/internal/futex.h +++ b/absl/synchronization/internal/futex.h
@@ -14,7 +14,17 @@ #ifndef ABSL_SYNCHRONIZATION_INTERNAL_FUTEX_H_ #define ABSL_SYNCHRONIZATION_INTERNAL_FUTEX_H_ +#include <errno.h> +#include <stdio.h> +#include <time.h> + +#include <atomic> +#include <cstdint> +#include <limits> + #include "absl/base/config.h" +#include "absl/base/optimization.h" +#include "absl/synchronization/internal/kernel_timeout.h" #ifndef _WIN32 #include <sys/time.h> @@ -26,17 +36,6 @@ #include <sys/syscall.h> #endif -#include <errno.h> -#include <stdio.h> -#include <time.h> - -#include <atomic> -#include <cstdint> -#include <limits> - -#include "absl/base/optimization.h" -#include "absl/synchronization/internal/kernel_timeout.h" - #ifdef ABSL_INTERNAL_HAVE_FUTEX #error ABSL_INTERNAL_HAVE_FUTEX may not be set on the command line #elif defined(__BIONIC__)
diff --git a/absl/synchronization/internal/graphcycles_test.cc b/absl/synchronization/internal/graphcycles_test.cc index 9e44a58..d4ba0f6 100644 --- a/absl/synchronization/internal/graphcycles_test.cc +++ b/absl/synchronization/internal/graphcycles_test.cc
@@ -20,6 +20,7 @@ #include <iterator> #include <map> #include <random> +#include <string> #include <unordered_set> #include <utility> #include <vector>
diff --git a/absl/synchronization/internal/kernel_timeout.cc b/absl/synchronization/internal/kernel_timeout.cc index cce8bf7..e359cfc 100644 --- a/absl/synchronization/internal/kernel_timeout.cc +++ b/absl/synchronization/internal/kernel_timeout.cc
@@ -14,10 +14,6 @@ #include "absl/synchronization/internal/kernel_timeout.h" -#ifndef _WIN32 -#include <sys/types.h> -#endif - #include <algorithm> #include <chrono> // NOLINT(build/c++11) #include <cstdint> @@ -29,6 +25,10 @@ #include "absl/time/clock.h" #include "absl/time/time.h" +#ifndef _WIN32 +#include <sys/types.h> +#endif + namespace absl { ABSL_NAMESPACE_BEGIN namespace synchronization_internal {
diff --git a/absl/synchronization/internal/kernel_timeout.h b/absl/synchronization/internal/kernel_timeout.h index c24fa86..7fc4291 100644 --- a/absl/synchronization/internal/kernel_timeout.h +++ b/absl/synchronization/internal/kernel_timeout.h
@@ -15,10 +15,6 @@ #ifndef ABSL_SYNCHRONIZATION_INTERNAL_KERNEL_TIMEOUT_H_ #define ABSL_SYNCHRONIZATION_INTERNAL_KERNEL_TIMEOUT_H_ -#ifndef _WIN32 -#include <sys/types.h> -#endif - #include <algorithm> #include <chrono> // NOLINT(build/c++11) #include <cstdint> @@ -30,6 +26,10 @@ #include "absl/time/clock.h" #include "absl/time/time.h" +#ifndef _WIN32 +#include <sys/types.h> +#endif + namespace absl { ABSL_NAMESPACE_BEGIN namespace synchronization_internal {
diff --git a/absl/synchronization/internal/kernel_timeout_test.cc b/absl/synchronization/internal/kernel_timeout_test.cc index baa2e0f..dc5bfc9 100644 --- a/absl/synchronization/internal/kernel_timeout_test.cc +++ b/absl/synchronization/internal/kernel_timeout_test.cc
@@ -17,9 +17,11 @@ #include <algorithm> #include <chrono> // NOLINT(build/c++11) #include <cstdint> +#include <ctime> #include <limits> #include "gtest/gtest.h" +#include "absl/time/civil_time.h" #include "absl/time/clock.h" #include "absl/time/time.h" @@ -67,6 +69,20 @@ using absl::synchronization_internal::KernelTimeout; +// Returns a time far in the future. +// On 32-bit time_t systems, the maximum representable time is in January 2038. +// On 64-bit systems, the maximum representable time in KernelTimeout is in +// April 2262 (int64_t max nanoseconds). +absl::Time FarFuture() { + static const absl::Time far_future = + sizeof(time_t) <= 4 + ? absl::FromCivil(absl::CivilSecond(2038, 1, 1, 0, 0, 0), + absl::UTCTimeZone()) + : absl::FromCivil(absl::CivilSecond(2262, 1, 1, 0, 0, 0), + absl::UTCTimeZone()); + return far_future; +} + // TODO(b/348224897): re-enabled when the flakiness is fixed. TEST(KernelTimeout, DISABLED_FiniteTimes) { constexpr absl::Duration kDurationsToTest[] = { @@ -126,16 +142,14 @@ // below, but we do try to do something reasonable if they don't. We may not // be able to round-trip back to absl::InfiniteDuration() or // absl::InfiniteFuture(), but we should return a very large value. - EXPECT_GT(absl::TimeFromTimespec(t.MakeAbsTimespec()), - absl::Now() + absl::Hours(100000)); + EXPECT_GT(absl::TimeFromTimespec(t.MakeAbsTimespec()), FarFuture()); #ifndef _WIN32 EXPECT_GT(absl::TimeFromTimespec(t.MakeClockAbsoluteTimespec(CLOCK_REALTIME)), - absl::Now() + absl::Hours(100000)); + FarFuture()); #endif EXPECT_GT(absl::DurationFromTimespec(t.MakeRelativeTimespec()), absl::Hours(100000)); - EXPECT_GT(absl::FromUnixNanos(t.MakeAbsNanos()), - absl::Now() + absl::Hours(100000)); + EXPECT_GT(absl::FromUnixNanos(t.MakeAbsNanos()), FarFuture()); EXPECT_EQ(t.InMillisecondsFromNow(), std::numeric_limits<KernelTimeout::DWord>::max()); EXPECT_EQ(t.ToChronoTimePoint(), @@ -151,16 +165,14 @@ // below, but we do try to do something reasonable if they don't. We may not // be able to round-trip back to absl::InfiniteDuration() or // absl::InfiniteFuture(), but we should return a very large value. - EXPECT_GT(absl::TimeFromTimespec(t.MakeAbsTimespec()), - absl::Now() + absl::Hours(100000)); + EXPECT_GT(absl::TimeFromTimespec(t.MakeAbsTimespec()), FarFuture()); #ifndef _WIN32 EXPECT_GT(absl::TimeFromTimespec(t.MakeClockAbsoluteTimespec(CLOCK_REALTIME)), - absl::Now() + absl::Hours(100000)); + FarFuture()); #endif EXPECT_GT(absl::DurationFromTimespec(t.MakeRelativeTimespec()), absl::Hours(100000)); - EXPECT_GT(absl::FromUnixNanos(t.MakeAbsNanos()), - absl::Now() + absl::Hours(100000)); + EXPECT_GT(absl::FromUnixNanos(t.MakeAbsNanos()), FarFuture()); EXPECT_EQ(t.InMillisecondsFromNow(), std::numeric_limits<KernelTimeout::DWord>::max()); EXPECT_EQ(t.ToChronoTimePoint(), @@ -176,16 +188,14 @@ // below, but we do try to do something reasonable if they don't. We may not // be able to round-trip back to absl::InfiniteDuration() or // absl::InfiniteFuture(), but we should return a very large value. - EXPECT_GT(absl::TimeFromTimespec(t.MakeAbsTimespec()), - absl::Now() + absl::Hours(100000)); + EXPECT_GT(absl::TimeFromTimespec(t.MakeAbsTimespec()), FarFuture()); #ifndef _WIN32 EXPECT_GT(absl::TimeFromTimespec(t.MakeClockAbsoluteTimespec(CLOCK_REALTIME)), - absl::Now() + absl::Hours(100000)); + FarFuture()); #endif EXPECT_GT(absl::DurationFromTimespec(t.MakeRelativeTimespec()), absl::Hours(100000)); - EXPECT_GT(absl::FromUnixNanos(t.MakeAbsNanos()), - absl::Now() + absl::Hours(100000)); + EXPECT_GT(absl::FromUnixNanos(t.MakeAbsNanos()), FarFuture()); EXPECT_EQ(t.InMillisecondsFromNow(), std::numeric_limits<KernelTimeout::DWord>::max()); EXPECT_EQ(t.ToChronoTimePoint(), @@ -201,16 +211,14 @@ // below, but we do try to do something reasonable if they don't. We may not // be able to round-trip back to absl::InfiniteDuration() or // absl::InfiniteFuture(), but we should return a very large value. - EXPECT_GT(absl::TimeFromTimespec(t.MakeAbsTimespec()), - absl::Now() + absl::Hours(100000)); + EXPECT_GT(absl::TimeFromTimespec(t.MakeAbsTimespec()), FarFuture()); #ifndef _WIN32 EXPECT_GT(absl::TimeFromTimespec(t.MakeClockAbsoluteTimespec(CLOCK_REALTIME)), - absl::Now() + absl::Hours(100000)); + FarFuture()); #endif EXPECT_GT(absl::DurationFromTimespec(t.MakeRelativeTimespec()), absl::Hours(100000)); - EXPECT_GT(absl::FromUnixNanos(t.MakeAbsNanos()), - absl::Now() + absl::Hours(100000)); + EXPECT_GT(absl::FromUnixNanos(t.MakeAbsNanos()), FarFuture()); EXPECT_EQ(t.InMillisecondsFromNow(), std::numeric_limits<KernelTimeout::DWord>::max()); EXPECT_EQ(t.ToChronoTimePoint(), @@ -335,16 +343,14 @@ // below, but we do try to do something reasonable if they don't. We may not // be able to round-trip back to absl::InfiniteDuration() or // absl::InfiniteFuture(), but we should return a very large value. - EXPECT_GT(absl::TimeFromTimespec(t.MakeAbsTimespec()), - absl::Now() + absl::Hours(100000)); + EXPECT_GT(absl::TimeFromTimespec(t.MakeAbsTimespec()), FarFuture()); #ifndef _WIN32 EXPECT_GT(absl::TimeFromTimespec(t.MakeClockAbsoluteTimespec(CLOCK_REALTIME)), - absl::Now() + absl::Hours(100000)); + FarFuture()); #endif EXPECT_GT(absl::DurationFromTimespec(t.MakeRelativeTimespec()), absl::Hours(100000)); - EXPECT_GT(absl::FromUnixNanos(t.MakeAbsNanos()), - absl::Now() + absl::Hours(100000)); + EXPECT_GT(absl::FromUnixNanos(t.MakeAbsNanos()), FarFuture()); EXPECT_EQ(t.InMillisecondsFromNow(), std::numeric_limits<KernelTimeout::DWord>::max()); EXPECT_EQ(t.ToChronoTimePoint(), @@ -360,16 +366,14 @@ // below, but we do try to do something reasonable if they don't. We may not // be able to round-trip back to absl::InfiniteDuration() or // absl::InfiniteFuture(), but we should return a very large value. - EXPECT_GT(absl::TimeFromTimespec(t.MakeAbsTimespec()), - absl::Now() + absl::Hours(100000)); + EXPECT_GT(absl::TimeFromTimespec(t.MakeAbsTimespec()), FarFuture()); #ifndef _WIN32 EXPECT_GT(absl::TimeFromTimespec(t.MakeClockAbsoluteTimespec(CLOCK_REALTIME)), - absl::Now() + absl::Hours(100000)); + FarFuture()); #endif EXPECT_GT(absl::DurationFromTimespec(t.MakeRelativeTimespec()), absl::Hours(100000)); - EXPECT_GT(absl::FromUnixNanos(t.MakeAbsNanos()), - absl::Now() + absl::Hours(100000)); + EXPECT_GT(absl::FromUnixNanos(t.MakeAbsNanos()), FarFuture()); EXPECT_EQ(t.InMillisecondsFromNow(), std::numeric_limits<KernelTimeout::DWord>::max()); EXPECT_EQ(t.ToChronoTimePoint(), @@ -385,16 +389,14 @@ absl::Duration duration = absl::Nanoseconds(limit) + absl::Seconds(1); KernelTimeout t(duration); // Timeouts should still be far in the future. - EXPECT_GT(absl::TimeFromTimespec(t.MakeAbsTimespec()), - absl::Now() + absl::Hours(100000)); + EXPECT_GT(absl::TimeFromTimespec(t.MakeAbsTimespec()), FarFuture()); #ifndef _WIN32 EXPECT_GT(absl::TimeFromTimespec(t.MakeClockAbsoluteTimespec(CLOCK_REALTIME)), - absl::Now() + absl::Hours(100000)); + FarFuture()); #endif EXPECT_GT(absl::DurationFromTimespec(t.MakeRelativeTimespec()), absl::Hours(100000)); - EXPECT_GT(absl::FromUnixNanos(t.MakeAbsNanos()), - absl::Now() + absl::Hours(100000)); + EXPECT_GT(absl::FromUnixNanos(t.MakeAbsNanos()), FarFuture()); EXPECT_LE(absl::Milliseconds(t.InMillisecondsFromNow()) - duration, absl::Milliseconds(5)); EXPECT_GT(t.ToChronoTimePoint(),
diff --git a/absl/synchronization/mutex.cc b/absl/synchronization/mutex.cc index cb982f6..6878256 100644 --- a/absl/synchronization/mutex.cc +++ b/absl/synchronization/mutex.cc
@@ -14,19 +14,6 @@ #include "absl/synchronization/mutex.h" - -#ifdef _WIN32 -#include <windows.h> -#ifdef ERROR -#undef ERROR -#endif -#else -#include <fcntl.h> -#include <pthread.h> -#include <sched.h> -#include <sys/time.h> -#endif - #include <assert.h> #include <stdio.h> #include <stdlib.h> @@ -39,6 +26,7 @@ #include <cstdint> #include <cstdlib> #include <cstring> +#include <iterator> #include <thread> // NOLINT(build/c++11) #include "absl/base/attributes.h" @@ -68,6 +56,18 @@ #include "absl/time/clock.h" #include "absl/time/time.h" +#ifdef _WIN32 +#include <windows.h> +#ifdef ERROR +#undef ERROR +#endif +#else +#include <fcntl.h> +#include <pthread.h> +#include <sched.h> +#include <sys/time.h> +#endif + using absl::base_internal::CurrentThreadIdentityIfPresent; using absl::base_internal::CycleClock; using absl::base_internal::PerThreadSynch; @@ -442,10 +442,10 @@ // or it explicitly says to log if (e == nullptr || e->log) { void* pcs[40]; - int n = absl::GetStackTrace(pcs, ABSL_ARRAYSIZE(pcs), 1); + int n = absl::GetStackTrace(pcs, std::size(pcs), 1); // A buffer with enough space for the ASCII for all the PCs, even on a // 64-bit machine. - char buffer[ABSL_ARRAYSIZE(pcs) * 24]; + char buffer[std::size(pcs) * 24]; int pos = snprintf(buffer, sizeof(buffer), " @"); for (int i = 0; i != n; i++) { int b = snprintf(&buffer[pos], sizeof(buffer) - static_cast<size_t>(pos), @@ -1247,7 +1247,7 @@ i++; } if (i == n) { - if (n == ABSL_ARRAYSIZE(held_locks->locks)) { + if (n == static_cast<int>(std::size(held_locks->locks))) { held_locks->overflow = true; // lost some data } else { // we have room for lock held_locks->locks[i].mu = mu; @@ -1353,7 +1353,7 @@ static char* CurrentStackString(char* buf, int maxlen, bool symbolize) { void* pcs[40]; - return StackString(pcs, absl::GetStackTrace(pcs, ABSL_ARRAYSIZE(pcs), 2), buf, + return StackString(pcs, absl::GetStackTrace(pcs, std::size(pcs), 2), buf, maxlen, symbolize); } @@ -1444,9 +1444,10 @@ "historical lock ordering graph has been observed", static_cast<void*>(mu), b->buf); ABSL_RAW_LOG(ERROR, "Cycle: "); - int path_len = deadlock_graph->FindPath(mu_id, other_node_id, - ABSL_ARRAYSIZE(b->path), b->path); - for (int j = 0; j != path_len && j != ABSL_ARRAYSIZE(b->path); j++) { + int path_len = deadlock_graph->FindPath( + mu_id, other_node_id, static_cast<int>(std::size(b->path)), b->path); + for (int j = 0; + j != path_len && j != static_cast<int>(std::size(b->path)); j++) { GraphId id = b->path[j]; Mutex* path_mu = static_cast<Mutex*>(deadlock_graph->Ptr(id)); if (path_mu == nullptr) continue; @@ -1459,7 +1460,7 @@ symbolize); ABSL_RAW_LOG(ERROR, "%s", b->buf); } - if (path_len > static_cast<int>(ABSL_ARRAYSIZE(b->path))) { + if (path_len > static_cast<int>(std::size(b->path))) { ABSL_RAW_LOG(ERROR, "(long cycle; list truncated)"); } if (synch_deadlock_detection.load(std::memory_order_acquire) ==
diff --git a/absl/synchronization/mutex_test.cc b/absl/synchronization/mutex_test.cc index 42e5eb9..a96bcff 100644 --- a/absl/synchronization/mutex_test.cc +++ b/absl/synchronization/mutex_test.cc
@@ -14,10 +14,6 @@ #include "absl/synchronization/mutex.h" -#ifdef _WIN32 -#include <windows.h> -#endif - #include <algorithm> #include <atomic> #include <cstdlib> @@ -43,6 +39,10 @@ #include "absl/time/clock.h" #include "absl/time/time.h" +#ifdef _WIN32 +#include <windows.h> +#endif + #ifdef ABSL_HAVE_PTHREAD_GETSCHEDPARAM #include <pthread.h> #include <string.h>
diff --git a/absl/time/clock.cc b/absl/time/clock.cc index 2a5f41b..b87611a 100644 --- a/absl/time/clock.cc +++ b/absl/time/clock.cc
@@ -14,13 +14,6 @@ #include "absl/time/clock.h" -#include "absl/base/attributes.h" -#include "absl/base/optimization.h" - -#ifdef _WIN32 -#include <windows.h> -#endif - #include <algorithm> #include <atomic> #include <cerrno> @@ -28,12 +21,18 @@ #include <ctime> #include <limits> +#include "absl/base/attributes.h" #include "absl/base/internal/spinlock.h" #include "absl/base/internal/unscaledcycleclock.h" #include "absl/base/macros.h" +#include "absl/base/optimization.h" #include "absl/base/port.h" #include "absl/base/thread_annotations.h" +#ifdef _WIN32 +#include <windows.h> +#endif + namespace absl { ABSL_NAMESPACE_BEGIN Time Now() {
diff --git a/absl/time/clock_benchmark.cc b/absl/time/clock_benchmark.cc index c5c795e..df14ce6 100644 --- a/absl/time/clock_benchmark.cc +++ b/absl/time/clock_benchmark.cc
@@ -13,15 +13,16 @@ #include "absl/time/clock.h" +#include <cstdio> + +#include "absl/base/internal/cycleclock.h" +#include "benchmark/benchmark.h" + #if !defined(_WIN32) #include <sys/time.h> #else #include <winsock2.h> #endif // _WIN32 -#include <cstdio> - -#include "absl/base/internal/cycleclock.h" -#include "benchmark/benchmark.h" namespace {
diff --git a/absl/time/clock_test.cc b/absl/time/clock_test.cc index fb1452a..9370a88 100644 --- a/absl/time/clock_test.cc +++ b/absl/time/clock_test.cc
@@ -14,7 +14,10 @@ #include "absl/time/clock.h" +#include "gtest/gtest.h" #include "absl/base/config.h" +#include "absl/time/time.h" + #if defined(ABSL_HAVE_ALARM) #include <signal.h> #include <unistd.h> @@ -26,9 +29,6 @@ #error all known Linux and Apple targets have alarm #endif -#include "gtest/gtest.h" -#include "absl/time/time.h" - namespace { TEST(Time, Now) {
diff --git a/absl/time/duration.cc b/absl/time/duration.cc index ec92206..487ccdd 100644 --- a/absl/time/duration.cc +++ b/absl/time/duration.cc
@@ -49,10 +49,6 @@ // // Arithmetic overflows/underflows to +/- infinity and saturates. -#if defined(_MSC_VER) -#include <winsock2.h> // for timeval -#endif - #include <algorithm> #include <cassert> #include <chrono> // NOLINT(build/c++11) @@ -73,6 +69,10 @@ #include "absl/strings/strip.h" #include "absl/time/time.h" +#if defined(_MSC_VER) +#include <winsock2.h> // for timeval +#endif + namespace absl { ABSL_NAMESPACE_BEGIN
diff --git a/absl/time/duration_test.cc b/absl/time/duration_test.cc index d265dbf..8fffa95 100644 --- a/absl/time/duration_test.cc +++ b/absl/time/duration_test.cc
@@ -12,10 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#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. @@ -44,6 +40,10 @@ #include "absl/strings/str_format.h" #include "absl/time/time.h" +#if defined(_MSC_VER) +#include <winsock2.h> // for timeval +#endif + namespace { constexpr int64_t kint64max = std::numeric_limits<int64_t>::max();
diff --git a/absl/time/internal/cctz/src/time_zone_info.cc b/absl/time/internal/cctz/src/time_zone_info.cc index 1f8f46a..9abbde7 100644 --- a/absl/time/internal/cctz/src/time_zone_info.cc +++ b/absl/time/internal/cctz/src/time_zone_info.cc
@@ -36,7 +36,9 @@ #if !defined(_MSC_VER) #include <fcntl.h> +#if !defined(__APPLE__) #include <sys/stat.h> +#endif #include <unistd.h> #endif @@ -415,8 +417,23 @@ #endif const int fd = open(path, O_RDONLY | O_NONBLOCK | O_CLOEXEC); if (fd >= 0) { - struct stat st; - if (fstat(fd, &st) == 0 && S_ISREG(st.st_mode)) { +#if defined(__APPLE__) + // On Apple platforms, avoid fstat() to prevent triggering Apple's Required + // Reason API (NSPrivacyAccessedAPICategoryFileTimestamp) scanner. + // Security implications of skipping this check on Apple platforms: + // - FIFO hangs are mitigated by O_NONBLOCK + // - Path traversal is handled by UnsafePath() + // - /usr/share/zoneinfo is a read-only system volume on iOS + // On general POSIX operating systems, the check remains as + // defense-in-depth. + auto is_regular = [](int) { return true; }; +#else + auto is_regular = [](int stat_fd) { + struct stat st; + return fstat(stat_fd, &st) == 0 && S_ISREG(st.st_mode); + }; +#endif + if (is_regular(fd)) { FILE* fp = fdopen(fd, "rb"); if (fp != nullptr) return FilePtr(fp, fclose); }
diff --git a/absl/time/internal/cctz/src/time_zone_posix.cc b/absl/time/internal/cctz/src/time_zone_posix.cc index c60f98b..62c5e87 100644 --- a/absl/time/internal/cctz/src/time_zone_posix.cc +++ b/absl/time/internal/cctz/src/time_zone_posix.cc
@@ -47,10 +47,11 @@ return p; } -// abbr = <.*?> | [^-+,\d]{3,} +// abbr = <.+?> | [^-+,\d]{3,} const char* ParseAbbr(const char* p, std::string* abbr) { const char* op = p; if (*p == '<') { // special zoneinfo <...> form + if (*++p == '>' || *p == '\0') return nullptr; // no "<>" while (*++p != '>') { if (*p == '\0') return nullptr; }
diff --git a/absl/time/internal/cctz/src/time_zone_posix_test.cc b/absl/time/internal/cctz/src/time_zone_posix_test.cc index 8e429f7..83b4b9d 100644 --- a/absl/time/internal/cctz/src/time_zone_posix_test.cc +++ b/absl/time/internal/cctz/src/time_zone_posix_test.cc
@@ -33,7 +33,7 @@ // them). So, ... // // spec = abbr offset [ abbr [ offset ] datetime datetime ] -// abbr = <.*?> | [^-+,\d]{3,} +// abbr = <.+?> | [^-+,\d]{3,} // offset = [+|-]hh[:mm[:ss]] // datetime = , ( Jn | n | Mm.w.d ) [ / offset ] @@ -141,7 +141,9 @@ EXPECT_FALSE(ParsePosixSpec("ET+", &zone)); EXPECT_FALSE(ParsePosixSpec("ET-", &zone)); EXPECT_FALSE(ParsePosixSpec("ET,", &zone)); + EXPECT_FALSE(ParsePosixSpec("<", &zone)); EXPECT_FALSE(ParsePosixSpec("<00", &zone)); + EXPECT_FALSE(ParsePosixSpec("<>0", &zone)); // STD offset errors. EXPECT_FALSE(ParsePosixSpec("<00>", &zone)); @@ -154,6 +156,7 @@ EXPECT_FALSE(ParsePosixSpec("EST5EDT+,M3.2.0,M11.1.0", &zone)); EXPECT_FALSE(ParsePosixSpec("EST5EDT-,M3.2.0,M11.1.0", &zone)); EXPECT_FALSE(ParsePosixSpec("<00>0<-01", &zone)); + EXPECT_FALSE(ParsePosixSpec("EST5<>,M3.2.0,M11.1.0", &zone)); // DST offset errors. EXPECT_FALSE(ParsePosixSpec("<01>1<00>?,0,0", &zone));
diff --git a/absl/time/time.cc b/absl/time/time.cc index faef864..4be13cf 100644 --- a/absl/time/time.cc +++ b/absl/time/time.cc
@@ -33,10 +33,6 @@ #include "absl/time/time.h" -#if defined(_MSC_VER) -#include <winsock2.h> // for timeval -#endif - #include <cstring> #include <ctime> #include <limits> @@ -44,6 +40,10 @@ #include "absl/time/internal/cctz/include/cctz/civil_time.h" #include "absl/time/internal/cctz/include/cctz/time_zone.h" +#if defined(_MSC_VER) +#include <winsock2.h> // for timeval +#endif + namespace cctz = absl::time_internal::cctz; namespace absl {
diff --git a/absl/time/time.h b/absl/time/time.h index fc1456b..ea9be32 100644 --- a/absl/time/time.h +++ b/absl/time/time.h
@@ -62,19 +62,6 @@ #ifndef ABSL_TIME_TIME_H_ #define ABSL_TIME_TIME_H_ -#if !defined(_MSC_VER) -#include <sys/time.h> -#else -// We don't include `winsock2.h` because it drags in `windows.h` and friends, -// and they define conflicting macros like OPAQUE, ERROR, and more. This has the -// potential to break Abseil users. -// -// Instead we only forward declare `timeval` and require Windows users include -// `winsock2.h` themselves. This is both inconsistent and troublesome, but so is -// 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. @@ -102,6 +89,19 @@ #include "absl/time/civil_time.h" #include "absl/time/internal/cctz/include/cctz/time_zone.h" +#if !defined(_MSC_VER) +#include <sys/time.h> +#else +// We don't include `winsock2.h` because it drags in `windows.h` and friends, +// and they define conflicting macros like OPAQUE, ERROR, and more. This has the +// potential to break Abseil users. +// +// Instead we only forward declare `timeval` and require Windows users include +// `winsock2.h` themselves. This is both inconsistent and troublesome, but so is +// including 'windows.h' so we are picking the lesser of two evils here. +struct timeval; +#endif + #if defined(__cpp_impl_three_way_comparison) && \ defined(__cpp_lib_three_way_comparison) #define ABSL_INTERNAL_TIME_HAS_THREE_WAY_COMPARISON 1
diff --git a/absl/time/time_benchmark.cc b/absl/time/time_benchmark.cc index 93a7c41..db8090a 100644 --- a/absl/time/time_benchmark.cc +++ b/absl/time/time_benchmark.cc
@@ -11,11 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "absl/time/time.h" - -#if !defined(_WIN32) -#include <sys/time.h> -#endif // _WIN32 #include <algorithm> #include <cmath> #include <cstddef> @@ -26,8 +21,13 @@ #include "absl/time/clock.h" #include "absl/time/internal/test_util.h" +#include "absl/time/time.h" #include "benchmark/benchmark.h" +#if !defined(_WIN32) +#include <sys/time.h> +#endif // _WIN32 + namespace { //
diff --git a/absl/time/time_test.cc b/absl/time/time_test.cc index 49f6dd6..d53198a 100644 --- a/absl/time/time_test.cc +++ b/absl/time/time_test.cc
@@ -14,12 +14,6 @@ #include "absl/time/time.h" -#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. @@ -45,9 +39,14 @@ #include "absl/hash/hash_testing.h" #include "absl/numeric/int128.h" #include "absl/strings/str_format.h" +#include "absl/time/civil_time.h" #include "absl/time/clock.h" #include "absl/time/internal/test_util.h" +#if defined(_MSC_VER) +#include <winsock2.h> // for timeval +#endif + namespace { #if defined(GTEST_USES_SIMPLE_RE) && GTEST_USES_SIMPLE_RE
diff --git a/absl/types/BUILD.bazel b/absl/types/BUILD.bazel index d38d4c7..7ded8da 100644 --- a/absl/types/BUILD.bazel +++ b/absl/types/BUILD.bazel
@@ -110,7 +110,6 @@ "//absl/base:config", "//absl/base:core_headers", "//absl/base:exception_testing", - "//absl/base:hardening", "//absl/container:fixed_array", "//absl/container:inlined_vector", "//absl/hash", @@ -154,7 +153,6 @@ "//absl/base:config", "//absl/base:core_headers", "//absl/base:exception_testing", - "//absl/base:hardening", "//absl/base:raw_logging_internal", "//absl/hash:hash_testing", "//absl/meta:type_traits",
diff --git a/absl/types/CMakeLists.txt b/absl/types/CMakeLists.txt index 28e1fe8..79a4c19 100644 --- a/absl/types/CMakeLists.txt +++ b/absl/types/CMakeLists.txt
@@ -58,7 +58,6 @@ absl::config absl::core_headers absl::exception_testing - absl::hardening absl::hash_testing absl::raw_logging_internal absl::span @@ -102,7 +101,6 @@ absl::core_headers absl::exception_testing absl::fixed_array - absl::hardening absl::hash absl::inlined_vector absl::hash_testing
diff --git a/absl/types/any_span_test.cc b/absl/types/any_span_test.cc index fe12b74..e5960c6 100644 --- a/absl/types/any_span_test.cc +++ b/absl/types/any_span_test.cc
@@ -30,7 +30,6 @@ #include "gtest/gtest.h" #include "absl/base/config.h" #include "absl/base/internal/exception_testing.h" -#include "absl/base/internal/hardening.h" #include "absl/base/internal/raw_logging.h" #include "absl/base/macros.h" #include "absl/hash/hash_testing.h" @@ -1042,7 +1041,6 @@ EXPECT_THAT(span.subspan(3, AnySpan<int>::npos), ElementsAre()); #if GTEST_HAS_DEATH_TEST if (IsHardened()) { - auto hardener = absl::base_internal::ScopedSetAbslHardeningForTesting(true); EXPECT_DEATH(span.subspan(4, AnySpan<int>::npos), ""); EXPECT_DEATH(span.subspan(AnySpan<int>::npos, AnySpan<int>::npos), ""); } @@ -1054,7 +1052,6 @@ AnySpan<int> span(v); #if GTEST_HAS_DEATH_TEST if (IsHardened()) { - auto hardener = absl::base_internal::ScopedSetAbslHardeningForTesting(true); EXPECT_DEATH(span.subspan(5, 0), ""); EXPECT_DEATH(span.subspan(5, 1), ""); EXPECT_DEATH(span.subspan(AnySpan<int>::npos, 0), "");
diff --git a/absl/types/span_test.cc b/absl/types/span_test.cc index 051e673..5a8b82e 100644 --- a/absl/types/span_test.cc +++ b/absl/types/span_test.cc
@@ -27,7 +27,6 @@ #include "absl/base/attributes.h" #include "absl/base/config.h" #include "absl/base/internal/exception_testing.h" -#include "absl/base/internal/hardening.h" #include "absl/base/options.h" #include "absl/container/fixed_array.h" #include "absl/container/inlined_vector.h" @@ -251,7 +250,6 @@ EXPECT_EQ(s.back(), s[9]); #if !defined(NDEBUG) || ABSL_OPTION_HARDENED - absl::base_internal::ScopedSetAbslHardeningForTesting hardener(true); EXPECT_DEATH_IF_SUPPORTED(s[-1], ""); EXPECT_DEATH_IF_SUPPORTED(s[10], ""); #endif @@ -293,7 +291,6 @@ EXPECT_EQ(v, MakeRamp(20, 1)); #if !defined(NDEBUG) || ABSL_OPTION_HARDENED - absl::base_internal::ScopedSetAbslHardeningForTesting hardener(true); absl::Span<int> prefix_death(v); EXPECT_DEATH_IF_SUPPORTED(prefix_death.remove_prefix(21), ""); absl::Span<int> suffix_death(v);