diff --git a/absl/abseil.podspec.gen.py b/absl/abseil.podspec.gen.py index e19f951..73eb9de 100755 --- a/absl/abseil.podspec.gen.py +++ b/absl/abseil.podspec.gen.py
@@ -49,6 +49,7 @@ s.tvos.deployment_target = '12.0' s.watchos.deployment_target = '4.0' s.visionos.deployment_target = '1.0' + s.exclude_files = [ 'absl/time/internal/cctz/src/*_win.cc' ] s.subspec 'xcprivacy' do |ss| ss.resource_bundles = { ss.module_name => 'PrivacyInfo.xcprivacy', @@ -189,7 +190,11 @@ # Since CocoaPods treats header_files a bit differently from bazel, # this won't generate a header_files field so that all source_files # are considered as header files. - srcs = sorted(set(rule.hdrs + rule.textual_hdrs + rule.srcs)) + srcs = [ + s + for s in sorted(set(rule.hdrs + rule.textual_hdrs + rule.srcs)) + if not s.endswith("_win.cc") + ] write_indented_list( f, "{indent}{var}.source_files = ".format(indent=indent, var=spec_var), srcs)
diff --git a/absl/algorithm/CMakeLists.txt b/absl/algorithm/CMakeLists.txt index cd7fa22..f062325 100644 --- a/absl/algorithm/CMakeLists.txt +++ b/absl/algorithm/CMakeLists.txt
@@ -49,10 +49,10 @@ ${ABSL_DEFAULT_COPTS} DEPS absl::algorithm - absl::hardening absl::config - absl::iterator_traits_internal absl::core_headers + absl::hardening + absl::iterator_traits_internal absl::meta PUBLIC )
diff --git a/absl/base/BUILD.bazel b/absl/base/BUILD.bazel index 059f43b..562f843 100644 --- a/absl/base/BUILD.bazel +++ b/absl/base/BUILD.bazel
@@ -512,6 +512,7 @@ "//absl/memory", "//absl/meta:type_traits", "//absl/strings", + "//absl/strings:string_view", "//absl/utility", "@googletest//:gtest", ], @@ -885,6 +886,7 @@ "//absl/flags:flag_internal", "//absl/flags:marshalling", "//absl/strings", + "//absl/strings:string_view", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -1033,7 +1035,7 @@ linkstatic = 1, deps = [ ":core_headers", - "//absl/strings", + "//absl/strings:string_view", "@googletest//:gtest", "@googletest//:gtest_main", ],
diff --git a/absl/base/CMakeLists.txt b/absl/base/CMakeLists.txt index 73eea03..2f8846f 100644 --- a/absl/base/CMakeLists.txt +++ b/absl/base/CMakeLists.txt
@@ -367,9 +367,10 @@ ${ABSL_TEST_COPTS} DEPS absl::config - absl::pretty_function absl::memory absl::meta + absl::pretty_function + absl::string_view absl::strings absl::utility GTest::gtest @@ -411,8 +412,8 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::atomic_hook_test_helper absl::atomic_hook + absl::atomic_hook_test_helper absl::core_headers GTest::gmock GTest::gtest_main @@ -509,8 +510,8 @@ ${ABSL_TEST_COPTS} DEPS absl::base - absl::config absl::base_internal + absl::config absl::core_headers absl::synchronization GTest::gtest @@ -600,8 +601,8 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::no_destructor absl::config + absl::no_destructor absl::raw_logging_internal GTest::gmock GTest::gtest_main @@ -678,10 +679,10 @@ absl_cc_library( NAME scoped_set_env - SRCS - "internal/scoped_set_env.cc" HDRS "internal/scoped_set_env.h" + SRCS + "internal/scoped_set_env.cc" COPTS ${ABSL_DEFAULT_COPTS} DEPS @@ -721,6 +722,7 @@ absl::flags_internal absl::flags_marshalling absl::log_severity + absl::string_view absl::strings GTest::gmock GTest::gtest_main @@ -730,10 +732,10 @@ absl_cc_library( NAME strerror - SRCS - "internal/strerror.cc" HDRS "internal/strerror.h" + SRCS + "internal/strerror.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -825,10 +827,10 @@ absl_cc_library( NAME poison - SRCS - "internal/poison.cc" HDRS "internal/poison.h" + SRCS + "internal/poison.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS
diff --git a/absl/base/call_once.h b/absl/base/call_once.h index 77852d1..58d5d23 100644 --- a/absl/base/call_once.h +++ b/absl/base/call_once.h
@@ -180,8 +180,8 @@ uint32_t old_control = kOnceInit; if (control->compare_exchange_strong(old_control, kOnceRunning, std::memory_order_relaxed) || - base_internal::SpinLockWait(control, std::size(trans), trans, - scheduling_mode) == kOnceInit) { + base_internal::SpinLockWait(control, static_cast<int>(std::size(trans)), + trans, scheduling_mode) == kOnceInit) { std::invoke(std::forward<Callable>(fn), std::forward<Args>(args)...); old_control = control->exchange(base_internal::kOnceDone, std::memory_order_release);
diff --git a/absl/container/BUILD.bazel b/absl/container/BUILD.bazel index f9b0c5c..99b1f53 100644 --- a/absl/container/BUILD.bazel +++ b/absl/container/BUILD.bazel
@@ -169,6 +169,9 @@ linkopts = ABSL_DEFAULT_LINKOPTS, textual_hdrs = ["internal/test_allocator.h"], visibility = ["//visibility:private"], + deps = [ + "//absl/base:config", + ], ) cc_test( @@ -322,6 +325,7 @@ ":flat_hash_set", ":hash_container_defaults", ":hash_generator_testing", + ":hash_policy_testing", ":test_allocator", ":unordered_set_constructor_test", ":unordered_set_lookup_test", @@ -331,7 +335,7 @@ "//absl/hash", "//absl/log:check", "//absl/memory", - "//absl/strings", + "//absl/strings:string_view", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -445,7 +449,7 @@ "//absl/base:config", "//absl/base:no_destructor", "//absl/meta:type_traits", - "//absl/strings", + "//absl/strings:string_view", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -464,8 +468,8 @@ "//absl/base:config", "//absl/hash", "//absl/meta:type_traits", - "//absl/strings", "//absl/strings:cord", + "//absl/strings:string_view", ], ) @@ -491,11 +495,12 @@ ":flat_hash_map", ":flat_hash_set", ":hash_function_defaults", + "//absl/base:core_headers", "//absl/hash", "//absl/random", - "//absl/strings", "//absl/strings:cord", "//absl/strings:cord_test_helpers", + "//absl/strings:string_view", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -515,7 +520,7 @@ "//absl/memory", "//absl/meta:type_traits", "//absl/random", - "//absl/strings", + "//absl/strings:string_view", ], ) @@ -530,7 +535,7 @@ ], deps = [ "//absl/hash", - "//absl/strings", + "//absl/strings:string_view", ], ) @@ -852,6 +857,7 @@ "//absl/numeric:int128", "//absl/random", "//absl/strings", + "//absl/strings:string_view", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -868,10 +874,13 @@ deps = [ ":container_memory", ":hash_function_defaults", + ":hashtable_control_bytes", ":raw_hash_set", "//absl/base:raw_logging_internal", + "//absl/hash", "//absl/random", "//absl/strings:str_format", + "//absl/strings:string_view", "@google_benchmark//:benchmark_main", ], ) @@ -896,6 +905,7 @@ "//absl/random:distributions", "//absl/strings", "//absl/strings:str_format", + "//absl/strings:string_view", ], ) @@ -1120,6 +1130,7 @@ linkopts = ABSL_DEFAULT_LINKOPTS, tags = ["no_test_loonix"], deps = [ + ":hash_policy_testing", ":unordered_set_constructor_test", ":unordered_set_lookup_test", ":unordered_set_members_test", @@ -1136,6 +1147,7 @@ linkopts = ABSL_DEFAULT_LINKOPTS, tags = ["no_test_loonix"], deps = [ + ":hash_policy_testing", ":unordered_map_constructor_test", ":unordered_map_lookup_test", ":unordered_map_members_test", @@ -1190,8 +1202,8 @@ "//absl/hash:weakly_mixed_integer", "//absl/memory", "//absl/meta:type_traits", - "//absl/strings", "//absl/strings:cord", + "//absl/strings:string_view", "//absl/types:compare", ], ) @@ -1206,7 +1218,6 @@ deps = [ ":btree", ":flat_hash_set", - "//absl/strings", "//absl/strings:cord", "//absl/time", ], @@ -1240,6 +1251,8 @@ "//absl/memory", "//absl/random", "//absl/strings", + "//absl/strings:cord", + "//absl/strings:string_view", "//absl/types:compare", "@googletest//:gtest", "@googletest//:gtest_main",
diff --git a/absl/container/CMakeLists.txt b/absl/container/CMakeLists.txt index effe790..cf460f0 100644 --- a/absl/container/CMakeLists.txt +++ b/absl/container/CMakeLists.txt
@@ -39,7 +39,7 @@ absl::layout absl::memory absl::raw_logging_internal - absl::strings + absl::string_view absl::throw_delegate absl::type_traits absl::weakly_mixed_integer @@ -59,7 +59,6 @@ absl::btree absl::cord absl::flat_hash_set - absl::strings absl::time TESTONLY ) @@ -83,6 +82,7 @@ absl::hash_testing absl::random_random absl::raw_logging_internal + absl::string_view absl::strings absl::test_allocator absl::test_instance_tracker @@ -125,15 +125,15 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS - absl::compressed_tuple absl::algorithm + absl::compressed_tuple absl::config absl::core_headers absl::dynamic_annotations absl::hardening absl::iterator_traits_internal - absl::throw_delegate absl::memory + absl::throw_delegate absl::weakly_mixed_integer PUBLIC ) @@ -146,9 +146,9 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::fixed_array absl::config absl::exception_testing + absl::fixed_array absl::hash_testing absl::iterator_traits_test_helper_internal absl::memory @@ -164,9 +164,9 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::fixed_array absl::config absl::exception_safety_testing + absl::fixed_array GTest::gmock_main ) @@ -202,8 +202,8 @@ absl::core_headers absl::hardening absl::inlined_vector_internal - absl::throw_delegate absl::memory + absl::throw_delegate absl::type_traits absl::weakly_mixed_integer PUBLIC @@ -252,9 +252,9 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::inlined_vector absl::config absl::exception_safety_testing + absl::inlined_vector GTest::gmock_main ) @@ -293,11 +293,11 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS + absl::algorithm_container absl::container_memory absl::core_headers absl::hash_container_defaults absl::raw_hash_map - absl::algorithm_container absl::type_traits PUBLIC ) @@ -332,12 +332,12 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS - absl::container_memory - absl::hash_container_defaults - absl::raw_hash_set absl::algorithm_container + absl::container_memory absl::core_headers + absl::hash_container_defaults absl::memory + absl::raw_hash_set absl::type_traits PUBLIC ) @@ -358,7 +358,7 @@ absl::hash_container_defaults absl::hash_generator_testing absl::memory - absl::strings + absl::string_view absl::test_allocator absl::unordered_set_constructor_test absl::unordered_set_lookup_test @@ -375,13 +375,13 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS + absl::algorithm_container absl::container_memory absl::core_headers absl::hash_container_defaults + absl::memory absl::node_slot_policy absl::raw_hash_map - absl::algorithm_container - absl::memory absl::type_traits PUBLIC ) @@ -413,13 +413,13 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS + absl::algorithm_container absl::container_memory absl::core_headers absl::hash_container_defaults + absl::memory absl::node_slot_policy absl::raw_hash_set - absl::algorithm_container - absl::memory absl::type_traits PUBLIC ) @@ -485,7 +485,7 @@ absl::config absl::container_memory absl::no_destructor - absl::strings + absl::string_view absl::test_instance_tracker absl::type_traits GTest::gmock_main @@ -504,7 +504,7 @@ absl::container_common absl::cord absl::hash - absl::strings + absl::string_view absl::type_traits PUBLIC ) @@ -521,10 +521,10 @@ absl::cord_test_helpers absl::flat_hash_map absl::flat_hash_set - absl::hash_function_defaults absl::hash + absl::hash_function_defaults absl::random_random - absl::strings + absl::string_view GTest::gmock_main ) @@ -545,7 +545,7 @@ absl::meta absl::no_destructor absl::random_random - absl::strings + absl::string_view TESTONLY ) @@ -559,7 +559,7 @@ ${ABSL_TEST_COPTS} DEPS absl::hash - absl::strings + absl::string_view TESTONLY ) @@ -584,8 +584,8 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS - absl::container_memory absl::common_policy_traits + absl::container_memory absl::meta PUBLIC ) @@ -726,13 +726,13 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS - absl::config absl::common_policy_traits + absl::config absl::container_memory absl::core_headers absl::raw_hash_set - absl::type_traits absl::throw_delegate + absl::type_traits PUBLIC ) @@ -843,6 +843,7 @@ absl::prefetch absl::random_random absl::raw_hash_set + absl::string_view absl::strings absl::test_allocator absl::test_instance_tracker @@ -904,8 +905,8 @@ absl::core_headers absl::debugging_internal absl::meta - absl::strings absl::span + absl::strings absl::utility PUBLIC ) @@ -918,9 +919,9 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::layout absl::check absl::config + absl::layout absl::span absl::utility GTest::gmock_main @@ -1099,9 +1100,9 @@ DEPS absl::flat_hash_map absl::flat_hash_set + absl::hashtablez_sampler absl::node_hash_map absl::node_hash_set - absl::hashtablez_sampler GTest::gmock_main ) @@ -1131,8 +1132,8 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS - absl::container_common absl::config + absl::container_common absl::core_headers absl::flat_hash_set ) @@ -1147,11 +1148,11 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS - absl::linked_hash_set absl::config - absl::heterogeneous_lookup_testing absl::hash_generator_testing absl::hash_policy_testing + absl::heterogeneous_lookup_testing + absl::linked_hash_set absl::string_view absl::test_allocator absl::test_instance_tracker @@ -1172,8 +1173,8 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS - absl::container_common absl::config + absl::container_common absl::core_headers absl::flat_hash_set absl::throw_delegate @@ -1189,12 +1190,12 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS - absl::linked_hash_map absl::config absl::exception_testing - absl::heterogeneous_lookup_testing absl::hash_generator_testing absl::hash_policy_testing + absl::heterogeneous_lookup_testing + absl::linked_hash_map absl::string_view absl::test_allocator absl::test_instance_tracker
diff --git a/absl/container/btree_benchmark.cc b/absl/container/btree_benchmark.cc index 69a8195..97931da 100644 --- a/absl/container/btree_benchmark.cc +++ b/absl/container/btree_benchmark.cc
@@ -15,8 +15,11 @@ #include <stdint.h> #include <algorithm> +#include <array> +#include <cstddef> #include <functional> #include <map> +#include <memory> #include <numeric> #include <random> #include <set> @@ -24,6 +27,7 @@ #include <type_traits> #include <unordered_map> #include <unordered_set> +#include <utility> #include <vector> #include "absl/algorithm/container.h"
diff --git a/absl/container/btree_test.cc b/absl/container/btree_test.cc index 5b76c34..9bcedc5 100644 --- a/absl/container/btree_test.cc +++ b/absl/container/btree_test.cc
@@ -16,6 +16,7 @@ #include <algorithm> #include <array> +#include <cstddef> #include <cstdint> #include <functional> #include <iostream> @@ -25,6 +26,7 @@ #include <memory> #include <numeric> #include <optional> +#include <set> #include <stdexcept> #include <string> #include <type_traits> @@ -44,6 +46,7 @@ #include "absl/hash/hash_testing.h" #include "absl/memory/memory.h" #include "absl/random/random.h" +#include "absl/strings/cord.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h"
diff --git a/absl/container/fixed_array_test.cc b/absl/container/fixed_array_test.cc index 71c6819..e82919e 100644 --- a/absl/container/fixed_array_test.cc +++ b/absl/container/fixed_array_test.cc
@@ -16,6 +16,8 @@ #include <stdio.h> +#include <cassert> +#include <cstdint> #include <cstring> #include <forward_list> #include <iterator>
diff --git a/absl/container/flat_hash_set_test.cc b/absl/container/flat_hash_set_test.cc index 95ead48..c5878aa 100644 --- a/absl/container/flat_hash_set_test.cc +++ b/absl/container/flat_hash_set_test.cc
@@ -28,6 +28,7 @@ #include "absl/container/hash_container_defaults.h" #include "absl/container/internal/container_memory.h" #include "absl/container/internal/hash_generator_testing.h" +#include "absl/container/internal/hash_policy_testing.h" #include "absl/container/internal/test_allocator.h" #include "absl/container/internal/unordered_set_constructor_test.h" #include "absl/container/internal/unordered_set_lookup_test.h"
diff --git a/absl/container/inlined_vector.h b/absl/container/inlined_vector.h index 8dfbf03..549151d 100644 --- a/absl/container/inlined_vector.h +++ b/absl/container/inlined_vector.h
@@ -41,6 +41,7 @@ #include <cstring> #include <initializer_list> #include <iterator> +#include <limits> #include <memory> #include <type_traits> #include <utility>
diff --git a/absl/container/inlined_vector_benchmark.cc b/absl/container/inlined_vector_benchmark.cc index 5a04277..e3f81bb 100644 --- a/absl/container/inlined_vector_benchmark.cc +++ b/absl/container/inlined_vector_benchmark.cc
@@ -13,9 +13,13 @@ // limitations under the License. #include <array> +#include <cstddef> +#include <cstdint> #include <string> +#include <utility> #include <vector> +#include "absl/base/attributes.h" #include "absl/base/internal/raw_logging.h" #include "absl/base/macros.h" #include "absl/container/inlined_vector.h"
diff --git a/absl/container/inlined_vector_test.cc b/absl/container/inlined_vector_test.cc index 73584ed..8bed847 100644 --- a/absl/container/inlined_vector_test.cc +++ b/absl/container/inlined_vector_test.cc
@@ -16,6 +16,7 @@ #include <algorithm> #include <cstddef> +#include <cstdint> #include <forward_list> #include <iterator> #include <list> @@ -1802,16 +1803,26 @@ const int ia[] = {0, 1, 2, 3, 4, 5, 6, 7}; int64_t allocated = 0; MyAlloc alloc(&allocated); - { AllocVec ABSL_ATTRIBUTE_UNUSED v; } - { AllocVec ABSL_ATTRIBUTE_UNUSED v(alloc); } { - AllocVec ABSL_ATTRIBUTE_UNUSED v(ia, ia + std::size(ia), alloc); + [[maybe_unused]] AllocVec v; } - { AllocVec ABSL_ATTRIBUTE_UNUSED v({1, 2, 3}, alloc); } + { + [[maybe_unused]] AllocVec v(alloc); + } + { + [[maybe_unused]] AllocVec v(ia, ia + std::size(ia), alloc); + } + { + [[maybe_unused]] AllocVec v({1, 2, 3}, alloc); + } AllocVec v2; - { AllocVec ABSL_ATTRIBUTE_UNUSED v(v2, alloc); } - { AllocVec ABSL_ATTRIBUTE_UNUSED v(std::move(v2), alloc); } + { + [[maybe_unused]] AllocVec v(v2, alloc); + } + { + [[maybe_unused]] AllocVec v(std::move(v2), alloc); + } } TEST(AllocatorSupportTest, CountAllocations) { @@ -1822,14 +1833,14 @@ int64_t instance_count = 0; MyAlloc alloc(&bytes_allocated, &instance_count); { - AllocVec ABSL_ATTRIBUTE_UNUSED v(ia, ia + 4, alloc); + [[maybe_unused]] AllocVec v(ia, ia + 4, alloc); EXPECT_THAT(bytes_allocated, Eq(0)); EXPECT_THAT(instance_count, Eq(4)); } EXPECT_THAT(bytes_allocated, Eq(0)); EXPECT_THAT(instance_count, Eq(0)); { - AllocVec ABSL_ATTRIBUTE_UNUSED v(ia, ia + std::size(ia), alloc); + [[maybe_unused]] AllocVec v(ia, ia + std::size(ia), alloc); EXPECT_THAT(bytes_allocated, Eq(static_cast<int64_t>(v.size() * sizeof(int)))); EXPECT_THAT(instance_count, Eq(static_cast<int64_t>(v.size()))); @@ -1843,12 +1854,12 @@ int64_t bytes_allocated2 = 0; MyAlloc alloc2(&bytes_allocated2); - ABSL_ATTRIBUTE_UNUSED AllocVec v2(v, alloc2); + [[maybe_unused]] AllocVec v2(v, alloc2); EXPECT_THAT(bytes_allocated2, Eq(0)); int64_t bytes_allocated3 = 0; MyAlloc alloc3(&bytes_allocated3); - ABSL_ATTRIBUTE_UNUSED AllocVec v3(std::move(v), alloc3); + [[maybe_unused]] AllocVec v3(std::move(v), alloc3); EXPECT_THAT(bytes_allocated3, Eq(0)); } EXPECT_THAT(bytes_allocated, Eq(0));
diff --git a/absl/container/internal/compressed_tuple.h b/absl/container/internal/compressed_tuple.h index 4d0fb2a..5d7567d 100644 --- a/absl/container/internal/compressed_tuple.h +++ b/absl/container/internal/compressed_tuple.h
@@ -32,6 +32,7 @@ #ifndef ABSL_CONTAINER_INTERNAL_COMPRESSED_TUPLE_H_ #define ABSL_CONTAINER_INTERNAL_COMPRESSED_TUPLE_H_ +#include <cstddef> #include <initializer_list> #include <tuple> #include <type_traits>
diff --git a/absl/container/internal/container_memory_test.cc b/absl/container/internal/container_memory_test.cc index 1aa459c..9ed387a 100644 --- a/absl/container/internal/container_memory_test.cc +++ b/absl/container/internal/container_memory_test.cc
@@ -16,7 +16,10 @@ #include <cstddef> #include <cstdint> +#include <cstring> +#include <map> #include <memory> +#include <string> #include <tuple> #include <type_traits> #include <typeindex>
diff --git a/absl/container/internal/hash_function_defaults_test.cc b/absl/container/internal/hash_function_defaults_test.cc index 67c853c..f1c9ccc 100644 --- a/absl/container/internal/hash_function_defaults_test.cc +++ b/absl/container/internal/hash_function_defaults_test.cc
@@ -14,14 +14,19 @@ #include "absl/container/internal/hash_function_defaults.h" +#include <algorithm> #include <cstddef> +#include <cstdint> #include <functional> +#include <memory> #include <string> #include <string_view> #include <type_traits> #include <utility> +#include <vector> #include "gtest/gtest.h" +#include "absl/base/port.h" #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" #include "absl/hash/hash.h"
diff --git a/absl/container/internal/hash_generator_testing.h b/absl/container/internal/hash_generator_testing.h index 79bff7c..72ef356 100644 --- a/absl/container/internal/hash_generator_testing.h +++ b/absl/container/internal/hash_generator_testing.h
@@ -22,6 +22,7 @@ #include <algorithm> #include <cassert> +#include <cstddef> #include <iosfwd> #include <memory> #include <random>
diff --git a/absl/container/internal/hash_policy_testing.h b/absl/container/internal/hash_policy_testing.h index 5eea528..b7cab68 100644 --- a/absl/container/internal/hash_policy_testing.h +++ b/absl/container/internal/hash_policy_testing.h
@@ -22,6 +22,7 @@ #include <limits> #include <memory> #include <ostream> +#include <string> #include <type_traits> #include <utility> #include <vector>
diff --git a/absl/container/internal/hash_policy_testing_test.cc b/absl/container/internal/hash_policy_testing_test.cc index f0b20fe..d932b0f 100644 --- a/absl/container/internal/hash_policy_testing_test.cc +++ b/absl/container/internal/hash_policy_testing_test.cc
@@ -14,6 +14,8 @@ #include "absl/container/internal/hash_policy_testing.h" +#include <utility> + #include "gtest/gtest.h" namespace absl {
diff --git a/absl/container/internal/hashtablez_sampler.h b/absl/container/internal/hashtablez_sampler.h index eff44bf..9e9a47c 100644 --- a/absl/container/internal/hashtablez_sampler.h +++ b/absl/container/internal/hashtablez_sampler.h
@@ -44,6 +44,7 @@ #include <cstdint> #include <functional> #include <memory> +#include <utility> #include <vector> #include "absl/base/attributes.h"
diff --git a/absl/container/internal/hashtablez_sampler_test.cc b/absl/container/internal/hashtablez_sampler_test.cc index ae89c02..0d863a8 100644 --- a/absl/container/internal/hashtablez_sampler_test.cc +++ b/absl/container/internal/hashtablez_sampler_test.cc
@@ -14,6 +14,7 @@ #include "absl/container/internal/hashtablez_sampler.h" +#include <algorithm> #include <atomic> #include <cassert> #include <cstddef>
diff --git a/absl/container/internal/inlined_vector.h b/absl/container/internal/inlined_vector.h index 5b9763e..e9eafdd 100644 --- a/absl/container/internal/inlined_vector.h +++ b/absl/container/internal/inlined_vector.h
@@ -29,6 +29,7 @@ #include "absl/base/config.h" #include "absl/base/internal/hardening.h" #include "absl/base/macros.h" +#include "absl/base/optimization.h" #include "absl/container/internal/compressed_tuple.h" #include "absl/memory/memory.h" #include "absl/meta/type_traits.h"
diff --git a/absl/container/internal/raw_hash_set.cc b/absl/container/internal/raw_hash_set.cc index 3f9263c..04c0448 100644 --- a/absl/container/internal/raw_hash_set.cc +++ b/absl/container/internal/raw_hash_set.cc
@@ -262,7 +262,7 @@ return; } size_t remaining = c.size(); - ABSL_ATTRIBUTE_UNUSED const size_t original_size_for_assert = remaining; + [[maybe_unused]] const size_t original_size_for_assert = remaining; while (remaining != 0) { for (uint32_t i : GroupFullEmptyOrDeleted(ctrl).MaskFull()) { ABSL_SWISSTABLE_ASSERT(IsFull(ctrl[i]) && @@ -282,58 +282,6 @@ "hash table was modified unexpectedly"); } -// NOTE: we don't use structure with bit fields for GrowthInfo because for -// correctness we rely on the lower bound being the most significant byte. - -// Returns the increment that needs to be added to the packed full growth info -// in order to increase lower bound by lower_bound_increment and increase -// overflow growth left by overflow_increment. -constexpr uint64_t GetPackedIncrement(uint64_t lower_bound_increment, - uint64_t overflow_increment) { - return (lower_bound_increment << GrowthInfoAccessor::kLowerBoundShift) + - overflow_increment; -} - -// Returns the increment that needs to be added to the packed full growth info -// in order to increase lower bound by overflow_to_lower_bound_size and -// decrease overflow growth left by overflow_to_lower_bound_size. -constexpr uint64_t GetRebalanceIncrement( - uint64_t overflow_to_lower_bound_size) { - return GetPackedIncrement(overflow_to_lower_bound_size, - 0u - overflow_to_lower_bound_size); -} - -// Returns the number of elements left to grow in the full growth info. -constexpr uint64_t GetOverflowGrowthLeftFromPacked( - uint64_t packed_full_growth_info) { - constexpr uint64_t kFullGrowthMask = - (uint64_t{1} << GrowthInfoAccessor::kLowerBoundShift) - 1; - return packed_full_growth_info & kFullGrowthMask; -} - -// Returns the GrowthInfoLowerBound object containing the information -// about minimum growth left. -constexpr GrowthInfoLowerBound GetGrowthInfoLowerBoundFromPacked( - uint64_t packed_full_growth_info) { - return GrowthInfoLowerBound(packed_full_growth_info >> - GrowthInfoAccessor::kLowerBoundShift); -} - -// Returns the number of elements left to grow in the lower bound. -constexpr uint64_t GetGrowthLeftLowerBoundFromPacked( - uint64_t packed_full_growth_info) { - return GetGrowthInfoLowerBoundFromPacked(packed_full_growth_info) - .GetGrowthLeft(); -} - -// Returns the total number of elements left to grow in the full growth info. -// Assumes that the table has capacity > kMaxGrowthLeftLowerBound. -uint64_t GetGrowthLeftTotalBigCapacity(void* full_growth_info) { - uint64_t packed_full_growth_left = little_endian::Load64(full_growth_info); - return GetOverflowGrowthLeftFromPacked(packed_full_growth_left) + - GetGrowthLeftLowerBoundFromPacked(packed_full_growth_left); -} - } // namespace void CommonFields::AssertNotDebugCapacityImpl() const { @@ -357,80 +305,6 @@ } } -void GrowthInfoAccessor::InitGrowthLeftNoDeleted(size_t growth_left, - size_t capacity) { - if (capacity <= GrowthInfoLowerBound::kMaxGrowthLeftLowerBound) { - *growth_info_lower_bound_ = static_cast<uint8_t>(growth_left); - } else { - uint64_t lower_bound = - (std::min)(uint64_t{growth_left}, - GrowthInfoLowerBound::kMaxGrowthLeftLowerBound); - little_endian::Store64( - full_growth_info_ptr(), - GetPackedIncrement(lower_bound, growth_left - lower_bound)); - } -} - -GrowthInfoLowerBound GrowthInfoAccessor::RebalanceGrowthLeftLowerBound( - size_t capacity) { - auto growth_left_lower_bound = GetGrowthInfoLowerBound(); - if (capacity <= GrowthInfoLowerBound::kMaxGrowthLeftLowerBound || - // For tables with deleted slots, we often call rebalance even if - // we have growth left in the lower bound. - growth_left_lower_bound.HasDeletedAndGrowthLeft()) { - return growth_left_lower_bound; - } else { - return RebalanceGrowthLeftLowerBoundLargeCapacity(); - } -} - -size_t GrowthInfoAccessor::GetGrowthLeftTotalSlow(size_t capacity) const { - if (capacity <= GrowthInfoLowerBound::kMaxGrowthLeftLowerBound) { - return GetGrowthLeftLowerBound(); - } else { - return static_cast<size_t>( - GetGrowthLeftTotalBigCapacity(full_growth_info_ptr())); - } -} - -ABSL_ATTRIBUTE_NOINLINE GrowthInfoLowerBound -GrowthInfoAccessor::RebalanceGrowthLeftLowerBoundLargeCapacity() { - void* full_growth_info = full_growth_info_ptr(); - uint64_t packed_full_growth_info = little_endian::Load64(full_growth_info); - uint64_t overflow_growth_left = - GetOverflowGrowthLeftFromPacked(packed_full_growth_info); - uint64_t lower_bound_growth_left = - GetGrowthLeftLowerBoundFromPacked(packed_full_growth_info); - uint64_t overflow_to_lower_bound_size = - (std::min)(overflow_growth_left, - GrowthInfoLowerBound::kMaxGrowthLeftLowerBound - - lower_bound_growth_left); - packed_full_growth_info += - GetRebalanceIncrement(overflow_to_lower_bound_size); - little_endian::Store64(full_growth_info, packed_full_growth_info); - auto result = GetGrowthInfoLowerBoundFromPacked(packed_full_growth_info); - ABSL_SWISSTABLE_ASSERT(result.HasNoDeleted() == - GetGrowthInfoLowerBound().HasNoDeleted()); - ABSL_SWISSTABLE_ASSERT( - (result.GetGrowthLeft() > 0 || - GetGrowthLeftTotalBigCapacity(full_growth_info_ptr()) == 0) && - "rebalance may return 0 only if we have absolutely no growth left"); - return result; -} - -void GrowthInfoAccessor::OverwriteFullAsEmpty() { - if (GetGrowthLeftLowerBound() < - GrowthInfoLowerBound::kMaxGrowthLeftLowerBound) { - ++(*growth_info_lower_bound_); - } else { - constexpr uint64_t kIncrement = GetPackedIncrement( - /*lower_bound_increment=*/0, /*overflow_increment=*/1); - void* const full_growth_info = full_growth_info_ptr(); - little_endian::Store64( - full_growth_info, little_endian::Load64(full_growth_info) + kIncrement); - } -} - void ConvertDeletedToEmptyAndFullToDeleted(ctrl_t* ctrl, size_t capacity) { ABSL_SWISSTABLE_ASSERT(ctrl[capacity] == ctrl_t::kSentinel); ABSL_SWISSTABLE_ASSERT(IsValidCapacity(capacity)); @@ -447,6 +321,71 @@ IterateOverFullSlotsImpl(c, slot_size, cb); } +void CommonFields::InitGrowthLeftNoDeleted(size_t growth_left, + size_t capacity) { + if (capacity <= GrowthInfoLowerBound::kMaxGrowthLeftLowerBound) { + inline_data_.set_growth_info_lower_bound( + GrowthInfoLowerBound(static_cast<uint8_t>(growth_left))); + } else { + uint64_t lower_bound = + (std::min)(uint64_t{growth_left}, + GrowthInfoLowerBound::kMaxGrowthLeftLowerBound); + inline_data_.set_growth_info_lower_bound( + GrowthInfoLowerBound(static_cast<uint8_t>(lower_bound))); + SetGrowthInfoOverflow(growth_left - lower_bound); + } +} + +size_t CommonFields::GetGrowthLeftTotalSlow(size_t capacity) const { + size_t result = inline_data_.growth_info_lower_bound().GetGrowthLeft(); + if (capacity > GrowthInfoLowerBound::kMaxGrowthLeftLowerBound) { + result += GetOverflowGrowthLeft(); + } + return result; +} + +void CommonFields::OverwriteFullAsEmpty() { + if (inline_data_.growth_info_lower_bound().GetGrowthLeft() < + GrowthInfoLowerBound::kMaxGrowthLeftLowerBound) { + inline_data_.overwrite_full_as_empty_in_lower_bound(); + } else { + SetGrowthInfoOverflow(GetOverflowGrowthLeft() + 1); + } +} + +GrowthInfoLowerBound CommonFields::RebalanceGrowthLeftLowerBound( + size_t capacity) { + auto growth_left_lower_bound = GetGrowthInfoLowerBound(); + if (capacity <= GrowthInfoLowerBound::kMaxGrowthLeftLowerBound || + // For tables with deleted slots, we often call rebalance even if + // we have growth left in the lower bound. + growth_left_lower_bound.HasDeletedAndGrowthLeft()) { + return growth_left_lower_bound; + } else { + return RebalanceGrowthLeftLowerBoundLargeCapacity(); + } +} + +ABSL_ATTRIBUTE_NOINLINE GrowthInfoLowerBound +CommonFields::RebalanceGrowthLeftLowerBoundLargeCapacity() { + uint64_t overflow_growth_left = GetOverflowGrowthLeft(); + uint64_t lower_bound_growth_left = GetGrowthLeftLowerBound(); + uint64_t overflow_to_lower_bound_size = + (std::min)(overflow_growth_left, + GrowthInfoLowerBound::kMaxGrowthLeftLowerBound - + lower_bound_growth_left); + SetGrowthInfoOverflow(overflow_growth_left - overflow_to_lower_bound_size); + inline_data_.increment_growth_info_lower_bound(overflow_to_lower_bound_size); + auto result = GetGrowthInfoLowerBound(); + ABSL_SWISSTABLE_ASSERT(result.HasNoDeleted() == + GetGrowthInfoLowerBound().HasNoDeleted()); + ABSL_SWISSTABLE_ASSERT( + (result.GetGrowthLeft() > 0 || + (GetGrowthLeftLowerBound() + GetOverflowGrowthLeft() == 0)) && + "rebalance may return 0 only if we have absolutely no growth left"); + return result; +} + HashtablezInfoHandle CommonFields::infoz_ptr() const { // growth_info is stored before control bytes. ABSL_SWISSTABLE_ASSERT(has_infoz()); @@ -466,10 +405,10 @@ namespace { -void ResetGrowthLeft(GrowthInfoAccessor growth_info, size_t capacity, - size_t occupied_elements) { - growth_info.InitGrowthLeftNoDeleted( - CapacityToGrowth(capacity) - occupied_elements, capacity); +void ResetGrowthLeft(size_t capacity, size_t occupied_elements, + CommonFields& common) { + common.InitGrowthLeftNoDeleted(CapacityToGrowth(capacity) - occupied_elements, + capacity); } // Finds guaranteed to exists empty slot from the given position. @@ -696,8 +635,7 @@ } // Prepare insert for the new element. PrepareInsertCommon(common); - ResetGrowthLeft(common.growth_info(), capacity, - common.size() + blocked_element_count); + ResetGrowthLeft(capacity, common.size() + blocked_element_count, common); FindInfo find_info = find_first_non_full(common, new_hash); SetCtrlInLargeTable(common, find_info.offset, H2(new_hash), slot_size); common.infoz().RecordInsertMiss(new_hash, find_info.probe_length); @@ -874,11 +812,11 @@ if (WasNeverFull(c, index)) { SetCtrl(c, index, ctrl_t::kEmpty, slot_size); - c.growth_info().OverwriteFullAsEmpty(); + c.OverwriteFullAsEmpty(); return; } - c.growth_info().OverwriteFullAsDeleted(); + c.OverwriteFullAsDeleted(); SetCtrlInLargeTable(c, index, ctrl_t::kDeleted, slot_size); } @@ -891,7 +829,7 @@ c.set_size_to_zero(); ABSL_SWISSTABLE_ASSERT(c.capacity() > policy.soo_capacity()); ResetCtrl(c, policy.slot_size, blocked_element_count); - ResetGrowthLeft(c.growth_info(), c.capacity(), blocked_element_count); + ResetGrowthLeft(c.capacity(), blocked_element_count, c); ABSL_SWISSTABLE_ASSERT(c.blocked_element_count() == blocked_element_count); c.infoz().RecordStorageChanged(0, c.capacity()); } else { @@ -1043,8 +981,6 @@ infoz.RecordRehash(total_probe_length); infoz.RecordInsertMiss(hash, distance_from_desired); common.set_has_infoz(); - // TODO(b/413062340): we could potentially store infoz in place of the - // control pointer for the capacity 1 case. common.set_infoz(infoz); } @@ -1133,10 +1069,7 @@ common.generate_new_seed(has_infoz); ResetCtrl(common, slot_size, blocked_element_count); - if (GrowthInfoSizeForCapacity(new_capacity) > 0) { - ResetGrowthLeft(GetGrowthInfoFromControl(new_ctrl), new_capacity, - blocked_element_count); - } + ResetGrowthLeft(new_capacity, blocked_element_count, common); if (ABSL_PREDICT_FALSE(has_infoz)) { ReportResizeToInfoz(common, infoz, 0); @@ -1218,7 +1151,7 @@ InsertOldSooSlotAndInitializeControlBytes(common, policy, new_ctrl, new_slots, has_infoz); - ResetGrowthLeft(common.growth_info(), new_capacity, kTableSize); + ResetGrowthLeft(new_capacity, kTableSize, common); if (has_infoz) { common.set_has_infoz(); common.set_infoz(infoz); @@ -1459,10 +1392,7 @@ // Initializes mirrored control bytes after // transfer_unprobed_elements_to_next_capacity. void InitializeMirroredControlBytes(ctrl_t* new_ctrl, size_t new_capacity) { - std::memcpy(new_ctrl + new_capacity, - // We own GrowthInfo just before control bytes. So it is ok - // to read one byte from it. - new_ctrl - 1, Group::kWidth); + std::memcpy(new_ctrl + new_capacity + 1, new_ctrl, Group::kWidth - 1); new_ctrl[new_capacity] = ctrl_t::kSentinel; } @@ -1764,8 +1694,7 @@ /*blocked_element_count=*/0); PrepareInsertCommon(common); ABSL_SWISSTABLE_ASSERT(common.size() == 2); - GetGrowthInfoFromControl(new_ctrl).InitGrowthLeftNoDeleted(kNewCapacity - 2, - kNewCapacity); + common.InitGrowthLeftNoDeleted(kNewCapacity - 2, kNewCapacity); if (ABSL_PREDICT_FALSE(has_infoz)) { ReportSingleGroupTableGrowthToInfoz(common, infoz, new_hash); @@ -1779,8 +1708,7 @@ CommonFields& common, const PolicyFunctions& __restrict policy, size_t new_hash) { const size_t old_capacity = common.capacity(); - ABSL_SWISSTABLE_ASSERT( - common.growth_info().GetGrowthLeftTotalSlow(old_capacity) == 0); + ABSL_SWISSTABLE_ASSERT(common.GetGrowthLeftTotalSlow(old_capacity) == 0); ABSL_SWISSTABLE_ASSERT(old_capacity > policy.soo_capacity()); ABSL_SWISSTABLE_ASSERT(!IsSmallCapacity(old_capacity)); ABSL_ASSUME(old_capacity > kMaxSmallCapacity); @@ -1838,8 +1766,7 @@ (*policy.dealloc)(alloc, old_capacity, old_ctrl, slot_size, slot_align, has_infoz, old_blocked_element_count); PrepareInsertCommon(common); - ResetGrowthLeft(GetGrowthInfoFromControl(new_ctrl), new_capacity, - common.size()); + ResetGrowthLeft(new_capacity, common.size(), common); if (ABSL_PREDICT_FALSE(has_infoz)) { ReportGrowthToInfoz(common, infoz, new_hash, total_probe_length, @@ -1907,8 +1834,7 @@ void* RehashOrGrowToNextCapacityAndPrepareInsert( CommonFields& common, const PolicyFunctions& __restrict policy, size_t new_hash) { - ABSL_SWISSTABLE_ASSERT( - !common.growth_info().GetGrowthInfoLowerBound().HasNoDeleted()); + ABSL_SWISSTABLE_ASSERT(!common.GetGrowthInfoLowerBound().HasNoDeleted()); const size_t cap = common.capacity(); ABSL_ASSUME(cap > 0); // Do these calculations in 64-bit to avoid overflow. @@ -1968,11 +1894,10 @@ void* PrepareInsertLargeSlow(CommonFields& common, const PolicyFunctions& __restrict policy, size_t hash) { - GrowthInfoAccessor growth_info = common.growth_info(); const size_t cap = common.capacity(); ABSL_ASSUME(cap > kMaxSmallCapacity); GrowthInfoLowerBound growth_info_lower_bound = - growth_info.RebalanceGrowthLeftLowerBound(cap); + common.RebalanceGrowthLeftLowerBound(cap); if (ABSL_PREDICT_TRUE( growth_info_lower_bound.HasNoGrowthLeftAndNoDeleted())) { // Table without deleted slots (>95% cases) that needs to be resized. @@ -1989,7 +1914,7 @@ // rebalanced. FindInfo target = find_first_non_full(common, hash); PrepareInsertCommon(common); - growth_info.OverwriteControlAsFull(common.control()[target.offset]); + common.OverwriteControlAsFull(common.control()[target.offset]); SetCtrlInLargeTable(common, target.offset, H2(hash), policy.slot_size); common.infoz().RecordInsertMiss(hash, target.probe_length); return SlotAddress(common.slot_array(cap), target.offset, policy.slot_size); @@ -2010,7 +1935,7 @@ /*blocked_element_count=*/0, /*force_infoz=*/true); PrepareInsertCommon(common); - common.growth_info().OverwriteEmptyAsFull(); + common.OverwriteEmptyAsFull(); const size_t new_hash = get_hash(common.seed().seed()); SetCtrlInSingleGroupTable(common, SooSlotIndex(), H2(new_hash), policy.slot_size); @@ -2133,10 +2058,7 @@ common, policy, old_ctrl, old_slots, old_capacity); (*policy.dealloc)(alloc, old_capacity, old_ctrl, slot_size, slot_align, has_infoz, old_blocked_element_count); - if (GrowthInfoSizeForCapacity(new_capacity) > 0) { - ResetGrowthLeft(GetGrowthInfoFromControl(new_ctrl), new_capacity, - common.size()); - } + ResetGrowthLeft(new_capacity, common.size(), common); if (ABSL_PREDICT_FALSE(has_infoz)) { ReportResizeToInfoz(common, infoz, total_probe_length); @@ -2171,8 +2093,7 @@ PrepareInsertCommon(common); ABSL_SWISSTABLE_ASSERT(common.size() == 2); - GetGrowthInfoFromControl(new_ctrl).InitGrowthLeftNoDeleted(kNewCapacity - 2, - kNewCapacity); + common.InitGrowthLeftNoDeleted(kNewCapacity - 2, kNewCapacity); common.generate_new_seed(/*has_infoz=*/false); const h2_t soo_slot_h2 = H2(policy.hash_slot( policy.hash_fn(common), common.soo_data(), common.seed().seed())); @@ -2338,7 +2259,7 @@ common.maybe_increment_generation_on_insert(); }); common.increment_size(size); - ResetGrowthLeft(common.growth_info(), cap, size + blocked_element_count); + ResetGrowthLeft(cap, size + blocked_element_count, common); } void ReserveTableToFitNewSize(CommonFields& common, @@ -2357,9 +2278,8 @@ ABSL_SWISSTABLE_ASSERT(!common.empty() || cap > policy.soo_capacity()); ABSL_SWISSTABLE_ASSERT(cap > 0); const size_t max_size_before_growth = - IsSmallCapacity(cap) - ? cap - : common.size() + common.growth_info().GetGrowthLeftTotalSlow(cap); + IsSmallCapacity(cap) ? cap + : common.size() + common.GetGrowthLeftTotalSlow(cap); if (new_size <= max_size_before_growth) { return; } @@ -2373,16 +2293,15 @@ Group::NonIterableBitMaskType mask_empty, FindInfo target_group) { ABSL_SWISSTABLE_ASSERT(!common.is_small()); - GrowthInfoAccessor growth_info = common.growth_info(); // When there are no deleted slots in the table // and growth_left is positive, we can insert at the first // empty slot in the probe sequence (target). if (ABSL_PREDICT_FALSE( - !growth_info.GetGrowthInfoLowerBound().HasNoDeletedAndGrowthLeft())) { + !common.GetGrowthInfoLowerBound().HasNoDeletedAndGrowthLeft())) { return PrepareInsertLargeSlow(common, policy, hash); } PrepareInsertCommon(common); - growth_info.OverwriteEmptyAsFull(); + common.OverwriteEmptyAsFull(); const size_t cap = common.capacity(); ABSL_ASSUME(cap > kMaxSmallCapacity); target_group.offset += mask_empty.LowestBitSet(); @@ -2410,7 +2329,7 @@ // NOLINTNEXTLINE(misc-static-assert) ABSL_SWISSTABLE_ASSERT(SwisstableGenerationsEnabled()); const size_t cap = common.capacity(); - const size_t growth_left = common.growth_info().GetGrowthLeftTotalSlow(cap); + const size_t growth_left = common.GetGrowthLeftTotalSlow(cap); // As an optimization, we avoid calling ShouldRehashForBugDetection if we // will end up rehashing anyways. if (growth_left > 0 && common.should_rehash_for_bug_detection_on_insert()) {
diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h index ad416cd..d02af7e 100644 --- a/absl/container/internal/raw_hash_set.h +++ b/absl/container/internal/raw_hash_set.h
@@ -62,10 +62,7 @@ // HashtablezInfoHandle infoz_; // optional // // Additional number that can be added to growth_left_lower_bound. // // Only stored for tables with large capacities. -// uint8_t growth_left_overflow[7]; // optional -// // The minimum number of elements we can insert before growing the -// // capacity. -// uint8_t growth_left_lower_bound; +// uint64_t growth_left_overflow; // optional // // Control bytes for the "real" slots. // ctrl_t ctrl[capacity]; // // Always `ctrl_t::kSentinel`. This is used by iterators to find when to @@ -204,6 +201,7 @@ #include "absl/base/internal/endian.h" #include "absl/base/internal/iterator_traits.h" #include "absl/base/internal/raw_logging.h" +#include "absl/base/internal/unaligned_access.h" #include "absl/base/macros.h" #include "absl/base/optimization.h" #include "absl/base/options.h" @@ -651,6 +649,96 @@ uint8_t tail_blocked_; }; +// Stored the information regarding number of slots we can still fill +// without needing to rehash. +// +// We want to ensure sufficient number of empty slots in the table in order +// to keep probe sequences relatively short. Empty slot in the probe group +// is required to stop probing. +// +// Tombstones (kDeleted slots) are not included in the growth capacity, +// because we'd like to rehash when the table is filled with tombstones and/or +// full slots. +// +// GrowthInfo also stores a bit that encodes whether table may have any +// deleted slots. +// Most of the tables (>95%) have no deleted slots, so some functions can +// be more efficient with this information. +// +// Callers can also force a rehash via the standard `rehash(0)`, +// which will recompute this value as a side-effect. +// +// See also `CapacityToGrowth()`. +// +// GrowthInfoLowerBound is stored as 8 bits in HashtableInlineData. +// For capacity > kMaxGrowthLeftLowerBound we additionally store 8 bytes +// at the beginning of the backing array. Storing GrowthInfoLowerBound in +// HashtableInlineData helps to avoid any branching in the hottest code +// accessing GrowthInfo. GrowthInfoLowerBound has 7 bits to store the growth +// left and 1 bit to store whether the table has any deleted slots. GrowthInfo +// overflow for capacity > kMaxGrowthLeftLowerBound is stored as unaligned +// uint64_t. + +// One byte encoding of lower bound GrowthInfo. +// It encodes number of growth left from 0 to kMaxGrowthLeftLowerBound and +// whether the table has any deleted slots. +class GrowthInfoLowerBound { + public: + static constexpr uint8_t kGrowthLeftMask = 0x7Fu; + static constexpr uint8_t kDeletedBit = 0x80u; + static constexpr uint64_t kMaxGrowthLeftLowerBound = 127; + static_assert(kMaxGrowthLeftLowerBound == kGrowthLeftMask); + + explicit constexpr GrowthInfoLowerBound(uint8_t growth_left) + : growth_left_(growth_left) {} + + // Returns the raw one byte encoded value of the GrowthInfoLowerBound. + uint8_t ToRawData() const { return growth_left_; } + + // Returns true if table satisfies two properties: + // 1. Guaranteed to have no kDeleted slots. + // 2. There is a place for at least one element to grow. + constexpr bool HasNoDeletedAndGrowthLeft() const { + return static_cast<int8_t>(growth_left_) > 0; + } + + // Returns true if table satisfies two properties: + // 1. May have kDeleted slots (kDeletedBit == 1). + // 2. There is a place for at least one element to grow. + constexpr bool HasDeletedAndGrowthLeft() const { + return growth_left_ > kDeletedBit; + } + + // Returns true if the table satisfies two properties: + // 1. Guaranteed to have no kDeleted slots. + // 2. There is no growth left. + constexpr bool HasNoGrowthLeftAndNoDeleted() const { + return growth_left_ == 0; + } + + // Returns true if GetGrowthLeft() == 0 and HasNoDeleted() is false. + // It is slightly more efficient. + constexpr bool HasNoGrowthLeftAndHaveDeleted() const { + return growth_left_ == kDeletedBit; + } + + // Returns true if table guaranteed to have no kDeleted slots. + constexpr bool HasNoDeleted() const { + return (growth_left_ & kDeletedBit) == 0; + } + + // Returns the minimum number of elements left to grow. + // Use GrowthInfoView::GetGrowthLeftTotal() to get the total number of + // elements left to grow. For tables with capacity <= + // kMaxGrowthLeftLowerBound, this is the same as GetGrowthLeftTotal(). + constexpr uint8_t GetGrowthLeft() const { + return growth_left_ & kGrowthLeftMask; + } + + private: + uint8_t growth_left_; +}; + // Capacity, size and also has additionally // 1) one bit that stores whether we have infoz. // 2) kBlockedElementsBitCount bits that stores number of blocked elements in @@ -668,6 +756,7 @@ public: static constexpr HashtableCapacityStorageMode kStorageMode = StorageMode; using HashtableCapacity = HashtableCapacityImpl<StorageMode>; + static constexpr size_t kGrowthInfoLowerBoundBitCount = 8; static constexpr size_t kBlockedElementBitCount = 3; static constexpr size_t kMaxBlockedElementCount = (uint64_t{1} << kBlockedElementBitCount) - 1; @@ -676,8 +765,9 @@ static constexpr size_t kCapacityBitStoredInDataCount = StorageMode == kCapacityByValue ? 0 : kCapacityBitCount; static constexpr size_t kSizeBitCount = - 64 - (kBlockedElementBitCount + kSeedBitCount + - /*has_infoz*/ 1 + kCapacityBitStoredInDataCount); + 64 - + (kBlockedElementBitCount + kSeedBitCount + kGrowthInfoLowerBoundBitCount + + /*has_infoz*/ 1 + kCapacityBitStoredInDataCount); explicit HashtableInlineDataImpl(uninitialized_tag_t) {} explicit HashtableInlineDataImpl(HashtableCapacity capacity, @@ -758,11 +848,63 @@ } void set_blocked_element_count_to_zero() { data_ &= ~kBlockedElementMask; } + GrowthInfoLowerBound growth_info_lower_bound() const { + ABSL_SWISSTABLE_ASSERT(!is_small() && + "we do not track growth for small tables"); + return GrowthInfoLowerBound(static_cast<uint8_t>( + (data_ & kGrowthInfoLowerBoundMask) >> kGrowthInfoLowerBoundShift)); + } + + void set_growth_info_lower_bound( + GrowthInfoLowerBound growth_info_lower_bound) { + data_ = (data_ & ~kGrowthInfoLowerBoundMask) | + (uint64_t{growth_info_lower_bound.ToRawData()} + << kGrowthInfoLowerBoundShift); + } + + // Overwrites single empty slot with a full slot. + // Must be called when growth left lower bound is positive. + void overwrite_empty_as_full() { + ABSL_SWISSTABLE_ASSERT(growth_info_lower_bound().GetGrowthLeft() > 0); + data_ -= kGrowthInfoLowerBoundOne; + } + + // Overwrites single full slot with an empty slot. + // Must be called when growth left lower bound is less than + // kMaxGrowthLeftLowerBound. + void overwrite_full_as_empty_in_lower_bound() { + increment_growth_info_lower_bound(1); + } + + // Increments the growth left lower bound by the given increment. + // Must be called when the growth left lower bound + increment does not exceed + // kMaxGrowthLeftLowerBound. + void increment_growth_info_lower_bound(size_t increment) { + ABSL_SWISSTABLE_ASSERT(growth_info_lower_bound().GetGrowthLeft() + + increment <= + GrowthInfoLowerBound::kMaxGrowthLeftLowerBound); + data_ += increment << kGrowthInfoLowerBoundShift; + } + + // Overwrites specified control element with full slot. + // Must be called when growth left lower bound is >= IsEmpty(ctrl). + void overwrite_control_as_full(ctrl_t ctrl) { + ABSL_SWISSTABLE_ASSERT(growth_info_lower_bound().GetGrowthLeft() >= + static_cast<size_t>(IsEmpty(ctrl))); + data_ -= static_cast<size_t>(IsEmpty(ctrl)) << kGrowthInfoLowerBoundShift; + } + + // Overwrites single full slot with a deleted slot. + void overwrite_full_as_deleted() { + data_ |= (GrowthInfoLowerBound::kDeletedBit << kGrowthInfoLowerBoundShift); + } + void set_no_seed_for_testing() { data_ &= ~kSeedMask; } private: // Bit layout of `data_` and `capacity_internal_` from MSB to LSB: - // (55/49 bits) : size + // (47/41 bits) : size + // (8 bits) : growth_info_lower_bound // (3 bits) : blocked_element_count // (1 bit) : has_infoz // (5 bits) : seed @@ -770,8 +912,7 @@ // We don't split these components of `data_` into separate bit field elements // because we get worse generated code that way. - static constexpr size_t kDataBitCount = - kSeedBitCount + 1 + kSizeBitCount + kBlockedElementBitCount; + static constexpr size_t kDataBitCount = 64 - kCapacityBitStoredInDataCount; static constexpr size_t kSizeShift = kDataBitCount - kSizeBitCount; static constexpr uint64_t kSizeOneNoMetadata = uint64_t{1} << kSizeShift; static constexpr uint64_t kMetadataMask = kSizeOneNoMetadata - 1; @@ -781,6 +922,12 @@ static constexpr uint64_t kBlockedElementsShift = kSeedBitCount + 1; static constexpr uint64_t kBlockedElementMask = kMaxBlockedElementCount << kBlockedElementsShift; + static constexpr uint64_t kGrowthInfoLowerBoundShift = + kBlockedElementsShift + kBlockedElementBitCount; + static constexpr uint64_t kGrowthInfoLowerBoundOne = + uint64_t{1} << kGrowthInfoLowerBoundShift; + static constexpr uint64_t kGrowthInfoLowerBoundMask = + uint64_t{0xff} << kGrowthInfoLowerBoundShift; // For SOO tables, the seed is unused, and bit 0 is repurposed to track // whether the table has already queried should_sample_soo(). static constexpr uint64_t kSooHasTriedSamplingMask = 1; @@ -976,171 +1123,6 @@ using HashSetIteratorGenerationInfo = HashSetIteratorGenerationInfoDisabled; #endif -// Stored the information regarding number of slots we can still fill -// without needing to rehash. -// -// We want to ensure sufficient number of empty slots in the table in order -// to keep probe sequences relatively short. Empty slot in the probe group -// is required to stop probing. -// -// Tombstones (kDeleted slots) are not included in the growth capacity, -// because we'd like to rehash when the table is filled with tombstones and/or -// full slots. -// -// GrowthInfo also stores a bit that encodes whether table may have any -// deleted slots. -// Most of the tables (>95%) have no deleted slots, so some functions can -// be more efficient with this information. -// -// Callers can also force a rehash via the standard `rehash(0)`, -// which will recompute this value as a side-effect. -// -// See also `CapacityToGrowth()`. -// -// GrowthInfo is stored as 1 or 8 bytes at the beginning of the backing array. -// For capacity <= kMaxGrowthLeftLowerBound we store single byte, otherwise we -// store 8 bytes. Byte before the first control byte for all tables is always -// used to store GrowthInfoLowerBound. That helps to avoid any branching in the -// hottest code accessing GrowthInfo. GrowthInfoLowerBound has 7 bits to store -// the growth left and 1 bit to store whether the table has any deleted slots. -// For capacity > kMaxGrowthLeftLowerBound we use another 7 bytes to store the -// full GrowthInfo. GrowthInfo for capacity > kMaxGrowthLeftLowerBound is stored -// as uint64_t in little endian encoding. Most significant 8 bits (last byte in -// little endian encoding) contains GrowthInfoLowerBound. -class GrowthInfoAccessor; - -// One byte encoding of lower bound GrowthInfo. -// It encodes number of growth left from 0 to kMaxGrowthLeftLowerBound and -// whether the table has any deleted slots. -class GrowthInfoLowerBound { - public: - static constexpr uint8_t kGrowthLeftMask = 0x7Fu; - static constexpr uint8_t kDeletedBit = 0x80u; - static constexpr uint64_t kMaxGrowthLeftLowerBound = 127; - static_assert(kMaxGrowthLeftLowerBound == kGrowthLeftMask); - - explicit constexpr GrowthInfoLowerBound(uint8_t growth_left) - : growth_left_(growth_left) {} - - // Returns true if table satisfies two properties: - // 1. Guaranteed to have no kDeleted slots. - // 2. There is a place for at least one element to grow. - constexpr bool HasNoDeletedAndGrowthLeft() const { - return static_cast<int8_t>(growth_left_) > 0; - } - - // Returns true if table satisfies two properties: - // 1. May have kDeleted slots (kDeletedBit == 1). - // 2. There is a place for at least one element to grow. - constexpr bool HasDeletedAndGrowthLeft() const { - return growth_left_ > kDeletedBit; - } - - // Returns true if the table satisfies two properties: - // 1. Guaranteed to have no kDeleted slots. - // 2. There is no growth left. - constexpr bool HasNoGrowthLeftAndNoDeleted() const { - return growth_left_ == 0; - } - - // Returns true if GetGrowthLeft() == 0 and HasNoDeleted() is false. - // It is slightly more efficient. - constexpr bool HasNoGrowthLeftAndHaveDeleted() const { - return growth_left_ == kDeletedBit; - } - - // Returns true if table guaranteed to have no kDeleted slots. - constexpr bool HasNoDeleted() const { - return (growth_left_ & kDeletedBit) == 0; - } - - // Returns the minimum number of elements left to grow. - // Use GrowthInfoView::GetGrowthLeftTotal() to get the total number of - // elements left to grow. For tables with capacity <= - // kMaxGrowthLeftLowerBound, this is the same as GetGrowthLeftTotal(). - constexpr uint8_t GetGrowthLeft() const { - return growth_left_ & kGrowthLeftMask; - } - - private: - uint8_t growth_left_; -}; - -// GrowthInfo is stored in the backing array, and this class provides a simple -// interface to access and modify it. -class GrowthInfoAccessor { - public: - // GrowthInfoLowerBound is stored in the most significant 8 bits of the - // full growth info. - static constexpr uint64_t kLowerBoundShift = 64 - 8; - - explicit GrowthInfoAccessor(void* control) - : growth_info_lower_bound_(reinterpret_cast<uint8_t*>(control) - 1 - - NumGenerationBytes()) {} - - // Initializes the GrowthInfo assuming we can grow `growth_left` elements - // and there are no kDeleted slots in the table. - void InitGrowthLeftNoDeleted(size_t growth_left, size_t capacity); - - // Returns a GrowthInfoLowerBound object containing the information - // about minimum growth left. - // It guarantees that GetGrowthLeft() will be > 0 if GetGrowthLeftTotal() > 0. - // It may optionally borrow some growth left from the full_growth_info. - GrowthInfoLowerBound RebalanceGrowthLeftLowerBound(size_t capacity); - - // Overwrites single full slot with an empty slot. - void OverwriteFullAsEmpty(); - - // Overwrites single empty slot with a full slot. - // Must be called when GetGrowthLeftLowerBound() > 0. - void OverwriteEmptyAsFull() { - ABSL_SWISSTABLE_ASSERT(GetGrowthLeftLowerBound() > 0); - --(*growth_info_lower_bound_); - } - - // Overwrites specified control element with full slot. - // Must be called when GetGrowthLeftLowerBound() >= IsEmpty(ctrl). - void OverwriteControlAsFull(ctrl_t ctrl) { - ABSL_SWISSTABLE_ASSERT(GetGrowthLeftLowerBound() >= - static_cast<size_t>(IsEmpty(ctrl))); - *growth_info_lower_bound_ -= static_cast<size_t>(IsEmpty(ctrl)); - } - - // Overwrites single full slot with a deleted slot. - void OverwriteFullAsDeleted() { - *growth_info_lower_bound_ |= GrowthInfoLowerBound::kDeletedBit; - } - - // Returns a GrowthInfoLowerBound object containing the information - // about minimum growth left. - GrowthInfoLowerBound GetGrowthInfoLowerBound() const { - return GrowthInfoLowerBound(*growth_info_lower_bound_); - } - - // Returns the minimum number of elements left to grow. - size_t GetGrowthLeftLowerBound() const { - return GetGrowthInfoLowerBound().GetGrowthLeft(); - } - - // The number of slots we can still fill without needing to rehash. - // Hot code paths should try to work with - // growth_info().GetGrowthLeftLowerBound() instead. - size_t GetGrowthLeftTotalSlow(size_t capacity) const; - - private: - void* full_growth_info_ptr() const { return growth_info_lower_bound_ - 7; } - - GrowthInfoLowerBound RebalanceGrowthLeftLowerBoundLargeCapacity(); - - // Pointer to the GrowthInfoLowerBound data. - // For large capacities, 7 bytes before this pointer is used to store - // the full growth info. - // NOTE: using a pointer here can result in the compiler being forced to - // assume aliasing can happen. So in hot code paths, we try to work with - // GrowthInfoLowerBound directly - uint8_t* growth_info_lower_bound_; -}; - // Returns the number of "cloned control bytes". // // This is the number of control bytes that are present both at the beginning @@ -1154,13 +1136,10 @@ } // Returns the size in bytes table with given capacity use to store GrowthInfo. -// Returns 0 for small tables that doesn't store GrowthInfo. +// Returns 0 for small tables that store GrowthInfo in the inline data. constexpr size_t GrowthInfoSizeForCapacity(size_t capacity) { - if (IsSmallCapacity(capacity)) { - return 0; - } return capacity <= GrowthInfoLowerBound::kMaxGrowthLeftLowerBound - ? sizeof(uint8_t) + ? 0 : sizeof(uint64_t); } @@ -1274,12 +1253,6 @@ unsigned char soo_data[MaxSooSlotSize()]; }; -// Returns a reference to the GrowthInfo object stored immediately before -// `control`. -inline GrowthInfoAccessor GetGrowthInfoFromControl(ctrl_t* control) { - return GrowthInfoAccessor(control); -} - // CommonFields hold the fields in raw_hash_set that do not depend // on template parameters. This allows us to conveniently pass all // of this state to helper functions as a single argument. @@ -1409,11 +1382,48 @@ } bool is_small() const { return inline_data_.is_small(); } - GrowthInfoAccessor growth_info() const { - ABSL_SWISSTABLE_ASSERT(GrowthInfoSizeForCapacity(capacity()) > 0); - return GetGrowthInfoFromControl(control()); + // Returns the GrowthInfoLowerBound of the table. + // This value is used to determine the minimum number of elements that can be + // inserted into the table before a rehash is required. + GrowthInfoLowerBound GetGrowthInfoLowerBound() const { + return inline_data_.growth_info_lower_bound(); } + // Returns the number of growth left in the lower bound of the table. + size_t GetGrowthLeftLowerBound() const { + return inline_data_.growth_info_lower_bound().GetGrowthLeft(); + } + + // The number of slots we can still fill without needing to rehash. + // Hot code paths should try to work with GetGrowthLeftLowerBound() instead. + size_t GetGrowthLeftTotalSlow(size_t capacity) const; + + // Initializes the GrowthInfo assuming we can grow `growth_left` elements + // and there are no kDeleted slots in the table. + void InitGrowthLeftNoDeleted(size_t growth_left, size_t capacity); + + // Modifies the GrowthInfo to mark full element as deleted. + void OverwriteFullAsDeleted() { inline_data_.overwrite_full_as_deleted(); } + + // Modifies the GrowthInfo to mark empty element as full. + // Requires: GetGrowthLeftLowerBound() > 0. + void OverwriteEmptyAsFull() { inline_data_.overwrite_empty_as_full(); } + + // Modifies the control byte to mark the element as full. + // Requires: GetGrowthLeftLowerBound() > IsEmpty(ctrl). + void OverwriteControlAsFull(ctrl_t ctrl) { + inline_data_.overwrite_control_as_full(ctrl); + } + + // Modifies the GrowthInfo to mark full element as empty. + void OverwriteFullAsEmpty(); + + // Returns a GrowthInfoLowerBound object containing the information + // about minimum growth left. + // It guarantees that GetGrowthLeft() will be > 0 if GetGrowthLeftTotal() > 0. + // It may optionally borrow some growth left from the full_growth_info. + GrowthInfoLowerBound RebalanceGrowthLeftLowerBound(size_t capacity); + bool has_infoz() const { return inline_data_.has_infoz(); } void set_has_infoz() { ABSL_SWISSTABLE_ASSERT(inline_data_.is_sampled_seed()); @@ -1509,6 +1519,26 @@ return (size_t{1} << HasInfozShift()) - 1; } + void* GrowthInfoOverflowAddress() const { + return reinterpret_cast<void*>( + reinterpret_cast<uintptr_t>(control()) - + /*growth_info_overflow_size=*/sizeof(uint64_t) - NumGenerationBytes()); + } + + size_t GetOverflowGrowthLeft() const { + ABSL_SWISSTABLE_ASSERT(capacity() > + GrowthInfoLowerBound::kMaxGrowthLeftLowerBound); + return base_internal::UnalignedLoad64(GrowthInfoOverflowAddress()); + } + + void SetGrowthInfoOverflow(size_t overflow) { + ABSL_SWISSTABLE_ASSERT(capacity() > + GrowthInfoLowerBound::kMaxGrowthLeftLowerBound); + base_internal::UnalignedStore64(GrowthInfoOverflowAddress(), overflow); + } + + GrowthInfoLowerBound RebalanceGrowthLeftLowerBoundLargeCapacity(); + // We can't assert that SOO is enabled because we don't have SooEnabled(), but // we assert what we can. void AssertInSooMode() const { @@ -2284,12 +2314,6 @@ 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), - // but it's a bit complicated if we want to support incomplete mapped_type in - // flat_hash_map. We could potentially do this for flat_hash_set and for an - // allowlist of `mapped_type`s of flat_hash_map that includes e.g. arithmetic - // types, strings, cords, and pairs/tuples of allowlisted types. constexpr static bool SooEnabled() { return PolicyTraits::soo_enabled() && sizeof(slot_type) <= sizeof(HeapOrSoo) && @@ -3834,8 +3858,6 @@ private: friend struct RawHashSetTestOnlyAccess; - GrowthInfoAccessor growth_info() const { return common().growth_info(); } - // Prefetch the heap-allocated memory region to resolve potential TLB and // cache misses. This is intended to overlap with execution of calculating the // hash for a key.
diff --git a/absl/container/internal/raw_hash_set_benchmark.cc b/absl/container/internal/raw_hash_set_benchmark.cc index 4c0a78a..58baabe 100644 --- a/absl/container/internal/raw_hash_set_benchmark.cc +++ b/absl/container/internal/raw_hash_set_benchmark.cc
@@ -17,7 +17,10 @@ #include <cmath> #include <cstddef> #include <cstdint> +#include <deque> +#include <functional> #include <limits> +#include <memory> #include <numeric> #include <random> #include <string> @@ -29,9 +32,12 @@ #include "absl/base/internal/raw_logging.h" #include "absl/container/internal/container_memory.h" #include "absl/container/internal/hash_function_defaults.h" +#include "absl/container/internal/hashtable_control_bytes.h" #include "absl/container/internal/raw_hash_set.h" +#include "absl/hash/hash.h" #include "absl/random/random.h" #include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" #include "benchmark/benchmark.h" namespace absl { @@ -164,6 +170,32 @@ using Base::Base; }; +struct MyInt { + int64_t value; +}; + +struct TransparentIntHash { + using is_transparent = void; + size_t operator()(int64_t x) const { return absl::Hash<int64_t>{}(x); } + size_t operator()(MyInt x) const { return absl::Hash<int64_t>{}(x.value); } +}; + +struct TransparentIntEq { + using is_transparent = void; + bool operator()(int64_t x, MyInt y) const { return x == y.value; } + bool operator()(MyInt x, MyInt y) const { return x.value == y.value; } + bool operator()(MyInt x, int64_t y) const { return x.value == y; } + bool operator()(int64_t x, int64_t y) const { return x == y; } +}; + +struct TransparentIntTable + : raw_hash_set<IntPolicy, TransparentIntHash, TransparentIntEq, + std::allocator<int64_t>> { + using Base = typename TransparentIntTable::raw_hash_set; + TransparentIntTable() = default; + using Base::Base; +}; + struct string_generator { template <class RNG> std::string operator()(RNG& rng) const { @@ -594,6 +626,20 @@ } BENCHMARK(BM_DropDeletes); +void BM_TransparentFind(benchmark::State& state) { + TransparentIntTable table; + for (int i = 0; i < 10000; ++i) { + table.insert(i); + } + while (state.KeepRunningBatch(10000)) { + for (int i = 0; i < 10000; ++i) { + auto it = table.find(MyInt{i}); + benchmark::DoNotOptimize(it); + } + } +} +BENCHMARK(BM_TransparentFind); + void BM_Resize(benchmark::State& state) { // For now just measure a small cheap hash table since we // are mostly interested in the overhead of type-erasure
diff --git a/absl/container/internal/raw_hash_set_test.cc b/absl/container/internal/raw_hash_set_test.cc index ec5ec30..06a73bf 100644 --- a/absl/container/internal/raw_hash_set_test.cc +++ b/absl/container/internal/raw_hash_set_test.cc
@@ -158,8 +158,7 @@ ASSERT_LE(capacity, GrowthInfoLowerBound::kMaxGrowthLeftLowerBound); RawHashSetLayout layout(capacity, slot_size, slot_align, has_infoz, blocked_element_count); - EXPECT_EQ(layout.control_offset(), - /*growth*/ 1 + padding + NumGenerationBytes()); + EXPECT_EQ(layout.control_offset(), padding + NumGenerationBytes()); size_t expected_slot_offset = layout.control_offset() + NumControlBytes(capacity); EXPECT_LT(padding, slot_align); @@ -172,17 +171,21 @@ TEST(RawHashSetLayout, MiddleSize) { VerifyMiddleSizeTableLayout(/*capacity=*/3, /*slot_size=*/4, + /*slot_align=*/1, /*has_infoz=*/false, + /*blocked_element_count=*/1, + /*padding=*/0); + VerifyMiddleSizeTableLayout(/*capacity=*/3, /*slot_size=*/4, /*slot_align=*/4, /*has_infoz=*/false, /*blocked_element_count=*/1, - /*padding=*/NumGenerationBytes() == 0 ? 0 : 3); + /*padding=*/NumGenerationBytes() == 0 ? 1 : 0); VerifyMiddleSizeTableLayout(/*capacity=*/7, /*slot_size=*/4, /*slot_align=*/4, /*has_infoz=*/false, /*blocked_element_count=*/1, - /*padding=*/NumGenerationBytes() == 0 ? 0 : 3); + /*padding=*/NumGenerationBytes() == 0 ? 1 : 0); VerifyMiddleSizeTableLayout(/*capacity=*/127, /*slot_size=*/8, /*slot_align=*/8, /*has_infoz=*/false, /*blocked_element_count=*/3, - /*padding=*/NumGenerationBytes() == 0 ? 0 : 7); + /*padding=*/NumGenerationBytes() == 0 ? 1 : 0); } #if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE) @@ -310,17 +313,22 @@ public: explicit GrowthInfoAllocator(size_t capacity) { if (capacity <= GrowthInfoLowerBound::kMaxGrowthLeftLowerBound) { - SanitizerPoisonMemoryRegion(control_.data(), 7); + SanitizerPoisonMemoryRegion(control_.data(), 8); } SanitizerPoisonMemoryRegion(control_.data() + kControlStart, 1); if constexpr (NumGenerationBytes() > 0) { - SanitizerPoisonMemoryRegion( - control_.data() + kControlStart + NumGenerationBytes(), - NumGenerationBytes()); + SanitizerPoisonMemoryRegion(control_.data() + 8, NumGenerationBytes()); } + common_fields_.set_capacity(capacity); + common_fields_.set_control(control_.data() + kControlStart); } - GrowthInfoAccessor* operator->() { return &growth_info_; } + ~GrowthInfoAllocator() { + SanitizerUnpoisonMemoryRegion(control_.data(), control_.size()); + } + + CommonFields* operator->() { return &common_fields_; } + const CommonFields* operator->() const { return &common_fields_; } private: static constexpr size_t kControlStart = 8 + NumGenerationBytes(); @@ -328,8 +336,7 @@ // on stack. std::vector<ctrl_t> control_ = std::vector<ctrl_t>( 9 + NumGenerationBytes(), /*garbage*/ ctrl_t::kSentinel); - GrowthInfoAccessor growth_info_ = - GrowthInfoAccessor(control_.data() + kControlStart); + CommonFields common_fields_ = CommonFields(non_soo_tag_t{}); }; TEST(GrowthInfoViewTest, GetGrowthLeft) { @@ -489,7 +496,7 @@ } TEST(GrowthInfoViewTest, BigCapacityGrowthOverflow) { - constexpr size_t kCapacity = 256; + constexpr size_t kCapacity = 255; for (bool has_deleted : {true, false}) { SCOPED_TRACE(testing::Message() << "has_deleted: " << has_deleted); GrowthInfoAllocator growth_info(kCapacity); @@ -526,7 +533,7 @@ } TEST(GrowthInfoViewTest, RebalanceOnInsert) { - constexpr size_t kCapacity = 512; + constexpr size_t kCapacity = 511; constexpr size_t kOrigGrowthLeft = 260; for (bool has_deleted : {false, true}) { SCOPED_TRACE(testing::Message() << "has_deleted: " << has_deleted); @@ -835,7 +842,7 @@ EXPECT_EQ(data.size(), 5); constexpr size_t kHugeIncrement = - (size_t(1) << (sizeof(size_t) == 4 ? 31 : 42)); + (size_t(1) << (sizeof(size_t) == 4 ? 31 : 39)); data.increment_size(kHugeIncrement); EXPECT_EQ(data.size(), kHugeIncrement + 5); @@ -1643,7 +1650,6 @@ // We want to test codepath deciding whether to rehash in place or not. // For this we need to potentially have tombstone. EXPECT_FALSE(RawHashSetTestOnlyAccess::GetCommon(t) - .growth_info() .GetGrowthInfoLowerBound() .HasNoDeleted()); for (int64_t i = static_cast<int64_t>(Group::kWidth); @@ -3452,19 +3458,16 @@ t.insert(i); } EXPECT_TRUE(RawHashSetTestOnlyAccess::GetCommon(t) - .growth_info() .GetGrowthInfoLowerBound() .HasNoDeleted()); t.erase(0); EXPECT_EQ(RawHashSetTestOnlyAccess::CountTombstones(t), 1); EXPECT_FALSE(RawHashSetTestOnlyAccess::GetCommon(t) - .growth_info() .GetGrowthInfoLowerBound() .HasNoDeleted()); t.rehash(0); EXPECT_EQ(RawHashSetTestOnlyAccess::CountTombstones(t), 0); EXPECT_TRUE(RawHashSetTestOnlyAccess::GetCommon(t) - .growth_info() .GetGrowthInfoLowerBound() .HasNoDeleted()); } @@ -5085,7 +5088,7 @@ } { - ABSL_ATTRIBUTE_UNUSED IntTable t1, t2, t3; + [[maybe_unused]] IntTable t1, t2, t3; t1.insert(1); t2 = std::move(t1); // NOLINTNEXTLINE(bugprone-use-after-move) @@ -5104,9 +5107,9 @@ EXPECT_DEATH_IF_SUPPORTED(t1.size(), "moved-from"); } { - ABSL_ATTRIBUTE_UNUSED IntTable t1; + [[maybe_unused]] IntTable t1; t1.insert(1); - ABSL_ATTRIBUTE_UNUSED IntTable t2(std::move(t1)); + [[maybe_unused]] IntTable t2(std::move(t1)); // NOLINTNEXTLINE(bugprone-use-after-move) EXPECT_DEATH_IF_SUPPORTED(t1.contains(1), "moved-from"); t1.clear(); // Clearing a moved-from table is allowed. @@ -5114,7 +5117,7 @@ { // Test that using a table (t3) that was moved-to from a moved-from table // (t1) fails. - ABSL_ATTRIBUTE_UNUSED IntTable t1, t2, t3; + [[maybe_unused]] IntTable t1, t2, t3; t1.insert(1); t2 = std::move(t1); // NOLINTNEXTLINE(bugprone-use-after-move) @@ -5202,6 +5205,34 @@ } }; +// We use unaligned value to verify that no padding is accidentally used during +// growth. +class UnalignedInt32 { + public: + UnalignedInt32() = default; + UnalignedInt32(uint32_t x) { // NOLINT: implicit conversion + std::memcpy(x_, &x, sizeof(uint32_t)); + } + + bool operator==(UnalignedInt32 other) const { + return static_cast<uint32_t>(*this) == static_cast<uint32_t>(other); + } + bool operator==(uint32_t other) const { + return static_cast<uint32_t>(*this) == other; + } + operator uint32_t() const { // NOLINT: implicit conversion + uint32_t result; + std::memcpy(&result, x_, 4); + return result; + } + + private: + uint8_t x_[4]; +}; + +static_assert(sizeof(UnalignedInt32) == 4); +static_assert(alignof(UnalignedInt32) == 1); + // This test is imitating growth of a very big table and triggers all buffer // overflows. // We try to insert all elements into the first probe group. @@ -5226,7 +5257,7 @@ NextCapacity(ProbedItem8Bytes::kMaxNewCapacity); #endif - absl::flat_hash_set<uint32_t, ZeroHash> t(63); + absl::flat_hash_set<UnalignedInt32, ZeroHash> t(21); CommonFields& common = RawHashSetTestOnlyAccess::GetCommon(t); // Set 0 seed so that H1 is always 0. common.set_no_seed_for_testing(); @@ -5244,8 +5275,7 @@ ASSERT_EQ(t.capacity(), cap); // Block upto 100 elements to test that kMarkedForSlowTransfer elements do // not conflict with blocked elements. - for (size_t i = cap - 1, - growth_left = common.growth_info().GetGrowthLeftTotalSlow(cap), + for (size_t i = cap - 1, growth_left = common.GetGrowthLeftTotalSlow(cap), blocked = 0; i > cap / 2; --i) { if (common.control()[i] == ctrl_t::kEmpty && growth_left > 1) { @@ -5257,7 +5287,7 @@ } // Update growth info to force resize on the next insert. This way we avoid // having to insert many elements. - common.growth_info().InitGrowthLeftNoDeleted(/*growth_left=*/0, cap); + common.InitGrowthLeftNoDeleted(/*growth_left=*/0, cap); t.insert(inserted_till++); ASSERT_EQ(t.capacity(), NextCapacity(cap)); for (uint8_t i = 0; i < inserted_till; ++i) {
diff --git a/absl/container/internal/test_instance_tracker.h b/absl/container/internal/test_instance_tracker.h index 5ff6fd7..ab1e3bc 100644 --- a/absl/container/internal/test_instance_tracker.h +++ b/absl/container/internal/test_instance_tracker.h
@@ -17,6 +17,7 @@ #include <cstdlib> #include <ostream> +#include <utility> #include "absl/types/compare.h"
diff --git a/absl/container/internal/test_instance_tracker_test.cc b/absl/container/internal/test_instance_tracker_test.cc index 1c6a4fa..58f1bfb 100644 --- a/absl/container/internal/test_instance_tracker_test.cc +++ b/absl/container/internal/test_instance_tracker_test.cc
@@ -14,6 +14,8 @@ #include "absl/container/internal/test_instance_tracker.h" +#include <utility> + #include "gtest/gtest.h" namespace {
diff --git a/absl/container/internal/unordered_map_constructor_test.h b/absl/container/internal/unordered_map_constructor_test.h index 1076aea..fcbcbd9 100644 --- a/absl/container/internal/unordered_map_constructor_test.h +++ b/absl/container/internal/unordered_map_constructor_test.h
@@ -16,6 +16,8 @@ #define ABSL_CONTAINER_INTERNAL_UNORDERED_MAP_CONSTRUCTOR_TEST_H_ #include <algorithm> +#include <cstddef> +#include <initializer_list> #include <unordered_map> #include <vector>
diff --git a/absl/container/internal/unordered_map_lookup_test.h b/absl/container/internal/unordered_map_lookup_test.h index ba037c0..6405ae4 100644 --- a/absl/container/internal/unordered_map_lookup_test.h +++ b/absl/container/internal/unordered_map_lookup_test.h
@@ -15,6 +15,8 @@ #ifndef ABSL_CONTAINER_INTERNAL_UNORDERED_MAP_LOOKUP_TEST_H_ #define ABSL_CONTAINER_INTERNAL_UNORDERED_MAP_LOOKUP_TEST_H_ +#include <vector> + #include "gmock/gmock.h" #include "gtest/gtest.h" #include "absl/container/internal/hash_generator_testing.h"
diff --git a/absl/container/internal/unordered_map_members_test.h b/absl/container/internal/unordered_map_members_test.h index e9f4979..6d7ebca 100644 --- a/absl/container/internal/unordered_map_members_test.h +++ b/absl/container/internal/unordered_map_members_test.h
@@ -15,7 +15,11 @@ #ifndef ABSL_CONTAINER_INTERNAL_UNORDERED_MAP_MEMBERS_TEST_H_ #define ABSL_CONTAINER_INTERNAL_UNORDERED_MAP_MEMBERS_TEST_H_ +#include <cstddef> +#include <memory> #include <type_traits> +#include <utility> + #include "gmock/gmock.h" #include "gtest/gtest.h" #include "absl/meta/type_traits.h"
diff --git a/absl/container/internal/unordered_map_modifiers_test.h b/absl/container/internal/unordered_map_modifiers_test.h index bb41e07..38605d8 100644 --- a/absl/container/internal/unordered_map_modifiers_test.h +++ b/absl/container/internal/unordered_map_modifiers_test.h
@@ -15,8 +15,10 @@ #ifndef ABSL_CONTAINER_INTERNAL_UNORDERED_MAP_MODIFIERS_TEST_H_ #define ABSL_CONTAINER_INTERNAL_UNORDERED_MAP_MODIFIERS_TEST_H_ +#include <cstddef> #include <memory> #include <type_traits> +#include <vector> #include "gmock/gmock.h" #include "gtest/gtest.h"
diff --git a/absl/container/internal/unordered_map_test.cc b/absl/container/internal/unordered_map_test.cc index 9cbf512..badd6b2 100644 --- a/absl/container/internal/unordered_map_test.cc +++ b/absl/container/internal/unordered_map_test.cc
@@ -13,8 +13,12 @@ // limitations under the License. #include <memory> +#include <string> #include <unordered_map> +#include <utility> +#include "gtest/gtest.h" +#include "absl/container/internal/hash_policy_testing.h" #include "absl/container/internal/unordered_map_constructor_test.h" #include "absl/container/internal/unordered_map_lookup_test.h" #include "absl/container/internal/unordered_map_members_test.h"
diff --git a/absl/container/internal/unordered_set_constructor_test.h b/absl/container/internal/unordered_set_constructor_test.h index 7038a0c..47b59f3 100644 --- a/absl/container/internal/unordered_set_constructor_test.h +++ b/absl/container/internal/unordered_set_constructor_test.h
@@ -16,6 +16,8 @@ #define ABSL_CONTAINER_INTERNAL_UNORDERED_SET_CONSTRUCTOR_TEST_H_ #include <algorithm> +#include <cstddef> +#include <initializer_list> #include <unordered_set> #include <vector>
diff --git a/absl/container/internal/unordered_set_lookup_test.h b/absl/container/internal/unordered_set_lookup_test.h index 932c320..4edb962 100644 --- a/absl/container/internal/unordered_set_lookup_test.h +++ b/absl/container/internal/unordered_set_lookup_test.h
@@ -15,6 +15,9 @@ #ifndef ABSL_CONTAINER_INTERNAL_UNORDERED_SET_LOOKUP_TEST_H_ #define ABSL_CONTAINER_INTERNAL_UNORDERED_SET_LOOKUP_TEST_H_ +#include <type_traits> +#include <vector> + #include "gmock/gmock.h" #include "gtest/gtest.h" #include "absl/container/internal/hash_generator_testing.h"
diff --git a/absl/container/internal/unordered_set_members_test.h b/absl/container/internal/unordered_set_members_test.h index b416fef..6cc173b 100644 --- a/absl/container/internal/unordered_set_members_test.h +++ b/absl/container/internal/unordered_set_members_test.h
@@ -15,7 +15,10 @@ #ifndef ABSL_CONTAINER_INTERNAL_UNORDERED_SET_MEMBERS_TEST_H_ #define ABSL_CONTAINER_INTERNAL_UNORDERED_SET_MEMBERS_TEST_H_ +#include <cstddef> +#include <memory> #include <type_traits> + #include "gmock/gmock.h" #include "gtest/gtest.h" #include "absl/meta/type_traits.h"
diff --git a/absl/container/internal/unordered_set_modifiers_test.h b/absl/container/internal/unordered_set_modifiers_test.h index 1d686af..e7ed774 100644 --- a/absl/container/internal/unordered_set_modifiers_test.h +++ b/absl/container/internal/unordered_set_modifiers_test.h
@@ -15,7 +15,9 @@ #ifndef ABSL_CONTAINER_INTERNAL_UNORDERED_SET_MODIFIERS_TEST_H_ #define ABSL_CONTAINER_INTERNAL_UNORDERED_SET_MODIFIERS_TEST_H_ +#include <cstddef> #include <type_traits> +#include <vector> #include "gmock/gmock.h" #include "gtest/gtest.h"
diff --git a/absl/container/internal/unordered_set_test.cc b/absl/container/internal/unordered_set_test.cc index a134b53..d03403b 100644 --- a/absl/container/internal/unordered_set_test.cc +++ b/absl/container/internal/unordered_set_test.cc
@@ -12,8 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include <string> #include <unordered_set> +#include "gtest/gtest.h" +#include "absl/container/internal/hash_policy_testing.h" #include "absl/container/internal/unordered_set_constructor_test.h" #include "absl/container/internal/unordered_set_lookup_test.h" #include "absl/container/internal/unordered_set_members_test.h"
diff --git a/absl/container/sample_element_size_test.cc b/absl/container/sample_element_size_test.cc index 9ce19fe..2993f2a 100644 --- a/absl/container/sample_element_size_test.cc +++ b/absl/container/sample_element_size_test.cc
@@ -13,6 +13,7 @@ // limitations under the License. #include <cstddef> +#include <cstring> #include <unordered_set> #include <utility> #include <vector>
diff --git a/absl/crc/BUILD.bazel b/absl/crc/BUILD.bazel index 88b9ea2..10b5a5f 100644 --- a/absl/crc/BUILD.bazel +++ b/absl/crc/BUILD.bazel
@@ -84,8 +84,8 @@ "//absl/base:cpu_detect", "//absl/base:endian", "//absl/base:prefetch", - "//absl/strings", "//absl/strings:str_format", + "//absl/strings:string_view", ], ) @@ -99,6 +99,7 @@ ":crc32c", "//absl/strings", "//absl/strings:str_format", + "//absl/strings:string_view", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -146,6 +147,7 @@ "//absl/random", "//absl/random:distributions", "//absl/strings", + "//absl/strings:string_view", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -206,7 +208,7 @@ deps = [ ":crc32c", "//absl/memory", - "//absl/strings", + "//absl/strings:string_view", "@google_benchmark//:benchmark_main", ], )
diff --git a/absl/crc/CMakeLists.txt b/absl/crc/CMakeLists.txt index 28f0bab..4269396 100644 --- a/absl/crc/CMakeLists.txt +++ b/absl/crc/CMakeLists.txt
@@ -53,14 +53,14 @@ ${ABSL_DEFAULT_COPTS} DEPS absl::base_cpu_detect - absl::crc_internal - absl::non_temporal_memcpy absl::config absl::core_headers + absl::crc_internal absl::endian + absl::non_temporal_memcpy absl::prefetch absl::str_format - absl::strings + absl::string_view ) absl_cc_test( @@ -72,8 +72,9 @@ ${ABSL_DEFAULT_COPTS} DEPS absl::crc32c - absl::strings absl::str_format + absl::string_view + absl::strings GTest::gtest_main ) @@ -98,9 +99,9 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS - absl::non_temporal_arm_intrinsics absl::config absl::core_headers + absl::non_temporal_arm_intrinsics ) absl_cc_test( @@ -113,8 +114,9 @@ DEPS absl::crc32c absl::memory - absl::random_random absl::random_distributions + absl::random_random + absl::string_view absl::strings GTest::gtest_main ) @@ -141,10 +143,10 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS - absl::crc32c absl::config - absl::strings + absl::crc32c absl::no_destructor + absl::strings ) absl_cc_test( @@ -155,7 +157,7 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS - absl::crc_cord_state absl::crc32c + absl::crc_cord_state GTest::gtest_main )
diff --git a/absl/debugging/BUILD.bazel b/absl/debugging/BUILD.bazel index d3eb74d..6230d39 100644 --- a/absl/debugging/BUILD.bazel +++ b/absl/debugging/BUILD.bazel
@@ -115,6 +115,7 @@ "//absl/base:malloc_internal", "//absl/base:raw_logging_internal", "//absl/strings", + "//absl/strings:string_view", ], ) @@ -144,6 +145,7 @@ "//absl/memory", "//absl/strings", "//absl/strings:str_format", + "//absl/strings:string_view", "@googletest//:gtest", ], )
diff --git a/absl/debugging/CMakeLists.txt b/absl/debugging/CMakeLists.txt index fbdb550..247e82f 100644 --- a/absl/debugging/CMakeLists.txt +++ b/absl/debugging/CMakeLists.txt
@@ -38,9 +38,9 @@ LINKOPTS $<$<BOOL:${EXECINFO_LIBRARY}>:${EXECINFO_LIBRARY}> DEPS - absl::debugging_internal absl::config absl::core_headers + absl::debugging_internal absl::dynamic_annotations absl::malloc_internal absl::raw_logging_internal @@ -55,11 +55,11 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::stacktrace absl::config absl::core_headers absl::errno_saver absl::span + absl::stacktrace GTest::gmock_main ) @@ -82,14 +82,15 @@ ${ABSL_DEFAULT_LINKOPTS} $<$<BOOL:${MINGW}>:-ldbghelp> DEPS - absl::debugging_internal - absl::demangle_internal absl::base absl::config absl::core_headers + absl::debugging_internal + absl::demangle_internal absl::dynamic_annotations absl::malloc_internal absl::raw_logging_internal + absl::string_view absl::strings PUBLIC ) @@ -114,8 +115,8 @@ absl::malloc_internal absl::memory absl::stack_consumption - absl::strings absl::str_format + absl::string_view absl::symbolize GTest::gmock ) @@ -131,11 +132,11 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS - absl::stacktrace - absl::symbolize absl::config absl::core_headers absl::raw_logging_internal + absl::stacktrace + absl::symbolize ) absl_cc_library( @@ -148,12 +149,12 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS - absl::examine_stack - absl::stacktrace absl::base absl::config absl::core_headers + absl::examine_stack absl::raw_logging_internal + absl::stacktrace PUBLIC ) @@ -167,10 +168,10 @@ DEPS absl::check absl::failure_signal_handler - absl::stacktrace - absl::symbolize - absl::strings absl::raw_logging_internal + absl::stacktrace + absl::strings + absl::symbolize Threads::Threads GTest::gmock ) @@ -191,8 +192,8 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS - absl::core_headers absl::config + absl::core_headers absl::dynamic_annotations absl::errno_saver absl::raw_logging_internal @@ -222,12 +223,12 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::demangle_internal - absl::stack_consumption absl::config absl::core_headers + absl::demangle_internal absl::log absl::memory + absl::stack_consumption GTest::gmock_main ) @@ -282,8 +283,8 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::decode_rust_punycode absl::config + absl::decode_rust_punycode GTest::gmock_main ) @@ -311,8 +312,8 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::demangle_rust absl::config + absl::demangle_rust GTest::gmock_main ) @@ -338,8 +339,8 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::utf8_for_code_point absl::config + absl::utf8_for_code_point GTest::gmock_main ) @@ -368,8 +369,8 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS - absl::leak_check absl::base + absl::leak_check absl::log GTest::gmock_main ) @@ -399,9 +400,9 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::stack_consumption absl::core_headers absl::log + absl::stack_consumption GTest::gmock_main ) @@ -412,7 +413,7 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS - absl::stacktrace absl::leak_check + absl::stacktrace PUBLIC )
diff --git a/absl/debugging/failure_signal_handler.cc b/absl/debugging/failure_signal_handler.cc index e15d49d..6d98d39 100644 --- a/absl/debugging/failure_signal_handler.cc +++ b/absl/debugging/failure_signal_handler.cc
@@ -219,7 +219,7 @@ // if the system supports using an alternate stack. static int MaybeSetupAlternateStack() { #ifdef ABSL_HAVE_SIGALTSTACK - ABSL_ATTRIBUTE_UNUSED static const bool kOnce = SetupAlternateStackOnce(); + [[maybe_unused]] static const bool kOnce = SetupAlternateStackOnce(); return SA_ONSTACK; #else return 0;
diff --git a/absl/debugging/stacktrace_test.cc b/absl/debugging/stacktrace_test.cc index 0bf94f7..02950bc 100644 --- a/absl/debugging/stacktrace_test.cc +++ b/absl/debugging/stacktrace_test.cc
@@ -68,7 +68,7 @@ // This test is currently only known to pass on Linux x86_64/aarch64. #if defined(__linux__) && (defined(__x86_64__) || defined(__aarch64__)) ABSL_ATTRIBUTE_NOINLINE void Unwind(void* p) { - ABSL_ATTRIBUTE_UNUSED static void* volatile sink = p; + [[maybe_unused]] static void* volatile sink = p; constexpr int kSize = 16; void* stack[kSize]; int frames[kSize];
diff --git a/absl/flags/BUILD.bazel b/absl/flags/BUILD.bazel index 4dd3b33..59cae99 100644 --- a/absl/flags/BUILD.bazel +++ b/absl/flags/BUILD.bazel
@@ -48,7 +48,7 @@ ], deps = [ "//absl/base:config", - "//absl/strings", + "//absl/strings:string_view", ], ) @@ -72,7 +72,7 @@ "//absl/base:config", "//absl/base:core_headers", "//absl/base:no_destructor", - "//absl/strings", + "//absl/strings:string_view", "//absl/synchronization", ], ) @@ -96,6 +96,7 @@ "//absl/base:core_headers", "//absl/base:no_destructor", "//absl/strings", + "//absl/strings:string_view", "//absl/synchronization", ], ) @@ -118,6 +119,7 @@ "//absl/numeric:int128", "//absl/strings", "//absl/strings:str_format", + "//absl/strings:string_view", "//absl/types:optional", ], ) @@ -157,7 +159,7 @@ "//absl/base:config", "//absl/base:fast_type_id", "//absl/base:nullability", - "//absl/strings", + "//absl/strings:string_view", "//absl/types:optional", ], ) @@ -181,7 +183,7 @@ ":commandlineflag", ":commandlineflag_internal", "//absl/base:config", - "//absl/strings", + "//absl/strings:string_view", ], ) @@ -208,6 +210,7 @@ "//absl/base:no_destructor", "//absl/container:flat_hash_map", "//absl/strings", + "//absl/strings:string_view", "//absl/synchronization", ], ) @@ -239,6 +242,7 @@ "//absl/memory", "//absl/meta:type_traits", "//absl/strings", + "//absl/strings:string_view", "//absl/synchronization", "//absl/utility", ], @@ -261,7 +265,7 @@ "//absl/base:config", "//absl/base:core_headers", "//absl/base:nullability", - "//absl/strings", + "//absl/strings:string_view", ], ) @@ -292,6 +296,7 @@ "//absl/base:core_headers", "//absl/base:no_destructor", "//absl/strings", + "//absl/strings:string_view", "//absl/synchronization", ], ) @@ -312,7 +317,7 @@ "//absl/base:config", "//absl/base:core_headers", "//absl/base:raw_logging_internal", - "//absl/strings", + "//absl/strings:string_view", "//absl/synchronization", ], ) @@ -343,6 +348,7 @@ "//absl/base:core_headers", "//absl/base:no_destructor", "//absl/strings", + "//absl/strings:string_view", "//absl/synchronization", ], ) @@ -373,6 +379,7 @@ ":reflection", "//absl/memory", "//absl/strings", + "//absl/strings:string_view", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -421,6 +428,7 @@ "//absl/base:raw_logging_internal", "//absl/numeric:int128", "//absl/strings", + "//absl/strings:string_view", "//absl/time", "@googletest//:gtest", "@googletest//:gtest_main", @@ -445,7 +453,7 @@ ":marshalling", ":parse", ":reflection", - "//absl/strings", + "//absl/strings:string_view", "//absl/time", "@google_benchmark//:benchmark_main", ], @@ -461,6 +469,7 @@ linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":marshalling", + "//absl/numeric:int128", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -491,6 +500,7 @@ "//absl/base:scoped_set_env", "//absl/log", "//absl/strings", + "//absl/strings:string_view", "//absl/types:span", "@googletest//:gtest", "@googletest//:gtest_main", @@ -527,6 +537,7 @@ deps = [ ":program_name", "//absl/strings", + "//absl/strings:string_view", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -553,6 +564,8 @@ ":reflection", "//absl/memory", "//absl/strings", + "//absl/strings:string_view", + "//absl/time", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -592,6 +605,7 @@ ":path_util", ":program_name", "//absl/strings", + "//absl/strings:string_view", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -622,6 +636,7 @@ ":usage", ":usage_internal", "//absl/strings", + "//absl/strings:string_view", "@googletest//:gtest", ], )
diff --git a/absl/flags/CMakeLists.txt b/absl/flags/CMakeLists.txt index 0c75c93..a96e294 100644 --- a/absl/flags/CMakeLists.txt +++ b/absl/flags/CMakeLists.txt
@@ -26,7 +26,7 @@ ${ABSL_DEFAULT_LINKOPTS} DEPS absl::config - absl::strings + absl::string_view PUBLIC ) @@ -34,10 +34,10 @@ absl_cc_library( NAME flags_program_name - SRCS - "internal/program_name.cc" HDRS "internal/program_name.h" + SRCS + "internal/program_name.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -45,9 +45,9 @@ DEPS absl::config absl::core_headers - absl::no_destructor absl::flags_path_util - absl::strings + absl::no_destructor + absl::string_view absl::synchronization PUBLIC ) @@ -55,10 +55,10 @@ absl_cc_library( NAME flags_config - SRCS - "usage_config.cc" HDRS "config.h" + SRCS + "usage_config.cc" "usage_config.h" COPTS ${ABSL_DEFAULT_COPTS} @@ -66,10 +66,11 @@ ${ABSL_DEFAULT_LINKOPTS} DEPS absl::config + absl::core_headers absl::flags_path_util absl::flags_program_name - absl::core_headers absl::no_destructor + absl::string_view absl::strings absl::synchronization ) @@ -77,10 +78,10 @@ absl_cc_library( NAME flags_marshalling - SRCS - "marshalling.cc" HDRS "marshalling.h" + SRCS + "marshalling.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -88,21 +89,22 @@ DEPS absl::config absl::core_headers - absl::log_severity absl::int128 + absl::log_severity absl::optional - absl::strings absl::str_format + absl::string_view + absl::strings ) # Internal-only target, do not depend on directly. absl_cc_library( NAME flags_commandlineflag_internal - SRCS - "internal/commandlineflag.cc" HDRS "internal/commandlineflag.h" + SRCS + "internal/commandlineflag.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -116,10 +118,10 @@ absl_cc_library( NAME flags_commandlineflag - SRCS - "commandlineflag.cc" HDRS "commandlineflag.h" + SRCS + "commandlineflag.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -130,17 +132,17 @@ absl::flags_commandlineflag_internal absl::nullability absl::optional - absl::strings + absl::string_view ) # Internal-only target, do not depend on directly. absl_cc_library( NAME flags_private_handle_accessor - SRCS - "internal/private_handle_accessor.cc" HDRS "internal/private_handle_accessor.h" + SRCS + "internal/private_handle_accessor.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -149,16 +151,16 @@ absl::config absl::flags_commandlineflag absl::flags_commandlineflag_internal - absl::strings + absl::string_view ) absl_cc_library( NAME flags_reflection - SRCS - "reflection.cc" HDRS "reflection.h" + SRCS + "reflection.cc" "internal/registry.h" COPTS ${ABSL_DEFAULT_COPTS} @@ -168,22 +170,23 @@ absl::config absl::fast_type_id absl::flags_commandlineflag - absl::flags_private_handle_accessor absl::flags_config - absl::strings - absl::synchronization + absl::flags_private_handle_accessor absl::flat_hash_map absl::no_destructor + absl::string_view + absl::strings + absl::synchronization ) # Internal-only target, do not depend on directly. absl_cc_library( NAME flags_internal - SRCS - "internal/flag.cc" HDRS "internal/flag.h" + SRCS + "internal/flag.cc" "internal/sequence_lock.h" COPTS ${ABSL_DEFAULT_COPTS} @@ -197,9 +200,9 @@ absl::flags_commandlineflag_internal absl::flags_config absl::flags_marshalling + absl::meta absl::no_destructor absl::synchronization - absl::meta absl::utility PUBLIC ) @@ -216,11 +219,11 @@ ${ABSL_DEFAULT_LINKOPTS} DEPS absl::config + absl::core_headers absl::flags_commandlineflag absl::flags_config absl::flags_internal absl::flags_reflection - absl::core_headers absl::nullability absl::strings ) @@ -229,24 +232,25 @@ absl_cc_library( NAME flags_usage_internal - SRCS - "internal/usage.cc" HDRS "internal/usage.h" + SRCS + "internal/usage.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS absl::config - absl::flags_config absl::flags absl::flags_commandlineflag + absl::flags_config absl::flags_internal absl::flags_path_util absl::flags_private_handle_accessor absl::flags_program_name absl::flags_reflection + absl::string_view absl::strings absl::synchronization ) @@ -254,10 +258,10 @@ absl_cc_library( NAME flags_usage - SRCS - "usage.cc" HDRS "usage.h" + SRCS + "usage.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -268,17 +272,17 @@ absl::flags_usage_internal absl::no_destructor absl::raw_logging_internal - absl::strings + absl::string_view absl::synchronization ) absl_cc_library( NAME flags_parse - SRCS - "parse.cc" HDRS "internal/parse.h" + SRCS + "parse.cc" "parse.h" COPTS ${ABSL_DEFAULT_COPTS} @@ -288,16 +292,17 @@ absl::algorithm_container absl::config absl::core_headers - absl::flags_config absl::flags absl::flags_commandlineflag absl::flags_commandlineflag_internal + absl::flags_config absl::flags_internal absl::flags_private_handle_accessor absl::flags_program_name absl::flags_reflection absl::flags_usage absl::no_destructor + absl::string_view absl::strings absl::synchronization ) @@ -319,6 +324,7 @@ absl::flags_private_handle_accessor absl::flags_reflection absl::memory + absl::string_view absl::strings GTest::gtest_main ) @@ -353,6 +359,7 @@ absl::flags_reflection absl::int128 absl::raw_logging_internal + absl::string_view absl::strings absl::time GTest::gtest_main @@ -386,6 +393,7 @@ absl::log absl::scoped_set_env absl::span + absl::string_view absl::strings GTest::gmock_main ) @@ -411,6 +419,7 @@ ${ABSL_TEST_COPTS} DEPS absl::flags_program_name + absl::string_view absl::strings GTest::gtest_main ) @@ -428,6 +437,7 @@ absl::flags_reflection absl::flags_usage absl::memory + absl::string_view absl::strings GTest::gmock_main ) @@ -457,6 +467,7 @@ absl::flags_config absl::flags_path_util absl::flags_program_name + absl::string_view absl::strings GTest::gtest_main ) @@ -469,13 +480,14 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::flags_config absl::flags + absl::flags_config + absl::flags_parse absl::flags_path_util absl::flags_program_name - absl::flags_parse absl::flags_reflection absl::flags_usage + absl::string_view absl::strings GTest::gmock )
diff --git a/absl/flags/flag.h b/absl/flags/flag.h index 4c328e3..2a95049 100644 --- a/absl/flags/flag.h +++ b/absl/flags/flag.h
@@ -300,7 +300,7 @@ // retired flags are cleaned up. #define ABSL_RETIRED_FLAG(type, name, default_value, explanation) \ static absl::flags_internal::RetiredFlag<type> RETIRED_FLAGS_##name; \ - ABSL_ATTRIBUTE_UNUSED static const auto RETIRED_FLAGS_REG_##name = \ + [[maybe_unused]] static const auto RETIRED_FLAGS_REG_##name = \ (RETIRED_FLAGS_##name.Retire(#name), \ ::absl::flags_internal::FlagRegistrarEmpty{})
diff --git a/absl/flags/flag_benchmark.cc b/absl/flags/flag_benchmark.cc index bbe9cba..be435d9 100644 --- a/absl/flags/flag_benchmark.cc +++ b/absl/flags/flag_benchmark.cc
@@ -15,6 +15,7 @@ #include <stdint.h> +#include <cstddef> #include <optional> #include <string> #include <vector>
diff --git a/absl/flags/flag_test.cc b/absl/flags/flag_test.cc index 1dd2f5c..7cbce88 100644 --- a/absl/flags/flag_test.cc +++ b/absl/flags/flag_test.cc
@@ -937,7 +937,7 @@ namespace { -bool initialization_order_fiasco_test ABSL_ATTRIBUTE_UNUSED = [] { +bool initialization_order_fiasco_test [[maybe_unused]] = [] { // Iterate over all the flags during static initialization. // This should not trigger ASan's initialization-order-fiasco. auto* handle1 = absl::FindCommandLineFlag("flag_on_separate_file");
diff --git a/absl/flags/internal/registry.h b/absl/flags/internal/registry.h index be9aacc..a1f4a82 100644 --- a/absl/flags/internal/registry.h +++ b/absl/flags/internal/registry.h
@@ -16,6 +16,7 @@ #ifndef ABSL_FLAGS_INTERNAL_REGISTRY_H_ #define ABSL_FLAGS_INTERNAL_REGISTRY_H_ +#include <cstddef> #include <functional> #include "absl/base/config.h"
diff --git a/absl/flags/internal/sequence_lock_test.cc b/absl/flags/internal/sequence_lock_test.cc index a244d67..79b301f 100644 --- a/absl/flags/internal/sequence_lock_test.cc +++ b/absl/flags/internal/sequence_lock_test.cc
@@ -15,6 +15,7 @@ #include <algorithm> #include <atomic> +#include <cstdint> #include <thread> // NOLINT(build/c++11) #include <tuple> #include <vector> @@ -23,6 +24,7 @@ #include "absl/base/internal/sysinfo.h" #include "absl/container/fixed_array.h" #include "absl/time/clock.h" +#include "absl/time/time.h" namespace {
diff --git a/absl/flags/marshalling_test.cc b/absl/flags/marshalling_test.cc index a5faabc..9629744 100644 --- a/absl/flags/marshalling_test.cc +++ b/absl/flags/marshalling_test.cc
@@ -24,6 +24,7 @@ #include <vector> #include "gtest/gtest.h" +#include "absl/numeric/int128.h" namespace {
diff --git a/absl/flags/parse.h b/absl/flags/parse.h index fdb3d1e..b1a4109 100644 --- a/absl/flags/parse.h +++ b/absl/flags/parse.h
@@ -28,6 +28,7 @@ #include "absl/base/config.h" #include "absl/flags/internal/parse.h" +#include "absl/strings/string_view.h" namespace absl { ABSL_NAMESPACE_BEGIN
diff --git a/absl/flags/reflection.cc b/absl/flags/reflection.cc index e92ff96..0729ba0 100644 --- a/absl/flags/reflection.cc +++ b/absl/flags/reflection.cc
@@ -17,9 +17,14 @@ #include <assert.h> +#include <algorithm> #include <atomic> +#include <cstdlib> +#include <functional> +#include <memory> #include <string> #include <utility> +#include <vector> #include "absl/base/config.h" #include "absl/base/no_destructor.h"
diff --git a/absl/flags/reflection.h b/absl/flags/reflection.h index e6baf5d..54b3e9a 100644 --- a/absl/flags/reflection.h +++ b/absl/flags/reflection.h
@@ -29,6 +29,7 @@ #include "absl/container/flat_hash_map.h" #include "absl/flags/commandlineflag.h" #include "absl/flags/internal/commandlineflag.h" +#include "absl/strings/string_view.h" namespace absl { ABSL_NAMESPACE_BEGIN
diff --git a/absl/flags/reflection_test.cc b/absl/flags/reflection_test.cc index 996a458..99a3525 100644 --- a/absl/flags/reflection_test.cc +++ b/absl/flags/reflection_test.cc
@@ -15,16 +15,21 @@ #include "absl/flags/reflection.h" +#include <cstdint> #include <memory> #include <string> +#include <vector> #include "gmock/gmock.h" #include "gtest/gtest.h" #include "absl/flags/config.h" #include "absl/flags/flag.h" #include "absl/memory/memory.h" +#include "absl/strings/numbers.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_split.h" +#include "absl/strings/string_view.h" +#include "absl/time/time.h" ABSL_FLAG(int, int_flag, 1, "int_flag help"); ABSL_FLAG(std::string, string_flag, "dflt", "string_flag help");
diff --git a/absl/flags/usage.cc b/absl/flags/usage.cc index e42b454..46e7524 100644 --- a/absl/flags/usage.cc +++ b/absl/flags/usage.cc
@@ -16,6 +16,7 @@ #include <stdlib.h> +#include <cstdlib> #include <string> #include "absl/base/attributes.h"
diff --git a/absl/functional/CMakeLists.txt b/absl/functional/CMakeLists.txt index 7780174..1ddfa29 100644 --- a/absl/functional/CMakeLists.txt +++ b/absl/functional/CMakeLists.txt
@@ -17,10 +17,10 @@ absl_cc_library( NAME any_invocable - SRCS - "internal/any_invocable.h" HDRS "any_invocable.h" + SRCS + "internal/any_invocable.h" COPTS ${ABSL_DEFAULT_COPTS} DEPS @@ -56,10 +56,10 @@ absl_cc_library( NAME bind_back - SRCS - "internal/back_binder.h" HDRS "bind_back.h" + SRCS + "internal/back_binder.h" COPTS ${ABSL_DEFAULT_COPTS} DEPS @@ -85,10 +85,10 @@ absl_cc_library( NAME bind_front - SRCS - "internal/front_binder.h" HDRS "bind_front.h" + SRCS + "internal/front_binder.h" COPTS ${ABSL_DEFAULT_COPTS} DEPS @@ -112,16 +112,16 @@ absl_cc_library( NAME function_ref - SRCS - "internal/function_ref.h" HDRS "function_ref.h" + SRCS + "internal/function_ref.h" COPTS ${ABSL_DEFAULT_COPTS} DEPS + absl::any_invocable absl::config absl::core_headers - absl::any_invocable absl::meta absl::utility PUBLIC
diff --git a/absl/hash/BUILD.bazel b/absl/hash/BUILD.bazel index 41d7d68..b264ebf 100644 --- a/absl/hash/BUILD.bazel +++ b/absl/hash/BUILD.bazel
@@ -57,7 +57,7 @@ "//absl/meta:type_traits", "//absl/numeric:bits", "//absl/numeric:int128", - "//absl/strings", + "//absl/strings:string_view", "//absl/types:optional", "//absl/types:variant", "//absl/utility", @@ -141,9 +141,9 @@ "//absl/base:core_headers", "//absl/container:flat_hash_set", "//absl/random", - "//absl/strings", "//absl/strings:cord", "//absl/strings:cord_test_helpers", + "//absl/strings:string_view", "@google_benchmark//:benchmark_main", ], ) @@ -218,6 +218,7 @@ deps = [ ":hash", "//absl/strings", + "//absl/strings:string_view", "@googletest//:gtest", "@googletest//:gtest_main", ],
diff --git a/absl/hash/CMakeLists.txt b/absl/hash/CMakeLists.txt index c593a5b..0c7e7f4 100644 --- a/absl/hash/CMakeLists.txt +++ b/absl/hash/CMakeLists.txt
@@ -32,12 +32,12 @@ absl::endian absl::fixed_array absl::function_ref - absl::meta absl::int128 - absl::strings + absl::meta absl::optional - absl::variant + absl::string_view absl::utility + absl::variant absl::weakly_mixed_integer PUBLIC ) @@ -50,8 +50,8 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::spy_hash_state absl::meta + absl::spy_hash_state absl::strings absl::variant GTest::gmock @@ -90,12 +90,12 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::hash - absl::hash_testing - absl::config absl::btree + absl::config absl::flat_hash_map absl::flat_hash_set + absl::hash + absl::hash_testing absl::node_hash_map absl::node_hash_set GTest::gmock_main @@ -115,8 +115,8 @@ ${ABSL_DEFAULT_COPTS} DEPS absl::hash - absl::strings absl::str_format + absl::strings absl::weakly_mixed_integer TESTONLY PUBLIC @@ -133,9 +133,9 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS + absl::bits absl::config absl::core_headers - absl::bits absl::endian ) @@ -172,6 +172,7 @@ ${ABSL_TEST_COPTS} DEPS absl::hash + absl::string_view absl::strings GTest::gmock_main )
diff --git a/absl/hash/hash_benchmark.cc b/absl/hash/hash_benchmark.cc index 978b5bc..a18d38f 100644 --- a/absl/hash/hash_benchmark.cc +++ b/absl/hash/hash_benchmark.cc
@@ -342,7 +342,7 @@ // measurements. static constexpr size_t kEntropySize = 16 << 10; static char entropy[kEntropySize + 1024]; -ABSL_ATTRIBUTE_UNUSED static const bool kInitialized = [] { +[[maybe_unused]] static const bool kInitialized = [] { absl::BitGen gen; static_assert(sizeof(entropy) % sizeof(uint64_t) == 0); for (int i = 0; i != sizeof(entropy); i += sizeof(uint64_t)) {
diff --git a/absl/hash/hash_test.cc b/absl/hash/hash_test.cc index 4198102..d80ccb4 100644 --- a/absl/hash/hash_test.cc +++ b/absl/hash/hash_test.cc
@@ -1306,6 +1306,10 @@ TEST(SwisstableCollisions, LowEntropyStrings) { constexpr char kMinChar = 0; constexpr char kMaxChar = 64; + // Scale the probe limit inversely with Group::kWidth so the test asserts a + // consistent bound on the number of probed slots across architectures. + constexpr size_t kMaxProbes = + 64 * 16 / absl::container_internal::Group::kWidth; // 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) { @@ -1321,7 +1325,7 @@ s[b + 1] = c2; set.insert(s); ASSERT_LT(HashtableDebugAccess<decltype(set)>::GetNumProbes(set, s), - 64) + kMaxProbes) << "size: " << size << "; bit: " << b; } }
diff --git a/absl/log/BUILD.bazel b/absl/log/BUILD.bazel index 1881866..1e5bdc8 100644 --- a/absl/log/BUILD.bazel +++ b/absl/log/BUILD.bazel
@@ -108,6 +108,7 @@ "//absl/log/internal:flags", "//absl/log/internal:vlog_config", "//absl/strings", + "//absl/strings:string_view", ], # Binaries which do not access these flags from C++ still want this library linked in. alwayslink = True, @@ -128,7 +129,7 @@ "//absl/base:raw_logging_internal", "//absl/hash", "//absl/log/internal:vlog_config", - "//absl/strings", + "//absl/strings:string_view", ], ) @@ -173,6 +174,7 @@ "//absl/log/internal:config", "//absl/log/internal:proto", "//absl/strings", + "//absl/strings:string_view", "//absl/time", "//absl/types:span", ], @@ -215,8 +217,8 @@ ":absl_log", "//absl/base:config", "//absl/base:log_severity", - "//absl/strings", "//absl/strings:internal", + "//absl/strings:string_view", "//absl/types:optional", "//absl/types:source_location", "//absl/utility", @@ -238,7 +240,7 @@ "//absl/base:config", "//absl/base:log_severity", "//absl/base:raw_logging_internal", - "//absl/strings", + "//absl/strings:string_view", "@googletest//:gtest", ], ) @@ -253,7 +255,7 @@ "//absl/base:config", "//absl/base:core_headers", "//absl/log/internal:structured", - "//absl/strings", + "//absl/strings:string_view", ], ) @@ -267,7 +269,7 @@ "//absl/base:config", "//absl/base:core_headers", "//absl/log/internal:vlog_config", - "//absl/strings", + "//absl/strings:string_view", ], ) @@ -494,6 +496,7 @@ "//absl/log/internal:format", "//absl/log/internal:test_helpers", "//absl/strings", + "//absl/strings:string_view", "//absl/time", "//absl/types:span", "@googletest//:gtest", @@ -517,6 +520,7 @@ "//absl/log/internal:test_matchers", "//absl/strings", "//absl/strings:str_format", + "//absl/strings:string_view", "//absl/types:source_location", "@googletest//:gtest", "@googletest//:gtest_main", @@ -561,7 +565,7 @@ "//absl/log/internal:test_actions", "//absl/log/internal:test_helpers", "//absl/log/internal:test_matchers", - "//absl/strings", + "//absl/strings:string_view", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -583,7 +587,7 @@ "//absl/log/internal:test_actions", "//absl/log/internal:test_helpers", "//absl/log/internal:test_matchers", - "//absl/strings", + "//absl/strings:string_view", "//absl/types:source_location", "@googletest//:gtest", "@googletest//:gtest_main", @@ -606,6 +610,7 @@ "//absl/log/internal:test_helpers", "//absl/log/internal:test_matchers", "//absl/strings", + "//absl/strings:string_view", "//absl/time", "//absl/types:source_location", "@googletest//:gtest", @@ -636,6 +641,7 @@ "//absl/log/internal:test_matchers", "//absl/memory", "//absl/strings", + "//absl/strings:string_view", "//absl/synchronization", "@googletest//:gtest", "@googletest//:gtest_main", @@ -661,6 +667,7 @@ "//absl/status", "//absl/strings", "//absl/strings:str_format", + "//absl/strings:string_view", "@googletest//:gtest", "@googletest//:gtest_main", ],
diff --git a/absl/log/CMakeLists.txt b/absl/log/CMakeLists.txt index e0a307b..d3bc26d 100644 --- a/absl/log/CMakeLists.txt +++ b/absl/log/CMakeLists.txt
@@ -17,7 +17,6 @@ absl_cc_library( NAME log_internal_check_impl - SRCS HDRS "internal/check_impl.h" COPTS @@ -34,10 +33,10 @@ absl_cc_library( NAME log_internal_check_op - SRCS - "internal/check_op.cc" HDRS "internal/check_op.h" + SRCS + "internal/check_op.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -52,16 +51,17 @@ absl::log_internal_nullstream absl::log_internal_strip absl::nullability + absl::string_view absl::strings ) absl_cc_library( NAME log_internal_conditions - SRCS - "internal/conditions.cc" HDRS "internal/conditions.h" + SRCS + "internal/conditions.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -76,7 +76,6 @@ absl_cc_library( NAME log_internal_config - SRCS HDRS "internal/config.h" COPTS @@ -91,7 +90,6 @@ absl_cc_library( NAME log_internal_flags - SRCS HDRS "internal/flags.h" COPTS @@ -105,10 +103,10 @@ absl_cc_library( NAME log_internal_format - SRCS - "internal/log_format.cc" HDRS "internal/log_format.h" + SRCS + "internal/log_format.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -120,19 +118,20 @@ absl::log_internal_config absl::log_internal_globals absl::log_severity - absl::strings - absl::str_format - absl::time absl::span + absl::str_format + absl::string_view + absl::strings + absl::time ) absl_cc_library( NAME log_internal_globals - SRCS - "internal/globals.cc" HDRS "internal/globals.h" + SRCS + "internal/globals.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -142,6 +141,7 @@ absl::core_headers absl::log_severity absl::raw_logging_internal + absl::string_view absl::strings absl::time ) @@ -149,7 +149,6 @@ absl_cc_library( NAME log_internal_log_impl - SRCS HDRS "internal/log_impl.h" COPTS @@ -157,19 +156,19 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS + absl::absl_vlog_is_on absl::log_internal_conditions absl::log_internal_message absl::log_internal_strip - absl::absl_vlog_is_on ) absl_cc_library( NAME log_internal_proto - SRCS - "internal/proto.cc" HDRS "internal/proto.h" + SRCS + "internal/proto.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -178,17 +177,17 @@ absl::base absl::config absl::core_headers - absl::strings absl::span + absl::string_view ) absl_cc_library( NAME log_internal_message - SRCS - "internal/log_message.cc" HDRS "internal/log_message.h" + SRCS + "internal/log_message.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -200,15 +199,15 @@ absl::errno_saver absl::examine_stack absl::inlined_vector + absl::log_entry + absl::log_globals absl::log_internal_append_truncated absl::log_internal_format absl::log_internal_globals - absl::log_internal_proto absl::log_internal_log_sink_set absl::log_internal_nullguard + absl::log_internal_proto absl::log_internal_structured_proto - absl::log_globals - absl::log_entry absl::log_severity absl::log_sink absl::log_sink_registry @@ -226,10 +225,10 @@ absl_cc_library( NAME log_internal_log_sink_set - SRCS - "internal/log_sink_set.cc" HDRS "internal/log_sink_set.h" + SRCS + "internal/log_sink_set.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -240,26 +239,26 @@ absl::cleanup absl::config absl::core_headers + absl::log_entry + absl::log_globals absl::log_internal_config absl::log_internal_globals - absl::log_globals - absl::log_entry absl::log_severity absl::log_sink absl::no_destructor absl::raw_logging_internal - absl::synchronization absl::span - absl::strings + absl::string_view + absl::synchronization ) absl_cc_library( NAME log_internal_nullguard - SRCS - "internal/nullguard.cc" HDRS "internal/nullguard.h" + SRCS + "internal/nullguard.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -272,7 +271,6 @@ absl_cc_library( NAME log_internal_nullstream - SRCS HDRS "internal/nullstream.h" COPTS @@ -283,13 +281,12 @@ absl::config absl::core_headers absl::log_severity - absl::strings + absl::string_view ) absl_cc_library( NAME log_internal_strip - SRCS HDRS "internal/strip.h" COPTS @@ -306,10 +303,10 @@ absl_cc_library( NAME log_internal_test_actions - SRCS - "internal/test_actions.cc" HDRS "internal/test_actions.h" + SRCS + "internal/test_actions.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -319,6 +316,7 @@ absl::core_headers absl::log_entry absl::log_severity + absl::string_view absl::strings absl::time TESTONLY @@ -327,10 +325,10 @@ absl_cc_library( NAME log_internal_test_helpers - SRCS - "internal/test_helpers.cc" HDRS "internal/test_helpers.h" + SRCS + "internal/test_helpers.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -348,10 +346,10 @@ absl_cc_library( NAME log_internal_test_matchers - SRCS - "internal/test_matchers.cc" HDRS "internal/test_matchers.h" + SRCS + "internal/test_matchers.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -362,17 +360,16 @@ absl::log_entry absl::log_internal_test_helpers absl::log_severity - absl::strings + absl::string_view absl::time - GTest::gtest GTest::gmock + GTest::gtest TESTONLY ) absl_cc_library( NAME log_internal_voidify - SRCS HDRS "internal/voidify.h" COPTS @@ -387,7 +384,6 @@ absl_cc_library( NAME log_internal_append_truncated - SRCS HDRS "internal/append_truncated.h" COPTS @@ -396,16 +392,15 @@ ${ABSL_DEFAULT_LINKOPTS} DEPS absl::config - absl::strings - absl::strings_internal absl::span + absl::string_view + absl::strings_internal ) # Public targets absl_cc_library( NAME absl_check - SRCS HDRS "absl_check.h" COPTS @@ -420,7 +415,6 @@ absl_cc_library( NAME absl_log - SRCS HDRS "absl_log.h" COPTS @@ -435,7 +429,6 @@ absl_cc_library( NAME check - SRCS HDRS "check.h" COPTS @@ -443,8 +436,8 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS - absl::log_internal_check_impl absl::core_headers + absl::log_internal_check_impl absl::log_internal_check_op absl::log_internal_conditions absl::log_internal_message @@ -455,10 +448,10 @@ absl_cc_library( NAME die_if_null - SRCS - "die_if_null.cc" HDRS "die_if_null.h" + SRCS + "die_if_null.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -481,10 +474,10 @@ absl_cc_library( NAME log_flags - SRCS - "flags.cc" HDRS "flags.h" + SRCS + "flags.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -492,12 +485,12 @@ DEPS absl::config absl::core_headers - absl::log_globals - absl::log_severity - absl::log_internal_config - absl::log_internal_flags absl::flags absl::flags_marshalling + absl::log_globals + absl::log_internal_config + absl::log_internal_flags + absl::log_severity absl::strings absl::vlog_config_internal PUBLIC @@ -506,10 +499,10 @@ absl_cc_library( NAME log_globals - SRCS - "globals.cc" HDRS "globals.h" + SRCS + "globals.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -528,10 +521,10 @@ absl_cc_library( NAME log_initialize - SRCS - "initialize.cc" HDRS "initialize.h" + SRCS + "initialize.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -547,7 +540,6 @@ absl_cc_library( NAME log - SRCS HDRS "log.h" COPTS @@ -563,10 +555,10 @@ absl_cc_library( NAME log_entry - SRCS - "log_entry.cc" HDRS "log_entry.h" + SRCS + "log_entry.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -578,6 +570,7 @@ absl::log_internal_proto absl::log_severity absl::span + absl::string_view absl::strings absl::time PUBLIC @@ -586,10 +579,10 @@ absl_cc_library( NAME log_sink - SRCS - "log_sink.cc" HDRS "log_sink.h" + SRCS + "log_sink.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -603,7 +596,6 @@ absl_cc_library( NAME log_sink_registry - SRCS HDRS "log_sink_registry.h" COPTS @@ -612,8 +604,8 @@ ${ABSL_DEFAULT_LINKOPTS} DEPS absl::config - absl::log_sink absl::log_internal_log_sink_set + absl::log_sink absl::nullability PUBLIC ) @@ -621,7 +613,6 @@ absl_cc_library( NAME log_streamer - SRCS HDRS "log_streamer.h" COPTS @@ -629,12 +620,12 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS - absl::config absl::absl_log + absl::config absl::log_severity absl::optional absl::source_location - absl::strings + absl::string_view absl::strings_internal absl::utility PUBLIC @@ -643,10 +634,10 @@ absl_cc_library( NAME scoped_mock_log - SRCS - "scoped_mock_log.cc" HDRS "scoped_mock_log.h" + SRCS + "scoped_mock_log.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -658,7 +649,7 @@ absl::log_sink absl::log_sink_registry absl::raw_logging_internal - absl::strings + absl::string_view GTest::gmock GTest::gtest PUBLIC @@ -680,25 +671,25 @@ absl::core_headers absl::log_internal_message absl::log_internal_structured_proto + absl::string_view absl::strings ) absl_cc_library( NAME log_internal_structured_proto - SRCS - "internal/structured_proto.cc" HDRS "internal/structured_proto.h" + SRCS + "internal/structured_proto.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS - absl::log_internal_proto absl::config + absl::log_internal_proto absl::span - absl::strings absl::variant PUBLIC ) @@ -741,10 +732,10 @@ absl_cc_library( NAME vlog_config_internal - SRCS - "internal/vlog_config.cc" HDRS "internal/vlog_config.h" + SRCS + "internal/vlog_config.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -771,10 +762,10 @@ HDRS "absl_vlog_is_on.h" DEPS - absl::vlog_config_internal absl::config absl::core_headers - absl::strings + absl::string_view + absl::vlog_config_internal ) absl_cc_library( @@ -800,30 +791,30 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS + absl::flags absl::log absl::log_flags absl::log_globals + absl::log_severity absl::scoped_mock_log absl::vlog_is_on - absl::log_severity - absl::flags GTest::gmock_main ) absl_cc_library( NAME log_internal_fnmatch - SRCS - "internal/fnmatch.cc" HDRS "internal/fnmatch.h" + SRCS + "internal/fnmatch.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS absl::config - absl::strings + absl::string_view ) # Test targets @@ -844,8 +835,8 @@ absl::core_headers absl::log_internal_test_helpers absl::status - absl::strings absl::string_view + absl::strings GTest::gmock_main ) @@ -860,15 +851,15 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS - absl::base absl::absl_log + absl::base absl::log_entry absl::log_globals - absl::log_severity absl::log_internal_globals absl::log_internal_test_actions absl::log_internal_test_helpers absl::log_internal_test_matchers + absl::log_severity absl::scoped_mock_log GTest::gmock_main ) @@ -889,8 +880,8 @@ absl::core_headers absl::log_internal_test_helpers absl::status - absl::strings absl::string_view + absl::strings GTest::gmock_main ) @@ -925,10 +916,10 @@ absl::log absl::log_entry absl::log_globals - absl::log_severity absl::log_internal_test_actions absl::log_internal_test_helpers absl::log_internal_test_matchers + absl::log_severity absl::scoped_mock_log GTest::gmock_main ) @@ -952,6 +943,7 @@ absl::log_internal_test_helpers absl::log_severity absl::span + absl::string_view absl::strings absl::time GTest::gmock_main @@ -968,6 +960,8 @@ ${ABSL_DEFAULT_LINKOPTS} DEPS absl::core_headers + absl::flags + absl::flags_reflection absl::log absl::log_flags absl::log_globals @@ -975,8 +969,6 @@ absl::log_internal_test_helpers absl::log_internal_test_matchers absl::log_severity - absl::flags - absl::flags_reflection absl::scoped_mock_log absl::strings GTest::gmock_main @@ -1019,6 +1011,7 @@ absl::scoped_mock_log absl::source_location absl::str_format + absl::string_view absl::strings GTest::gmock_main ) @@ -1055,11 +1048,11 @@ absl::log_internal_test_actions absl::log_internal_test_helpers absl::log_internal_test_matchers + absl::log_severity absl::log_sink absl::log_sink_registry - absl::log_severity absl::scoped_mock_log - absl::strings + absl::string_view GTest::gmock_main ) @@ -1079,11 +1072,11 @@ absl::log_internal_test_actions absl::log_internal_test_helpers absl::log_internal_test_matchers - absl::log_streamer absl::log_severity + absl::log_streamer absl::scoped_mock_log absl::source_location - absl::strings + absl::string_view GTest::gmock_main ) @@ -1104,6 +1097,7 @@ absl::log_sink absl::scoped_mock_log absl::source_location + absl::string_view absl::strings absl::time GTest::gmock_main @@ -1128,6 +1122,7 @@ absl::log_severity absl::memory absl::scoped_mock_log + absl::string_view absl::strings absl::synchronization GTest::gmock @@ -1168,9 +1163,9 @@ absl::log_internal_test_helpers absl::log_severity absl::status + absl::str_format absl::strerror absl::strings - absl::str_format GTest::gmock_main ) @@ -1235,7 +1230,7 @@ absl::config absl::log_internal_container absl::span - absl::strings absl::str_format + absl::strings GTest::gmock_main )
diff --git a/absl/log/die_if_null_test.cc b/absl/log/die_if_null_test.cc index b0aab78..1956ffa 100644 --- a/absl/log/die_if_null_test.cc +++ b/absl/log/die_if_null_test.cc
@@ -26,7 +26,7 @@ namespace { -auto* test_env ABSL_ATTRIBUTE_UNUSED = ::testing::AddGlobalTestEnvironment( +auto* test_env [[maybe_unused]] = ::testing::AddGlobalTestEnvironment( new absl::log_internal::LogTestEnvironment); // TODO(b/69907837): Revisit these tests with the goal of making them less
diff --git a/absl/log/flags.cc b/absl/log/flags.cc index 287b3e9..36a56b3 100644 --- a/absl/log/flags.cc +++ b/absl/log/flags.cc
@@ -47,7 +47,7 @@ return true; } -ABSL_ATTRIBUTE_UNUSED const bool unused = RegisterSyncLoggingFlags(); +[[maybe_unused]] const bool unused = RegisterSyncLoggingFlags(); template <typename T> T GetFromEnv(const char* varname, T dflt) {
diff --git a/absl/log/flags_test.cc b/absl/log/flags_test.cc index f5a2b51..6bb4fed 100644 --- a/absl/log/flags_test.cc +++ b/absl/log/flags_test.cc
@@ -36,7 +36,7 @@ using ::testing::HasSubstr; using ::testing::Not; -auto* test_env ABSL_ATTRIBUTE_UNUSED = ::testing::AddGlobalTestEnvironment( +auto* test_env [[maybe_unused]] = ::testing::AddGlobalTestEnvironment( new absl::log_internal::LogTestEnvironment); constexpr static absl::LogSeverityAtLeast DefaultStderrThreshold() {
diff --git a/absl/log/globals_test.cc b/absl/log/globals_test.cc index 78430d4..f7fbd2b 100644 --- a/absl/log/globals_test.cc +++ b/absl/log/globals_test.cc
@@ -28,7 +28,7 @@ using ::testing::_; using ::testing::StrEq; -auto* test_env ABSL_ATTRIBUTE_UNUSED = ::testing::AddGlobalTestEnvironment( +auto* test_env [[maybe_unused]] = ::testing::AddGlobalTestEnvironment( new absl::log_internal::LogTestEnvironment); constexpr static absl::LogSeverityAtLeast DefaultMinLogLevel() {
diff --git a/absl/log/internal/BUILD.bazel b/absl/log/internal/BUILD.bazel index d9cb7b2..42114ed 100644 --- a/absl/log/internal/BUILD.bazel +++ b/absl/log/internal/BUILD.bazel
@@ -85,6 +85,7 @@ "//absl/debugging:leak_check", "//absl/strings", "//absl/strings:has_ostream_operator", + "//absl/strings:string_view", ], ) @@ -144,6 +145,7 @@ "//absl/base:log_severity", "//absl/strings", "//absl/strings:str_format", + "//absl/strings:string_view", "//absl/time", "//absl/types:span", ], @@ -165,6 +167,7 @@ "//absl/base:log_severity", "//absl/base:raw_logging_internal", "//absl/strings", + "//absl/strings:string_view", "//absl/time", ], ) @@ -216,6 +219,7 @@ "//absl/log:log_sink_registry", "//absl/strings", "//absl/strings:internal", + "//absl/strings:string_view", "//absl/time", "//absl/types:source_location", "//absl/types:span", @@ -229,8 +233,8 @@ linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ "//absl/base:config", - "//absl/strings", "//absl/strings:internal", + "//absl/strings:string_view", "//absl/types:span", ], ) @@ -257,7 +261,7 @@ "//absl/log:globals", "//absl/log:log_entry", "//absl/log:log_sink", - "//absl/strings", + "//absl/strings:string_view", "//absl/synchronization", "//absl/types:span", ], @@ -284,7 +288,7 @@ "//absl/base:config", "//absl/base:core_headers", "//absl/base:log_severity", - "//absl/strings", + "//absl/strings:string_view", ], ) @@ -318,6 +322,7 @@ "//absl/base:core_headers", "//absl/functional:any_invocable", "//absl/strings", + "//absl/strings:string_view", ], ) @@ -333,7 +338,6 @@ deps = [ ":proto", "//absl/base:config", - "//absl/strings", "//absl/types:span", "//absl/types:variant", ], @@ -365,6 +369,7 @@ "//absl/base:log_severity", "//absl/log:log_entry", "//absl/strings", + "//absl/strings:string_view", "//absl/time", ] + select({ "@rules_cc//cc/compiler:msvc-cl": [], @@ -413,7 +418,7 @@ "//absl/base:core_headers", "//absl/base:log_severity", "//absl/log:log_entry", - "//absl/strings", + "//absl/strings:string_view", "//absl/time", "@googletest//:gtest", ] + select({ @@ -444,7 +449,7 @@ "//absl/base", "//absl/base:config", "//absl/base:core_headers", - "//absl/strings", + "//absl/strings:string_view", "//absl/types:span", ], ) @@ -457,7 +462,7 @@ linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ "//absl/base:config", - "//absl/strings", + "//absl/strings:string_view", ], ) @@ -481,6 +486,7 @@ "//absl/base:no_destructor", "//absl/base:nullability", "//absl/strings", + "//absl/strings:string_view", "//absl/synchronization", ], )
diff --git a/absl/log/internal/conditions.h b/absl/log/internal/conditions.h index 8be029d..f63e709 100644 --- a/absl/log/internal/conditions.h +++ b/absl/log/internal/conditions.h
@@ -94,7 +94,7 @@ absl_log_internal_stateful_condition_do_log && \ absl_log_internal_stateful_condition_state.ShouldLog(__VA_ARGS__); \ absl_log_internal_stateful_condition_do_log = false) \ - for (const uint32_t COUNTER ABSL_ATTRIBUTE_UNUSED = \ + for (const uint32_t COUNTER [[maybe_unused]] = \ absl_log_internal_stateful_condition_state.counter(); \ absl_log_internal_stateful_condition_do_log; \ absl_log_internal_stateful_condition_do_log = false) \
diff --git a/absl/log/internal/fnmatch.cc b/absl/log/internal/fnmatch.cc index 26e1e57..ee77a4f 100644 --- a/absl/log/internal/fnmatch.cc +++ b/absl/log/internal/fnmatch.cc
@@ -23,50 +23,40 @@ ABSL_NAMESPACE_BEGIN namespace log_internal { bool FNMatch(absl::string_view pattern, absl::string_view str) { - bool in_wildcard_match = false; - while (true) { - if (pattern.empty()) { - // `pattern` is exhausted; succeed if all of `str` was consumed matching - // it. - return in_wildcard_match || str.empty(); - } - if (str.empty()) { - // `str` is exhausted; succeed if `pattern` is empty or all '*'s. - return pattern.find_first_not_of('*') == pattern.npos; - } - switch (pattern.front()) { - case '*': - pattern.remove_prefix(1); - in_wildcard_match = true; - break; - case '?': - pattern.remove_prefix(1); - str.remove_prefix(1); - break; - default: - if (in_wildcard_match) { - absl::string_view fixed_portion = pattern; - const size_t end = fixed_portion.find_first_of("*?"); - if (end != fixed_portion.npos) { - fixed_portion = fixed_portion.substr(0, end); - } - const size_t match = str.find(fixed_portion); - if (match == str.npos) { - return false; - } - pattern.remove_prefix(fixed_portion.size()); - str.remove_prefix(match + fixed_portion.size()); - in_wildcard_match = false; - } else { - if (pattern.front() != str.front()) { - return false; - } - pattern.remove_prefix(1); - str.remove_prefix(1); - } - break; + // Two-pointer glob matcher: '?' matches exactly one character and '*' matches + // any run of characters (including the empty run). We remember the position + // just after the most recent '*' so that, on a later mismatch, that '*' can + // consume one more character of `str` and the match be retried. + size_t p = 0; // Current position in `pattern`. + size_t s = 0; // Current position in `str`. + // `pattern` position just after the most recent '*', and the `str` position + // when it was seen; `npos` until a '*' has been encountered. + size_t star_p = absl::string_view::npos; + size_t star_s = 0; + while (s < str.size()) { + if (p < pattern.size() && pattern[p] == '*') { + // Found '*'. Record checkpoint after '*' and advance pattern index only. + star_p = ++p; + star_s = s; + } else if (p < pattern.size() && + (pattern[p] == '?' || pattern[p] == str[s])) { + // Literal character match or single-character wildcard '?'. Advance both + // pattern and string pointers. + ++p; + ++s; + } else if (star_p != absl::string_view::npos) { + // Mismatch, but a preceding '*' exists. Backtrack: reset pattern to after + // the '*', and let that '*' consume one more character. + p = star_p; + s = ++star_s; + } else { + // Mismatch and no preceding '*' exists to absorb it. + return false; } } + // `str` is exhausted; the remainder of `pattern` must be all '*'s. + while (p < pattern.size() && pattern[p] == '*') ++p; + return p == pattern.size(); } } // namespace log_internal ABSL_NAMESPACE_END
diff --git a/absl/log/internal/fnmatch_test.cc b/absl/log/internal/fnmatch_test.cc index 614c7d3..27611e3 100644 --- a/absl/log/internal/fnmatch_test.cc +++ b/absl/log/internal/fnmatch_test.cc
@@ -57,4 +57,19 @@ EXPECT_THAT(FNMatch("*?", "*"), IsTrue()); } +TEST(FNMatchTest, BacktracksAfterStar) { + using absl::log_internal::FNMatch; + // A literal run after '*' may occur more than once in `str`; the match must + // not commit to the first occurrence. + EXPECT_THAT(FNMatch("*test", "testtest"), IsTrue()); + EXPECT_THAT(FNMatch("*.cc", "aa.cc.cc"), IsTrue()); + EXPECT_THAT(FNMatch("*_test", "unit_test_test"), IsTrue()); + EXPECT_THAT(FNMatch("*aa", "aaa"), IsTrue()); + EXPECT_THAT(FNMatch("*a*b", "aXaXb"), IsTrue()); + EXPECT_THAT(FNMatch("*ab*ab", "abXab"), IsTrue()); + // Backtracking must still reject genuine non-matches. + EXPECT_THAT(FNMatch("*test", "testtes"), IsFalse()); + EXPECT_THAT(FNMatch("*_test", "unit_tests"), IsFalse()); +} + } // namespace
diff --git a/absl/log/internal/stderr_log_sink_test.cc b/absl/log/internal/stderr_log_sink_test.cc index 763690d..4e5787e 100644 --- a/absl/log/internal/stderr_log_sink_test.cc +++ b/absl/log/internal/stderr_log_sink_test.cc
@@ -29,7 +29,7 @@ using ::testing::AllOf; using ::testing::HasSubstr; -auto* test_env ABSL_ATTRIBUTE_UNUSED = ::testing::AddGlobalTestEnvironment( +auto* test_env [[maybe_unused]] = ::testing::AddGlobalTestEnvironment( new absl::log_internal::LogTestEnvironment); MATCHER_P2(HasSubstrTimes, substr, expected_count, "") {
diff --git a/absl/log/log_benchmark.cc b/absl/log/log_benchmark.cc index 60c0fd6..50a64ea 100644 --- a/absl/log/log_benchmark.cc +++ b/absl/log/log_benchmark.cc
@@ -88,7 +88,7 @@ absl::LogSeverityAtLeast::kInfinity); absl::log_internal::ScopedMinLogLevel scoped_min_log_level( absl::LogSeverityAtLeast::kInfo); - ABSL_ATTRIBUTE_UNUSED NullLogSink null_sink; + [[maybe_unused]] NullLogSink null_sink; for (auto _ : state) { LOG(INFO); } @@ -143,7 +143,7 @@ absl::ScopedStderrThreshold disable_stderr_logging( absl::LogSeverityAtLeast::kInfinity); absl::SetMinLogLevel(absl::LogSeverityAtLeast::kInfinity); - ABSL_ATTRIBUTE_UNUSED NullLogSink null_sink; + [[maybe_unused]] NullLogSink null_sink; while (state.KeepRunningBatch(10)) { LOG_EVERY_N_SEC(INFO, 10);
diff --git a/absl/log/log_entry_test.cc b/absl/log/log_entry_test.cc index 3af10b6..4b3af4c 100644 --- a/absl/log/log_entry_test.cc +++ b/absl/log/log_entry_test.cc
@@ -47,7 +47,7 @@ using ::testing::StartsWith; using ::testing::StrEq; -auto* test_env ABSL_ATTRIBUTE_UNUSED = ::testing::AddGlobalTestEnvironment( +auto* test_env [[maybe_unused]] = ::testing::AddGlobalTestEnvironment( new absl::log_internal::LogTestEnvironment); } // namespace
diff --git a/absl/log/log_format_test.cc b/absl/log/log_format_test.cc index eb7585c..5c9f05d 100644 --- a/absl/log/log_format_test.cc +++ b/absl/log/log_format_test.cc
@@ -1273,7 +1273,7 @@ int y = 20; }; -ABSL_ATTRIBUTE_UNUSED std::ostream& operator<<( +[[maybe_unused]] std::ostream& operator<<( std::ostream& os, const PointWithAbslStringifiyAndOstream&) { return os << "Default to AbslStringify()"; }
diff --git a/absl/log/log_macro_hygiene_test.cc b/absl/log/log_macro_hygiene_test.cc index dad9389..e3f813c 100644 --- a/absl/log/log_macro_hygiene_test.cc +++ b/absl/log/log_macro_hygiene_test.cc
@@ -77,7 +77,7 @@ } TEST(LogHygieneTest, WorksWithAlternativeINFOSymbol) { - const double INFO ABSL_ATTRIBUTE_UNUSED = 7.77; + const double INFO [[maybe_unused]] = 7.77; absl::ScopedMockLog test_sink(absl::MockLogDefault::kDisallowUnexpected); EXPECT_CALL(test_sink, Log(absl::LogSeverity::kInfo, _, "Hello world")); @@ -87,7 +87,7 @@ } TEST(LogHygieneTest, WorksWithAlternativeWARNINGSymbol) { - const double WARNING ABSL_ATTRIBUTE_UNUSED = 7.77; + const double WARNING [[maybe_unused]] = 7.77; absl::ScopedMockLog test_sink(absl::MockLogDefault::kDisallowUnexpected); EXPECT_CALL(test_sink, Log(absl::LogSeverity::kWarning, _, "Hello world")); @@ -97,7 +97,7 @@ } TEST(LogHygieneTest, WorksWithAlternativeERRORSymbol) { - const double ERROR ABSL_ATTRIBUTE_UNUSED = 7.77; + const double ERROR [[maybe_unused]] = 7.77; absl::ScopedMockLog test_sink(absl::MockLogDefault::kDisallowUnexpected); EXPECT_CALL(test_sink, Log(absl::LogSeverity::kError, _, "Hello world")); @@ -107,7 +107,7 @@ } TEST(LogHygieneTest, WorksWithAlternativeLEVELSymbol) { - const double LEVEL ABSL_ATTRIBUTE_UNUSED = 7.77; + const double LEVEL [[maybe_unused]] = 7.77; absl::ScopedMockLog test_sink(absl::MockLogDefault::kDisallowUnexpected); EXPECT_CALL(test_sink, Log(absl::LogSeverity::kError, _, "Hello world"));
diff --git a/absl/log/log_sink_test.cc b/absl/log/log_sink_test.cc index cbb5a53..82961db 100644 --- a/absl/log/log_sink_test.cc +++ b/absl/log/log_sink_test.cc
@@ -39,7 +39,7 @@ using ::testing::HasSubstr; using ::testing::InSequence; -auto* test_env ABSL_ATTRIBUTE_UNUSED = ::testing::AddGlobalTestEnvironment( +auto* test_env [[maybe_unused]] = ::testing::AddGlobalTestEnvironment( new absl::log_internal::LogTestEnvironment); // Tests for global log sink registration.
diff --git a/absl/log/log_streamer_test.cc b/absl/log/log_streamer_test.cc index e45a293..a6f41c0 100644 --- a/absl/log/log_streamer_test.cc +++ b/absl/log/log_streamer_test.cc
@@ -55,7 +55,7 @@ using ::testing::IsEmpty; using ::testing::IsTrue; -auto* test_env ABSL_ATTRIBUTE_UNUSED = ::testing::AddGlobalTestEnvironment( +auto* test_env [[maybe_unused]] = ::testing::AddGlobalTestEnvironment( new absl::log_internal::LogTestEnvironment); void WriteToStream(absl::string_view data, std::ostream* os) {
diff --git a/absl/log/scoped_mock_log_test.cc b/absl/log/scoped_mock_log_test.cc index 6f1d8fb..31bcdc5 100644 --- a/absl/log/scoped_mock_log_test.cc +++ b/absl/log/scoped_mock_log_test.cc
@@ -49,7 +49,7 @@ using absl::log_internal::TextMessageWithPrefix; using absl::log_internal::ThreadID; -auto* test_env ABSL_ATTRIBUTE_UNUSED = ::testing::AddGlobalTestEnvironment( +auto* test_env [[maybe_unused]] = ::testing::AddGlobalTestEnvironment( new absl::log_internal::LogTestEnvironment); #if GTEST_HAS_DEATH_TEST
diff --git a/absl/log/structured_test.cc b/absl/log/structured_test.cc index cde8199..a68ec99 100644 --- a/absl/log/structured_test.cc +++ b/absl/log/structured_test.cc
@@ -33,7 +33,7 @@ using ::testing::ElementsAre; using ::testing::Eq; -auto *test_env ABSL_ATTRIBUTE_UNUSED = ::testing::AddGlobalTestEnvironment( +auto* test_env [[maybe_unused]] = ::testing::AddGlobalTestEnvironment( new absl::log_internal::LogTestEnvironment); // Abseil Logging library uses these by default, so we set them on the
diff --git a/absl/memory/CMakeLists.txt b/absl/memory/CMakeLists.txt index c5ed4b4..f6a05f6 100644 --- a/absl/memory/CMakeLists.txt +++ b/absl/memory/CMakeLists.txt
@@ -35,7 +35,7 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::memory absl::core_headers + absl::memory GTest::gmock_main )
diff --git a/absl/meta/CMakeLists.txt b/absl/meta/CMakeLists.txt index c98c360..644fc1b 100644 --- a/absl/meta/CMakeLists.txt +++ b/absl/meta/CMakeLists.txt
@@ -82,8 +82,8 @@ ${ABSL_TEST_COPTS} DEPS absl::config - absl::time absl::core_headers + absl::time absl::type_traits GTest::gmock_main )
diff --git a/absl/meta/internal/constexpr_testing_test.cc b/absl/meta/internal/constexpr_testing_test.cc index 50c8c53..761a081 100644 --- a/absl/meta/internal/constexpr_testing_test.cc +++ b/absl/meta/internal/constexpr_testing_test.cc
@@ -14,6 +14,7 @@ #include "absl/meta/internal/constexpr_testing.h" +#include <cstdlib> #include <map> #include <string_view>
diff --git a/absl/meta/type_traits.h b/absl/meta/type_traits.h index 0bccd0b..b60579c 100644 --- a/absl/meta/type_traits.h +++ b/absl/meta/type_traits.h
@@ -45,6 +45,7 @@ #include <utility> #include <variant> #include <vector> +#include <version> #include "absl/base/attributes.h" #include "absl/base/config.h"
diff --git a/absl/numeric/CMakeLists.txt b/absl/numeric/CMakeLists.txt index 68446b0..a03d548 100644 --- a/absl/numeric/CMakeLists.txt +++ b/absl/numeric/CMakeLists.txt
@@ -55,10 +55,10 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS + absl::bits absl::compare absl::config absl::core_headers - absl::bits PUBLIC ) @@ -71,12 +71,12 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::int128 absl::base absl::compare absl::hash_testing - absl::type_traits + absl::int128 absl::strings + absl::type_traits GTest::gmock_main )
diff --git a/absl/profiling/BUILD.bazel b/absl/profiling/BUILD.bazel index e958307..c5b49eb 100644 --- a/absl/profiling/BUILD.bazel +++ b/absl/profiling/BUILD.bazel
@@ -163,6 +163,7 @@ "//absl/container:hash_container_defaults", "//absl/strings", "//absl/strings:str_format", + "//absl/strings:string_view", "//absl/types:span", ], )
diff --git a/absl/profiling/CMakeLists.txt b/absl/profiling/CMakeLists.txt index 6441dae..0169182 100644 --- a/absl/profiling/CMakeLists.txt +++ b/absl/profiling/CMakeLists.txt
@@ -41,10 +41,10 @@ absl_cc_library( NAME exponential_biased - SRCS - "internal/exponential_biased.cc" HDRS "internal/exponential_biased.h" + SRCS + "internal/exponential_biased.cc" COPTS ${ABSL_DEFAULT_COPTS} DEPS @@ -68,10 +68,10 @@ absl_cc_library( NAME periodic_sampler - SRCS - "internal/periodic_sampler.cc" HDRS "internal/periodic_sampler.h" + SRCS + "internal/periodic_sampler.cc" COPTS ${ABSL_DEFAULT_COPTS} DEPS @@ -103,14 +103,15 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS + absl::btree absl::config absl::core_headers - absl::raw_logging_internal absl::flat_hash_map - absl::btree - absl::strings - absl::str_format + absl::raw_logging_internal absl::span + absl::str_format + absl::string_view + absl::strings ) absl_cc_library( @@ -123,10 +124,10 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS - absl::profile_builder absl::config absl::core_headers - absl::strings - absl::span absl::hashtablez_sampler + absl::profile_builder + absl::span + absl::strings )
diff --git a/absl/random/BUILD.bazel b/absl/random/BUILD.bazel index 7d62fa5..edc4e93 100644 --- a/absl/random/BUILD.bazel +++ b/absl/random/BUILD.bazel
@@ -89,6 +89,7 @@ "//absl/random/internal:uniform_helper", "//absl/random/internal:wide_multiply", "//absl/strings", + "//absl/strings:string_view", ], )
diff --git a/absl/random/CMakeLists.txt b/absl/random/CMakeLists.txt index 4a13e84..914ba0f 100644 --- a/absl/random/CMakeLists.txt +++ b/absl/random/CMakeLists.txt
@@ -45,9 +45,9 @@ absl::config absl::core_headers absl::random_internal_fast_uniform_bits - absl::type_traits - absl::random_mocking_access absl::random_internal_traits + absl::random_mocking_access + absl::type_traits ) absl_cc_test( @@ -61,10 +61,10 @@ ${ABSL_DEFAULT_LINKOPTS} DEPS absl::config - absl::random_bit_gen_ref - absl::random_random - absl::random_internal_sequence_urbg absl::fast_type_id + absl::random_bit_gen_ref + absl::random_internal_sequence_urbg + absl::random_random GTest::gmock GTest::gtest_main ) @@ -113,8 +113,8 @@ ${ABSL_DEFAULT_LINKOPTS} DEPS absl::config - absl::random_mocking_bit_gen absl::random_internal_mock_helpers + absl::random_mocking_bit_gen TESTONLY ) @@ -133,10 +133,10 @@ absl::core_headers absl::fast_type_id absl::flat_hash_map - absl::raw_logging_internal absl::random_internal_mock_helpers absl::random_mocking_access absl::random_random + absl::raw_logging_internal absl::type_traits absl::utility GTest::gmock @@ -205,10 +205,10 @@ absl::base_internal absl::config absl::core_headers - absl::random_internal_generate_real absl::random_internal_distribution_caller absl::random_internal_fast_uniform_bits absl::random_internal_fastmath + absl::random_internal_generate_real absl::random_internal_iostream_state_saver absl::random_internal_traits absl::random_internal_uniform_helper @@ -220,10 +220,10 @@ absl_cc_library( NAME random_seed_gen_exception - SRCS - "seed_gen_exception.cc" HDRS "seed_gen_exception.h" + SRCS + "seed_gen_exception.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -236,10 +236,10 @@ absl_cc_library( NAME random_seed_sequences - SRCS - "seed_sequences.cc" HDRS "seed_sequences.h" + SRCS + "seed_sequences.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -267,9 +267,9 @@ ${ABSL_DEFAULT_LINKOPTS} DEPS absl::random_distributions - absl::random_random - absl::random_internal_sequence_urbg absl::random_internal_pcg_engine + absl::random_internal_sequence_urbg + absl::random_random GTest::gmock GTest::gtest_main ) @@ -287,12 +287,12 @@ absl::log absl::numeric_representation absl::random_distributions - absl::random_random absl::random_internal_distribution_test_util - absl::random_internal_sequence_urbg absl::random_internal_pcg_engine - absl::strings + absl::random_internal_sequence_urbg + absl::random_random absl::str_format + absl::strings GTest::gmock GTest::gtest_main ) @@ -307,11 +307,11 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS + absl::int128 absl::random_distributions + absl::random_internal_distribution_test_util absl::random_random absl::type_traits - absl::int128 - absl::random_internal_distribution_test_util GTest::gmock GTest::gtest_main ) @@ -349,8 +349,8 @@ absl::random_internal_pcg_engine absl::random_internal_sequence_urbg absl::random_random - absl::strings absl::str_format + absl::strings GTest::gmock GTest::gtest_main ) @@ -386,16 +386,16 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS - absl::random_distributions - absl::random_random absl::core_headers absl::flat_hash_map absl::log + absl::random_distributions absl::random_internal_distribution_test_util absl::random_internal_pcg_engine absl::random_internal_sequence_urbg - absl::strings + absl::random_random absl::str_format + absl::strings GTest::gmock GTest::gtest_main ) @@ -418,8 +418,8 @@ absl::random_internal_pcg_engine absl::random_internal_sequence_urbg absl::random_random - absl::strings absl::str_format + absl::strings GTest::gmock GTest::gtest_main ) @@ -441,8 +441,8 @@ absl::random_internal_distribution_test_util absl::random_internal_sequence_urbg absl::random_random - absl::strings absl::str_format + absl::strings GTest::gmock GTest::gtest_main ) @@ -535,9 +535,9 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS - absl::random_seed_sequences absl::random_internal_nonsecure_base absl::random_random + absl::random_seed_sequences GTest::gmock GTest::gtest_main ) @@ -553,10 +553,10 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS - absl::config - absl::type_traits absl::bits + absl::config absl::int128 + absl::type_traits ) # Internal-only target, do not depend on directly. @@ -571,10 +571,10 @@ ${ABSL_DEFAULT_LINKOPTS} DEPS absl::config - absl::utility absl::fast_type_id - absl::type_traits absl::random_mocking_access + absl::type_traits + absl::utility ) # Internal-only target, do not depend on directly. @@ -595,10 +595,10 @@ absl_cc_library( NAME random_internal_seed_material - SRCS - "internal/seed_material.cc" HDRS "internal/seed_material.h" + SRCS + "internal/seed_material.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -610,6 +610,7 @@ absl::random_internal_fast_uniform_bits absl::raw_logging_internal absl::span + absl::string_view absl::strings ) @@ -617,10 +618,10 @@ absl_cc_library( NAME random_internal_entropy_pool - SRCS - "internal/entropy_pool.cc" HDRS "internal/entropy_pool.h" + SRCS + "internal/entropy_pool.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -681,8 +682,8 @@ DEPS absl::inlined_vector absl::optional - absl::span absl::random_internal_seed_material + absl::span absl::type_traits ) @@ -825,10 +826,10 @@ absl_cc_library( NAME random_internal_randen - SRCS - "internal/randen.cc" HDRS "internal/randen.h" + SRCS + "internal/randen.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS @@ -843,27 +844,27 @@ absl_cc_library( NAME random_internal_randen_slow - SRCS - "internal/randen_slow.cc" HDRS "internal/randen_slow.h" + SRCS + "internal/randen_slow.cc" COPTS ${ABSL_DEFAULT_COPTS} LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS - absl::random_internal_platform absl::config + absl::random_internal_platform ) # Internal-only target, do not depend on directly. absl_cc_library( NAME random_internal_randen_hwaes - SRCS - "internal/randen_detect.cc" HDRS "internal/randen_detect.h" + SRCS + "internal/randen_detect.cc" "internal/randen_hwaes.h" COPTS ${ABSL_DEFAULT_COPTS} @@ -871,9 +872,9 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS + absl::config absl::random_internal_platform absl::random_internal_randen_hwaes_impl - absl::config ) # Internal-only target, do not depend on directly. @@ -889,8 +890,8 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS - absl::random_internal_platform absl::config + absl::random_internal_platform ) # Internal-only target, do not depend on directly. @@ -911,9 +912,10 @@ absl::config absl::core_headers absl::raw_logging_internal - absl::strings - absl::str_format absl::span + absl::str_format + absl::string_view + absl::strings ) # Internal-only target, do not depend on directly. @@ -1213,12 +1215,12 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS + absl::config absl::random_internal_iostream_state_saver absl::random_internal_uniform_helper - absl::config absl::raw_logging_internal - absl::strings absl::string_view + absl::strings TESTONLY ) @@ -1233,9 +1235,9 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS + absl::int128 absl::random_internal_uniform_helper GTest::gtest_main - absl::int128 ) # Internal-only target, do not depend on directly. @@ -1264,8 +1266,8 @@ LINKOPTS ${ABSL_DEFAULT_LINKOPTS} DEPS - absl::random_internal_wide_multiply absl::int128 + absl::random_internal_wide_multiply GTest::gmock GTest::gtest_main )
diff --git a/absl/random/internal/BUILD.bazel b/absl/random/internal/BUILD.bazel index 3ba8d9c..5b03203 100644 --- a/absl/random/internal/BUILD.bazel +++ b/absl/random/internal/BUILD.bazel
@@ -174,6 +174,7 @@ "//absl/base:dynamic_annotations", "//absl/base:raw_logging_internal", "//absl/strings", + "//absl/strings:string_view", "//absl/types:optional", "//absl/types:span", ], @@ -459,6 +460,7 @@ "//absl/base:raw_logging_internal", "//absl/strings", "//absl/strings:str_format", + "//absl/strings:string_view", "//absl/types:span", ], )
diff --git a/absl/status/BUILD.bazel b/absl/status/BUILD.bazel index 5a611ec..3508b11 100644 --- a/absl/status/BUILD.bazel +++ b/absl/status/BUILD.bazel
@@ -71,6 +71,7 @@ "//absl/strings", "//absl/strings:cord", "//absl/strings:str_format", + "//absl/strings:string_view", "//absl/types:optional", "//absl/types:optional_ref", "//absl/types:source_location", @@ -88,6 +89,7 @@ "//absl/strings", "//absl/strings:cord", "//absl/strings:str_format", + "//absl/strings:string_view", "//absl/types:source_location", "@googletest//:gtest", "@googletest//:gtest_main", @@ -129,6 +131,7 @@ "//absl/strings", "//absl/strings:has_ostream_operator", "//absl/strings:str_format", + "//absl/strings:string_view", "//absl/types:source_location", "//absl/types:span", "//absl/types:variant", @@ -147,6 +150,7 @@ "//absl/base", "//absl/memory", "//absl/strings", + "//absl/strings:string_view", "//absl/types:any", "//absl/types:source_location", "//absl/types:variant", @@ -184,6 +188,7 @@ "//absl/strings", "//absl/strings:cord", "//absl/strings:internal", + "//absl/strings:string_view", "//absl/strings:stringify_stream", "//absl/time", "//absl/types:source_location", @@ -205,7 +210,7 @@ "//absl/log:flags", "//absl/log:log_entry", "//absl/log:log_sink", - "//absl/strings", + "//absl/strings:string_view", "//absl/types:source_location", "@googletest//:gtest", "@googletest//:gtest_main", @@ -273,7 +278,7 @@ ":status", ":status_matchers", ":statusor", - "//absl/strings", + "//absl/strings:string_view", "@googletest//:gtest", "@googletest//:gtest_main", ], @@ -290,7 +295,7 @@ ":status", ":status_matchers", ":statusor", - "//absl/strings", + "//absl/strings:string_view", "@googletest//:gtest", "@googletest//:gtest_main", ],
diff --git a/absl/status/CMakeLists.txt b/absl/status/CMakeLists.txt index 90d4baf..13ff4a6 100644 --- a/absl/status/CMakeLists.txt +++ b/absl/status/CMakeLists.txt
@@ -47,6 +47,7 @@ absl::stacktrace absl::str_format absl::strerror + absl::string_view absl::strings absl::symbolize PUBLIC @@ -60,9 +61,10 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::status absl::source_location + absl::status absl::str_format + absl::string_view absl::strings GTest::gmock_main ) @@ -84,9 +86,10 @@ absl::has_ostream_operator absl::nullability absl::raw_logging_internal - absl::status absl::source_location + absl::status absl::str_format + absl::string_view absl::strings absl::type_traits absl::utility @@ -102,10 +105,11 @@ COPTS ${ABSL_TEST_COPTS} DEPS + absl::source_location absl::status absl::status_matchers absl::statusor - absl::source_location + absl::string_view absl::strings GTest::gmock_main ) @@ -128,6 +132,7 @@ absl::source_location absl::span absl::status + absl::string_view absl::strings absl::time PUBLIC @@ -143,7 +148,6 @@ DEPS absl::core_headers absl::flags - GTest::gmock_main absl::log absl::log_entry absl::log_flags @@ -154,11 +158,13 @@ absl::source_location absl::span absl::status - absl::statusor absl::status_builder absl::status_matchers + absl::statusor + absl::string_view absl::strings absl::time + GTest::gmock_main ) absl_cc_library( @@ -228,8 +234,9 @@ ${ABSL_TEST_COPTS} DEPS absl::status - absl::statusor absl::status_matchers + absl::statusor + absl::string_view GTest::gmock_main ) @@ -244,7 +251,8 @@ "ABSL_DEFINE_UNQUALIFIED_STATUS_TESTING_MACROS" DEPS absl::status - absl::statusor absl::status_matchers + absl::statusor + absl::string_view GTest::gmock_main )
diff --git a/absl/strings/BUILD.bazel b/absl/strings/BUILD.bazel index 7f8ca5f..7a10c09 100644 --- a/absl/strings/BUILD.bazel +++ b/absl/strings/BUILD.bazel
@@ -211,6 +211,7 @@ copts = ABSL_TEST_COPTS, visibility = ["//visibility:private"], deps = [ + ":string_view", ":strings", "@googletest//:gtest", "@googletest//:gtest_main", @@ -245,6 +246,7 @@ ":charset", ":cord", ":str_format", + ":string_view", ":strings", "//absl/base:core_headers", "//absl/container:fixed_array", @@ -265,6 +267,7 @@ tags = ["benchmark"], visibility = ["//visibility:private"], deps = [ + ":string_view", ":strings", "//absl/base:raw_logging_internal", "@google_benchmark//:benchmark_main", @@ -315,6 +318,7 @@ copts = ABSL_TEST_COPTS, visibility = ["//visibility:private"], deps = [ + ":string_view", ":strings", "//absl/base:core_headers", "@googletest//:gtest", @@ -424,6 +428,7 @@ copts = ABSL_TEST_COPTS, visibility = ["//visibility:private"], deps = [ + ":string_view", ":strings", "@googletest//:gtest", "@googletest//:gtest_main", @@ -517,6 +522,7 @@ visibility = ["//visibility:private"], deps = [ ":charset", + ":string_view", ":strings", "@googletest//:gtest", "@googletest//:gtest_main", @@ -549,6 +555,7 @@ "//visibility:private", ], deps = [ + ":string_view", ":strings", "//absl/base:config", "//absl/base:core_headers", @@ -573,7 +580,7 @@ deps = [ ":cord_internal", ":cord_rep_test_util", - ":strings", + ":string_view", "//absl/base:config", "@googletest//:gtest", "@googletest//:gtest_main", @@ -590,6 +597,7 @@ deps = [ ":cord_internal", ":cord_rep_test_util", + ":string_view", ":strings", "//absl/base:config", "//absl/base:raw_logging_internal", @@ -609,6 +617,7 @@ deps = [ ":cord_internal", ":cord_rep_test_util", + ":string_view", ":strings", "//absl/base:config", "//absl/base:raw_logging_internal", @@ -627,7 +636,7 @@ ":cord", ":cord_internal", ":cord_rep_test_util", - ":strings", + ":string_view", "//absl/base:config", "//absl/base:raw_logging_internal", "@googletest//:gtest", @@ -698,6 +707,7 @@ ":cordz_update_tracker", ":internal", ":resize_and_overwrite", + ":string_view", ":strings", "//absl/base:config", "//absl/base:core_headers", @@ -716,7 +726,6 @@ "//absl/types:compare", "//absl/types:optional", "//absl/types:span", - "@do_not_use_for_gloop_visibility_only//gloop/base:fprint", ], ) @@ -956,7 +965,7 @@ deps = [ ":cord", ":cord_internal", - ":strings", + ":string_view", "//absl/base:config", ], ) @@ -969,7 +978,7 @@ linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":cord_internal", - ":strings", + ":string_view", "//absl/base:config", "//absl/base:raw_logging_internal", "//absl/types:span", @@ -1035,6 +1044,7 @@ ":cordz_test_helpers", ":cordz_update_tracker", ":str_format", + ":string_view", ":strings", "//absl/base:config", "//absl/base:core_headers", @@ -1078,6 +1088,7 @@ ":cordz_statistics", ":cordz_test_helpers", ":cordz_update_tracker", + ":string_view", ":strings", "//absl/base:config", "//absl/base:core_headers", @@ -1094,6 +1105,7 @@ copts = ABSL_TEST_COPTS, visibility = ["//visibility:private"], deps = [ + ":string_view", ":strings", "//absl/base:core_headers", "@googletest//:gtest", @@ -1138,6 +1150,7 @@ copts = ABSL_TEST_COPTS, visibility = ["//visibility:private"], deps = [ + ":string_view", ":strings", "@googletest//:gtest", "@googletest//:gtest_main", @@ -1150,6 +1163,7 @@ copts = ABSL_TEST_COPTS, visibility = ["//visibility:private"], deps = [ + ":string_view", ":strings", "//absl/base:core_headers", "//absl/base:dynamic_annotations", @@ -1170,6 +1184,7 @@ tags = ["benchmark"], visibility = ["//visibility:private"], deps = [ + ":string_view", ":strings", "//absl/base:raw_logging_internal", "@google_benchmark//:benchmark_main", @@ -1226,6 +1241,7 @@ copts = ABSL_TEST_COPTS, visibility = ["//visibility:private"], deps = [ + ":string_view", ":strings", "//absl/base:core_headers", "//absl/memory", @@ -1255,6 +1271,7 @@ visibility = ["//visibility:private"], deps = [ ":str_format", + ":string_view", ":strings", "//absl/base:config", "@googletest//:gtest", @@ -1271,6 +1288,7 @@ visibility = ["//visibility:private"], deps = [ ":str_format", + ":string_view", ":strings", "//absl/random", "//absl/random:distributions", @@ -1290,6 +1308,7 @@ deps = [ ":internal", ":pow10_helper", + ":string_view", ":strings", "//absl/base:config", "//absl/cleanup", @@ -1310,6 +1329,7 @@ tags = ["benchmark"], visibility = ["//visibility:private"], deps = [ + ":string_view", ":strings", "//absl/base:raw_logging_internal", "//absl/random", @@ -1325,6 +1345,7 @@ copts = ABSL_TEST_COPTS, visibility = ["//visibility:private"], deps = [ + ":string_view", ":strings", "@googletest//:gtest", "@googletest//:gtest_main", @@ -1338,6 +1359,7 @@ deps = [ ":pow10_helper", ":str_format", + ":string_view", ":strings", "@googletest//:gtest", "@googletest//:gtest_main", @@ -1352,6 +1374,7 @@ ], copts = ABSL_TEST_COPTS, deps = [ + ":string_view", ":strings", "//absl/base:config", "//absl/log:check", @@ -1369,6 +1392,7 @@ ], copts = ABSL_TEST_COPTS, deps = [ + ":string_view", ":strings", "//absl/base:config", "@googletest//:gtest", @@ -1434,6 +1458,7 @@ visibility = ["//visibility:private"], deps = [ ":internal", + ":string_view", ":strings", "//absl/base:config", "//absl/base:core_headers", @@ -1458,6 +1483,7 @@ ":cord", ":str_format", ":str_format_internal", + ":string_view", ":strings", "//absl/base:config", "//absl/base:core_headers", @@ -1477,7 +1503,7 @@ deps = [ ":str_format", ":str_format_internal", - ":strings", + ":string_view", "//absl/random", "@googletest//:gtest", "@googletest//:gtest_main", @@ -1535,6 +1561,7 @@ deps = [ ":str_format", ":str_format_internal", + ":string_view", ":strings", "//absl/base", "//absl/base:config", @@ -1610,6 +1637,7 @@ visibility = ["//visibility:private"], deps = [ ":str_format", + ":string_view", ":strings", "//absl/base", ], @@ -1643,6 +1671,7 @@ ], deps = [ ":str_format", + ":string_view", ":strings", "//absl/base:config", "//absl/log/internal:container", @@ -1658,6 +1687,7 @@ deps = [ ":generic_printer", ":str_format", + ":string_view", ":strings", "//absl/base:config", "//absl/base:core_headers",
diff --git a/absl/strings/CMakeLists.txt b/absl/strings/CMakeLists.txt index 3ea24fe..2d301d8 100644 --- a/absl/strings/CMakeLists.txt +++ b/absl/strings/CMakeLists.txt
@@ -70,10 +70,6 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS - absl::string_view - absl::strings_append_and_overwrite - absl::strings_internal - absl::strings_resize_and_overwrite absl::base absl::bits absl::charset @@ -87,6 +83,10 @@ absl::nullability absl::raw_logging_internal absl::source_location + absl::string_view + absl::strings_append_and_overwrite + absl::strings_internal + absl::strings_resize_and_overwrite absl::throw_delegate absl::type_traits PUBLIC @@ -125,8 +125,8 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS - absl::string_view absl::config + absl::string_view ) absl_cc_test( @@ -137,9 +137,9 @@ COPTS ${ABSL_TEST_COPTS} DEPS + absl::str_format absl::string_view absl::stringify_stream - absl::str_format GTest::gmock_main ) @@ -190,9 +190,9 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::strings_resize_and_overwrite absl::absl_check absl::dynamic_annotations + absl::strings_resize_and_overwrite GTest::gmock_main ) @@ -219,8 +219,8 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::strings_resize_and_overwrite absl::absl_check + absl::strings_resize_and_overwrite GTest::gmock_main ) @@ -232,8 +232,9 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::strings absl::base + absl::string_view + absl::strings GTest::gmock_main ) @@ -246,12 +247,13 @@ ${ABSL_TEST_COPTS} DEPS absl::charset - absl::strings - absl::str_format + absl::check absl::core_headers absl::fixed_array + absl::str_format + absl::string_view + absl::strings GTest::gmock_main - absl::check ) absl_cc_test( @@ -286,8 +288,9 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::strings absl::core_headers + absl::string_view + absl::strings GTest::gmock_main ) @@ -299,8 +302,8 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::strings absl::base + absl::strings GTest::gmock_main ) @@ -313,8 +316,8 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::strings absl::core_headers + absl::strings GTest::gmock_main ) @@ -326,10 +329,10 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::string_view - absl::strings_internal absl::base absl::core_headers + absl::string_view + absl::strings_internal GTest::gmock_main ) @@ -341,6 +344,7 @@ COPTS ${ABSL_TEST_COPTS} DEPS + absl::string_view absl::strings GTest::gmock_main ) @@ -353,10 +357,10 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::strings absl::config absl::core_headers absl::dynamic_annotations + absl::strings absl::type_traits GTest::gmock_main ) @@ -369,8 +373,9 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::strings absl::core_headers + absl::string_view + absl::strings GTest::gmock_main ) @@ -382,6 +387,7 @@ COPTS ${ABSL_TEST_COPTS} DEPS + absl::string_view absl::strings GTest::gmock_main ) @@ -394,13 +400,14 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::strings + absl::btree absl::core_headers absl::dynamic_annotations - absl::btree absl::flat_hash_map absl::hash absl::node_hash_map + absl::string_view + absl::strings GTest::gmock_main ) @@ -424,9 +431,9 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::strings_internal absl::base absl::core_headers + absl::strings_internal absl::type_traits GTest::gmock_main ) @@ -439,10 +446,11 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::strings absl::base absl::core_headers absl::memory + absl::string_view + absl::strings GTest::gmock_main ) @@ -454,10 +462,11 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::strings - absl::str_format absl::config absl::core_headers + absl::str_format + absl::string_view + absl::strings GTest::gmock_main ) @@ -478,6 +487,7 @@ absl::pow10_helper absl::random_distributions absl::random_random + absl::string_view absl::strings absl::strings_internal GTest::gmock_main @@ -491,8 +501,9 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::strings absl::base + absl::string_view + absl::strings GTest::gmock_main ) @@ -504,6 +515,7 @@ COPTS ${ABSL_TEST_COPTS} DEPS + absl::string_view absl::strings GTest::gmock_main ) @@ -516,9 +528,10 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::strings - absl::str_format absl::pow10_helper + absl::str_format + absl::string_view + absl::strings GTest::gmock_main ) @@ -533,6 +546,7 @@ DEPS absl::check absl::config + absl::string_view absl::strings GTest::gmock_main ) @@ -547,8 +561,9 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::strings absl::config + absl::string_view + absl::strings GTest::gmock_main ) @@ -593,17 +608,18 @@ ${ABSL_DEFAULT_COPTS} DEPS absl::bits - absl::strings absl::config absl::core_headers absl::fixed_array absl::inlined_vector + absl::int128 absl::numeric_representation + absl::span + absl::string_view + absl::strings + absl::strings_internal absl::type_traits absl::utility - absl::int128 - absl::span - absl::strings_internal ) absl_cc_test( @@ -619,6 +635,7 @@ absl::core_headers absl::span absl::str_format + absl::string_view absl::strings GTest::gmock_main ) @@ -634,7 +651,7 @@ absl::random_random absl::str_format absl::str_format_internal - absl::strings + absl::string_view GTest::gmock_main ) @@ -692,6 +709,7 @@ absl::span absl::str_format absl::str_format_internal + absl::string_view absl::strings GTest::gmock_main ) @@ -704,8 +722,8 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::str_format_internal absl::cord + absl::str_format_internal GTest::gmock_main ) @@ -717,10 +735,10 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::str_format_internal - absl::string_view absl::config absl::core_headers + absl::str_format_internal + absl::string_view GTest::gmock_main ) @@ -789,16 +807,17 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS + absl::compare absl::compressed_tuple absl::config absl::container_memory - absl::compare absl::core_headers absl::crc_cord_state absl::endian absl::inlined_vector absl::layout absl::raw_logging_internal + absl::string_view absl::strings absl::throw_delegate absl::type_traits @@ -870,8 +889,8 @@ ${ABSL_DEFAULT_COPTS} DEPS absl::config - absl::core_headers absl::cordz_update_tracker + absl::core_headers absl::synchronization ) @@ -903,8 +922,8 @@ absl::cordz_handle absl::cordz_test_helpers absl::memory - absl::random_random absl::random_distributions + absl::random_random absl::synchronization absl::time GTest::gmock_main @@ -929,10 +948,10 @@ absl::cordz_statistics absl::cordz_update_tracker absl::core_headers - absl::no_destructor absl::inlined_vector - absl::span + absl::no_destructor absl::raw_logging_internal + absl::span absl::stacktrace absl::synchronization absl::time @@ -948,11 +967,11 @@ DEPS absl::config absl::cord_internal - absl::cordz_test_helpers absl::cordz_handle absl::cordz_info absl::cordz_statistics absl::cordz_test_helpers + absl::cordz_test_helpers absl::cordz_update_tracker absl::span absl::stacktrace @@ -1085,6 +1104,7 @@ absl::optional absl::raw_logging_internal absl::span + absl::string_view absl::strings absl::strings_append_and_overwrite absl::strings_resize_and_overwrite @@ -1105,7 +1125,7 @@ absl::config absl::cord_internal absl::raw_logging_internal - absl::strings + absl::string_view TESTONLY ) @@ -1120,7 +1140,7 @@ absl::config absl::cord absl::cord_internal - absl::strings + absl::string_view TESTONLY PUBLIC ) @@ -1167,10 +1187,11 @@ absl::function_ref absl::hash absl::hash_testing - absl::no_destructor absl::log + absl::no_destructor absl::random_random absl::str_format + absl::string_view absl::strings GTest::gmock_main ) @@ -1188,7 +1209,7 @@ absl::cord_internal absl::cord_rep_test_util absl::core_headers - absl::strings + absl::string_view GTest::gmock_main ) @@ -1207,6 +1228,7 @@ absl::cord_rep_test_util absl::core_headers absl::raw_logging_internal + absl::string_view absl::strings GTest::gmock_main ) @@ -1225,6 +1247,7 @@ absl::cord_rep_test_util absl::core_headers absl::raw_logging_internal + absl::string_view absl::strings GTest::gmock_main ) @@ -1243,7 +1266,7 @@ absl::cord_rep_test_util absl::core_headers absl::raw_logging_internal - absl::strings + absl::string_view GTest::gmock_main ) @@ -1270,19 +1293,20 @@ COPTS ${ABSL_TEST_COPTS} DEPS + absl::base + absl::config absl::cord absl::cord_internal absl::cord_test_helpers - absl::cordz_test_helpers absl::cordz_functions absl::cordz_info absl::cordz_sample_token absl::cordz_statistics + absl::cordz_test_helpers absl::cordz_update_tracker - absl::base - absl::config absl::core_headers absl::raw_logging_internal + absl::string_view absl::strings GTest::gmock_main ) @@ -1299,10 +1323,10 @@ ${ABSL_DEFAULT_COPTS} DEPS absl::config - absl::strings - absl::str_format absl::log_internal_container absl::requires_internal + absl::str_format + absl::strings ) absl_cc_test( @@ -1321,6 +1345,7 @@ absl::status absl::statusor absl::str_format + absl::string_view absl::strings GTest::gmock_main )
diff --git a/absl/strings/cord.cc b/absl/strings/cord.cc index 5827d89..6d9dd10 100644 --- a/absl/strings/cord.cc +++ b/absl/strings/cord.cc
@@ -301,8 +301,7 @@ // -------------------------------------------------------------------- // Constructors and destructors -Cord::Cord(absl::string_view src, MethodIdentifier method) - : contents_(InlineData::kDefaultInit) { +Cord::Cord(absl::string_view src, MethodIdentifier method) { const size_t n = src.size(); if (n <= InlineRep::kMaxInline) { contents_.set_data(src.data(), n); @@ -313,7 +312,7 @@ } template <typename T, Cord::EnableIfString<T>> -Cord::Cord(T&& src) : contents_(InlineData::kDefaultInit) { +Cord::Cord(T&& src) { if (src.size() <= InlineRep::kMaxInline) { contents_.set_data(src.data(), src.size()); } else { @@ -594,7 +593,7 @@ size_t cur_size = contents_.inline_size(); if (cur_size + src.size() <= InlineRep::kMaxInline) { // Use embedded storage. - InlineData data; + InlineData data{}; data.set_inline_size(cur_size + src.size()); memcpy(data.as_chars(), src.data(), src.size()); memcpy(data.as_chars() + src.size(), contents_.data(), cur_size); @@ -623,7 +622,7 @@ assert(src.size() <= cord_internal::kMaxFlatLength); if (contents_.remaining_inline_capacity() >= src.size()) { const size_t cur_size = contents_.inline_size(); - InlineData data; + InlineData data{}; data.set_inline_size(cur_size + src.size()); memcpy(data.as_chars(), src.data(), src.size()); memcpy(data.as_chars() + src.size(), contents_.data(), cur_size);
diff --git a/absl/strings/cord.h b/absl/strings/cord.h index fad5d97..cbba501 100644 --- a/absl/strings/cord.h +++ b/absl/strings/cord.h
@@ -920,8 +920,7 @@ static constexpr unsigned char kMaxInline = cord_internal::kMaxInline; static_assert(kMaxInline >= sizeof(absl::cord_internal::CordRep*)); - constexpr InlineRep() : data_() {} - explicit InlineRep(InlineData::DefaultInitType init) : data_(init) {} + InlineRep() = default; InlineRep(const InlineRep& src); InlineRep(InlineRep&& src); InlineRep& operator=(const InlineRep& src); @@ -1181,8 +1180,7 @@ CordRep* absl_nullable rep) : data_(sv, rep) {} -inline Cord::InlineRep::InlineRep(const Cord::InlineRep& src) - : data_(InlineData::kDefaultInit) { +inline Cord::InlineRep::InlineRep(const Cord::InlineRep& src) { if (CordRep* tree = src.tree()) { EmplaceTree(CordRep::Ref(tree), src.data_, CordzUpdateTracker::kConstructorCord); @@ -1364,7 +1362,7 @@ ResetToEmpty(); } -constexpr inline Cord::Cord() noexcept {} +constexpr inline Cord::Cord() noexcept : contents_() {} inline Cord::Cord(absl::string_view src) : Cord(src, CordzUpdateTracker::kConstructorString) {}
diff --git a/absl/strings/internal/cord_internal.h b/absl/strings/internal/cord_internal.h index cf45907..8a7e85f 100644 --- a/absl/strings/internal/cord_internal.h +++ b/absl/strings/internal/cord_internal.h
@@ -472,9 +472,6 @@ class ABSL_ATTRIBUTE_TRIVIAL_ABI InlineData { public: - // DefaultInitType forces the use of the default initialization constructor. - enum DefaultInitType { kDefaultInit }; - // kNullCordzInfo holds the little endian representation of intptr_t(1) // This is the 'null' / initial value of 'cordz_info'. The null value // is specifically big endian 1 as with 64-bit pointers, the last @@ -488,8 +485,6 @@ InlineData() = default; - explicit InlineData(DefaultInitType) noexcept : rep_(kDefaultInit) {} - explicit InlineData(CordRep* rep) noexcept : rep_(rep) { ABSL_ASSERT(rep != nullptr); } @@ -657,16 +652,16 @@ struct Rep { // See cordz_info_t for forced alignment and size of `cordz_info` details. struct AsTree { + AsTree() = default; + explicit constexpr AsTree(absl::cord_internal::CordRep* tree) - : rep(tree) {} - cordz_info_t cordz_info = kNullCordzInfo; + : cordz_info(kNullCordzInfo), rep(tree) {} + + cordz_info_t cordz_info; absl::cord_internal::CordRep* rep; }; - explicit Rep(DefaultInitType) {} - constexpr Rep() : data{0} {} - constexpr Rep(const Rep&) = default; - constexpr Rep& operator=(const Rep&) = default; + Rep() = default; explicit constexpr Rep(CordRep* rep) : as_tree(rep) {}
diff --git a/absl/strings/internal/cord_rep_flat.h b/absl/strings/internal/cord_rep_flat.h index 34da171..9a2604b 100644 --- a/absl/strings/internal/cord_rep_flat.h +++ b/absl/strings/internal/cord_rep_flat.h
@@ -111,7 +111,7 @@ // Creates a new flat node. template <size_t max_flat_size, typename... Args> - static CordRepFlat* NewImpl(size_t len, Args... args ABSL_ATTRIBUTE_UNUSED) { + static CordRepFlat* NewImpl(size_t len, Args... args [[maybe_unused]]) { if (len <= kMinFlatLength) { len = kMinFlatLength; } else if (len > max_flat_size - kFlatOverhead) {
diff --git a/absl/strings/internal/cordz_info_statistics_test.cc b/absl/strings/internal/cordz_info_statistics_test.cc index 859bb20..fbd4b0e 100644 --- a/absl/strings/internal/cordz_info_statistics_test.cc +++ b/absl/strings/internal/cordz_info_statistics_test.cc
@@ -444,7 +444,7 @@ // Track 0 - 2 cordz infos at a time, providing permutations of 0, 1 // and 2 CordzHandle and CordzInfo queues being active, with plenty of // 'empty to non empty' transitions. - InlineData cords[2]; + InlineData cords[2] = {}; std::minstd_rand gen; std::uniform_int_distribution<int> coin_toss(0, 1); std::uniform_int_distribution<int> dice_roll(1, 6);
diff --git a/absl/synchronization/BUILD.bazel b/absl/synchronization/BUILD.bazel index 57740ef..d5438ba 100644 --- a/absl/synchronization/BUILD.bazel +++ b/absl/synchronization/BUILD.bazel
@@ -146,6 +146,7 @@ "//absl/debugging:stacktrace", "//absl/debugging:symbolize", "//absl/meta:type_traits", + "//absl/strings:string_view", "//absl/time", ] + select({ "//conditions:default": [], @@ -368,7 +369,6 @@ deps = [ ":per_thread_sem_test_common", ":synchronization", - "//absl/strings", "//absl/time", "@googletest//:gtest_main", ],
diff --git a/absl/synchronization/CMakeLists.txt b/absl/synchronization/CMakeLists.txt index 2805000..3502d11 100644 --- a/absl/synchronization/CMakeLists.txt +++ b/absl/synchronization/CMakeLists.txt
@@ -59,8 +59,8 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::kernel_timeout_internal absl::config + absl::kernel_timeout_internal absl::random_random absl::time GTest::gmock_main @@ -100,19 +100,20 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS - absl::graphcycles_internal - absl::kernel_timeout_internal absl::atomic_hook absl::base absl::base_internal absl::config absl::core_headers absl::dynamic_annotations + absl::graphcycles_internal + absl::kernel_timeout_internal absl::malloc_internal absl::meta absl::nullability absl::raw_logging_internal absl::stacktrace + absl::string_view absl::symbolize absl::time absl::tracing_internal @@ -186,8 +187,6 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::synchronization - absl::thread_pool absl::base absl::check absl::config @@ -195,6 +194,8 @@ absl::log absl::memory absl::random_random + absl::synchronization + absl::thread_pool absl::time GTest::gmock_main ) @@ -239,10 +240,10 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::synchronization absl::base absl::config absl::strings + absl::synchronization absl::time GTest::gmock TESTONLY @@ -258,7 +259,6 @@ DEPS absl::per_thread_sem_test_common absl::synchronization - absl::strings absl::time GTest::gmock_main ) @@ -288,7 +288,7 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::synchronization - absl::core_headers absl::check + absl::core_headers + absl::synchronization )
diff --git a/absl/synchronization/mutex.cc b/absl/synchronization/mutex.cc index 6878256..be0d91a 100644 --- a/absl/synchronization/mutex.cc +++ b/absl/synchronization/mutex.cc
@@ -782,7 +782,7 @@ // Since it's not possible to take address of a destructor, we move the // actual destructor code into the separate Dtor function and force the // compiler to emit this function even if it's inline by taking its address. - ABSL_ATTRIBUTE_UNUSED volatile auto dtor = &Mutex::Dtor; + [[maybe_unused]] volatile auto dtor = &Mutex::Dtor; ABSL_ANNOTATE_IGNORE_WRITES_END(); }
diff --git a/absl/time/BUILD.bazel b/absl/time/BUILD.bazel index 073c229..eaea38a 100644 --- a/absl/time/BUILD.bazel +++ b/absl/time/BUILD.bazel
@@ -58,6 +58,7 @@ "//absl/base", "//absl/base:config", "//absl/base:core_headers", + "//absl/base:cycleclock_internal", "//absl/base:raw_logging_internal", "//absl/numeric:int128", "//absl/strings", @@ -215,6 +216,7 @@ ":time", "//absl/flags:flag", "//absl/flags:reflection", + "//absl/strings:string_view", "@googletest//:gtest", "@googletest//:gtest_main", ],
diff --git a/absl/time/CMakeLists.txt b/absl/time/CMakeLists.txt index c3ae98c..7b3e5d6 100644 --- a/absl/time/CMakeLists.txt +++ b/absl/time/CMakeLists.txt
@@ -99,9 +99,9 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS - absl::time absl::config absl::raw_logging_internal + absl::time absl::time_zone TESTONLY ) @@ -119,14 +119,14 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::time_internal_test_util - absl::time absl::config absl::core_headers absl::hash_testing absl::random_random - absl::strings absl::str_format + absl::strings + absl::time + absl::time_internal_test_util absl::time_zone GTest::gmock_main ) @@ -141,13 +141,13 @@ COPTS ${ABSL_DEFAULT_COPTS} DEPS - absl::time absl::config absl::core_headers absl::no_destructor absl::nullability absl::raw_logging_internal absl::synchronization + absl::time ) absl_cc_test( @@ -158,11 +158,11 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::clock_interface - absl::time - absl::config absl::bind_front + absl::clock_interface + absl::config absl::synchronization + absl::time GTest::gmock_main ) @@ -177,11 +177,11 @@ ${ABSL_DEFAULT_COPTS} DEPS absl::clock_interface - absl::time absl::config absl::core_headers absl::nullability absl::synchronization + absl::time TESTONLY ) @@ -193,14 +193,14 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::clock_interface - absl::simulated_clock - absl::time - absl::config absl::bind_front + absl::clock_interface + absl::config absl::random_random absl::raw_logging_internal + absl::simulated_clock absl::synchronization + absl::time GTest::gmock_main )
diff --git a/absl/time/civil_time.cc b/absl/time/civil_time.cc index eae7e7f..33160a7 100644 --- a/absl/time/civil_time.cc +++ b/absl/time/civil_time.cc
@@ -20,6 +20,7 @@ #include <string> #include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" #include "absl/time/time.h" namespace absl {
diff --git a/absl/time/civil_time.h b/absl/time/civil_time.h index 865a99b..6c90659 100644 --- a/absl/time/civil_time.h +++ b/absl/time/civil_time.h
@@ -76,6 +76,7 @@ #include "absl/base/config.h" #include "absl/strings/string_view.h" #include "absl/time/internal/cctz/include/cctz/civil_time.h" +#include "absl/time/internal/cctz/include/cctz/civil_time_detail.h" namespace absl { ABSL_NAMESPACE_BEGIN
diff --git a/absl/time/civil_time_test.cc b/absl/time/civil_time_test.cc index fed0c30..3f03fc1 100644 --- a/absl/time/civil_time_test.cc +++ b/absl/time/civil_time_test.cc
@@ -16,6 +16,7 @@ #include <cstddef> #include <iomanip> +#include <ios> #include <iterator> #include <limits> #include <sstream>
diff --git a/absl/time/clock.cc b/absl/time/clock.cc index b87611a..a5724df 100644 --- a/absl/time/clock.cc +++ b/absl/time/clock.cc
@@ -24,10 +24,12 @@ #include "absl/base/attributes.h" #include "absl/base/internal/spinlock.h" #include "absl/base/internal/unscaledcycleclock.h" +#include "absl/base/internal/unscaledcycleclock_config.h" #include "absl/base/macros.h" #include "absl/base/optimization.h" #include "absl/base/port.h" #include "absl/base/thread_annotations.h" +#include "absl/time/time.h" #ifdef _WIN32 #include <windows.h>
diff --git a/absl/time/clock_benchmark.cc b/absl/time/clock_benchmark.cc index df14ce6..3f83a57 100644 --- a/absl/time/clock_benchmark.cc +++ b/absl/time/clock_benchmark.cc
@@ -11,11 +11,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "absl/time/clock.h" - #include <cstdio> +#include <ctime> #include "absl/base/internal/cycleclock.h" +#include "absl/time/clock.h" +#include "absl/time/time.h" #include "benchmark/benchmark.h" #if !defined(_WIN32)
diff --git a/absl/time/duration_benchmark.cc b/absl/time/duration_benchmark.cc index 5a33c65..069ae44 100644 --- a/absl/time/duration_benchmark.cc +++ b/absl/time/duration_benchmark.cc
@@ -16,6 +16,7 @@ #include <cstdint> #include <ctime> #include <iterator> +#include <limits> #include <string> #include "absl/base/attributes.h"
diff --git a/absl/time/flag_test.cc b/absl/time/flag_test.cc index 8f8532b..59b27dd 100644 --- a/absl/time/flag_test.cc +++ b/absl/time/flag_test.cc
@@ -18,6 +18,7 @@ #include "gtest/gtest.h" #include "absl/flags/reflection.h" +#include "absl/strings/string_view.h" #include "absl/time/civil_time.h" #include "absl/time/time.h"
diff --git a/absl/time/format.cc b/absl/time/format.cc index aa2ae2c..217da58 100644 --- a/absl/time/format.cc +++ b/absl/time/format.cc
@@ -15,7 +15,9 @@ #include <string.h> #include <cctype> +#include <chrono> // NOLINT(build/c++11) #include <cstdint> +#include <string> #include <utility> #include "absl/strings/ascii.h"
diff --git a/absl/time/format_benchmark.cc b/absl/time/format_benchmark.cc index 45109fa..634c371 100644 --- a/absl/time/format_benchmark.cc +++ b/absl/time/format_benchmark.cc
@@ -15,6 +15,7 @@ #include <iterator> #include <string> +#include "absl/time/civil_time.h" #include "absl/time/internal/test_util.h" #include "absl/time/time.h" #include "benchmark/benchmark.h"
diff --git a/absl/time/format_test.cc b/absl/time/format_test.cc index 38c0e3d..0222b6e 100644 --- a/absl/time/format_test.cc +++ b/absl/time/format_test.cc
@@ -18,6 +18,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" +#include "absl/time/civil_time.h" #include "absl/time/internal/test_util.h" #include "absl/time/time.h"
diff --git a/absl/time/internal/test_util.cc b/absl/time/internal/test_util.cc index 3e2452e..cb7455f 100644 --- a/absl/time/internal/test_util.cc +++ b/absl/time/internal/test_util.cc
@@ -14,8 +14,11 @@ #include "absl/time/internal/test_util.h" +#include <string> + #include "absl/base/config.h" #include "absl/base/internal/raw_logging.h" +#include "absl/time/time.h" namespace absl { ABSL_NAMESPACE_BEGIN
diff --git a/absl/time/simulated_clock_test.cc b/absl/time/simulated_clock_test.cc index 4618338..d428f57 100644 --- a/absl/time/simulated_clock_test.cc +++ b/absl/time/simulated_clock_test.cc
@@ -17,6 +17,7 @@ #include <cstddef> #include <cstdint> #include <memory> +#include <optional> #include <thread> // NOLINT(build/c++11) #include <vector>
diff --git a/absl/time/time.cc b/absl/time/time.cc index 4be13cf..4077e2d 100644 --- a/absl/time/time.cc +++ b/absl/time/time.cc
@@ -33,10 +33,14 @@ #include "absl/time/time.h" +#include <chrono> // NOLINT(build/c++11) +#include <cstdint> #include <cstring> #include <ctime> #include <limits> +#include "absl/base/attributes.h" +#include "absl/time/civil_time.h" #include "absl/time/internal/cctz/include/cctz/civil_time.h" #include "absl/time/internal/cctz/include/cctz/time_zone.h"
diff --git a/absl/time/time_benchmark.cc b/absl/time/time_benchmark.cc index db8090a..a7f2421 100644 --- a/absl/time/time_benchmark.cc +++ b/absl/time/time_benchmark.cc
@@ -19,6 +19,7 @@ #include <memory> #include <string> +#include "absl/time/civil_time.h" #include "absl/time/clock.h" #include "absl/time/internal/test_util.h" #include "absl/time/time.h"
diff --git a/absl/time/time_test.cc b/absl/time/time_test.cc index d53198a..7d67ca0 100644 --- a/absl/time/time_test.cc +++ b/absl/time/time_test.cc
@@ -31,6 +31,7 @@ #include <iomanip> #include <ios> #include <limits> +#include <ratio> // NOLINT(build/c++11) #include <string> #include <type_traits>
diff --git a/absl/types/BUILD.bazel b/absl/types/BUILD.bazel index 7ded8da..3ccd28e 100644 --- a/absl/types/BUILD.bazel +++ b/absl/types/BUILD.bazel
@@ -157,6 +157,7 @@ "//absl/hash:hash_testing", "//absl/meta:type_traits", "//absl/strings", + "//absl/strings:string_view", "@googletest//:gtest", "@googletest//:gtest_main", ],
diff --git a/absl/types/CMakeLists.txt b/absl/types/CMakeLists.txt index 79a4c19..e210314 100644 --- a/absl/types/CMakeLists.txt +++ b/absl/types/CMakeLists.txt
@@ -61,6 +61,7 @@ absl::hash_testing absl::raw_logging_internal absl::span + absl::string_view absl::strings absl::type_traits GTest::gmock_main @@ -95,15 +96,15 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::span absl::base absl::config absl::core_headers absl::exception_testing absl::fixed_array absl::hash - absl::inlined_vector absl::hash_testing + absl::inlined_vector + absl::span absl::strings absl::type_traits GTest::gmock_main @@ -117,14 +118,14 @@ COPTS ${ABSL_TEST_COPTS} DEPS - absl::span absl::base absl::config absl::core_headers absl::exception_testing absl::fixed_array - absl::inlined_vector absl::hash_testing + absl::inlined_vector + absl::span absl::strings GTest::gmock_main )
diff --git a/absl/types/span_test.cc b/absl/types/span_test.cc index 5a8b82e..3cc9e3d 100644 --- a/absl/types/span_test.cc +++ b/absl/types/span_test.cc
@@ -796,9 +796,9 @@ template <int i> struct ConstexprTester {}; -#define ABSL_TEST_CONSTEXPR(expr) \ - do { \ - ABSL_ATTRIBUTE_UNUSED ConstexprTester<(static_cast<void>(expr), 1)> t; \ +#define ABSL_TEST_CONSTEXPR(expr) \ + do { \ + [[maybe_unused]] ConstexprTester<(static_cast<void>(expr), 1)> t; \ } while (0) struct ContainerWithConstexprMethods {