re2 1.23.0 → 1.23.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (280) hide show
  1. package/README.md +2 -0
  2. package/binding.gyp +3 -2
  3. package/package.json +5 -5
  4. package/vendor/abseil-cpp/CMake/AbseilDll.cmake +25 -4
  5. package/vendor/abseil-cpp/CMake/AbseilHelpers.cmake +6 -1
  6. package/vendor/abseil-cpp/CMakeLists.txt +2 -2
  7. package/vendor/abseil-cpp/MODULE.bazel +2 -2
  8. package/vendor/abseil-cpp/absl/algorithm/BUILD.bazel +0 -1
  9. package/vendor/abseil-cpp/absl/algorithm/CMakeLists.txt +0 -2
  10. package/vendor/abseil-cpp/absl/algorithm/container.h +191 -140
  11. package/vendor/abseil-cpp/absl/algorithm/container_test.cc +818 -0
  12. package/vendor/abseil-cpp/absl/base/BUILD.bazel +44 -5
  13. package/vendor/abseil-cpp/absl/base/CMakeLists.txt +42 -3
  14. package/vendor/abseil-cpp/absl/base/attributes.h +5 -1
  15. package/vendor/abseil-cpp/absl/base/call_once_test.cc +10 -10
  16. package/vendor/abseil-cpp/absl/base/casts.cc +61 -0
  17. package/vendor/abseil-cpp/absl/base/casts.h +128 -2
  18. package/vendor/abseil-cpp/absl/base/casts_test.cc +151 -0
  19. package/vendor/abseil-cpp/absl/base/config.h +13 -37
  20. package/vendor/abseil-cpp/absl/base/internal/dynamic_annotations.h +1 -1
  21. package/vendor/abseil-cpp/absl/base/internal/iterator_traits.h +4 -0
  22. package/vendor/abseil-cpp/absl/base/internal/nullability_traits.h +71 -0
  23. package/vendor/abseil-cpp/absl/base/internal/nullability_traits_test.cc +98 -0
  24. package/vendor/abseil-cpp/absl/base/internal/raw_logging.cc +3 -4
  25. package/vendor/abseil-cpp/absl/base/internal/spinlock.cc +13 -7
  26. package/vendor/abseil-cpp/absl/base/internal/spinlock.h +16 -11
  27. package/vendor/abseil-cpp/absl/base/internal/strerror_test.cc +2 -1
  28. package/vendor/abseil-cpp/absl/base/internal/sysinfo.cc +0 -9
  29. package/vendor/abseil-cpp/absl/base/internal/sysinfo_test.cc +0 -6
  30. package/vendor/abseil-cpp/absl/base/internal/unscaledcycleclock.cc +1 -1
  31. package/vendor/abseil-cpp/absl/base/internal/unscaledcycleclock_config.h +1 -1
  32. package/vendor/abseil-cpp/absl/base/macros.h +40 -17
  33. package/vendor/abseil-cpp/absl/base/nullability.h +1 -1
  34. package/vendor/abseil-cpp/absl/base/optimization.h +1 -3
  35. package/vendor/abseil-cpp/absl/base/options.h +1 -27
  36. package/vendor/abseil-cpp/absl/base/spinlock_test_common.cc +5 -8
  37. package/vendor/abseil-cpp/absl/cleanup/cleanup.h +4 -0
  38. package/vendor/abseil-cpp/absl/container/BUILD.bazel +195 -2
  39. package/vendor/abseil-cpp/absl/container/CMakeLists.txt +136 -2
  40. package/vendor/abseil-cpp/absl/container/btree_map.h +56 -6
  41. package/vendor/abseil-cpp/absl/container/btree_set.h +52 -6
  42. package/vendor/abseil-cpp/absl/container/btree_test.cc +107 -1
  43. package/vendor/abseil-cpp/absl/container/chunked_queue.h +755 -0
  44. package/vendor/abseil-cpp/absl/container/chunked_queue_benchmark.cc +386 -0
  45. package/vendor/abseil-cpp/absl/container/chunked_queue_test.cc +768 -0
  46. package/vendor/abseil-cpp/absl/container/fixed_array.h +4 -6
  47. package/vendor/abseil-cpp/absl/container/flat_hash_map.h +16 -6
  48. package/vendor/abseil-cpp/absl/container/flat_hash_map_test.cc +1 -2
  49. package/vendor/abseil-cpp/absl/container/flat_hash_set.h +16 -6
  50. package/vendor/abseil-cpp/absl/container/flat_hash_set_test.cc +0 -2
  51. package/vendor/abseil-cpp/absl/container/inlined_vector.h +12 -4
  52. package/vendor/abseil-cpp/absl/container/inlined_vector_test.cc +21 -0
  53. package/vendor/abseil-cpp/absl/container/internal/btree_container.h +14 -5
  54. package/vendor/abseil-cpp/absl/container/internal/chunked_queue.h +173 -0
  55. package/vendor/abseil-cpp/absl/container/internal/common.h +51 -0
  56. package/vendor/abseil-cpp/absl/container/internal/container_memory.h +7 -1
  57. package/vendor/abseil-cpp/absl/container/internal/container_memory_test.cc +11 -0
  58. package/vendor/abseil-cpp/absl/container/internal/hash_generator_testing.cc +0 -2
  59. package/vendor/abseil-cpp/absl/container/internal/hash_generator_testing.h +1 -2
  60. package/vendor/abseil-cpp/absl/container/internal/hash_policy_testing.h +0 -14
  61. package/vendor/abseil-cpp/absl/container/internal/hashtable_control_bytes.h +11 -8
  62. package/vendor/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +3 -4
  63. package/vendor/abseil-cpp/absl/container/internal/hashtablez_sampler.h +23 -6
  64. package/vendor/abseil-cpp/absl/container/internal/hashtablez_sampler_test.cc +31 -15
  65. package/vendor/abseil-cpp/absl/container/internal/heterogeneous_lookup_testing.h +80 -0
  66. package/vendor/abseil-cpp/absl/container/internal/inlined_vector.h +4 -12
  67. package/vendor/abseil-cpp/absl/container/internal/raw_hash_map.h +35 -10
  68. package/vendor/abseil-cpp/absl/container/internal/raw_hash_set.cc +149 -23
  69. package/vendor/abseil-cpp/absl/container/internal/raw_hash_set.h +120 -126
  70. package/vendor/abseil-cpp/absl/container/internal/raw_hash_set_allocator_test.cc +4 -0
  71. package/vendor/abseil-cpp/absl/container/internal/raw_hash_set_benchmark.cc +8 -0
  72. package/vendor/abseil-cpp/absl/container/internal/raw_hash_set_probe_benchmark.cc +14 -59
  73. package/vendor/abseil-cpp/absl/container/internal/raw_hash_set_test.cc +111 -22
  74. package/vendor/abseil-cpp/absl/container/internal/unordered_map_constructor_test.h +53 -112
  75. package/vendor/abseil-cpp/absl/container/internal/unordered_map_lookup_test.h +10 -15
  76. package/vendor/abseil-cpp/absl/container/internal/unordered_map_members_test.h +3 -3
  77. package/vendor/abseil-cpp/absl/container/internal/unordered_map_modifiers_test.h +45 -61
  78. package/vendor/abseil-cpp/absl/container/internal/unordered_set_constructor_test.h +53 -112
  79. package/vendor/abseil-cpp/absl/container/internal/unordered_set_lookup_test.h +6 -9
  80. package/vendor/abseil-cpp/absl/container/internal/unordered_set_members_test.h +3 -3
  81. package/vendor/abseil-cpp/absl/container/internal/unordered_set_modifiers_test.h +25 -31
  82. package/vendor/abseil-cpp/absl/container/linked_hash_map.h +666 -0
  83. package/vendor/abseil-cpp/absl/container/linked_hash_map_benchmark.cc +140 -0
  84. package/vendor/abseil-cpp/absl/container/linked_hash_map_test.cc +987 -0
  85. package/vendor/abseil-cpp/absl/container/linked_hash_set.h +527 -0
  86. package/vendor/abseil-cpp/absl/container/linked_hash_set_benchmark.cc +84 -0
  87. package/vendor/abseil-cpp/absl/container/linked_hash_set_test.cc +947 -0
  88. package/vendor/abseil-cpp/absl/container/node_hash_map.h +17 -6
  89. package/vendor/abseil-cpp/absl/container/node_hash_set.h +16 -5
  90. package/vendor/abseil-cpp/absl/container/node_hash_set_test.cc +1 -2
  91. package/vendor/abseil-cpp/absl/copts/GENERATED_AbseilCopts.cmake +79 -0
  92. package/vendor/abseil-cpp/absl/copts/GENERATED_copts.bzl +79 -0
  93. package/vendor/abseil-cpp/absl/copts/copts.py +17 -4
  94. package/vendor/abseil-cpp/absl/crc/internal/crc_x86_arm_combined.cc +67 -13
  95. package/vendor/abseil-cpp/absl/crc/internal/non_temporal_arm_intrinsics.h +4 -2
  96. package/vendor/abseil-cpp/absl/debugging/BUILD.bazel +31 -0
  97. package/vendor/abseil-cpp/absl/debugging/CMakeLists.txt +34 -0
  98. package/vendor/abseil-cpp/absl/debugging/failure_signal_handler.cc +2 -2
  99. package/vendor/abseil-cpp/absl/debugging/internal/borrowed_fixup_buffer.cc +118 -0
  100. package/vendor/abseil-cpp/absl/debugging/internal/borrowed_fixup_buffer.h +71 -0
  101. package/vendor/abseil-cpp/absl/debugging/internal/borrowed_fixup_buffer_test.cc +97 -0
  102. package/vendor/abseil-cpp/absl/debugging/internal/demangle.cc +2 -2
  103. package/vendor/abseil-cpp/absl/debugging/internal/elf_mem_image.h +4 -4
  104. package/vendor/abseil-cpp/absl/debugging/internal/examine_stack.cc +4 -0
  105. package/vendor/abseil-cpp/absl/debugging/internal/examine_stack.h +7 -0
  106. package/vendor/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +1 -1
  107. package/vendor/abseil-cpp/absl/debugging/internal/stacktrace_emscripten-inl.inc +0 -7
  108. package/vendor/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +3 -2
  109. package/vendor/abseil-cpp/absl/debugging/internal/stacktrace_riscv-inl.inc +2 -1
  110. package/vendor/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc +8 -3
  111. package/vendor/abseil-cpp/absl/debugging/internal/symbolize.h +2 -2
  112. package/vendor/abseil-cpp/absl/debugging/stacktrace.cc +35 -67
  113. package/vendor/abseil-cpp/absl/debugging/stacktrace.h +3 -0
  114. package/vendor/abseil-cpp/absl/debugging/stacktrace_benchmark.cc +24 -1
  115. package/vendor/abseil-cpp/absl/debugging/stacktrace_test.cc +39 -15
  116. package/vendor/abseil-cpp/absl/debugging/symbolize_emscripten.inc +4 -17
  117. package/vendor/abseil-cpp/absl/debugging/symbolize_test.cc +25 -40
  118. package/vendor/abseil-cpp/absl/debugging/symbolize_win32.inc +2 -4
  119. package/vendor/abseil-cpp/absl/flags/BUILD.bazel +1 -0
  120. package/vendor/abseil-cpp/absl/flags/declare.h +9 -0
  121. package/vendor/abseil-cpp/absl/flags/flag.h +2 -1
  122. package/vendor/abseil-cpp/absl/flags/internal/commandlineflag.h +1 -1
  123. package/vendor/abseil-cpp/absl/flags/internal/flag.cc +3 -2
  124. package/vendor/abseil-cpp/absl/flags/marshalling.cc +1 -16
  125. package/vendor/abseil-cpp/absl/flags/parse.cc +4 -2
  126. package/vendor/abseil-cpp/absl/flags/parse_test.cc +1 -1
  127. package/vendor/abseil-cpp/absl/flags/reflection.cc +4 -3
  128. package/vendor/abseil-cpp/absl/functional/BUILD.bazel +4 -0
  129. package/vendor/abseil-cpp/absl/functional/CMakeLists.txt +4 -0
  130. package/vendor/abseil-cpp/absl/functional/any_invocable.h +3 -1
  131. package/vendor/abseil-cpp/absl/functional/function_ref.h +125 -20
  132. package/vendor/abseil-cpp/absl/functional/function_ref_test.cc +122 -9
  133. package/vendor/abseil-cpp/absl/functional/internal/any_invocable.h +13 -2
  134. package/vendor/abseil-cpp/absl/functional/internal/function_ref.h +42 -4
  135. package/vendor/abseil-cpp/absl/hash/hash_benchmark.cc +11 -0
  136. package/vendor/abseil-cpp/absl/hash/hash_test.cc +5 -2
  137. package/vendor/abseil-cpp/absl/hash/internal/hash.cc +184 -53
  138. package/vendor/abseil-cpp/absl/hash/internal/hash.h +116 -10
  139. package/vendor/abseil-cpp/absl/hash/internal/low_level_hash_test.cc +43 -4
  140. package/vendor/abseil-cpp/absl/log/BUILD.bazel +2 -0
  141. package/vendor/abseil-cpp/absl/log/CMakeLists.txt +35 -1
  142. package/vendor/abseil-cpp/absl/log/check_test_impl.inc +59 -4
  143. package/vendor/abseil-cpp/absl/log/die_if_null.cc +3 -1
  144. package/vendor/abseil-cpp/absl/log/die_if_null.h +24 -3
  145. package/vendor/abseil-cpp/absl/log/internal/BUILD.bazel +31 -1
  146. package/vendor/abseil-cpp/absl/log/internal/check_impl.h +2 -1
  147. package/vendor/abseil-cpp/absl/log/internal/check_op.cc +3 -1
  148. package/vendor/abseil-cpp/absl/log/internal/check_op.h +44 -18
  149. package/vendor/abseil-cpp/absl/log/internal/conditions.h +38 -35
  150. package/vendor/abseil-cpp/absl/log/internal/container.h +312 -0
  151. package/vendor/abseil-cpp/absl/log/internal/container_test.cc +254 -0
  152. package/vendor/abseil-cpp/absl/log/internal/log_impl.h +108 -110
  153. package/vendor/abseil-cpp/absl/log/internal/log_message.cc +5 -2
  154. package/vendor/abseil-cpp/absl/log/internal/log_message.h +5 -1
  155. package/vendor/abseil-cpp/absl/log/internal/strip.h +30 -31
  156. package/vendor/abseil-cpp/absl/log/internal/vlog_config.cc +19 -19
  157. package/vendor/abseil-cpp/absl/log/internal/vlog_config.h +0 -1
  158. package/vendor/abseil-cpp/absl/log/log.h +2 -2
  159. package/vendor/abseil-cpp/absl/meta/BUILD.bazel +51 -0
  160. package/vendor/abseil-cpp/absl/meta/CMakeLists.txt +46 -0
  161. package/vendor/abseil-cpp/absl/meta/internal/constexpr_testing.h +73 -0
  162. package/vendor/abseil-cpp/absl/meta/internal/constexpr_testing_test.cc +40 -0
  163. package/vendor/abseil-cpp/absl/meta/internal/requires.h +67 -0
  164. package/vendor/abseil-cpp/absl/meta/internal/requires_test.cc +66 -0
  165. package/vendor/abseil-cpp/absl/meta/type_traits.h +42 -1
  166. package/vendor/abseil-cpp/absl/meta/type_traits_test.cc +14 -0
  167. package/vendor/abseil-cpp/absl/numeric/int128.h +41 -21
  168. package/vendor/abseil-cpp/absl/numeric/int128_have_intrinsic.inc +16 -22
  169. package/vendor/abseil-cpp/absl/numeric/int128_no_intrinsic.inc +5 -7
  170. package/vendor/abseil-cpp/absl/numeric/int128_test.cc +52 -5
  171. package/vendor/abseil-cpp/absl/profiling/BUILD.bazel +1 -0
  172. package/vendor/abseil-cpp/absl/profiling/CMakeLists.txt +1 -0
  173. package/vendor/abseil-cpp/absl/profiling/hashtable.cc +18 -7
  174. package/vendor/abseil-cpp/absl/profiling/internal/profile_builder.cc +1 -0
  175. package/vendor/abseil-cpp/absl/random/internal/fastmath_test.cc +3 -5
  176. package/vendor/abseil-cpp/absl/random/internal/platform.h +0 -13
  177. package/vendor/abseil-cpp/absl/random/internal/randen_engine_test.cc +0 -1
  178. package/vendor/abseil-cpp/absl/random/internal/seed_material.cc +1 -27
  179. package/vendor/abseil-cpp/absl/status/BUILD.bazel +17 -0
  180. package/vendor/abseil-cpp/absl/status/CMakeLists.txt +16 -0
  181. package/vendor/abseil-cpp/absl/status/internal/status_internal.h +4 -2
  182. package/vendor/abseil-cpp/absl/status/internal/status_matchers.h +2 -2
  183. package/vendor/abseil-cpp/absl/status/internal/statusor_internal.h +2 -1
  184. package/vendor/abseil-cpp/absl/status/status.cc +4 -0
  185. package/vendor/abseil-cpp/absl/status/status.h +5 -0
  186. package/vendor/abseil-cpp/absl/status/status_matchers.h +48 -0
  187. package/vendor/abseil-cpp/absl/status/status_matchers_test.cc +27 -0
  188. package/vendor/abseil-cpp/absl/status/status_test.cc +1 -0
  189. package/vendor/abseil-cpp/absl/status/statusor.h +1 -1
  190. package/vendor/abseil-cpp/absl/strings/BUILD.bazel +101 -21
  191. package/vendor/abseil-cpp/absl/strings/CMakeLists.txt +99 -5
  192. package/vendor/abseil-cpp/absl/strings/ascii.h +9 -4
  193. package/vendor/abseil-cpp/absl/strings/cord.cc +15 -10
  194. package/vendor/abseil-cpp/absl/strings/cord.h +1 -1
  195. package/vendor/abseil-cpp/absl/strings/escaping.cc +126 -94
  196. package/vendor/abseil-cpp/absl/strings/internal/append_and_overwrite.h +93 -0
  197. package/vendor/abseil-cpp/absl/strings/internal/append_and_overwrite_test.cc +95 -0
  198. package/vendor/abseil-cpp/absl/strings/internal/cord_internal.h +2 -0
  199. package/vendor/abseil-cpp/absl/strings/internal/cord_rep_btree_test.cc +8 -8
  200. package/vendor/abseil-cpp/absl/strings/internal/cordz_info.cc +24 -18
  201. package/vendor/abseil-cpp/absl/strings/internal/cordz_info.h +10 -16
  202. package/vendor/abseil-cpp/absl/strings/internal/escaping.h +9 -7
  203. package/vendor/abseil-cpp/absl/strings/internal/generic_printer.cc +107 -0
  204. package/vendor/abseil-cpp/absl/strings/internal/generic_printer.h +115 -0
  205. package/vendor/abseil-cpp/absl/strings/internal/generic_printer_internal.h +423 -0
  206. package/vendor/abseil-cpp/absl/strings/internal/generic_printer_test.cc +685 -0
  207. package/vendor/abseil-cpp/absl/strings/internal/resize_uninitialized.h +0 -12
  208. package/vendor/abseil-cpp/absl/strings/internal/str_format/checker.h +2 -4
  209. package/vendor/abseil-cpp/absl/strings/internal/str_format/convert_test.cc +21 -7
  210. package/vendor/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc +495 -8
  211. package/vendor/abseil-cpp/absl/strings/internal/str_join_internal.h +18 -15
  212. package/vendor/abseil-cpp/absl/strings/numbers.cc +71 -8
  213. package/vendor/abseil-cpp/absl/strings/numbers.h +25 -12
  214. package/vendor/abseil-cpp/absl/strings/numbers_test.cc +70 -0
  215. package/vendor/abseil-cpp/absl/strings/resize_and_overwrite.h +194 -0
  216. package/vendor/abseil-cpp/absl/strings/resize_and_overwrite_test.cc +154 -0
  217. package/vendor/abseil-cpp/absl/strings/str_cat.cc +96 -91
  218. package/vendor/abseil-cpp/absl/strings/str_cat.h +17 -12
  219. package/vendor/abseil-cpp/absl/strings/str_format_test.cc +4 -4
  220. package/vendor/abseil-cpp/absl/strings/str_split.h +1 -1
  221. package/vendor/abseil-cpp/absl/strings/str_split_test.cc +1 -1
  222. package/vendor/abseil-cpp/absl/strings/string_view.h +8 -718
  223. package/vendor/abseil-cpp/absl/strings/string_view_test.cc +1 -1265
  224. package/vendor/abseil-cpp/absl/strings/substitute.cc +24 -24
  225. package/vendor/abseil-cpp/absl/synchronization/BUILD.bazel +2 -3
  226. package/vendor/abseil-cpp/absl/synchronization/CMakeLists.txt +1 -0
  227. package/vendor/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +2 -2
  228. package/vendor/abseil-cpp/absl/synchronization/internal/kernel_timeout_test.cc +15 -5
  229. package/vendor/abseil-cpp/absl/synchronization/mutex.cc +2 -1
  230. package/vendor/abseil-cpp/absl/synchronization/mutex.h +47 -23
  231. package/vendor/abseil-cpp/absl/synchronization/notification.h +1 -1
  232. package/vendor/abseil-cpp/absl/time/CMakeLists.txt +2 -0
  233. package/vendor/abseil-cpp/absl/time/civil_time_benchmark.cc +1 -2
  234. package/vendor/abseil-cpp/absl/time/civil_time_test.cc +58 -103
  235. package/vendor/abseil-cpp/absl/time/clock.cc +18 -16
  236. package/vendor/abseil-cpp/absl/time/clock_test.cc +2 -2
  237. package/vendor/abseil-cpp/absl/time/duration_benchmark.cc +144 -0
  238. package/vendor/abseil-cpp/absl/time/duration_test.cc +26 -29
  239. package/vendor/abseil-cpp/absl/time/internal/cctz/BUILD.bazel +7 -1
  240. package/vendor/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc +4 -2
  241. package/vendor/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc +6 -103
  242. package/vendor/abseil-cpp/absl/time/internal/cctz/src/time_zone_name_win.cc +186 -0
  243. package/vendor/abseil-cpp/absl/time/internal/cctz/src/time_zone_name_win.h +37 -0
  244. package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/version +1 -1
  245. package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Ensenada +0 -0
  246. package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Santa_Isabel +0 -0
  247. package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Tijuana +0 -0
  248. package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Mexico/BajaNorte +0 -0
  249. package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/iso3166.tab +9 -9
  250. package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/zone1970.tab +12 -12
  251. package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/zonenow.tab +47 -47
  252. package/vendor/abseil-cpp/absl/time/time.cc +4 -4
  253. package/vendor/abseil-cpp/absl/time/time.h +10 -10
  254. package/vendor/abseil-cpp/absl/time/time_test.cc +1 -0
  255. package/vendor/abseil-cpp/absl/types/compare.h +62 -61
  256. package/vendor/abseil-cpp/absl/types/compare_test.cc +3 -3
  257. package/vendor/abseil-cpp/absl/types/internal/span.h +1 -0
  258. package/vendor/abseil-cpp/absl/types/optional.h +2 -2
  259. package/vendor/abseil-cpp/absl/types/span.h +10 -2
  260. package/vendor/abseil-cpp/absl/utility/utility.h +13 -0
  261. package/vendor/abseil-cpp/ci/absl_alternate_options.h +0 -1
  262. package/vendor/abseil-cpp/ci/cmake_common.sh +1 -1
  263. package/vendor/abseil-cpp/ci/cmake_install_test.sh +6 -0
  264. package/vendor/abseil-cpp/ci/linux_arm_clang-latest_libcxx_bazel.sh +1 -0
  265. package/vendor/abseil-cpp/ci/linux_clang-latest_libcxx_asan_bazel.sh +2 -0
  266. package/vendor/abseil-cpp/ci/linux_clang-latest_libcxx_bazel.sh +1 -0
  267. package/vendor/abseil-cpp/ci/linux_clang-latest_libcxx_tsan_bazel.sh +1 -0
  268. package/vendor/abseil-cpp/ci/linux_clang-latest_libstdcxx_bazel.sh +1 -0
  269. package/vendor/abseil-cpp/ci/linux_gcc-floor_libstdcxx_bazel.sh +1 -0
  270. package/vendor/abseil-cpp/ci/linux_gcc-latest_libstdcxx_bazel.sh +1 -0
  271. package/vendor/abseil-cpp/ci/linux_gcc-latest_libstdcxx_cmake.sh +6 -0
  272. package/vendor/abseil-cpp/ci/linux_gcc_alpine_cmake.sh +6 -0
  273. package/vendor/abseil-cpp/ci/macos_xcode_bazel.sh +3 -2
  274. package/vendor/abseil-cpp/ci/macos_xcode_cmake.sh +5 -0
  275. package/vendor/abseil-cpp/ci/windows_clangcl_bazel.bat +1 -0
  276. package/vendor/abseil-cpp/ci/windows_msvc_bazel.bat +1 -0
  277. package/vendor/abseil-cpp/ci/windows_msvc_cmake.bat +6 -1
  278. package/vendor/abseil-cpp/absl/base/internal/identity.h +0 -39
  279. package/vendor/abseil-cpp/absl/strings/string_view.cc +0 -257
  280. package/vendor/abseil-cpp/absl/strings/string_view_benchmark.cc +0 -380
@@ -50,11 +50,15 @@ ABSL_NAMESPACE_BEGIN
50
50
  bool SimpleAtof(absl::string_view str, float* absl_nonnull out) {
51
51
  *out = 0.0;
52
52
  str = StripAsciiWhitespace(str);
53
+ if (str.empty()) {
54
+ // absl::from_chars doesn't accept empty strings.
55
+ return false;
56
+ }
53
57
  // std::from_chars doesn't accept an initial +, but SimpleAtof does, so if one
54
58
  // is present, skip it, while avoiding accepting "+-0" as valid.
55
- if (!str.empty() && str[0] == '+') {
59
+ if (str[0] == '+') {
56
60
  str.remove_prefix(1);
57
- if (!str.empty() && str[0] == '-') {
61
+ if (str.empty() || str[0] == '-') {
58
62
  return false;
59
63
  }
60
64
  }
@@ -81,11 +85,15 @@ bool SimpleAtof(absl::string_view str, float* absl_nonnull out) {
81
85
  bool SimpleAtod(absl::string_view str, double* absl_nonnull out) {
82
86
  *out = 0.0;
83
87
  str = StripAsciiWhitespace(str);
88
+ if (str.empty()) {
89
+ // absl::from_chars doesn't accept empty strings.
90
+ return false;
91
+ }
84
92
  // std::from_chars doesn't accept an initial +, but SimpleAtod does, so if one
85
93
  // is present, skip it, while avoiding accepting "+-0" as valid.
86
- if (!str.empty() && str[0] == '+') {
94
+ if (str[0] == '+') {
87
95
  str.remove_prefix(1);
88
- if (!str.empty() && str[0] == '-') {
96
+ if (str.empty() || str[0] == '-') {
89
97
  return false;
90
98
  }
91
99
  }
@@ -234,6 +242,18 @@ inline uint64_t PrepareEightDigits(uint32_t i) {
234
242
  return tens;
235
243
  }
236
244
 
245
+
246
+ // Encodes v to buffer as 16 digits padded with leading zeros.
247
+ // Pre-condition: v must be < 10^16.
248
+ inline char* EncodePadded16(uint64_t v, char* absl_nonnull buffer) {
249
+ constexpr uint64_t k1e8 = 100000000;
250
+ uint32_t hi = static_cast<uint32_t>(v / k1e8);
251
+ uint32_t lo = static_cast<uint32_t>(v % k1e8);
252
+ little_endian::Store64(buffer, PrepareEightDigits(hi) + kEightZeroBytes);
253
+ little_endian::Store64(buffer + 8, PrepareEightDigits(lo) + kEightZeroBytes);
254
+ return buffer + 16;
255
+ }
256
+
237
257
  inline ABSL_ATTRIBUTE_ALWAYS_INLINE char* absl_nonnull EncodeFullU32(
238
258
  uint32_t n, char* absl_nonnull out_str) {
239
259
  if (n < 10) {
@@ -257,19 +277,19 @@ inline ABSL_ATTRIBUTE_ALWAYS_INLINE char* absl_nonnull EncodeFullU32(
257
277
  return out_str + sizeof(bottom);
258
278
  }
259
279
 
260
- inline ABSL_ATTRIBUTE_ALWAYS_INLINE char* EncodeFullU64(uint64_t i,
261
- char* buffer) {
280
+ inline ABSL_ATTRIBUTE_ALWAYS_INLINE char* absl_nonnull EncodeFullU64(
281
+ uint64_t i, char* absl_nonnull buffer) {
262
282
  if (i <= std::numeric_limits<uint32_t>::max()) {
263
283
  return EncodeFullU32(static_cast<uint32_t>(i), buffer);
264
284
  }
265
285
  uint32_t mod08;
266
286
  if (i < 1'0000'0000'0000'0000ull) {
267
287
  uint32_t div08 = static_cast<uint32_t>(i / 100'000'000ull);
268
- mod08 = static_cast<uint32_t>(i % 100'000'000ull);
288
+ mod08 = static_cast<uint32_t>(i % 100'000'000ull);
269
289
  buffer = EncodeFullU32(div08, buffer);
270
290
  } else {
271
291
  uint64_t div08 = i / 100'000'000ull;
272
- mod08 = static_cast<uint32_t>(i % 100'000'000ull);
292
+ mod08 = static_cast<uint32_t>(i % 100'000'000ull);
273
293
  uint32_t div016 = static_cast<uint32_t>(div08 / 100'000'000ull);
274
294
  uint32_t div08mod08 = static_cast<uint32_t>(div08 % 100'000'000ull);
275
295
  uint64_t mid_result = PrepareEightDigits(div08mod08) + kEightZeroBytes;
@@ -282,6 +302,30 @@ inline ABSL_ATTRIBUTE_ALWAYS_INLINE char* EncodeFullU64(uint64_t i,
282
302
  return buffer + sizeof(mod_result);
283
303
  }
284
304
 
305
+ inline ABSL_ATTRIBUTE_ALWAYS_INLINE char* absl_nonnull EncodeFullU128(
306
+ uint128 i, char* absl_nonnull buffer) {
307
+ if (absl::Uint128High64(i) == 0) {
308
+ return EncodeFullU64(absl::Uint128Low64(i), buffer);
309
+ }
310
+ // We divide the number into 16-digit chunks because `EncodePadded16` is
311
+ // optimized to handle 16 digits at a time (as two 8-digit chunks).
312
+ constexpr uint64_t k1e16 = uint64_t{10'000'000'000'000'000};
313
+ uint128 high = i / k1e16;
314
+ uint64_t low = absl::Uint128Low64(i % k1e16);
315
+ uint64_t mid = absl::Uint128Low64(high % k1e16);
316
+ high /= k1e16;
317
+
318
+ if (high == 0) {
319
+ buffer = EncodeFullU64(mid, buffer);
320
+ buffer = EncodePadded16(low, buffer);
321
+ } else {
322
+ buffer = EncodeFullU64(absl::Uint128Low64(high), buffer);
323
+ buffer = EncodePadded16(mid, buffer);
324
+ buffer = EncodePadded16(low, buffer);
325
+ }
326
+ return buffer;
327
+ }
328
+
285
329
  } // namespace
286
330
 
287
331
  void numbers_internal::PutTwoDigits(uint32_t i, char* absl_nonnull buf) {
@@ -337,6 +381,25 @@ char* absl_nonnull numbers_internal::FastIntToBuffer(
337
381
  return buffer;
338
382
  }
339
383
 
384
+ char* absl_nonnull numbers_internal::FastIntToBuffer(
385
+ uint128 i, char* absl_nonnull buffer) {
386
+ buffer = EncodeFullU128(i, buffer);
387
+ *buffer = '\0';
388
+ return buffer;
389
+ }
390
+
391
+ char* absl_nonnull numbers_internal::FastIntToBuffer(
392
+ int128 i, char* absl_nonnull buffer) {
393
+ uint128 u = static_cast<uint128>(i);
394
+ if (i < 0) {
395
+ *buffer++ = '-';
396
+ u = -u;
397
+ }
398
+ buffer = EncodeFullU128(u, buffer);
399
+ *buffer = '\0';
400
+ return buffer;
401
+ }
402
+
340
403
  // Given a 128-bit number expressed as a pair of uint64_t, high half first,
341
404
  // return that number multiplied by the given 32-bit value. If the result is
342
405
  // too large to fit in a 128-bit number, divide it by 2 until it fits.
@@ -174,8 +174,9 @@ bool safe_strtou64_base(absl::string_view text, uint64_t* absl_nonnull value,
174
174
  bool safe_strtou128_base(absl::string_view text,
175
175
  absl::uint128* absl_nonnull value, int base);
176
176
 
177
- static const int kFastToBufferSize = 32;
178
- static const int kSixDigitsToBufferSize = 16;
177
+ inline constexpr int kFastToBuffer128Size = 41;
178
+ inline constexpr int kFastToBufferSize = 32;
179
+ inline constexpr int kSixDigitsToBufferSize = 16;
179
180
 
180
181
  // Helper function for fast formatting of floating-point values.
181
182
  // The result is the same as printf's "%g", a.k.a. "%.6g"; that is, six
@@ -188,7 +189,8 @@ size_t SixDigitsToBuffer(double d, char* absl_nonnull buffer);
188
189
  // WARNING: These functions may write more characters than necessary, because
189
190
  // they are intended for speed. All functions take an output buffer
190
191
  // as an argument and return a pointer to the last byte they wrote, which is the
191
- // terminating '\0'. At most `kFastToBufferSize` bytes are written.
192
+ // terminating '\0'. The maximum size written is `kFastToBufferSize` for 64-bit
193
+ // integers or less, and `kFastToBuffer128Size` for 128-bit integers.
192
194
  char* absl_nonnull FastIntToBuffer(int32_t i, char* absl_nonnull buffer)
193
195
  ABSL_INTERNAL_NEED_MIN_SIZE(buffer, kFastToBufferSize);
194
196
  char* absl_nonnull FastIntToBuffer(uint32_t n, char* absl_nonnull out_str)
@@ -197,25 +199,36 @@ char* absl_nonnull FastIntToBuffer(int64_t i, char* absl_nonnull buffer)
197
199
  ABSL_INTERNAL_NEED_MIN_SIZE(buffer, kFastToBufferSize);
198
200
  char* absl_nonnull FastIntToBuffer(uint64_t i, char* absl_nonnull buffer)
199
201
  ABSL_INTERNAL_NEED_MIN_SIZE(buffer, kFastToBufferSize);
200
-
201
- // For enums and integer types that are not an exact match for the types above,
202
- // use templates to call the appropriate one of the four overloads above.
202
+ char* absl_nonnull FastIntToBuffer(int128 i, char* absl_nonnull buffer)
203
+ ABSL_INTERNAL_NEED_MIN_SIZE(buffer, kFastToBuffer128Size);
204
+ char* absl_nonnull FastIntToBuffer(uint128 i, char* absl_nonnull buffer)
205
+ ABSL_INTERNAL_NEED_MIN_SIZE(buffer, kFastToBuffer128Size);
206
+
207
+ // For enums and integer types that are up to 128 bits and are not an exact
208
+ // match for the types above, use templates to call the appropriate one of the
209
+ // four overloads above.
203
210
  template <typename int_type>
204
- char* absl_nonnull FastIntToBuffer(int_type i, char* absl_nonnull buffer)
205
- ABSL_INTERNAL_NEED_MIN_SIZE(buffer, kFastToBufferSize) {
206
- static_assert(sizeof(i) <= 64 / 8,
207
- "FastIntToBuffer works only with 64-bit-or-less integers.");
211
+ char* absl_nonnull FastIntToBuffer(int_type i,
212
+ char* absl_nonnull buffer)
213
+ ABSL_INTERNAL_NEED_MIN_SIZE(
214
+ buffer, (sizeof(int_type) > 8 ? kFastToBuffer128Size
215
+ : kFastToBufferSize)) {
208
216
  // These conditions are constexpr bools to suppress MSVC warning C4127.
209
217
  constexpr bool kIsSigned = is_signed<int_type>();
210
218
  constexpr bool kUse64Bit = sizeof(i) > 32 / 8;
219
+ constexpr bool kUse128Bit = sizeof(i) > 64 / 8;
211
220
  if (kIsSigned) {
212
- if (kUse64Bit) {
221
+ if constexpr (kUse128Bit) {
222
+ return FastIntToBuffer(static_cast<int128>(i), buffer);
223
+ } else if constexpr (kUse64Bit) {
213
224
  return FastIntToBuffer(static_cast<int64_t>(i), buffer);
214
225
  } else {
215
226
  return FastIntToBuffer(static_cast<int32_t>(i), buffer);
216
227
  }
217
228
  } else {
218
- if (kUse64Bit) {
229
+ if constexpr (kUse128Bit) {
230
+ return FastIntToBuffer(static_cast<uint128>(i), buffer);
231
+ } else if constexpr (kUse64Bit) {
219
232
  return FastIntToBuffer(static_cast<uint64_t>(i), buffer);
220
233
  } else {
221
234
  return FastIntToBuffer(static_cast<uint32_t>(i), buffer);
@@ -159,6 +159,8 @@ struct MyInteger {
159
159
 
160
160
  typedef MyInteger<int64_t> MyInt64;
161
161
  typedef MyInteger<uint64_t> MyUInt64;
162
+ typedef MyInteger<absl::uint128> MyUInt128;
163
+ typedef MyInteger<absl::int128> MyInt128;
162
164
 
163
165
  void CheckInt32(int32_t x) {
164
166
  char buffer[absl::numbers_internal::kFastToBufferSize];
@@ -212,6 +214,32 @@ void CheckUInt64(uint64_t x) {
212
214
  EXPECT_EQ(expected, std::string(&buffer[1], my_actual)) << " Input " << x;
213
215
  }
214
216
 
217
+ void CheckUInt128(absl::uint128 x) {
218
+ char buffer[absl::numbers_internal::kFastToBuffer128Size];
219
+ char* actual = absl::numbers_internal::FastIntToBuffer(x, buffer);
220
+ std::string s;
221
+ absl::strings_internal::OStringStream strm(&s);
222
+ strm << x;
223
+ EXPECT_EQ(s, std::string(buffer, actual)) << " Input " << s;
224
+
225
+ char* my_actual =
226
+ absl::numbers_internal::FastIntToBuffer(MyUInt128(x), buffer);
227
+ EXPECT_EQ(s, std::string(buffer, my_actual)) << " Input " << s;
228
+ }
229
+
230
+ void CheckInt128(absl::int128 x) {
231
+ char buffer[absl::numbers_internal::kFastToBuffer128Size];
232
+ char* actual = absl::numbers_internal::FastIntToBuffer(x, buffer);
233
+ std::string s;
234
+ absl::strings_internal::OStringStream strm(&s);
235
+ strm << x;
236
+ EXPECT_EQ(s, std::string(buffer, actual)) << " Input " << s;
237
+
238
+ char* my_actual =
239
+ absl::numbers_internal::FastIntToBuffer(MyInt128(x), buffer);
240
+ EXPECT_EQ(s, std::string(buffer, my_actual)) << " Input " << s;
241
+ }
242
+
215
243
  void CheckHex64(uint64_t v) {
216
244
  char expected[16 + 1];
217
245
  std::string actual = absl::StrCat(absl::Hex(v, absl::kZeroPad16));
@@ -251,6 +279,34 @@ TEST(Numbers, TestFastPrints) {
251
279
  CheckUInt64(uint64_t{1000000000000000000});
252
280
  CheckUInt64(uint64_t{1199999999999999999});
253
281
  CheckUInt64(std::numeric_limits<uint64_t>::max());
282
+ CheckUInt128(0);
283
+ CheckUInt128(1);
284
+ CheckUInt128(9);
285
+ CheckUInt128(10);
286
+ CheckUInt128(99);
287
+ CheckUInt128(100);
288
+ CheckUInt128(std::numeric_limits<uint64_t>::max());
289
+ CheckUInt128(absl::uint128(std::numeric_limits<uint64_t>::max()) + 1);
290
+ CheckUInt128(absl::MakeUint128(1, 0));
291
+ absl::uint128 k1e16 = 10000000000000000ULL;
292
+ CheckUInt128(k1e16 - 1);
293
+ CheckUInt128(k1e16);
294
+ CheckUInt128(k1e16 + 1);
295
+ CheckUInt128(k1e16 * k1e16 - 1);
296
+ CheckUInt128(k1e16 * k1e16);
297
+ CheckUInt128(k1e16 * k1e16 + 1);
298
+ CheckUInt128(absl::Uint128Max() - 1);
299
+ CheckUInt128(absl::Uint128Max());
300
+
301
+ CheckInt128(0);
302
+ CheckInt128(1);
303
+ CheckInt128(-1);
304
+ CheckInt128(10);
305
+ CheckInt128(-10);
306
+ CheckInt128(absl::Int128Max());
307
+ CheckInt128(absl::Int128Min());
308
+ CheckInt128(absl::MakeInt128(-1, 1));
309
+ CheckInt128(absl::MakeInt128(-1, std::numeric_limits<uint64_t>::max()));
254
310
 
255
311
  for (int i = 0; i < 10000; i++) {
256
312
  CheckHex64(i);
@@ -451,6 +507,20 @@ TEST(NumbersTest, Atoi) {
451
507
  VerifySimpleAtoiGood<std::string::size_type>(42, 42);
452
508
  }
453
509
 
510
+ TEST(NumbersTest, AtodEmpty) {
511
+ double d;
512
+ EXPECT_FALSE(absl::SimpleAtod("", &d));
513
+ // Empty string_view takes a different code path from "".
514
+ EXPECT_FALSE(absl::SimpleAtod({}, &d));
515
+ }
516
+
517
+ TEST(NumbersTest, AtofEmpty) {
518
+ float f;
519
+ EXPECT_FALSE(absl::SimpleAtof("", &f));
520
+ // Empty string_view takes a different code path from "".
521
+ EXPECT_FALSE(absl::SimpleAtof({}, &f));
522
+ }
523
+
454
524
  TEST(NumbersTest, Atod) {
455
525
  // DBL_TRUE_MIN and FLT_TRUE_MIN were not mandated in <cfloat> before C++17.
456
526
  #if !defined(DBL_TRUE_MIN)
@@ -0,0 +1,194 @@
1
+ // Copyright 2025 The Abseil Authors
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // https://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ //
15
+ // -----------------------------------------------------------------------------
16
+ // File: resize_and_overwrite.h
17
+ // -----------------------------------------------------------------------------
18
+ //
19
+ // This file contains a polyfill for C++23's
20
+ // std::basic_string<CharT,Traits,Allocator>::resize_and_overwrite
21
+ //
22
+ // The polyfill takes the form of a free function:
23
+
24
+ // template<typename T, typename Op>
25
+ // void StringResizeAndOverwrite(T& str, typename T::size_type count, Op op);
26
+ //
27
+ // This avoids the cost of initializing a suitably-sized std::string when it is
28
+ // intended to be used as a char array, for example, to be populated by a
29
+ // C-style API.
30
+ //
31
+ // Example usage:
32
+ //
33
+ // std::string IntToString(int n) {
34
+ // std::string result;
35
+ // constexpr size_t kMaxIntChars = 10;
36
+ // absl::StringResizeAndOverwrite(
37
+ // result, kMaxIntChars, [n](char* buffer, size_t buffer_size) {
38
+ // return snprintf(buffer, buffer_size, "%d", n);
39
+ // });
40
+ // return result;
41
+ // }
42
+ //
43
+ // https://en.cppreference.com/w/cpp/string/basic_string/resize_and_overwrite.html
44
+ // https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p1072r10.html
45
+
46
+ #ifndef ABSL_STRINGS_RESIZE_AND_OVERWRITE_H_
47
+ #define ABSL_STRINGS_RESIZE_AND_OVERWRITE_H_
48
+
49
+ #include <cstddef>
50
+ #include <string> // IWYU pragma: keep
51
+ #include <type_traits>
52
+ #include <utility>
53
+
54
+ #include "absl/base/config.h"
55
+ #include "absl/base/dynamic_annotations.h"
56
+ #include "absl/base/internal/throw_delegate.h"
57
+ #include "absl/base/macros.h"
58
+ #include "absl/base/optimization.h"
59
+
60
+ #if defined(__cpp_lib_string_resize_and_overwrite) && \
61
+ __cpp_lib_string_resize_and_overwrite >= 202110L
62
+ #define ABSL_INTERNAL_HAS_RESIZE_AND_OVERWRITE 1
63
+ #endif
64
+
65
+ namespace absl {
66
+ ABSL_NAMESPACE_BEGIN
67
+
68
+ namespace strings_internal {
69
+
70
+ #ifndef ABSL_INTERNAL_HAS_RESIZE_AND_OVERWRITE
71
+
72
+ inline size_t ProbeResizeAndOverwriteOp(char*, size_t) { return 0; }
73
+
74
+ // Prior to C++23, Google's libc++ backports resize_and_overwrite as
75
+ // __google_nonstandard_backport_resize_and_overwrite
76
+ template <typename T, typename = void>
77
+ struct has__google_nonstandard_backport_resize_and_overwrite : std::false_type {
78
+ };
79
+
80
+ template <typename T>
81
+ struct has__google_nonstandard_backport_resize_and_overwrite<
82
+ T,
83
+ std::void_t<
84
+ decltype(std::declval<T&>()
85
+ .__google_nonstandard_backport_resize_and_overwrite(
86
+ std::declval<size_t>(), ProbeResizeAndOverwriteOp))>>
87
+ : std::true_type {};
88
+
89
+ // Prior to C++23, the version of libstdc++ that shipped with GCC >= 14
90
+ // has __resize_and_overwrite.
91
+ template <typename T, typename = void>
92
+ struct has__resize_and_overwrite : std::false_type {};
93
+
94
+ template <typename T>
95
+ struct has__resize_and_overwrite<
96
+ T, std::void_t<decltype(std::declval<T&>().__resize_and_overwrite(
97
+ std::declval<size_t>(), ProbeResizeAndOverwriteOp))>>
98
+ : std::true_type {};
99
+
100
+ // libc++ used __resize_default_init to achieve uninitialized string resizes
101
+ // before removing it September 2025, in favor of resize_and_overwrite.
102
+ // https://github.com/llvm/llvm-project/commit/92f5d8df361bb1bb6dea88f86faeedfd295ab970
103
+ template <typename T, typename = void>
104
+ struct has__resize_default_init : std::false_type {};
105
+
106
+ template <typename T>
107
+ struct has__resize_default_init<
108
+ T, std::void_t<decltype(std::declval<T&>().__resize_default_init(42))>>
109
+ : std::true_type {};
110
+
111
+ // Prior to C++23, some versions of MSVC have _Resize_and_overwrite.
112
+ template <typename T, typename = void>
113
+ struct has_Resize_and_overwrite : std::false_type {};
114
+
115
+ template <typename T>
116
+ struct has_Resize_and_overwrite<
117
+ T, std::void_t<decltype(std::declval<T&>()._Resize_and_overwrite(
118
+ std::declval<size_t>(), ProbeResizeAndOverwriteOp))>>
119
+ : std::true_type {};
120
+
121
+ #endif // ifndef ABSL_INTERNAL_HAS_RESIZE_AND_OVERWRITE
122
+
123
+ // A less-efficient fallback implementation that uses resize().
124
+ template <typename T, typename Op>
125
+ void StringResizeAndOverwriteFallback(T& str, typename T::size_type n, Op op) {
126
+ if (ABSL_PREDICT_FALSE(n > str.max_size())) {
127
+ absl::base_internal::ThrowStdLengthError("absl::StringResizeAndOverwrite");
128
+ }
129
+ #ifdef ABSL_HAVE_MEMORY_SANITIZER
130
+ auto old_size = str.size();
131
+ #endif
132
+ str.resize(n);
133
+ #ifdef ABSL_HAVE_MEMORY_SANITIZER
134
+ if (old_size < n) {
135
+ ABSL_ANNOTATE_MEMORY_IS_UNINITIALIZED(str.data() + old_size, n - old_size);
136
+ }
137
+ #endif
138
+ auto new_size = std::move(op)(str.data(), n);
139
+ ABSL_HARDENING_ASSERT(new_size >= 0 && new_size <= n);
140
+ ABSL_HARDENING_ASSERT(str.data()[n] == typename T::value_type{});
141
+ str.erase(static_cast<typename T::size_type>(new_size));
142
+ }
143
+
144
+ template <typename T, typename Op>
145
+ void StringResizeAndOverwriteImpl(T& str, typename T::size_type n, Op op) {
146
+ #ifdef ABSL_INTERNAL_HAS_RESIZE_AND_OVERWRITE
147
+ str.resize_and_overwrite(n, std::move(op));
148
+ #else
149
+ if constexpr (strings_internal::
150
+ has__google_nonstandard_backport_resize_and_overwrite<
151
+ T>::value) {
152
+ str.__google_nonstandard_backport_resize_and_overwrite(n, std::move(op));
153
+ } else if constexpr (strings_internal::has__resize_and_overwrite<T>::value) {
154
+ str.__resize_and_overwrite(n, std::move(op));
155
+ } else if constexpr (strings_internal::has__resize_default_init<T>::value) {
156
+ str.__resize_default_init(n);
157
+ str.__resize_default_init(
158
+ static_cast<typename T::size_type>(std::move(op)(str.data(), n)));
159
+ } else if constexpr (strings_internal::has_Resize_and_overwrite<T>::value) {
160
+ str._Resize_and_overwrite(n, std::move(op));
161
+ } else {
162
+ strings_internal::StringResizeAndOverwriteFallback(str, n, std::move(op));
163
+ }
164
+ #endif
165
+ }
166
+
167
+ } // namespace strings_internal
168
+
169
+ // Resizes `str` to contain at most `n` characters, using the user-provided
170
+ // operation `op` to modify the possibly indeterminate contents. `op` must
171
+ // return the finalized length of `str`.
172
+ //
173
+ // Invalidates all iterators, pointers, and references into `str`, regardless
174
+ // of whether reallocation occurs.
175
+ //
176
+ // `op(value_type* buf, size_t buf_size)` is allowed to write `value_type{}` to
177
+ // `buf[buf_size]`, which facilitiates interoperation with functions that write
178
+ // a trailing NUL. Please note that this requirement is more strict than
179
+ // `basic_string::resize_and_overwrite()`, which allows writing an abitrary
180
+ // value to `buf[buf_size]`.
181
+ template <typename T, typename Op>
182
+ void StringResizeAndOverwrite(T& str, typename T::size_type n, Op op) {
183
+ strings_internal::StringResizeAndOverwriteImpl(str, n, std::move(op));
184
+ #if defined(ABSL_HAVE_MEMORY_SANITIZER)
185
+ __msan_check_mem_is_initialized(str.data(), str.size());
186
+ #endif
187
+ }
188
+
189
+ ABSL_NAMESPACE_END
190
+ } // namespace absl
191
+
192
+ #undef ABSL_INTERNAL_HAS_RESIZE_AND_OVERWRITE
193
+
194
+ #endif // ABSL_STRINGS_RESIZE_AND_OVERWRITE_H_
@@ -0,0 +1,154 @@
1
+ // Copyright 2025 The Abseil Authors
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // https://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ #include "absl/strings/resize_and_overwrite.h"
16
+
17
+ #include <algorithm>
18
+ #include <cstddef>
19
+ #include <string>
20
+
21
+ #include "gtest/gtest.h"
22
+ #include "absl/base/dynamic_annotations.h"
23
+ #include "absl/log/absl_check.h"
24
+
25
+ namespace {
26
+
27
+ struct ResizeAndOverwriteParam {
28
+ size_t initial_size;
29
+ size_t requested_capacity;
30
+ size_t final_size;
31
+ };
32
+
33
+ using StringResizeAndOverwriteTest =
34
+ ::testing::TestWithParam<ResizeAndOverwriteParam>;
35
+
36
+ TEST_P(StringResizeAndOverwriteTest, StringResizeAndOverwrite) {
37
+ const auto& param = GetParam();
38
+ std::string s(param.initial_size, 'a');
39
+ absl::StringResizeAndOverwrite(
40
+ s, param.requested_capacity, [&](char* p, size_t n) {
41
+ ABSL_CHECK_EQ(n, param.requested_capacity);
42
+ if (param.final_size >= param.initial_size) {
43
+ // Append case.
44
+ std::fill(p + param.initial_size, p + param.final_size, 'b');
45
+ } else if (param.final_size > 0) {
46
+ // Truncate case.
47
+ p[param.final_size - 1] = 'b';
48
+ }
49
+ p[param.final_size] = '\0';
50
+ return param.final_size;
51
+ });
52
+
53
+ std::string expected;
54
+ if (param.final_size >= param.initial_size) {
55
+ // Append case.
56
+ expected = std::string(param.initial_size, 'a') +
57
+ std::string(param.final_size - param.initial_size, 'b');
58
+ } else if (param.final_size > 0) {
59
+ // Truncate case.
60
+ expected = std::string(param.final_size - 1, 'a') + std::string("b");
61
+ }
62
+
63
+ EXPECT_EQ(s, expected);
64
+ EXPECT_EQ(s.c_str()[param.final_size], '\0');
65
+ }
66
+
67
+ TEST_P(StringResizeAndOverwriteTest, StringResizeAndOverwriteFallback) {
68
+ const auto& param = GetParam();
69
+ std::string s(param.initial_size, 'a');
70
+ absl::strings_internal::StringResizeAndOverwriteFallback(
71
+ s, param.requested_capacity, [&](char* p, size_t n) {
72
+ ABSL_CHECK_EQ(n, param.requested_capacity);
73
+ if (param.final_size >= param.initial_size) {
74
+ // Append case.
75
+ std::fill(p + param.initial_size, p + param.final_size, 'b');
76
+ } else if (param.final_size > 0) {
77
+ // Truncate case.
78
+ p[param.final_size - 1] = 'b';
79
+ }
80
+ p[param.final_size] = '\0';
81
+ return param.final_size;
82
+ });
83
+
84
+ std::string expected;
85
+ if (param.final_size >= param.initial_size) {
86
+ // Append case.
87
+ expected = std::string(param.initial_size, 'a') +
88
+ std::string(param.final_size - param.initial_size, 'b');
89
+ } else if (param.final_size > 0) {
90
+ // Truncate case.
91
+ expected = std::string(param.final_size - 1, 'a') + std::string("b");
92
+ }
93
+
94
+ EXPECT_EQ(s, expected);
95
+ EXPECT_EQ(s.c_str()[param.final_size], '\0');
96
+ }
97
+
98
+ #ifdef ABSL_HAVE_MEMORY_SANITIZER
99
+ constexpr bool kMSan = true;
100
+ #else
101
+ constexpr bool kMSan = false;
102
+ #endif
103
+
104
+ TEST_P(StringResizeAndOverwriteTest, Initialized) {
105
+ if (!kMSan) {
106
+ GTEST_SKIP() << "Skipping test without MSan.";
107
+ }
108
+
109
+ const auto& param = GetParam();
110
+ std::string s(param.initial_size, 'a');
111
+
112
+ auto op = [&]() {
113
+ absl::StringResizeAndOverwrite(s, param.requested_capacity,
114
+ [&](char*, size_t) {
115
+ // Fail to initialize the buffer in full.
116
+ return param.final_size;
117
+ });
118
+ };
119
+
120
+ if (param.initial_size < param.final_size) {
121
+ #ifndef NDEBUG
122
+ EXPECT_DEATH_IF_SUPPORTED(op(),
123
+ "MemorySanitizer: use-of-uninitialized-value");
124
+ #endif
125
+ } else {
126
+ // The string is fully initialized from the initial constructor, or we skip
127
+ // the check in optimized builds.
128
+ op();
129
+ }
130
+ }
131
+
132
+ // clang-format off
133
+ INSTANTIATE_TEST_SUITE_P(StringResizeAndOverwriteTestSuite,
134
+ StringResizeAndOverwriteTest,
135
+ ::testing::ValuesIn<ResizeAndOverwriteParam>({
136
+ // Append cases.
137
+ {0, 10, 5},
138
+ {10, 10, 10},
139
+ {10, 15, 15},
140
+ {10, 20, 15},
141
+ {10, 40, 40},
142
+ {10, 50, 40},
143
+ {30, 35, 35},
144
+ {30, 45, 35},
145
+ {10, 30, 15},
146
+ // Truncate cases.
147
+ {15, 15, 10},
148
+ {40, 40, 35},
149
+ {40, 30, 10},
150
+ {10, 15, 0},
151
+ }));
152
+ // clang-format on
153
+
154
+ } // namespace