346 Commits

Author SHA1 Message Date
Abseil Team
bd6adb86c2 Change abseil hardening assertions in the strings directory from macros to functions
This associates debug information with the assertion sites, allowing clearer stack-traces for assertion failures and better accounting of the performance overhead of assertions.

PiperOrigin-RevId: 910863016
Change-Id: Ic615a9eeb8ad4b3f8c035074df4ff8347190e5c7
2026-05-05 13:00:46 -07:00
Abseil Team
bbdeb411c7 Add GenericPrint specialization for std::monostate.
`std::monostate` is a struct without any fields thus there is no content to be printed at all. However, the default printer prints it as `"unprintable value of size 1 @{some address}"` which is not very useful unless we're really interested in the address of struct having nothing.

PiperOrigin-RevId: 906966193
Change-Id: I7121bd9d58ac9930fa19432d76788d1df6dc5b78
2026-04-28 07:28:18 -07:00
Abseil Team
852fc61f31 Remove more lingering C++17 type traits polyfill usages
This will let us deprecate the declarations without triggering warnings in Abseil itself.

PiperOrigin-RevId: 906360966
Change-Id: Iee362ac0eac647909ef38003280f1179813f764d
2026-04-27 08:03:53 -07:00
Derek Mauro
cd0423dc25 Stop exporting internal Base64 escaping functions that do not need to
be exported. The one function that is currently using it is easily
implemented with absl::Base64Escape().

PiperOrigin-RevId: 900830658
Change-Id: I859d67efafd5ba96921bb75c9207438975d055d6
2026-04-16 11:38:13 -07:00
Abseil Team
9cb62a03a4 Remove unnecessary usages of absl::void_t
Most usages of absl::void_t compile fine with std::void_t, so we migrate them here. A few don't compile due to overly eager template instantiations, so we leave those.

PiperOrigin-RevId: 897231619
Change-Id: Iad34101916dac2b995257ebd5d6aacb9a0acfa32
2026-04-09 12:01:41 -07:00
Abhi Raman
354d4d9d13 StrFormat: format %g without heap allocation
PiperOrigin-RevId: 897196391
Change-Id: I0eeb47f4263344a7ce577d78c6029e31a7430385
2026-04-09 10:55:10 -07:00
Abseil Team
95619d531e Remove more lingering C++17 type traits polyfill usages
This will let us deprecate the declarations without triggering warnings in Abseil itself.

PiperOrigin-RevId: 895480358
Change-Id: I2e15877c15ed83f48ddb68cc73344c14b533bc68
2026-04-06 13:44:35 -07:00
Abseil Team
ed2114e8ff Stop using C++17 type traits polyfills
This will let us deprecate the declarations without triggering warnings in Abseil itself.

PiperOrigin-RevId: 894202105
Change-Id: I57bb2a1647be1fedf9b724a07042fd0f564ce074
2026-04-03 12:34:35 -07:00
Abseil Team
5c01794f79 Support passing I/O manipulators such as std::endl to StringifyStream
PiperOrigin-RevId: 892740803
Change-Id: I7c0c2d330080492d1451960bc21c04e6dbcbeb22
2026-03-31 23:34:03 -07:00
Abseil Team
0a7fe7e8da Add absl::strings_internal::AbslStringifyStream
PiperOrigin-RevId: 883300728
Change-Id: Ib5c83114fdc4e292ad8fcf96a899878315707353
2026-03-13 13:01:43 -07:00
Abseil Team
81f4d83f38 Add supporting code for absl::SourceLocation
PiperOrigin-RevId: 883256961
Change-Id: I536f9dc76ce4f248b5c87eaf27515cd8a4a484ca
2026-03-13 11:25:47 -07:00
Samuel Benzaquen
93a7a9cfe1 Prepare GenericPrinter for the rename of ArenaSafeUniquePtr.
PiperOrigin-RevId: 882021829
Change-Id: Idf65e88bd3ba1f285195dd60a9d8fc82bb61e516
2026-03-11 08:15:53 -07:00
Derek Mauro
ab54e73e59 Use reserve() to grow in STLStringResizeUninitializedAmortized()
When falling back to resize(), the entire resized block gets
initialized, which causes pathological behavior in the case of many
small appends. reserve() fixes this problem.

PiperOrigin-RevId: 877497660
Change-Id: I3ae8b45d74a62f975b1050851fe6fd9561071bec
2026-03-02 11:30:27 -08:00
Derek Mauro
443adb7497 Use reserve() to grow in absl::string_internal::StringAppendAndOverwrite()
When using the fallback, resize() is used, which initializes the
entire block, which causes pathological behavior in the case of many
small appends.

PiperOrigin-RevId: 877019230
Change-Id: If685b888ba55233c3c7436a6af19333561308424
2026-03-01 08:35:46 -08:00
Derek Mauro
dee6c62837 Remove unused include of resize_uninitialized.h
PiperOrigin-RevId: 875788912
Change-Id: I221428e693a26b59c69e3ef62a2c267f636737b8
2026-02-26 10:36:28 -08:00
Derek Mauro
5088cf5194 Cleanup the uses of the polyfills absl::any, absl::optional,
absl::variant, and related types

The corresponding headers are removed from cc files, but kept in
headers to prevent breakages from transitive dependencies.

PiperOrigin-RevId: 872421685
Change-Id: I867d4c3f7c9e422289c63816d44719b0530fb0a6
2026-02-19 08:53:17 -08:00
Derek Mauro
81839fc522 Open up the throw_delegate library to public usage
This library contains helper functions that allow throwing exceptions
consistently from anywhere, without risk of ODR violations. When
execptions are disabled, these functions abort the program.

The old internal spellings will be removed in a follow up change.

PiperOrigin-RevId: 867594519
Change-Id: Ibd7a447f5577247bced718617f5da662d983d185
2026-02-09 07:28:03 -08:00
Derek Mauro
fa3783ec81 Reimplement STLStringResizeUninitializedAmortized() using
StringResizeAndOverwriteImpl()

This change bridges the gap between the legacy uninitialized resize
behavior and the modern absl::StringResizeAndOverwrite(). The internal
StringResizeAndOverwriteImpl function is used directly because the
public Abseil API requires the buffer to be initialized, whereas these
legacy functions rely on the behavior of leaving it uninitialized
(which is technically UB but relied upon here).

This is part of the work to migrate away from these legacy
utilities.

PiperOrigin-RevId: 855779916
Change-Id: If22484048024eae8ddedd29ebb08e8884e0198a3
2026-01-13 10:18:30 -08:00
Abseil Team
6715d82763 Update includes in Damerau-Levenshtein distance implementation.
PiperOrigin-RevId: 853729717
Change-Id: Ic4d761e12cfddcba8ada06b43963ca7988370399
2026-01-08 07:18:29 -08:00
Derek Mauro
d9d76ba372 Fix unused variable warning in GCC7
PiperOrigin-RevId: 853321697
Change-Id: I44b09e10e6ca1bb9b9f30a01a0f5acd5923371c1
2026-01-07 10:34:36 -08:00
Abseil Team
9391635247 StrFormat: format scientific notation without heap allocation
PiperOrigin-RevId: 852845312
Change-Id: I26dcfc5784383d1cf86fab795ba931445f24c575
2026-01-06 10:44:01 -08:00
Derek Mauro
2d4a5a87fd Delete absl::strings_internal::STLStringReserveAmortized()
PiperOrigin-RevId: 850064010
Change-Id: Ieb280f2ba70726bbd4f27d2aed1f0ff4e5a683d1
2025-12-29 08:15:26 -08:00
Chris Kennelly
5d365d332a absl/strings: Prepare helper for printing objects to string representations.
PiperOrigin-RevId: 847935770
Change-Id: I7f96940e5ba11d6a602d34e7dc3dbfde112bb142
2025-12-22 17:29:23 -08:00
Chris Kennelly
6baba4dc59 Avoid discarding test matchers.
PiperOrigin-RevId: 838904511
Change-Id: I02f3bf3f2c51e4cdb21aa638a4f265f2ef4e2f25
2025-12-01 13:17:26 -08:00
Derek Mauro
f43bcc04d9 Fixes for String{Resize|Append}AndOverwrite
- StringAppendAndOverwrite() should always call StringResizeAndOverwrite()
    with at least capacity() in case the standard library decides to shrink
    the buffer (Fixes #1965)
  - Small refactor to make the minimum growth an addition for clarity and
    to make it easier to test 1.5x growth in the future
  - Turn an ABSL_HARDENING_ASSERT into a ThrowStdLengthError
  - Add a missing std::move

PiperOrigin-RevId: 826107106
Change-Id: I73ee3e98daa10161aa9023b2a879f6178ebedbcf
2025-10-30 11:06:09 -07:00
Derek Mauro
9a2624f3e7 Use the new absl::StringResizeAndOverwrite() in string escaping utilities
PiperOrigin-RevId: 825168879
Change-Id: I5dfcd546ffe01fc2035f4380c92ffd9afaa52331
2025-10-28 13:00:59 -07:00
Derek Mauro
f81f1b1d08 Add an internal-only helper StringAppendAndOverwrite() similar to
StringResizeAndOverwrite() but optimized for repeated appends, using
exponential growth to ensure amortized complexity of increasing
a string size by a small amount is O(1).

Use this function to replace STLStringResizeUninitializedAmortized()

PiperOrigin-RevId: 825100704
Change-Id: Ife64b13301bc4288d68154b7c496f57aaad4b6a4
2025-10-28 10:26:25 -07:00
Derek Mauro
b8c46feecc Rollback StringAppendAndOverwrite() - the problem is that
StringResizeAndOverwrite has MSAN testing of the entire string.
This causes quadratic MSAN verification on small appends.

PiperOrigin-RevId: 824629932
Change-Id: Ibefff781f5923c8bd2c1dc364f5b63fcb1d0f5ab
2025-10-27 12:30:02 -07:00
Derek Mauro
d3c55ba366 Add an internal-only helper StringAppendAndOverwrite() similar to
StringResizeAndOverwrite() but optimized for repeated appends, using
exponential growth to ensure amortized complexity of increasing
a string size by a small amount is O(1).

Use this function to replace STLStringResizeUninitializedAmortized()

PiperOrigin-RevId: 824571998
Change-Id: I6fe4a9cadd469ceee6a3818d7b8709e2fa286b9c
2025-10-27 10:16:39 -07:00
Abseil Team
d71fcd13f6 Use the new absl::StringResizeAndOverwrite() in string escaping utilities
PiperOrigin-RevId: 823263060
Change-Id: Ife62660889ce8602013ccbb563ec853ae22fee9f
2025-10-23 18:08:57 -07:00
Derek Mauro
09c29fe055 Use the new absl::StringResizeAndOverwrite() in string escaping utilities
PiperOrigin-RevId: 823159114
Change-Id: I94ccf42464a5fee6233b15dc8d44503b0b3f9db2
2025-10-23 13:10:11 -07:00
Abseil Team
04e19d0731 absl::StrFormat: improve test coverage with scientific exponent test cases
PiperOrigin-RevId: 822611844
Change-Id: Idc5af6835868ac7336e945ecc29d5b83d1325e09
2025-10-22 09:03:14 -07:00
Derek Mauro
f807de027a CordzInfo: Use absl::NoDestructor to remove a global destructor.
Chromium requires no global destructors.

PiperOrigin-RevId: 822156140
Change-Id: Ieedc7e042df035e000649a2f07a217dee6ca40e7
2025-10-21 09:40:32 -07:00
Abseil Team
8faaaebc12 Use the new absl::StringResizeAndOverwrite() in string escaping utilities
PiperOrigin-RevId: 821867896
Change-Id: I6fe8456d8081ad87c8512dff6fc9235ab73e9448
2025-10-20 17:16:32 -07:00
Derek Mauro
c9ffd888c1 Use the new absl::StringResizeAndOverwrite() in string escaping utilities
PiperOrigin-RevId: 821767972
Change-Id: Ia4d38b49bc97a485dec3e352dcb056ca1c4465d6
2025-10-20 13:02:08 -07:00
Derek Mauro
4dbcee4b9e Use the new absl::StringResizeAndOverwrite() in absl::StrJoin()
PiperOrigin-RevId: 821692002
Change-Id: I47d1e8ef24fdef314f96eb28f5d36d098570d0e6
2025-10-20 10:00:25 -07:00
Martijn Vels
511de5babb Change Cordz to synchronize tracked cords with Snapshots / DeleteQueue
PiperOrigin-RevId: 817217091
Change-Id: I93ae36c50ec475daa765b53877b1e23bcee6fad6
2025-10-09 09:20:50 -07:00
Abseil Team
a54cb45cb9 Expose typed releasers of externally appended memory.
PiperOrigin-RevId: 813913805
Change-Id: I4e8596697627c769619c041832a6f26dec2afd64
2025-10-01 14:26:26 -07:00
Abseil Team
f8c283dabf Remove support for Native Client
Native Client has been fully removed from Chromium.

PiperOrigin-RevId: 803093147
Change-Id: I7fea87a8a66b35b2f0cc3d815c23f90e5e4d2043
2025-09-04 10:54:42 -07:00
Chris Kennelly
d473c92b9e Inline internal usages of Mutex::Lock, etc. in favor of lock.
PiperOrigin-RevId: 789459507
Change-Id: I573dec1c33b047388509cfea129342ea7bdfe494
2025-07-31 13:51:06 -07:00
Chris Kennelly
0f1abc9b73 Inline internal usages of pointerful SpinLockHolder/MutexLock.
PiperOrigin-RevId: 789441157
Change-Id: I2ed5d12f4b9725edbe3fd6cf629a0563a2f2d739
2025-07-31 12:59:26 -07:00
Dmitry Vyukov
2e99bf25d4 Remove wrong comment in Cord::Unref
We both call DecrementExpectHighRefcount which assumes ref>1,
and we PREDICT_FALSE that it's 1.

PiperOrigin-RevId: 789316655
Change-Id: Icbb1586d91a34f8c02b2ce1341af3c36c8837c80
2025-07-31 06:47:05 -07:00
Derek Mauro
d60e95741c Add an assert that absl::StrSplit is not called with a null char*
argument.

This is already undefined behavior since the argument is immediately
used to construct a string_view, and passing a null argument to the
single-arg string_view constructor is undefined behavior. Adding the
check will prevent introduction of new bugs when using standard
library implementations that do not detect this case.

PiperOrigin-RevId: 787676394
Change-Id: Ia3e069071e28c8e17df956b8b713bf17fb1e3be3
2025-07-27 04:35:30 -07:00
Abseil Team
fb2340658e Revert a change for breaking downstream third party libs
PiperOrigin-RevId: 781310397
Change-Id: I86e0c2662f95fee7047daa2d55dca1954850b77a
2025-07-09 19:18:55 -07:00
Abseil Team
d851be6f01 Remove unneeded include from cord_rep_btree_navigator.h
This header doesn't need to include <iostream>.

PiperOrigin-RevId: 781263165
Change-Id: I1cbd951164af81420493ed29e26e6d2580017a17
2025-07-09 16:46:53 -07:00
Abseil Team
2b320cbfaa Fix includes and fuse constructors of SpinLock.
PiperOrigin-RevId: 774835829
Change-Id: I0fa7cab1b98c1b7222de0acd71b7846df693f1e2
2025-06-23 10:32:42 -07:00
Omer Mor
83e249f264 Rewrite WideToUtf8 for improved readability.
This is supposed to be a zero-diff change.

PiperOrigin-RevId: 756859112
Change-Id: Ia81a84bc5d1e6f2a1299ca0ff5dbcec48583ab76
2025-05-09 12:12:44 -07:00
Omer Mor
464b5b366c Deprecate ABSL_HAVE_STD_STRING_VIEW.
This macro is no longer necessary now that Abseil requires C++17.

PiperOrigin-RevId: 755992345
Change-Id: Id1361d62d860a0ba4bdfca22e8f39d54812ef82c
2025-05-07 13:52:30 -07:00
Derek Mauro
668f174945 Fix new -Wnullability-completeness warnings found after upgrading
the Clang version used in the Linux ARM CI to Clang 19.

nullability-completeness is an all-or-nothing warning, and it is
enabled by default. If anything is annotated, everything has to be
annotated.

There are a few types of fixes in this change. The most common is just
to add missing annotations. In a few cases, some SFINAE methods are
changed not to use pointers at all. In some cases, like
cord_internal.h, I removed the single annotation as that is easier
than doing the entire complicated file for now. cordz_test_helpers.h
uses GoogleTest macros, which bring in pointers that can't easily be
annotated, so I removed the annotations from this file as well.
Tests are also opted-out of the warning.

I'm not sure why the x86 Clang version didn't pick these issues up.

PiperOrigin-RevId: 755844859
Change-Id: I7d7f4cc4f6d779f52c86a4d96e07880341244491
2025-05-07 07:28:51 -07:00
Omer Mor
dd69c96310 Extract WideToUtf8 helper to utf8.h.
This change allows to reuse the conversion of `wchar_t` into UTF-8 from other code.
It also adds tests that covers the conversion.

PiperOrigin-RevId: 755365598
Change-Id: I0f1c0b7949dec3c9874be99f01540748436532ce
2025-05-06 07:36:53 -07:00