Add [[clang::nomerge]] to absl::base_internal::HardeningAbort()
This lets us distinguish crashes due to different hardening checks.
PiperOrigin-RevId: 910658969
Change-Id: I820eb5291d7ce8330df0dac10ea09fafef405bbb
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
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
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
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
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
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
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
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
StringResizeAndOverwrite has MSAN testing of the entire string.
This causes quadratic MSAN verification on small appends.
PiperOrigin-RevId: 824629932
Change-Id: Ibefff781f5923c8bd2c1dc364f5b63fcb1d0f5ab
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
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
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
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
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
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
"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
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
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
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