Commit Graph

141 Commits

Author SHA1 Message Date
Abseil Team
213609f5c8 Fix a bug in LogMessage::CopyToEncodedBufferWithStructuredProtoField where all strings are encoded as not literal strings.
PiperOrigin-RevId: 917976428
Change-Id: Idd6b77216dccdbd761748f185fb466b716fff38b
2026-05-19 12:50:06 -07:00
Abseil Team
18e7230eee Fix visibility issue in absl/log/internal:flags
PiperOrigin-RevId: 916300899
Change-Id: I219afa7d0fd85e950a05e569cb151e414358b325
2026-05-15 20:03:24 -07:00
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
Derek Mauro
97aea89f78 Add a comment about the dataflow to //absl/log/internal/proto.cc
for the benefit people using of AI to scan the code

This will hopefully prevent pull-requests like #2045 that see a local
problem with DecodeVarint() without understanding the larger picture.

See https://github.com/abseil/abseil-cpp/pull/2045

PiperOrigin-RevId: 910971345
Change-Id: I76e1524e4577799ae391716928f10b7fff82e112
2026-05-05 16:12:31 -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
709bf9ea18 nullstream: fix a header guard comment
PiperOrigin-RevId: 895415828
Change-Id: I2cb4dc6bb5e890bfc9fedf1517d45bf52c1362c1
2026-04-06 11:23:14 -07:00
Abseil Team
81f4d83f38 Add supporting code for absl::SourceLocation
PiperOrigin-RevId: 883256961
Change-Id: I536f9dc76ce4f248b5c87eaf27515cd8a4a484ca
2026-03-13 11:25:47 -07:00
Derek Mauro
1d3714755a Fix ambiguous call to EncodeVarint()
Fixes #2021

PiperOrigin-RevId: 877567617
Change-Id: I99f8f6f121e1dcea2b45d679bdda86b89cf14582
2026-03-02 14:05:26 -08:00
Mike Kruskal
45c8989b87 Add a visibility placeholder to Abseil for Gloop.
PiperOrigin-RevId: 875292936
Change-Id: I5622f33f8d6581ca3f55783579f612e3e5c4822f
2026-02-25 12:48:48 -08:00
Derek Mauro
5088cf5194 Cleanup the uses of the polyfills absl::any, absl::optional,
absl::variant, and related types

The corresponding headers are removed from cc files, but kept in
headers to prevent breakages from transitive dependencies.

PiperOrigin-RevId: 872421685
Change-Id: I867d4c3f7c9e422289c63816d44719b0530fb0a6
2026-02-19 08:53:17 -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
Abseil Team
0cc960ece0 Automated rollback of commit 9f40d6d6f3.
PiperOrigin-RevId: 838084272
Change-Id: I8b1b15618e12cc17d85a71b7f5062b66ceaaf04f
2025-11-29 05:02:02 -08:00
Abseil Team
9f40d6d6f3 Enable clang-specific warnings on the clang-cl build
instead of just trying to be MSVC

This also fixes the new warnings that are caught.
These include:
  * Unreachable code after GTEST_SKIP (this is kind of ugly)
  * Some -Wundef warnings
  * A -Wshadow warning in vlog_config.cc

PiperOrigin-RevId: 838046186
Change-Id: Ief48d6db2b8755d2173997d052560880593d5819
2025-11-29 01:22:25 -08:00
Derek Mauro
b20370e0d6 Enable clang-specific warnings on the clang-cl build
instead of just trying to be MSVC

This also fixes the new warnings that are caught.
These include:
  * Unreachable code after GTEST_SKIP (this is kind of ugly)
  * Some -Wundef warnings
  * A -Wshadow warning in vlog_config.cc

PiperOrigin-RevId: 838017208
Change-Id: I39373c0ccc57c8660c22815c51ac5b4180aec53c
2025-11-28 22:41:40 -08:00
Samuel Benzaquen
f0a99676ff Fix the CHECK_XX family of macros to not print char* arguments as C-strings if the comparison happened as pointers.
Printing as pointers is more relevant to the result of the comparison.

PiperOrigin-RevId: 824656335
Change-Id: I3b586e633c1271c1728c961193db106e4f4e5a8b
2025-10-27 13:35:03 -07:00
Andy Getzendanner
2f1be7bdae cleanup: s/logging_internal/log_internal/ig for consistency
PiperOrigin-RevId: 822103413
Change-Id: I500f098847906439b869b2eb34c98abba10b10ea
2025-10-21 07:12:57 -07:00
Andy Getzendanner
86372e7a21 Remove an undocumented behavior of --vmodule and absl::SetVLogLevel that could set a module_pattern to defer to the global vlog threshold.
PiperOrigin-RevId: 819849697
Change-Id: Ic1ddb5e92338e6cae07850a6ebbed001df496022
2025-10-15 11:45:46 -07:00
Andy Getzendanner
620d600442 Expose (internally) a LogMessage constructor taking file as a string_view for (internal, upcoming) FFI integration.
PiperOrigin-RevId: 809039806
Change-Id: I4fb3513ba5914ba9e874ec7c759fbc3b6d4bc992
2025-09-19 08:02:11 -07:00
Sohaib Iftikhar
e8c1a5ff23 Fix check_op(s) compilation failures on gcc 8 which eagerly tries to
instantiate std::underlying_type for non-num types.

Before cpp20 using std::underlying_t on non enum types is undefined behaviour.

PiperOrigin-RevId: 806567586
Change-Id: I5e0694d52296b33a4d3689fa464139319f48429e
2025-09-13 00:05:10 -07:00
Andy Getzendanner
266b1a0bf8 Cast ABSL_MIN_LOG_LEVEL to absl::LogSeverityAtLeast instead of absl::LogSeverity.
PiperOrigin-RevId: 804953870
Change-Id: I1cf4abd1e13c9644eb6e46a22d9d8c642c420d1d
2025-09-09 09:55:01 -07:00
Andy Getzendanner
79bdf3b41f When printing CHECK_XX failures and both types are unprintable, don't bother printing " (UNPRINTABLE vs. UNPRINTABLE)".
PiperOrigin-RevId: 802287138
Change-Id: I8b4815fdc089427be9f276e10f9a72b398ed8f80
2025-09-02 14:14:03 -07:00
Derek Mauro
ba9a180d22 Fix CHECK_<OP> ambiguous overload for operator<< in older versions of GCC
when C-style strings are compared

Regression introduced in 57bc7edd87

PiperOrigin-RevId: 800142107
Change-Id: Ibafe2dc58b1d1cb0e24e3e0c36d095d35a5f7bd3
2025-08-27 13:01:51 -07:00
Abseil Team
9d0ba8dc5c Remove unused include statement
PiperOrigin-RevId: 796516033
Change-Id: I0e6db865f9ad9c8d157be14b270dca98e2e9d195
2025-08-18 11:54:16 -07:00
Chris Kennelly
0f1abc9b73 Inline internal usages of pointerful SpinLockHolder/MutexLock.
PiperOrigin-RevId: 789441157
Change-Id: I2ed5d12f4b9725edbe3fd6cf629a0563a2f2d739
2025-07-31 12:59:26 -07:00
Chris Kennelly
3e0d9ff64a Inline SpinLock Lock->lock, Unlock->unlock internal to Abseil.
PiperOrigin-RevId: 788531193
Change-Id: Icca9ff096c2ec2fc0662f1f94ecfb232a8492974
2025-07-29 11:12:36 -07:00
Abseil Team
57bc7edd87 Allow CHECK_<OP> variants to be used with unprintable types.
PiperOrigin-RevId: 786406173
Change-Id: Ifc362a702f82a6b3ad33210980dda6f40f14fca4
2025-07-23 13:37:00 -07:00
Abseil Team
878361312d Automated Code Change
PiperOrigin-RevId: 783054860
Change-Id: I3f84881642f2f77be5d5275983243edf6305178c
2025-07-14 15:00:34 -07:00
Abseil Team
2b320cbfaa Fix includes and fuse constructors of SpinLock.
PiperOrigin-RevId: 774835829
Change-Id: I0fa7cab1b98c1b7222de0acd71b7846df693f1e2
2025-06-23 10:32:42 -07:00
Ryan Buckley
888c22115f Add support for scoped enumerations in CHECK_XX().
This change allows values of a scoped enum (that is, an `enum class` or `enum struct`) to be passed to CHECK_EQ and its relatives (CHECK_NE, DCHECK_GE, etc). Before this change, this was not possible because enum class values could not be printed without a custom operator<< or AbslStringify implementation. This change adds support by converting the scoped-enum values to their underlying types for printing purposes when a CHECK_XX fails. If a scoped enum already has operator<< or AbslStringify defined, those methods are still preferred.

One design detail: enums can have char as their underlying type. For consistency with unscoped enums, a char-backed scoped enum is printed as an ASCII character when its value is in the printable ASCII range (decimal 32 to 126).

PiperOrigin-RevId: 771129686
Change-Id: I4d0ba0f4e1dc1264df4ee8d0230d3dbd02581c9b
2025-06-13 09:56:01 -07:00
Abseil Team
ca47784155 Revert no-inline on Voidify::operator&&() -- caused unexpected binary size growth
PiperOrigin-RevId: 770801572
Change-Id: Ia553cfcc5bfc2906d82990cec259d1ffdfbda2d4
2025-06-12 14:44:39 -07:00
Abseil Team
58e9ca14e6 Mark Voidify::operator&&() as no-inline.
This improves stack trace for `LOG(FATAL)` with optimization on.

PiperOrigin-RevId: 770679129
Change-Id: I2c7326725d5f1749165c04d3225833fdb22191d6
2025-06-12 09:05:10 -07:00
Abseil Team
e1ff6a3339 Fix a false nullability warning in [Q]CHECK_OK by replacing nullptr with an empty char*
PiperOrigin-RevId: 765346332
Change-Id: I3a56ef48c9f5b241dcbc56b0a4ee5aa1d9c9614f
2025-05-30 14:50:39 -07:00
Omer Mor
db8171fd8b Remove dependency on wcsnlen for string length calculation.
The `wcsnlen` function is not consistently available across all target environments. Its prior use was intended as a micro-optimization and safeguard to limit string scanning to the remaining buffer size and prevent potential issues with malformed strings lacking a null terminator.

This change now relies on the implicit `std::wstring_view` constructor to determine the string length. `CopyToEncodedBuffer` will continue to handle truncation effectively, mitigating the original concerns.

PiperOrigin-RevId: 756378282
Change-Id: I858bad01724507f7926f868aa300eabad8a4358c
2025-05-08 10:55:43 -07:00
Omer Mor
bba13cb1ac Add support for logging wide strings in absl::log.
The logged strings are truncated to fit the available buffer in the same way as regular strings.

Invalid characters are replaced by the replacement char (`U+FFFD`).

Wide string literals are recorded as literals in `logging.proto.Value`.

PiperOrigin-RevId: 756052375
Change-Id: If3960b4230f923061028bd738eb209b5a82a31eb
2025-05-07 16:32:42 -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
Abseil Team
6ffd744821 Automated Code Change
PiperOrigin-RevId: 752028272
Change-Id: Ie369fd7ddc7097e54567bb3f2f2222cf8f9f1ac7
2025-04-27 09:35:50 -07:00
Abseil Team
269ce47cc0 Migrate template alias nullability annotations to macros.
absl::Nonnull -> absl_nonnull, absl::Nullable -> absl_nullable, and absl::NullabilityUnknown -> absl_nullability_unknown. The new macros are positioned as a qualifier on the affected type, similar to const, rather than as a templated
type wrapping the affected type.
PiperOrigin-RevId: 747888537
Change-Id: Ibd4d3596214a7825fe8c90490f1c988568ec1787
2025-04-15 08:37:09 -07:00
Samuel Benzaquen
7bb1ccb703 Fully qualify absl names in check macros to avoid invalid name resolution when the
user scope has those names defined.

PiperOrigin-RevId: 744732490
Change-Id: I74428596209251adaa01f60b6fea27cce1b50dea
2025-04-07 08:34:03 -07:00
Abseil Team
d97663ee23 Automated Code Change
PiperOrigin-RevId: 744017203
Change-Id: I69b4418b306bdb5f89194bbcddaed9813e46ec6f
2025-04-04 11:43:03 -07:00
Abseil Team
12f6534acf Automated Code Change
PiperOrigin-RevId: 743027058
Change-Id: Ia207ff569bb7d991823b47e182e0e90c7b62b0ed
2025-04-02 01:37:52 -07:00
Abseil Team
f9ea7cf87d Fully annotate nullability in headers where it is partially annotated.
To support building abseil with -Wnullability-completeness flag

PiperOrigin-RevId: 741425018
Change-Id: I894049b80149198a1ab242efd88af8b8df826ba4
2025-03-28 00:27:33 -07:00
Abseil Team
d79e680580 Add nullability annotations to some very-commonly-used APIs.
Manual annotation of these APIs specifically helps us avoid inferring them with tooling as having conflicted nullability due to a small number of incorrect uses out of many, many uses.

These annotations have no runtime impact.

PiperOrigin-RevId: 739258146
Change-Id: Id18bd1f0313c5b196e1d9e8ed4d1ce057dfcd582
2025-03-21 12:11:24 -07:00
Abseil Team
9f5fc9d1e9 Add a test case to make it clear that --vmodule=foo/*=1 does match any children and grandchildren and so on under foo/.
PiperOrigin-RevId: 738558725
Change-Id: Iea67a50a2af65e5e7226fec4ffd6196f804283bd
2025-03-19 15:23:07 -07:00
Derek Mauro
de292e8548 Add a log severity alias DO_NOT_$UBMIT intended for logging during development
'S' should be replace with S, in DO_NOT_$UBMIT :-)

`DO_NOT_$UBMIT` is an alias for `ERROR`, and is the right level to use
when you are using `LOG` for what's often called `printf()` debugging.
The name is easy to spot in review and is caught by common (but not
on-by-default) presubmit checks.

The contract is that **it must not be checked in**, so the Abseil team
reserves the right to delete it, change what it does, and/or scrub any
instances that do end up checked in, with or without notice.

Git users could consider adding a pre-commit hook to reject
the string "DO_NOT_$UBMIT" to use this feature.
https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks

PiperOrigin-RevId: 738364247
Change-Id: I3a277a941e7735ebf64b8da641bd42ca4830df9c
2025-03-19 06:02:48 -07:00
Derek Mauro
1af129f1c3 Use C++17 [[nodiscard]] instead of the deprecated ABSL_MUST_USE_RESULT
In this change, //absl/status is intentionally excluded because of
complication with SWIG compatibility. This may be handled separately.

PiperOrigin-RevId: 731387819
Change-Id: I71bf2e02f3a477d65575d467f5e5ab163846d31e
2025-02-26 11:16:38 -08:00
Derek Mauro
ea9951d3a9 MSVC: Fix warnings c4244 and c4267 in the main library code
These are integer-type shortening warnings.
These warnings are still disabled in tests.

c4244: conversion from 'type1' to 'type2', possible loss of data
https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-levels-3-and-4-c4244?view=msvc-170
c4267: conversion from 'size_t' to 'type', possible loss of data
https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4267?view=msvc-170

Fixes https://github.com/abseil/abseil-cpp/issues/1844

PiperOrigin-RevId: 730882892
Change-Id: Id6506d71846caf1a6a5be3375c34266299c221e1
2025-02-25 07:44:44 -08:00
Derek Mauro
8b68380077 Fix a use-after-free bug in which the string passed to AtLocation may be
referenced after it is destroyed. While the string does live until the end of
the full statement, logging (previously occurred) in the destructor of the
`LogMessage` which may be constructed before the temporary string (and thus
destroyed after the temporary string's destructor).

This change moves logging to occur inside the internal `Voidify`. This does not
affect when logging occurs relative to any other observable, other than the
fact that it runs later than any temporary destructors in the log statement.

PiperOrigin-RevId: 729708145
Change-Id: I9b90367d7a5f4ed3cf091d4d33756262acc03ec6
2025-02-21 17:17:36 -08:00
Dino Radakovic
5f4f38e15c internal/log_message: Use if constexpr instead of SFINAE for operator<<
SFINAE is harder to read and it makes mangled names longer.

PiperOrigin-RevId: 729591470
Change-Id: I8d254fdd02b993580c7a4df8f477ef4fa11b6f76
2025-02-21 11:11:13 -08:00
Dino Radakovic
c0788c7c5b absl: Deprecate ABSL_HAVE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION
Always define it as `1`. CTAD is a C++17 feature, and Abseil does not support older versions of the language.

PiperOrigin-RevId: 729144923
Change-Id: I13572569004d7f0b56a2c11f264b7a3de15927b9
2025-02-20 09:37:58 -08:00