233 Commits

Author SHA1 Message Date
Abseil Team
d96371953c Use constexpr instead of ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20
These are equivalent since they fall back to the standard library. There's no need to reimpose whatever constraints the standard library already imposes.

PiperOrigin-RevId: 926341943
Change-Id: I406d1203ca2d4fec68ae7a06eef0cf2dad6916dd
2026-06-03 16:36:30 -07:00
Abseil Team
259108c6b8 Remove empty build targets in Abseil
PiperOrigin-RevId: 926172397
Change-Id: I4bcd6c86fe30f59ab5f375db268bf78fdcf3a21e
2026-06-03 11:49:40 -07:00
Abseil Team
f883d40d20 Fix comment in variant.h to refer to absl::variant.
The comment is updated to accurately reflect that `absl::variant` was the polyfill and is now an alias for `std::variant`.

PiperOrigin-RevId: 919336725
Change-Id: If39bd3f61f229f561d547391ca97015688b1fad1
2026-05-21 17:21:03 -07:00
Abseil Team
1ea7b9254f Undo deprecate and inline of absl::optional and absl::nullopt
PiperOrigin-RevId: 916628855
Change-Id: Iadbb9574d526aa1b6d65992135de21529600fc01
2026-05-16 20:27:56 -07:00
Abseil Team
7eaa5fbb22 Deprecate and inline absl::optional and absl::nullopt
PiperOrigin-RevId: 916205787
Change-Id: I3b9e732184f45fc33f7c9fc3976c27b45bce81f9
2026-05-15 15:16:24 -07:00
Abseil Team
a20313e890 Deprecate and inline historical functions in Abseil
PiperOrigin-RevId: 916125223
Change-Id: I79a4bb099685ef9119718f5ab468fdb2aff21ed0
2026-05-15 12:17:13 -07:00
Abseil Team
d4aba0a323 Deprecate and inline historical functions in Abseil
Migrates uses of absl:: symbols to std:: symbols

PiperOrigin-RevId: 914475818
Change-Id: I35908b9d91b4fba465b9fe3e5b2c8f497f2f192b
2026-05-12 14:21:33 -07:00
Abseil Team
d0d4c59910 Deprecate and inline some historical inline variables in Abseil
PiperOrigin-RevId: 911711219
Change-Id: Icf6fa5f06d4c9f251d1f4139f942182c078db743
2026-05-06 20:55:45 -07:00
Abseil Team
49fe184484 Deprecate and inline historical typedefs in Abseil
PiperOrigin-RevId: 910228893
Change-Id: I35c700e73c665f7eff07bd069a79905146e9d50b
2026-05-04 14:01:46 -07:00
Abseil Team
8f7e820769 Deprecate and inline absl::variant
PiperOrigin-RevId: 910095755
Change-Id: If517f379a6ada76fd447f0568726805bc37436bb
2026-05-04 10:10:08 -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
Abseil Team
8a6b6ae902 Automated rollback of commit 34e723033b.
PiperOrigin-RevId: 903357540
Change-Id: I0c25be897ce7cd5d0e4e82f66f912516b2943400
2026-04-21 12:10:31 -07:00
Abseil Team
34e723033b Change abseil hardening assertions in types 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.

This change also changes the assertion functions from inline to constexpr, to allow functions using them to be called from static assertions (like optional_ref::operator* in optional_ref's constexpr test).

PiperOrigin-RevId: 903344377
Change-Id: I50166b6cf12a8f139ed3c9fe4f6c6e0f24b51812
2026-04-21 11:43:47 -07:00
Abseil Team
ac5ea999a3 Change abseil hardening assertions in types 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.

This change also changes the assertion functions from inline to constexpr, to allow functions using them to be called from static assertions (like optional_ref::operator* in optional_ref's constexpr test).

PiperOrigin-RevId: 903309187
Change-Id: Icbe0fd9d0fe9e212036d17468e80833b95b8a82d
2026-04-21 10:38:58 -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
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
0093ac6cac Prevent users of absl::AnySpan::subspan(pos, len) from relying on truncation behavior while the migration from this nonstandard function is in progress.
PiperOrigin-RevId: 889935946
Change-Id: I0b3e95ba579f66f1e1982ddb768844f7554c932c
2026-03-26 10:57:52 -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
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
Abseil Team
a62029e346 Add absl::optional_ref<T>
PiperOrigin-RevId: 872459397
Change-Id: Ib2a3265c46c1ceca31190f5d4722bde06b59eeb4
2026-02-19 10:27:08 -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
fc3eb05099 Remove unused dependency in absl/types/optional.h
PiperOrigin-RevId: 866108635
Change-Id: If8981b0c4631d4bc81df1eb51f7b737cb97d3d2c
2026-02-05 14:16:04 -08:00
Abseil Team
0e2e1ba7d4 Remove unused dependency in absl/types/optional.h
PiperOrigin-RevId: 866096664
Change-Id: Ibb4a59f691953e5d0e4cf3ff667f0f0c898d3d75
2026-02-05 13:47:59 -08:00
Abseil Team
eef1a08f4b Update absl::Span and std::span differences comment
PiperOrigin-RevId: 856366482
Change-Id: I55a33a56f83ed2c0bf30bd14a08c770f18e13d32
2026-01-14 14:31:15 -08:00
Derek Mauro
b9baf19a19 Document the differing trimming behavior of absl::Span::subspan() and std::span::subspan()
`std::span::subspan()` has stricter preconditions than its `absl::`
counterpart. Supplying a `len` that would extend beyond the end of the
span is undefined behavior for `std::span` (unless `len` is the default
`npos` value), whereas `absl::span` simply truncates the result.

PiperOrigin-RevId: 836331418
Change-Id: I0e9a11cb434deca0b88d761e8233a44d5a9273ce
2025-11-24 12:50:53 -08:00
Aaron Jacobs
ab4f684de4 absl/types: format code with clang-format.
PiperOrigin-RevId: 820434760
Change-Id: I70e5e4b6a433137e55d4ec27be04f6acd46ad649
2025-10-16 16:14:40 -07:00
Abseil Team
ef1ae8e310 Rollback absl/types: format code with clang-format.
PiperOrigin-RevId: 819885003
Change-Id: I6063473267eeb82eb48db7d339005cb4f5adbc3a
2025-10-15 13:16:51 -07:00
Aaron Jacobs
dfd10a6b42 absl/types: format code with clang-format.
PiperOrigin-RevId: 819753014
Change-Id: Iceecb1a53de5126d41cc1069ab0a1c935a6f28ca
2025-10-15 07:51:53 -07:00
Abseil Team
41d463fd9e Add lifetimebound annotations to absl::MakeSpan and absl::MakeConstSpan to detect dangling references
PiperOrigin-RevId: 791264370
Change-Id: Iae2831f768582e49620ac50cc8cd1d2ccd29a0e9
2025-08-05 10:06:05 -07:00
Abseil Team
18dd270ff9 Adds required load statements for C++ rules to BUILD and bzl files.
PiperOrigin-RevId: 786301329
Change-Id: I342de39e40e90c82501baac9858291b7c4d5c2d0
2025-07-23 08:59:55 -07:00
Abseil Team
f8b473612e Add triviality tests for absl::Span
PiperOrigin-RevId: 783026645
Change-Id: Ibacb4371f0b9d3285577bc9b9bccaa02076114c3
2025-07-14 13:43:53 -07:00
Abseil Team
f35d6ad413 Prevent conversion constructions from absl::Span to itself
The conversions invoke the wrong constructor and merely happen to work correctly. However, they break trivial-copyability, and may also break if the constructor behaviors diverge (such as if a lifetime attribute is added).

PiperOrigin-RevId: 782932715
Change-Id: I280a03341887af241cf636c09f1c4318dc98fc16
2025-07-14 09:23:34 -07:00
Vitaly Goldshteyn
fbb1d06795 Make combine_contiguous to mix length in a weak way by adding size << 24, so that we can avoid a separate mixing of size later. The empty range is mixing 0x57 byte.
It was also considered to add just `size` without transformation. But this causes collisions for small contiguous strings that may be quite a common case. So it is better to avoid additional disruptions for client code.

```
name                           old INSTRUCTIONS/op  new INSTRUCTIONS/op  delta
BM_latency_AbslHash_Int32        9.00 ± 0%            9.00 ± 0%     ~     (all samples are equal)
BM_latency_AbslHash_Int64        9.00 ± 0%            9.00 ± 0%     ~     (all samples are equal)
BM_latency_AbslHash_String3      32.0 ± 0%            34.0 ± 0%   +6.25%        (p=0.000 n=57+57)
BM_latency_AbslHash_String5      31.0 ± 5%            32.8 ± 5%   +6.00%        (p=0.000 n=57+57)
BM_latency_AbslHash_String9      28.8 ± 4%            30.2 ± 5%   +4.94%        (p=0.000 n=53+53)
BM_latency_AbslHash_String17     27.4 ± 3%            27.6 ± 4%   +0.64%        (p=0.032 n=53+52)
BM_latency_AbslHash_String33     32.8 ± 4%            32.5 ± 8%     ~           (p=0.079 n=51+53)
BM_latency_AbslHash_String65     55.9 ±14%            55.1 ±10%     ~           (p=0.288 n=52+51)
BM_latency_AbslHash_String257     122 ±11%             121 ±11%     ~           (p=0.432 n=50+55)

name                           old CYCLES/op        new CYCLES/op        delta
BM_latency_AbslHash_Int32        16.0 ± 2%            16.1 ± 4%     ~           (p=0.433 n=56+57)
BM_latency_AbslHash_Int64        16.4 ± 4%            16.5 ± 3%     ~           (p=0.076 n=56+46)
BM_latency_AbslHash_String3      22.6 ± 0%            21.0 ± 1%   -6.83%        (p=0.000 n=52+47)
BM_latency_AbslHash_String5      22.2 ± 5%            21.2 ± 4%   -4.53%        (p=0.000 n=54+56)
BM_latency_AbslHash_String9      22.1 ±11%            20.4 ± 5%   -7.72%        (p=0.000 n=51+55)
BM_latency_AbslHash_String17     21.4 ± 3%            19.6 ± 4%   -8.52%        (p=0.000 n=54+51)
BM_latency_AbslHash_String33     23.5 ± 4%            20.8 ± 7%  -11.42%        (p=0.000 n=53+54)
BM_latency_AbslHash_String65     28.6 ± 6%            27.0 ± 7%   -5.47%        (p=0.000 n=53+55)
BM_latency_AbslHash_String257    46.7 ± 9%            44.4 ±10%   -4.93%        (p=0.000 n=52+56)
```

PiperOrigin-RevId: 765281185
Change-Id: I0754877ca7eaa4d187390fe631ef407d379ccae7
2025-05-30 12:01:00 -07:00
Derek Mauro
9fcfa0602d Change some nullability annotations in absl::Span to
absl_nullability_unknown to workaround a bug that makes nullability
checks trigger in foreach loops, while still fixing the
-Wnullability-completeness warnings.

PiperOrigin-RevId: 755951074
Change-Id: Ia6eea53f381d9255856a3f85efa41f0dfbd5c684
2025-05-07 12:04:51 -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
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
d97663ee23 Automated Code Change
PiperOrigin-RevId: 744017203
Change-Id: I69b4418b306bdb5f89194bbcddaed9813e46ec6f
2025-04-04 11:43:03 -07:00
Derek Mauro
c52afac4f8 Restore the empty CMake targets for bad_any_cast, bad_optional_access,
and bad_variant_access to allow clients to migrate.

PiperOrigin-RevId: 734687090
Change-Id: I2c48020c1634aa487dc1294763a740847418ce3f
2025-03-07 14:21:06 -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
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
e78a8ce497 Delete absl/base/internal/inline_variable.h
PiperOrigin-RevId: 728684812
Change-Id: If4e2d0fed045c1cb312a48f250d5ebb1aaa1b41f
2025-02-19 08:32:03 -08:00
Dino Radakovic
60d29be650 absl: Replace base_internal::{invoke,invoke_result_t,is_invocable_r} with std equivalents
Now that Abseil only supports C++17 and beyond, these `base_internal` symbols [are just aliases](05e72a3285/absl/base/internal/invoke.h (L42)) in C++ >= 17. Replacing them in `Abseil`'s internals will allow us to delete `absl/base/internal/invoke.h`.

PiperOrigin-RevId: 726051909
Change-Id: Ic571307c6e11d7b3e2a380255bd4c9be98e232f9
2025-02-12 07:45:45 -08:00
Derek Mauro
90a7ba66e8 Updates to CI to support newer versions of tools
Linux "latest" containers updated to
GCC 14.2
CMake 3.31.2
Bazel 8.0.0

Included are various fixes to get these versions to work.

Bazel now references repositories by their canonical names from the
Bazel Central Registry. For example, Abseil is now @abseil-cpp instead
of @com_google_absl, and GoogleTest is now @googletest instead of
@com_google_googletest. Users still using the old WORKSPACE system may
need to use `repo_mapping` on repositories using the old names. See
`WORKSPACE.bazel` in this commit for an example.

PiperOrigin-RevId: 709102146
Change-Id: I02327ed4f8fb947766480bdeef2b1930a7f831eb
2024-12-23 10:58:05 -08:00
Abseil Team
f0e59054ff Move ABSL_HARDENING_ASSERTs in constexpr methods to their own lines.
Prior to this change, some ABSL_HARDENING_ASSERTs were sequenced with the main
work of some constexpr methods using the comma operator in order to satisfy
C++11's constexpr requirements. However, putting the assertion and the main
work of the function on the same line complicates measuring the performance
impact of the assertions. As C++11 is no longer supported, this change moves
the assertions to their own lines in order to make measuring their performance
impact easier.

PiperOrigin-RevId: 707614464
Change-Id: Idb621bb183b80db17e2db44c3ffc671b76bba92b
2024-12-18 11:25:36 -08:00
Abseil Team
8d272b2871 Make Span's relational operators constexpr since C++20.
_The implementation has not changed, only constexpr markers have been added._

PiperOrigin-RevId: 695435063
Change-Id: I66cd03195e429534c0e58c330f1019c89025abed
2024-11-11 12:03:45 -08:00
Abseil Team
4b4f41e93d Add ABSL_ATTRIBUTE_LIFETIME_BOUND to absl::Span constructors.
This enables clang to catch more use-after-free bugs.

PiperOrigin-RevId: 692275317
Change-Id: I86c414a90d24d239ed67b3316fe74e1c24f95ed9
2024-11-01 13:30:09 -07:00
Abseil Team
878313658e Marks absl::Span as view and borrowed_range, like std::span.
This allows containers that either optimize based on these
concepts or produce lifetime warnings based on them to
handle absl::Span appropriately. An example is Chromium's
base::span, which warns more aggressively about construction
from rvalues that are not borrowed ranges.

This only has an effect for codebases using C++20. While
many such codebases will presumably also be using std::span
directly, they may use absl::Span for backwards compat, or
compile against libraries that do so.

Also fixes lint's that fired when I tried to edit this.

PiperOrigin-RevId: 688552975
Change-Id: I603e04cd74d60ac6b65754ac73037d7f0ab457fe
2024-10-22 08:07:07 -07:00
Abseil Team
2abe94a3b0 Migrate ABSL_INTERNAL_ATTRIBUTE_OWNER and ABSL_INTERNAL_ATTRIBUTE_VIEW to ABSL_ATTRIBUTE_OWNER and ABSL_ATTRIBUTE_VIEW
PiperOrigin-RevId: 666390885
Change-Id: I85457d39cf5ecb1c6622c6d59cb1876b154d64c3
2024-08-22 09:59:40 -07:00