Commit Graph

263 Commits

Author SHA1 Message Date
Abseil Team
c20be0a44d Add absl::StatusBuilder and status macros (ASSIGN_OR_RETURN, RETURN_IF_ERROR, etc.)
PiperOrigin-RevId: 915476143
Change-Id: If1ce23cf40e4e44c39164f81f6d5ca66988d405c
2026-05-14 09:45:04 -07:00
Abseil Team
a7fbfa4486 Add [[clang::nomerge]] to absl::base_internal::HardeningAbort()
This lets us distinguish crashes due to different hardening checks.

PiperOrigin-RevId: 914894842
Change-Id: I5a875bceac5ae398308c5edaa45fea952fec501f
2026-05-13 09:03:01 -07:00
Abseil Team
c7a875c193 Rollback of
Add [[clang::nomerge]] to absl::base_internal::HardeningAbort()

This lets us distinguish crashes due to different hardening checks.

PiperOrigin-RevId: 910658969
Change-Id: I820eb5291d7ce8330df0dac10ea09fafef405bbb
2026-05-05 06:58:56 -07:00
Abseil Team
d061f5f134 Add [[clang::nomerge]] to absl::base_internal::HardeningAbort()
This lets us distinguish crashes due to different hardening checks.

PiperOrigin-RevId: 910325607
Change-Id: I902df2b849af9dcc0330315cf913d9ed63163bc1
2026-05-04 17:09:23 -07:00
Abseil Team
3a4bad5944 Add absl::bind_back
PiperOrigin-RevId: 905242962
Change-Id: I7ba08d1b610db5be723b2313e11f7a5d4d7ddb6e
2026-04-24 15:15:51 -07:00
Taylor Cramer
cc986e47a7 Use absl::SourceLocation for Rust source locations in Status
This is intentionally not exposing absl::SourceLocation to Rust yet, since the ownership questions (absl::Status vs. interning etc.) have not yet been decided.

PiperOrigin-RevId: 889297573
Change-Id: I14ed9c1b03c4229bc59e746b49685e87778e6b46
2026-03-25 09:53:05 -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
522a5a8b51 Open-source absl::AnySpan
PiperOrigin-RevId: 883174961
Change-Id: Iea8fe182d759350f2b84e78892243867cd9f4be8
2026-03-13 08:20:14 -07:00
Abseil Team
e7ba8a7852 Add absl::SourceLocation
PiperOrigin-RevId: 881550268
Change-Id: I1add4438cecc44f41f01c0570c69bb85f706ecfc
2026-03-10 11:52:33 -07:00
Dino Radakovic
db50e84fae AbseilDll.cmake: sort list of files alphabetically
PiperOrigin-RevId: 876807018
Change-Id: Ib9872be339aa9ab943ccce1ad6134dcaebb22dc8
2026-02-28 17:17:40 -08:00
Abseil Team
b6808e6f7c Remove stack trace fixup code from Abseil
PiperOrigin-RevId: 875236816
Change-Id: I88f7d894cc30d23c77b7d43953fe4d85deb65728
2026-02-25 10:48:11 -08:00
Abseil Team
d85c5281b8 Create bounds check functions to improve observability of hardening check failures to monitoring.
The current ABSL_HARDENING_ASSERT macros are difficult to observe in stack traces in core dumps or sampling profiler output.  This change creates a pair of bounds check functions which can be used in place of some of instances of these ABSL_HARDENING_ASSERT macros while remaining clearly distinguishable in production monitoring infrastructure.

PiperOrigin-RevId: 874680671
Change-Id: Ife503e63076bb92b2a9919f18b42f305d683b99d
2026-02-24 10:30:14 -08:00
Abseil Team
a62029e346 Add absl::optional_ref<T>
PiperOrigin-RevId: 872459397
Change-Id: Ib2a3265c46c1ceca31190f5d4722bde06b59eeb4
2026-02-19 10:27:08 -08:00
Abseil Team
5ec376e34b Remove helper libraries for absl/extend
PiperOrigin-RevId: 869797319
Change-Id: I0d1c145f5e6275a455b73f2dd645aeaff6af0885
2026-02-13 10:41:31 -08:00
Derek Mauro
35e6a9517b Delete the internal version of throw_delegate
PiperOrigin-RevId: 868253845
Change-Id: I1cf9e2208242d0fdba8de43bfc5d698377d1c157
2026-02-10 11:57:29 -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
Abseil Team
0e5031d3c0 Add helper libraries for absl/extend
PiperOrigin-RevId: 863363038
Change-Id: If6845e9711d39cee83f166291eb86720ba9ca5b7
2026-01-30 13:11:56 -08:00
Abseil Team
b2f60a18b5 Undo add helper libraries for absl/extend
PiperOrigin-RevId: 863302753
Change-Id: I0908c0421bac4e3c8c6d72424980f612ea8a57f8
2026-01-30 10:41:21 -08:00
Abseil Team
bf4988f5f6 Add helper libraries for absl/extend
PiperOrigin-RevId: 863296052
Change-Id: Ia633bfc74418cc030b4c614d04617d8c5b9860a0
2026-01-30 10:26:58 -08:00
Derek Mauro
1fdbcb591f Add absl::Clock, an abstract interface that interface allows
decoupling code that uses time from the code that creates a point in
time.  You can use this to your advantage by injecting Clocks into
interfaces rather than having implementations call absl::Now()
directly. absl::Clock::GetRealClock() returns an absl::Clock backed by
absl::Now().

Add absl::SimulatedClock, a test-only Clock implementation that does
not "tick" on its own. Time is advanced by explicit calls to the
AdvanceTime() or SetTime() functions. This is intended to be used for
dependency injection in tests to test how code behaves under simulated
time conditions.

PiperOrigin-RevId: 862858341
Change-Id: Ied9946dd84063c95505269971d3c996d4b66c6d8
2026-01-29 12:51:12 -08:00
Derek Mauro
7599e36e7c Add absl::chunked_queue
This change introduces absl::chunked_queue, a sequence container
optimized for use as a FIFO (First-In, First-Out) queue. It is similar
in purpose to std::deque but with different performance trade-offs and
features.

absl::chunked_queue stores elements in a series of
exponentially-growing chunks of memory.

absl::chunked_queue is often a better choice than std::deque in the
following situations:
  * Large queues: For very large numbers of elements, the exponential
    growth strategy of absl::chunked_queue can lead to fewer, larger
    memory allocations compared to std::deque, which can be a
    performance advantage.
  * Strict FIFO processing: When you only need to add elements to the
    back (push_back) and remove them from the front (pop_front).

std::deque should be preferred in the following cases:
  * Operations at both ends: std::deque is designed for efficient
    insertions and deletions at both the front and the
    back. absl::chunked_queue is optimized for push_back and pop_front
    and does not offer a pop_back method.
  * Random access: std::deque provides amortized O(1) random access to
    elements via operator[]. absl::chunked_queue does not support
    random access.
PiperOrigin-RevId: 850999629
Change-Id: Ie71737c10b6125b9e498109267cac87a4ca2f9e8
2026-01-01 05:09:05 -08:00
Abseil Team
7b40ebf946 Add absl::down_cast
PiperOrigin-RevId: 850445526
Change-Id: I15e34dc543dc5aa72ae58ff471410d219fef2444
2025-12-30 10:05:03 -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
6c846a3540 [log] Prepare helper for streaming container contents to strings.
PiperOrigin-RevId: 846769302
Change-Id: Ice80fd61edaf7fa4b97286444251abccb204679f
2025-12-19 09:43:56 -08:00
Derek Mauro
630e92d5d5 Add absl::linked_hash_set and absl::linked_hash_map
These are hash containers ordered by insertion.

PiperOrigin-RevId: 846682470
Change-Id: I1c7fc54197d074666754f94b477782400197a14e
2025-12-19 04:50:33 -08:00
Chris Kennelly
03ea849fa2 absl/meta: Add C++17 port of C++20 requires expression for internal use
PiperOrigin-RevId: 846259270
Change-Id: I0126a78949b15fbbafca7c8dba3e3b60df30914b
2025-12-18 07:29:32 -08:00
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