From 17137c084a3d502277bea803b076894eef06af41 Mon Sep 17 00:00:00 2001 From: Derek Mauro Date: Wed, 12 Jun 2024 08:23:36 -0700 Subject: Add the missing inline namespace to the nullability files PiperOrigin-RevId: 642621989 Change-Id: I95efa4bd9fe8fe3c449304706401374f851f0fbe --- absl/base/nullability.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'absl/base/nullability.h') diff --git a/absl/base/nullability.h b/absl/base/nullability.h index 6f49b6f5..7804de2e 100644 --- a/absl/base/nullability.h +++ b/absl/base/nullability.h @@ -150,9 +150,11 @@ #ifndef ABSL_BASE_NULLABILITY_H_ #define ABSL_BASE_NULLABILITY_H_ +#include "absl/base/config.h" #include "absl/base/internal/nullability_impl.h" namespace absl { +ABSL_NAMESPACE_BEGIN // absl::Nonnull // @@ -219,6 +221,7 @@ using Nullable = nullability_internal::NullableImpl; template using NullabilityUnknown = nullability_internal::NullabilityUnknownImpl; +ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_BASE_NULLABILITY_H_ -- cgit v1.2.3 From 69195d5bd2416a7224416887c78353ee8edf67ee Mon Sep 17 00:00:00 2001 From: Martin Brænne Date: Mon, 17 Jun 2024 21:38:52 -0700 Subject: Add `ABSL_NULLABILITY_COMPATIBLE` attribute. This is a replacement for the `absl_nullability_compatible` tag. The attribute has the advantage that, unlike the tag, it can be applied to forward declarations. This does not yet change the implementation of the nullability annotations -- that will come in a followup patch. As the nullability annotations themselves have not been changed, the `absl_nullability_compatible` tag is currently still used to check whether the annotations can be applied to a given type; see also the comments in the code. PiperOrigin-RevId: 644238698 Change-Id: I5882606f82ce7a6dd98e83e6d920573437561b50 --- absl/base/nullability.h | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'absl/base/nullability.h') diff --git a/absl/base/nullability.h b/absl/base/nullability.h index 7804de2e..077bd42f 100644 --- a/absl/base/nullability.h +++ b/absl/base/nullability.h @@ -128,9 +128,17 @@ // // By default, nullability annotations are applicable to raw and smart // pointers. User-defined types can indicate compatibility with nullability -// annotations by providing an `absl_nullability_compatible` nested type. The -// actual definition of this inner type is not relevant as it is used merely as -// a marker. It is common to use a using declaration of +// annotations by adding the ABSL_NULLABILITY_COMPATIBLE attribute. +// +// // Example: +// struct ABSL_NULLABILITY_COMPATIBLE MyPtr { +// ... +// }; +// +// Note: For the time being, nullability-compatible classes should additionally +// be marked with an `absl_nullability_compatible` nested type (this will soon +// be deprecated). The actual definition of this inner type is not relevant as +// it is used merely as a marker. It is common to use a using declaration of // `absl_nullability_compatible` set to void. // // // Example: @@ -224,4 +232,19 @@ using NullabilityUnknown = nullability_internal::NullabilityUnknownImpl; ABSL_NAMESPACE_END } // namespace absl +// ABSL_NULLABILITY_COMPATIBLE +// +// Indicates that a class is compatible with nullability annotations. +// +// For example: +// +// struct ABSL_NULLABILITY_COMPATIBLE MyPtr { +// ... +// }; +#if ABSL_HAVE_FEATURE(nullability_on_classes) +#define ABSL_NULLABILITY_COMPATIBLE _Nullable +#else +#define ABSL_NULLABILITY_COMPATIBLE +#endif + #endif // ABSL_BASE_NULLABILITY_H_ -- cgit v1.2.3 From 3ff94461f8cf00fa976225f3b020e65268e24626 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 26 Jun 2024 08:05:22 -0700 Subject: internal-only change PiperOrigin-RevId: 646949076 Change-Id: I0d3fc57aee38e5b3a5b85e2301f5035bfd0e388b --- absl/base/nullability.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'absl/base/nullability.h') diff --git a/absl/base/nullability.h b/absl/base/nullability.h index 077bd42f..39e9b1cc 100644 --- a/absl/base/nullability.h +++ b/absl/base/nullability.h @@ -208,9 +208,9 @@ using Nullable = nullability_internal::NullableImpl; // migrated into one of the above two nullability states: `Nonnull` or // `Nullable`. // -// NOTE: Because this annotation is the global default state, pointers without -// any annotation are assumed to have "unknown" semantics. This assumption is -// designed to minimize churn and reduce clutter within the codebase. +// NOTE: Because this annotation is the global default state, unannotated +// pointers are assumed to have "unknown" semantics. This assumption is designed +// to minimize churn and reduce clutter within the codebase. // // Example: // -- cgit v1.2.3 From 65ede0a387bb3aab32634e9e840b8b4955bc1e1c Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Mon, 15 Jul 2024 11:49:37 -0700 Subject: Remove unneeded 'be' from comment. PiperOrigin-RevId: 652552642 Change-Id: Ic4e367531893714aa216624176a56f39a5f59144 --- absl/base/nullability.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'absl/base/nullability.h') diff --git a/absl/base/nullability.h b/absl/base/nullability.h index 39e9b1cc..34dc083a 100644 --- a/absl/base/nullability.h +++ b/absl/base/nullability.h @@ -167,7 +167,7 @@ ABSL_NAMESPACE_BEGIN // absl::Nonnull // // The indicated pointer is never null. It is the responsibility of the provider -// of this pointer across an API boundary to ensure that the pointer is never be +// of this pointer across an API boundary to ensure that the pointer is never // set to null. Consumers of this pointer across an API boundary may safely // dereference the pointer. // -- cgit v1.2.3