Commit Graph

2370 Commits

Author SHA1 Message Date
Martin Brænne
f555f69ba8 LSC: Fix null safety issues diagnosed by Clang’s -Wnonnull and -Wnullability.
**Note**: These changes are generated by hand. Review with care.

This CL changes the `absl_internal` implementations of `AsciiStrToLower()` /
`AsciiStrToUpper()` to allow `src` to be null. This can, in fact, happen if the
`string_view` passed to the public API is empty, and the implementations handle
it correctly. I have added comments noting that `src` is allowed to be null
iff the size is zero.

`-Wnonnull` diagnoses cases where a `nullptr` literal is passed to a parameter
annotated nonnull, or where `nullptr` is returned from a function whose return
type is annotated nonnull.

`-Wnullability` diagnoses cases where nullability annotations conflict, for
example between the declaration and definition of a function.

PiperOrigin-RevId: 673846759
Change-Id: I6cf3490ce13837eba9814156c420598000ecc596
2024-09-12 07:57:05 -07:00
Abseil Team
a1a7086ead Remove the extraneous variable creation in Match().
PiperOrigin-RevId: 673830978
Change-Id: I81e52da873dcff75d6a8502578600ec7db50f221
2024-09-12 07:06:46 -07:00
Derek Mauro
1d4466e8d3 Import of CCTZ from GitHub.
- d1397431006ea1362a5914d4a90b265d0c7c6f2c Update zoneinfo files to 2024b (#300) by Bradley White <14679271+devbww@users.noreply.github.com>
  - 8bdbd840e97ff32e17f25db85c82589819ad3352 Fix mingw compiler error due to missing function declarat... by Biswapriyo Nath <nathbappai@gmail.com>
  - 6624659e01e73e41527d6b27036e9f79a556560f Add GitHub Actions CI (#299) by Derek Mauro <761129+derekmauro@users.noreply.github.com>

PiperOrigin-RevId: 673451051
Change-Id: Id39f2186bbdcb802d4fc4c5e21207c6f3709c56f
2024-09-11 10:43:29 -07:00
Evan Brown
0bc0e9a02d Add more debug capacity validation checks on merge/swap.
PiperOrigin-RevId: 673403995
Change-Id: I62d8bb37d4538c340783fb55e5a00694e932b6d1
2024-09-11 08:32:06 -07:00
Abseil Team
67d126083c Add absl:: namespace to c_linear_search implementation in order to avoid ADL
PiperOrigin-RevId: 671868434
Change-Id: I3c6a5f545fd7535ea20485547cdc3680a2362824
2024-09-06 13:15:19 -07:00
Evan Brown
e9ca8d1ca2 Distinguish the debug message for the case of self-move-assigned swiss tables.
PiperOrigin-RevId: 671484965
Change-Id: Ia1da7db0db1f776d48c74efaeab7252445208088
2024-09-05 13:16:03 -07:00
Abseil Team
043fe3c1d6 Update LowLevelHash comment regarding number of hash state variables.
PiperOrigin-RevId: 671385555
Change-Id: Ic98587062de121f127a56fecf2c494a82c6350ba
2024-09-05 08:39:51 -07:00
Abseil Team
f7f316824d Add an example for the --vmodule flag.
This makes it easier to copy-paste, without having to read the full documentation.

PiperOrigin-RevId: 670982905
Change-Id: I2f3844f30bc289053943aef3c15fdc5433203eb9
2024-09-04 08:38:32 -07:00
Abseil Team
b014bff59d Remove first prefetch.
The rationale behind this being that it is close too close to the first access of the data pointed by the pointer and is of no significant improvement as seen in the benchmarks.

PiperOrigin-RevId: 670574898
Change-Id: I43a495f23871a2870f4ffd9ab9232083d9668c79
2024-09-03 08:48:40 -07:00
Evan Brown
e64dd622d7 Add moved-from validation for the case of self-move-assignment.
PiperOrigin-RevId: 669363872
Change-Id: I2aeac23eb082a7bdabe65b3f55fd8adea6930386
2024-08-30 10:09:40 -07:00
Abseil Team
1031858eb2 Allow slow and fast abseil hardening checks to be enabled independently.
This change adds a new macro, ABSL_HARDENING_ASSERT_SLOW, which can be used for hardening assertions which have too great a performance impact to enable widely.  It also adds an additional supported value for ABSL_OPTION_HARDENED to only enable assertions which are not slow.  ABSL_OPTION_HARDENED=1 will continue to enable all hardening assertions, while ABSL_OPTION_HARDENED=2 will only enable assertions not marked as SLOW.

PiperOrigin-RevId: 668976425
Change-Id: I12cb209715d5b359c4093cc8c62e16794d7729b3
2024-08-29 10:06:30 -07:00
Abseil Team
8f942c0019 Update ABSL_RETIRED_FLAG comment to reflect default_value is no longer
used.

PiperOrigin-RevId: 668612700
Change-Id: I018ce756632154a9e7f2de77e6faa24296d80002
2024-08-28 14:41:25 -07:00
Evan Brown
f61aac8c41 Add validation against use of moved-from hash tables.
We enable this validation when sanitizers are enabled rather than in debug mode because debug mode can be enabled/disabled separately in different translation units, which can cause bugs for this type of validation. E.g. a hashtable that was moved from in a TU with debug enabled is then destroyed in a TU with debug disabled.

PiperOrigin-RevId: 668492783
Change-Id: Ifab6894de0890aa0a7d8ea338b53b6759b097cb1
2024-08-28 09:46:06 -07:00
Abseil Team
0f93828785 Provide file-scoped pragma behind macro ABSL_POINTERS_DEFAULT_NONNULL to
indicate the default nullability.
This is a no-op for now (not understood by checkers), but does communicate
intention to human readers.

PiperOrigin-RevId: 668448175
Change-Id: I19802d19be9a310aa5f0dacf8b0567dd768fb830
2024-08-28 07:41:25 -07:00
Francois Bleibel
40a975ff1e Add stacktrace config for android using the generic implementation
This change adds support for unwinding stack traces on supported android platforms (NDK 33+) to absl::GetStackTrace().

PiperOrigin-RevId: 668041186
Change-Id: Ie4c4c123686050c6b81683b71fe0246e8fa75f2b
2024-08-27 10:23:20 -07:00
Abseil Team
9457dfd9b4 Fix nullability annotations in ABSL code.
PiperOrigin-RevId: 667621254
Change-Id: Ibff25d275c1c6846f857d90ed905c70f9545d8dd
2024-08-26 10:03:27 -07:00
Abseil Team
63322a26c0 Replace CHECKs with ASSERTs and EXPECTs -- no reason to crash on failure.
PiperOrigin-RevId: 666760220
Change-Id: I9e85d4db0442546bdebc13b0a6e6d9c7f8d3c459
2024-08-23 05:46:12 -07:00
Abseil Team
fd58e18f2b Remove ABSL_INTERNAL_ATTRIBUTE_OWNER and ABSL_INTERNAL_ATTRIBUTE_VIEW
PiperOrigin-RevId: 666465929
Change-Id: Idcbed10e4e787f625f45460cd3651a37d06845bc
2024-08-22 13:22:27 -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
Derek Mauro
fd7713cb9a Disable ABSL_ATTRIBUTE_OWNER and ABSL_ATTRIBUTE_VIEW prior to Clang-13
due to false positives.

https://godbolt.org/z/evjd73cv6

PiperOrigin-RevId: 666027404
Change-Id: Ib0fe9c7b3d2aeb8710342e9e2aadc6a346e03e60
2024-08-21 14:12:31 -07:00
Abseil Team
5a01d0f77e Make ABSL_ATTRIBUTE_VIEW and ABSL_ATTRIBUTE_OWNER public
Deprecates ABSL_INTERNAL_ATTRIBUTE_VIEW and ABSL_INTERNAL_ATTRIBUTE_OWNER

PiperOrigin-RevId: 665523780
Change-Id: Ic4f7e3083a7db9d8fd057d3e002b81c775a4a87e
2024-08-20 14:19:54 -07:00
Evan Brown
116f0af9ec Optimize raw_hash_set::AssertHashEqConsistent a bit to avoid having as much runtime overhead.
PiperOrigin-RevId: 664999751
Change-Id: I6f908cc1b8de8a6a11bb1e02cca761df6aae4e07
2024-08-19 15:10:11 -07:00
Yuriy Chernyshov
8bb5dc4362 PR #1728: Workaround broken compilation against NDK r25
Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1728

When targeting Android NDK r25 (reached EOL now, but still in some use) one gets the following error:
```
$(SOURCE_ROOT)/contrib/restricted/abseil-cpp/absl/time/time.h:1762:37: error: invalid operands to binary expression ('std::strong_ordering' and 'const std::strong_ordering')
  if (auto c = lhs_hi <=> rhs_hi; c != std::strong_ordering::equal) {
```

The error indicates the lack of `operator<=>` between two `std::strong_ordering` items.
I believe that this should be controlled by `__cpp_lib_three_way_comparison` (_Three-way comparison (library support)_, see [this article](https://en.cppreference.com/w/cpp/feature_test)), not by `__cpp_impl_three_way_comparison` (which stands for _Three-way comparison (compiler support)_).

Fixes #1725.
The problem was introduced in a27662352e.

Merge 32e1d3d889 into 69c4683962

Merging this change closes #1728

COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1728 from georgthegreat:fix-time 32e1d3d889
PiperOrigin-RevId: 663723253
Change-Id: I29f7d2b562cc5ad8e11cd46b538ba69acee0f314
2024-08-16 07:23:53 -07:00
Evan Brown
17c1a5e821 Add validation against use of destroyed hash tables.
PiperOrigin-RevId: 663373500
Change-Id: I6b2014f8cc4244e1599c907197cfaadb6739f72b
2024-08-15 11:10:37 -07:00
Abseil Team
b2665cee02 Do not truncate ABSL_RAW_LOG output at null bytes
This fixes the behavior of
```c++
ABSL_RAW_LOG(INFO, "RAW INFO: %s%c%s", "Hello", 0, "World");
```
which would previously truncate at the `\0`. The new behavior is consistent with `printf`.

PiperOrigin-RevId: 663049889
Change-Id: I171dcb8a61b19873b88920e383f03acf7fb112d7
2024-08-14 14:15:19 -07:00
Chris Kennelly
69c4683962 Use several unused cord instances in tests and benchmarks.
PiperOrigin-RevId: 662635356
Change-Id: I8b3d992147ee3affb92947135f09076c851448e3
2024-08-13 13:40:27 -07:00
Abseil Team
70502ae69d Add comments about ThreadIdentity struct allocation behavior.
PiperOrigin-RevId: 662586240
Change-Id: Ibee60b935da5d8135ac99b6caf00b3c035ecfd89
2024-08-13 11:19:06 -07:00
Evan Brown
62ad2bac84 Refactoring followup for reentrancy validation in swisstable.
The motivation for renaming AssertValidCapacity() is to avoid confusion with IsValidCapacity().

PiperOrigin-RevId: 662178137
Change-Id: If4fd15725376a899c4f40afc3db9e300c8c1edc7
2024-08-12 12:03:46 -07:00
Evan Brown
ac267be5cf Add debug mode checks that element constructors/destructors don't make reentrant calls to raw_hash_set member functions.
PiperOrigin-RevId: 660889825
Change-Id: I02e0e364a5215431eddeeabde66531a95aa03f22
2024-08-08 10:29:54 -07:00
Michael Brase
9bd9a2d6df Add tagging for cc_tests that are incompatible with Fuchsia
PiperOrigin-RevId: 660539039
Change-Id: I2f3dee7c60ce2234ea81c64b23e50448681fa885
2024-08-07 14:28:00 -07:00
Michael Brase
3848ed7f1b Add GetTID() implementation for Fuchsia
The GetTID() now uses the value of the current thread handle from
zx_thread_self() on Fuchsia for the thread ID. This is better than the default
implementation which uses pthread_self(), since that results in a 64-bit
pointer being truncated into the 32-bit pid_t type.

PiperOrigin-RevId: 660270084
Change-Id: I7c8b4a26cca775be62eb6f6926cb734cbb893585
2024-08-07 00:36:46 -07: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
Abseil Team
ee18629017 Disable weak attribute when absl compiled as windows DLL
PiperOrigin-RevId: 659987892
Change-Id: I8cb64c7569abe932851ab52d68e3b44c0c008ece
2024-08-06 09:34:47 -07:00
Martin Brænne
08850701d2 Remove CharIterator::operator->.
An `operator->` that doesn't return a record type doesn't really serve a useful
purpose, and it is not required by the iterator concepts. I haven't been able
to find any usage in non-test code, so I'm removing it.

Even though the `pointer` type alias is now not being used anywhere, I'm keeping
it because otherwise some standard libraries don't accept `CharIterator` when
passed to `std::string::apend()`, for example.

PiperOrigin-RevId: 659832167
Change-Id: I5de183a01009bfd71c8477f2023973075be8d860
2024-08-06 00:06:36 -07:00
Abseil Team
00478de3e9 Mark non-modifying container algorithms as constexpr for C++20.
This change marks Abseil's non-modifying sequence operations including
absl::linear_search and absl::c_linear_search as constexpr when building with
C++20.
PiperOrigin-RevId: 659812405
Change-Id: I8dc2cee873f30531b2eb8fb3da12085505a43a1a
2024-08-05 22:55:39 -07:00
Christopher Fore
809e5de7b9 PR #1739: container/internal: Explicitly include <cstdint>
Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1739

GCC 15 will no longer include <cstdint> by default, resulting in build failures in projects that do not explicitly include it.

Merge faf1b03a59 into 9cb5e5d15c

Merging this change closes #1739

COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1739 from csfore:gcc-15-fix faf1b03a59
PiperOrigin-RevId: 659637669
Change-Id: If14cb0e3522774cb700bd5a74abffb75feb7a0f5
2024-08-05 12:10:00 -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
Frédéric Bastien
372124e6af PR #1732: Fix build on NVIDIA Jetson board. Fix #1665
Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1732

Fix build on NVIDIA Jetson board. Fix #1665

This patch is already used by the spark project.
I'm fixing this as this break the build of Tensorflow and JAX on Jetson board.
Merge 7db2d2ab9f into 6b8ebb35c0

Merging this change closes #1732

COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1732 from nouiz:fix_neon_on_jetson 7db2d2ab9f
PiperOrigin-RevId: 658501520
Change-Id: If502ede4efc8c877fb3fed227eca6dc7622dd181
2024-08-01 12:40:25 -07:00
Derek Mauro
d0159eab59 Update GoogleTest dependency to 1.15.2
This updates to a version of GoogleTest that fixes
https://github.com/google/googletest/issues/4581
for downstream users of rules_python

PiperOrigin-RevId: 658398482
Change-Id: I4c6d431fd38d3a108e3c252eb26be9d81ff05a8e
2024-08-01 07:46:25 -07:00
Abseil Team
6b8ebb35c0 Enable AsciiStrToLower and AsciiStrToUpper overloads for rvalue references.
PiperOrigin-RevId: 657719871
Change-Id: If0f16b1d8cfae79f31427a804a5b838599154895
2024-07-30 13:55:47 -07:00
Pavel P
983652e494 PR #1735: Avoid int to bool conversion warning
Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1735

If asan is enabled with VS, the following warning is issued by the compiler:

1>C:\work\abseil-cpp\absl\debugging\leak_check.cc(46,68): error C4800: Implicit conversion from 'int' to bool. Possible information loss
1>    C:\work\abseil-cpp\absl\debugging\leak_check.cc(46,68):
1>    consider using explicit cast or comparison to 0 to avoid this warning
Merge 9a6a677add into 8cdf482136

Merging this change closes #1735

COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1735 from pps83:master-int-bool-warn 9a6a677add
PiperOrigin-RevId: 657591557
Change-Id: I709424b5064160860186a42f854a1856465e80d0
2024-07-30 07:57:14 -07:00
Abseil Team
13ec8d5d29 Add absl::swap functions for *_hash_* to avoid calling std::swap
We already have `swap(raw_hash_set&, raw_hash_set&)` thus we may expect argument dependent lookup will use that function in following code snippet:
```
absl::flat_hash_map<...> x, y;
using std::swap;
swap(x, y);
```
But in practice `std::swap` will be called because `swap(raw_hash_set&, raw_hash_set&)` requires derived-to-base conversion while `std::swap` doesn't (it is a function template), thus `std::swap` is picked by compiler.

To avoid this, we need a `swap` implementations which accept the exact `*_hash_*` types which is more preferred over `std::swap`.

Note that this will fix issues#1571.

PiperOrigin-RevId: 657419420
Change-Id: Id003b2129187ce2d4583029789ff96247d1490de
2024-07-29 20:04:12 -07:00
Martijn Vels
52fad5aa02 Change internal visibility
PiperOrigin-RevId: 657352849
Change-Id: I443f218b5500492948cd4c974313209907916355
2024-07-29 15:51:28 -07:00
Abseil Team
6c45955423 Remove resolved issue.
https://github.com/llvm/llvm-project/issues/100639

The second issue is still relevant.

PiperOrigin-RevId: 657298935
Change-Id: Ifa2f1627deee3fc24e23ea78c5b01ed232813390
2024-07-29 13:02:59 -07:00
Michael Brase
8cdf482136 Increase test timeouts to support running on Fuchsia emulators
PiperOrigin-RevId: 656439732
Change-Id: I7f405d8075c57e634d51c11a37fbe3e317abf103
2024-07-26 10:04:20 -07:00
Martijn Vels
bb63788b4b Add tracing annotations to absl::Notification
PiperOrigin-RevId: 656188416
Change-Id: I43d901d99f8a4688406b8aab08bc2655a065af46
2024-07-25 19:12:40 -07:00
Abseil Team
e342b7fc37 Suppress compiler optimizations which may break container poisoning.
Many compiler optimizations, even some in Asan, assume that size of
the object on the stack is fixed. Compiler takes into account the lifetime
of the stack object, but it does not expect that size of the object can
change.

This assumption allow to accesses when ever object is alive.

However, this assumption does not work well with custom poisoning
of objects by sanitizers. `Cord` may poison parts of the object
to improve a precision of the bug detection. But compiler still may
load from poisoned parts of the object, assuming it's alive.

So without the patch we can have `false-positive`, because
compiler reordered load from poisoned local before size-check.
https://github.com/llvm/llvm-project/issues/100639

Alternative is to make compiler optimization to know about
possibility of local object resize, but it's not worth of effort,
as it's needed only for sanitizers so far.

Another minor issue fixed with this patch is `false-negative`.
https://github.com/llvm/llvm-project/issues/100640
Asan drops instrumentation of memory accesses proven to be inbound
of local variable. However if we if we take into account `custom
poisoning` we will have to pessimize too often: any random function
call can potentially `resize` a variable by `poisoning`.

We are already using similar `poisoning` workaround in libc++:
https://github.com/llvm/llvm-project/pull/79536/files#diff-534bc2907ddb3b074ded1353d18fd7d578daf1707943b3039bab4ed975aba3b3R772

PiperOrigin-RevId: 656129711
Change-Id: I6d78997da6d31c7ab979a00b84dc9b3b7cffc26f
2024-07-25 16:10:16 -07:00
Abseil Team
bd3ae17f02 Disable ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION for Fuchsia
The POSIX sigaltstack() function is not implemented on Fuchsia.

PiperOrigin-RevId: 656080882
Change-Id: Ibf4892df85f299b888eb7f0016c220f49f975b96
2024-07-25 14:00:10 -07:00
Martijn Vels
034f8d0598 Add tracing annotations to absl::BlockingCounter
PiperOrigin-RevId: 656010740
Change-Id: I99ef6f18502a0cb2c363c805ae5f9a9a42bd3b41
2024-07-25 10:54:32 -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