Commit Graph

237 Commits

Author SHA1 Message Date
Derek Mauro
9ebd93a774 Remove the implementation of absl::string_view, which was only needed
prior to C++17. `absl::string_view` is now an alias for `std::string_view`.
It is recommended that clients simply use `std::string_view`.

PiperOrigin-RevId: 845822478
Change-Id: I220530c84118e5b9ef110baa002c232ac8f2c5f2
2025-12-17 10:23:48 -08:00
Derek Mauro
31ef391f80 Import of CCTZ from GitHub.
PiperOrigin-RevId: 833899408
Change-Id: I5b6ee41676a8e0e207462e0b30dde3843478ef19
2025-11-18 11:30:31 -08:00
Abseil Team
03cc841ff0 Use non-stack storage for stack trace buffers
Doing this opportunistically allows us to avoid performance overhead in the vast majority of calls (rare, non-reentrant ones) while simultaneously minimizing stack space usage.

PiperOrigin-RevId: 831560881
Change-Id: Idc6ba1dd0dcf1b4aaf3ee7cf468054bcfdcf90af
2025-11-12 15:23:29 -08:00
Corentin Le Molgat
d1ddbf4d21 windows(cmake): add abseil_test_dll to target link libraries when required
Fix #1967

PiperOrigin-RevId: 827621016
Change-Id: I0ba2b2259851cce99cd719c1daeb4ada528baa93
2025-11-03 13:12:04 -08: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
Derek Mauro
0cf55c4fd6 Adds absl::StringResizeAndOverwrite as a polyfill for C++23's
`std::basic_string<CharT,Traits,Allocator>::resize_and_overwrite`

#1136

PiperOrigin-RevId: 815709814
Change-Id: Ie6b98d19058c5403fb3f6d65ccc82e2bb46ec4f6
2025-10-06 07:07:47 -07:00
Jesse Rosenstock
820cd9ee90 type_traits: Add type_identity and type_traits_t backfills
https://en.cppreference.com/w/cpp/types/type_identity.html

PiperOrigin-RevId: 812886166
Change-Id: I159cf4e4bdbe2ac801768ff6c996c2d2a3d47a71
2025-09-29 12:03:04 -07:00
Abseil Team
f138b9d6fa Annotate ABSL_DIE_IF_NULL's return type with absl_nonnull
This helps inform Nullability inference without needing any special casing.

Since ABSL_DIE_IF_NULL is allowed for pointers, smart pointers, or classes marked with ABSL_NULLABILITY_COMPATIBLE we introduce a trait to help add the annotation only when compatible. This trait is kept internal for now out of caution for what we are supporting, though people have asked about it before (see b/394789178).

Simple cases are tested by `-Wnonnull` in absl/base/nullability_nc_test.cc. However, it's unclear how to test the complex cases like templates with universal references with the simple compiler `-Wnonnull`. There is a followup nullability inference test (cl/808830606).

Since there is Wnullability-completeness, needed to annotate the rest of die_if_null.h

PiperOrigin-RevId: 810463021
Change-Id: Id5156996bf3a29a99e689974ac2af7b94b21c460
2025-09-23 09:09:36 -07:00
pastdue
f2dee57baf PR #1921: Fix ABSL_BUILD_DLL mode (absl_make_dll) with mingw
Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1921

Fixes linking errors when compiling `ABSL_BUILD_MONOLITHIC_SHARED_LIBS=ON` with mingw, by adding the missing `-ladvapi32`, `-ldbghelp`, and `-lbcrypt` in `absl_make_dll()`.

Merge 4520f2c9cc into c5e00729c3

Merging this change closes #1921

COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1921 from past-due:mingw-dll-patch-1 4520f2c9cc
PiperOrigin-RevId: 796514257
Change-Id: I05f5d27530cb0910670afa278d97341ecb263e83
2025-08-18 11:49:30 -07:00
Andy Getzendanner
698d4f483b In logging tests that write expectations against ScopedMockLog::Send, suppress the default behavior that forwards to ScopedMockLog::Log so that unexpected logs are printed with full metadata. Many of these tests are poking at those metadata, and a failure message that doesn't include them is unhelpful.
Also, add a GoogleTest debug `PrintTo` routine for `LogEntry`, so that unexpected calls to `ScopedMockLog::Send` print metadata legibly.

PiperOrigin-RevId: 790735226
Change-Id: If21821812a9b7ecfaefef9ea5085f161f9331cf4
2025-08-04 07:14:57 -07:00
Chris Kennelly
b7c2f08f18 Add converter for extracting SwissMap profile information into a https://github.com/google/pprof suitable format for inspection.
PiperOrigin-RevId: 784620356
Change-Id: Iceb25ca22e4969c18fbca912018de41198ead7b7
2025-07-18 10:14:42 -07:00
Derek Mauro
6ee80c1d4e CMake: Add a fatal error when the compiler defaults to or is set to a
C++ language standard prior to C++17.

Users encountering this error should set -DCMAKE_CXX_STANDARD=17 (or a
higher standard), or find an equivalent method of specifying the correct
C++ standard for the entire build.

The current behavior is to try to detect the standard being used and
upgrade it to C++17 if it defaults to or is set to a prior
version. However, CMake also generates options.h for installation, and
it does this without the automatic upgrade, which leads to an
inconsistency.

Another possible fix is to not do the automatic upgrade at all, but
then we fail the build at a later step, so better just to add an error
earlier in the process.

PiperOrigin-RevId: 772997895
Change-Id: I5ace8ecf5799cacf6010bbba4d880004e0bc9650
2025-06-18 11:31:01 -07:00
Vitaly Goldshteyn
2ea5334068 Refactor long strings hash computations and move len <= PiecewiseChunkSize() out of the line to keep only one function call in the inlined hash code.
I am moving low level hash to hash.cc. It is needed to allow the compiler to inline low level hash and avoid two function calls. I also find it easier to follow.

```
name                           old CYCLES/op        new CYCLES/op        delta
BM_latency_AbslHash_Int32        16.0 ± 3%            16.1 ± 3%    ~         (p=0.285 n=151+150)
BM_latency_AbslHash_Int64        16.4 ± 5%            16.5 ± 4%    ~         (p=0.073 n=152+144)
BM_latency_AbslHash_String3      21.1 ± 0%            21.1 ± 0%  -0.07%      (p=0.000 n=132+140)
BM_latency_AbslHash_String5      21.1 ±11%            21.1 ±10%    ~         (p=0.862 n=152+154)
BM_latency_AbslHash_String9      21.0 ±13%            20.7 ±14%  -1.27%      (p=0.006 n=151+147)
BM_latency_AbslHash_String17     19.9 ±11%            20.5 ±21%  +3.27%      (p=0.033 n=131+144)
BM_latency_AbslHash_String33     21.1 ± 4%            21.2 ± 5%    ~         (p=0.122 n=140+146)
BM_latency_AbslHash_String65     26.9 ± 7%            27.2 ± 7%  +1.06%      (p=0.000 n=140+145)
BM_latency_AbslHash_String257    44.4 ±10%            44.5 ±11%    ~         (p=0.754 n=149+143)
```

PiperOrigin-RevId: 770672450
Change-Id: Ia6195c8a149cae89c8ca9013d4bf48052c09ba55
2025-06-12 08:49:03 -07:00
Abseil Team
e4c43850ad Remove template alias nullability annotations.
These were deprecated before the last LTS release.

PiperOrigin-RevId: 762205726
Change-Id: I9d15a08967086296ecc9650a7ae0ae9c4973c405
2025-05-22 18:22:59 -07:00
Vitaly Goldshteyn
7bf6d7918f Use weaker mixing for absl::Hash for types that mix their sizes.
When a container or a string is mixed, size is only supplementary data.
We are still mixing size to avoid hash expansion to be a suffix of one another.

Mixing is done by addition `size + Seed()`. `+ Seed()` is needed to make an empty string to change the hash state. We assume that `Seed()` is already loaded to some register. Addition would modify low bits that will be spread with data mixing later.

We considered the following optimization. Mix the size at the beginning in order to improve the dependency graph. Mixing would happen in parallel with reading strings data. It's not feasible because absl::Hash API requires that hash expansions can't be suffixes of each other.

```
name                           old CYCLES/op        new CYCLES/op        delta
BM_latency_AbslHash_String3      27.2 ± 0%            21.5 ± 0%  -21.08%        (p=0.000 n=52+52)
BM_latency_AbslHash_String5      28.1 ± 8%            22.3 ±11%  -20.70%        (p=0.000 n=57+57)
BM_latency_AbslHash_String9      27.7 ± 9%            22.2 ±17%  -19.77%        (p=0.000 n=56+57)
BM_latency_AbslHash_String17     25.9 ± 5%            21.2 ±23%  -18.02%        (p=0.000 n=57+54)
BM_latency_AbslHash_String33     28.0 ± 5%            22.5 ± 4%  -19.69%        (p=0.000 n=54+54)
BM_latency_AbslHash_String65     37.9 ± 8%            32.2 ±10%  -15.19%        (p=0.000 n=52+53)
BM_latency_AbslHash_String257    57.1 ± 8%            52.0 ±10%   -8.88%        (p=0.000 n=52+54)
```

PiperOrigin-RevId: 750151406
Change-Id: I2245bad4906960d9236bea671738a218a85eb1af
2025-04-22 05:26:01 -07:00
Abseil Team
caf854d58c Deprecate template type alias nullability annotations.
Relocates them and their implementations to a header that can still be transitively included through absl/base/nullability.h but where they are less visible.

Prefer to use the macro nullability annotations instead (absl_nonnull, absl_nullable, and absl_nullability_unknown).

These will be removed after the next Long Term Support release.

PiperOrigin-RevId: 748689234
Change-Id: I33038678725f555b35b2f08dd0081e3cc11040db
2025-04-17 08:26:56 -07:00
Vitaly Goldshteyn
1abce160de Fast growing to the next capacity based on carbon hash table ideas.
"Classical" growth is type erased and may become slower than before. Such growth is only used for usecases reserve/rehash non empty tables.

PiperOrigin-RevId: 744049527
Change-Id: I13e89b324f3bdcfdbb7a433c45fbfc17ade7f8de
2025-04-04 13:22:33 -07:00
Derek Mauro
7c5528251a Add absl::FastTypeId<T>()
absl::FastTypeId<Type>() evaluates at compile-time to a unique id for the
passed-in type. These are meant to be good match for keys into maps or
straight up comparisons.

Previously this was an internal implemention detail used by a few libraries.
This is now a supported utility function.

PiperOrigin-RevId: 743194478
Change-Id: Ie01ed8a2850696ee661acb91726252adb4c20538
2025-04-02 10:37:37 -07:00
Abseil Team
4d6cb98f27 Migrate ClearPacBits() to a more generic implementation and location
PiperOrigin-RevId: 736664098
Change-Id: Ic99ff4ebae02097b9f7691ebdcb2e10f7d255834
2025-03-13 15:44:42 -07:00
Laramie Leavitt
80b6a00e5a Simplify some random/internal types; expose one function to acquire entropy.
PiperOrigin-RevId: 734243580
Change-Id: Ibc8f3642329b1e7a5a6ed54e505b2ced8dec2f4c
2025-03-06 12:25:18 -08:00
Derek Mauro
aea2fc0ea1 Remove the implementation of absl::variant, which was only needed
prior to C++17. `absl::variant` is now an alias for `std::variant`.
It is recommended that clients simply use `std::variant`.

PiperOrigin-RevId: 730940936
Change-Id: I7157612a62eec036abf61dd1ad42c5945afeac1d
2025-02-25 10:34:52 -08:00
Derek Mauro
22b1f421fa Remove the implementation of absl::optional, which was only needed
prior to C++17. `absl::optional` is now an alias for `std::optional`.
It is recommended that clients simply use `std::optional`.

PiperOrigin-RevId: 729860560
Change-Id: I8f3a23ed46c451cb441771cc544df79e6c326b67
2025-02-22 05:58:57 -08:00
Vitaly Goldshteyn
9eece6e175 Move hashtable control bytes manipulation to a separate file.
Motivations:
1) raw_hash_set is becoming too big and hard to work with.
2) I have an experiment to use Group::Bitmask in policy traits and need this code to be available as a smaller library to avoid circular dependency.

Additionally added BitMask and NonIterableBitmask aliases inside of the group in order to be able to use these types as function arguments (needed for an ongoing experiment).

PiperOrigin-RevId: 729748373
Change-Id: Ie0aef40aa3d8dc7fe8ae27cc7808eacfa1a37319
2025-02-21 20:06:41 -08:00
Derek Mauro
8ce0c88d6a Remove the implementation of absl::any, which was only needed prior
to C++17. `absl::any` is now an alias for `std::any`. It is
recommended that clients simply use `std::any`.

PiperOrigin-RevId: 729541787
Change-Id: I4a677704bca31d4c602b73ac2dc12cac1fe18793
2025-02-21 08:39:31 -08:00
Derek Mauro
feb3d276d4 Remove ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
which is longer needed with the C++17 floor

PiperOrigin-RevId: 729365281
Change-Id: Ife5e778ead193bb37150b9799099e92f53252cb4
2025-02-20 21:07:28 -08:00
Derek Mauro
14cfd97abe Delete absl/utility/internal/if_constexpr.h
PiperOrigin-RevId: 728798591
Change-Id: I86947936df752c706657d6cf1cf22178e4c0815c
2025-02-19 13:41:19 -08:00
Derek Mauro
e78a8ce497 Delete absl/base/internal/inline_variable.h
PiperOrigin-RevId: 728684812
Change-Id: If4e2d0fed045c1cb312a48f250d5ebb1aaa1b41f
2025-02-19 08:32:03 -08:00
Dino Radakovic
7555944ed6 absl/base: Delete internal/invoke.h and invoke_test.cc
Abseil doesn't use `invoke.h` anymore. It's an internal header, which means nobody outside of Abseil should either.

PiperOrigin-RevId: 726159434
Change-Id: I3b17a313ce95fbe25fae5b091c9df73752548684
2025-02-12 12:45:44 -08:00
Justin Bassett
9e764b4f25 Factor out some iterator traits detection code
There are a few different cases where we check iterator categorization, mostly for forward iterators for preallocating buffers of the correct size. Factoring this out makes it easier to make all of these cases support the C++20 iterator model.

PiperOrigin-RevId: 725791190
Change-Id: Icf9d687654618c7ceff98ec76ec59e83c682dd6b
2025-02-11 15:19:06 -08:00
Derek Mauro
7a03cdb4c0 Require C++17
Policy information:
https://opensource.google/documentation/policies/cplusplus-support#c_language_standard
https://github.com/google/oss-policies-info/blob/main/foundational-cxx-support-matrix.md

PiperOrigin-RevId: 723589409
Change-Id: Ia8665c052ed40f2a78308f7eb0c330191b0cf981
2025-02-05 11:33:01 -08:00
simonla
41984a2258 PR #1806: Fix undefined symbol: __android_log_write
This adds -llog under CMake. The Bazel build already has this.

Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1806

close #1805
Merge 76dd9e3378 into a1de53ddde

Merging this change closes #1806

COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1806 from simonla:fix_compile_android_shared_lib 76dd9e3378
PiperOrigin-RevId: 715779297
Change-Id: I19ea9433fda94a60c1d2c1b3a0b40e80bdd3c078
2025-01-15 06:47:52 -08:00
Abseil Team
51b7426e92 New class StructuredProtoField
PiperOrigin-RevId: 711892840
Change-Id: I2321e83e2939d21836ba1df335b2e97366594076
2025-01-03 17:13:49 -08:00
Ruoyu Zhong
bd0c9c58ca PR #1738: Fix shell option group handling in pkgconfig files
Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1738

Since #1707 and #1710, `-Xarch_` option groups are present as single elements in the libraries' COPTS, and a `SHELL:` prefix is added to each of them. While these addressed certain build issues, they broke the handling of `-Xarch_` option groups in pkgconfig files.

Fix that by taking care of the `SHELL:` prefix in COPTS when generating pkgconfig files. The skip-next-flag mechanism is also removed as the option groups are now present as single elements.

Merge fd1246acbf into 08850701d2

Merging this change closes #1738

COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1738 from ZhongRuoyu:pkgconfig-xarch-handling fd1246acbf
PiperOrigin-RevId: 660055129
Change-Id: I57a1a51b2eb8983d076a3d5336acef12acae4560
2024-08-06 12:29:06 -07:00
Derek Mauro
9cb5e5d15c Don't match -Wnon-virtual-dtor in the "flags are needed to suppress
warnings in headers". It should fall through to the "don't impose our
warnings on others" case. Do this by matching on "-Wno-*" instead of
"-Wno*".

Fixes #1737

PiperOrigin-RevId: 659548798
Change-Id: I49d7ba7ddcd7be30f946fca90ba9be467181e854
2024-08-05 07:35:57 -07:00
Sandy Zhang
9a0743ac27 Add absl_vlog_is_on and vlog_is_on to ABSL_INTERNAL_DLL_TARGETS
PiperOrigin-RevId: 655958414
Change-Id: I09b3a86b009cd64e53d27b615c0ec127ed64e8e4
2024-07-25 08:09:13 -07:00
Mizux
2138590007 PR #1726: cmake: Fix RUNPATH when using BUILD_WITH_INSTALL_RPATH=True
Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1726

ref: https://cmake.org/cmake/help/latest/prop_tgt/BUILD_WITH_INSTALL_RPATH.html
Merge d7d460773f into 5ea745c2ae

Merging this change closes #1726

COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1726 from Mizux:master d7d460773f
PiperOrigin-RevId: 655593538
Change-Id: Iedd70d3a8b4f6256664aee26a698d4af0523d6b8
2024-07-24 09:24:35 -07:00
Martijn Vels
58df17f78e Add weak internal tracing API
PiperOrigin-RevId: 654799253
Change-Id: Ide284386e864a21ab2dfae777912409bc74eebf8
2024-07-22 10:07:01 -07:00
Derek Mauro
0598e582f6 Delete absl/strings/internal/has_absl_stringify.h now that the
GoogleTest version we depend on uses the public file

PiperOrigin-RevId: 653606441
Change-Id: Id49b18835443162ddf9747cc31619f3acf01f4ef
2024-07-18 07:04:49 -07:00
Derek Mauro
7795d0843a Update versions of dependencies in preparation for release
PiperOrigin-RevId: 653567769
Change-Id: I0448322da95558ff6a04ab1aeab2b238674b69d1
2024-07-18 04:32:47 -07:00
Evan Brown
5b6285e7c5 Roll forward poisoned pointer API and fix portability issues.
Also, return the middle of the poisoned block.

PiperOrigin-RevId: 651119057
Change-Id: Iae0fc3dcb40e32cd449f469d9b8d62c37f3773f4
2024-07-10 12:45:28 -07:00
Christoph Grüninger
f46495ea96 PR #1706: Require CMake version 3.16
Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1706

Follow Google OSS policy.
Merge 2ba42b9e5a into af4c589ed6

Merging this change closes #1706

COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1706 from gruenich:feature/cmake-3-16 2ba42b9e5a
PiperOrigin-RevId: 650646746
Change-Id: Ib600608fbc727161c8b8e69cda9a09637188fef8
2024-07-09 09:00:35 -07:00
Derek Mauro
57f04ad892 Rollback new poisoned pointer API
This breaks Chromium due to global constructor and incorrectly
assumes page size.
https://github.com/abseil/abseil-cpp/pull/1697

PiperOrigin-RevId: 648377066
Change-Id: I19f8b2655971a0c314091e26e62e10a5a9c46e94
2024-07-01 08:26:37 -07:00
Chris Mihelich
16452e1418 Decoder for Rust-style Punycode encodings of bounded length.
PiperOrigin-RevId: 647093624
Change-Id: Ic76bfa4aa8fb616cb23095ce7bfa30c3812dcb21
2024-06-26 15:14:45 -07:00
Evan Brown
e486af700c Add an internal API to get a poisoned pointer.
The motivation is to make destroyed/moved-from objects cause crashes when they are accessed.

PiperOrigin-RevId: 646229564
Change-Id: I68d9c189b542df0933af08f5ad63dc1f5764d856
2024-06-24 14:53:59 -07:00
Chris Mihelich
fc7612086f Sequence of 1-to-4 values with prefix sum to support Punycode decoding.
PiperOrigin-RevId: 642696557
Change-Id: Ia6b8e174ddb55e44bd082bf0d81d2f9c53c94016
2024-06-12 12:21:10 -07:00
Chris Mihelich
d30298a1b6 UTF-8 encoding library to support Rust Punycode decoding.
PiperOrigin-RevId: 641983507
Change-Id: Iad7933884aef6bfd90d159c049a1d698d19456c6
2024-06-10 12:18:15 -07:00
Abseil Team
d06b82773e Move SOVERSION to global CMakeLists, apply SOVERSION to DLL
So that multiple LTS builds can co-exist.

PiperOrigin-RevId: 639154515
Change-Id: Id34d6fbef823151a4f3c73cf7b9b340257eadd63
2024-05-31 14:32:29 -07:00
Abseil Team
3f9c32553c Include flags in DLL build (non-Windows only)
On Windows flags will likely never be compatible due to the typeid issues.

PiperOrigin-RevId: 638326696
Change-Id: If605d612af2efa4d60483ca4a03daf58511eda51
2024-05-29 10:12:11 -07:00