Commit 5a01d0f7 by Abseil Team Committed by Copybara-Service

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
parent 116f0af9
...@@ -829,31 +829,56 @@ ...@@ -829,31 +829,56 @@
#define ABSL_ATTRIBUTE_LIFETIME_BOUND #define ABSL_ATTRIBUTE_LIFETIME_BOUND
#endif #endif
// ABSL_INTERNAL_ATTRIBUTE_VIEW indicates that a type acts like a view i.e. a // ABSL_ATTRIBUTE_VIEW indicates that a type is solely a "view" of data that it
// raw (non-owning) pointer. This enables diagnoses similar to those enabled by // points to, similarly to a span, string_view, or other non-owning reference
// ABSL_ATTRIBUTE_LIFETIME_BOUND. // type.
// This enables diagnosing certain lifetime issues similar to those enabled by
// ABSL_ATTRIBUTE_LIFETIME_BOUND, such as:
//
// struct ABSL_ATTRIBUTE_VIEW StringView {
// template<class R>
// StringView(const R&);
// };
//
// StringView f(std::string s) {
// return s; // warning: address of stack memory returned
// }
// //
// See the following links for details: // See the following links for details:
// https://reviews.llvm.org/D64448 // https://reviews.llvm.org/D64448
// https://lists.llvm.org/pipermail/cfe-dev/2018-November/060355.html // https://lists.llvm.org/pipermail/cfe-dev/2018-November/060355.html
#if ABSL_HAVE_CPP_ATTRIBUTE(gsl::Pointer) #if ABSL_HAVE_CPP_ATTRIBUTE(gsl::Pointer)
#define ABSL_INTERNAL_ATTRIBUTE_VIEW [[gsl::Pointer]] #define ABSL_ATTRIBUTE_VIEW [[gsl::Pointer]]
#else #else
#define ABSL_INTERNAL_ATTRIBUTE_VIEW #define ABSL_ATTRIBUTE_VIEW
#endif #endif
#define ABSL_INTERNAL_ATTRIBUTE_VIEW ABSL_ATTRIBUTE_VIEW // Deprecated
// ABSL_INTERNAL_ATTRIBUTE_OWNER indicates that a type acts like a smart // ABSL_ATTRIBUTE_OWNER indicates that a type is a container, smart pointer, or
// (owning) pointer. This enables diagnoses similar to those enabled by // similar class that owns all the data that it points to.
// ABSL_ATTRIBUTE_LIFETIME_BOUND. // This enables diagnosing certain lifetime issues similar to those enabled by
// ABSL_ATTRIBUTE_LIFETIME_BOUND, such as:
//
// struct ABSL_ATTRIBUTE_VIEW StringView {
// template<class R>
// StringView(const R&);
// };
//
// struct ABSL_ATTRIBUTE_OWNER String {};
//
// StringView f(String s) {
// return s; // warning: address of stack memory returned
// }
// //
// See the following links for details: // See the following links for details:
// https://reviews.llvm.org/D64448 // https://reviews.llvm.org/D64448
// https://lists.llvm.org/pipermail/cfe-dev/2018-November/060355.html // https://lists.llvm.org/pipermail/cfe-dev/2018-November/060355.html
#if ABSL_HAVE_CPP_ATTRIBUTE(gsl::Owner) #if ABSL_HAVE_CPP_ATTRIBUTE(gsl::Owner)
#define ABSL_INTERNAL_ATTRIBUTE_OWNER [[gsl::Owner]] #define ABSL_ATTRIBUTE_OWNER [[gsl::Owner]]
#else #else
#define ABSL_INTERNAL_ATTRIBUTE_OWNER #define ABSL_ATTRIBUTE_OWNER
#endif #endif
#define ABSL_INTERNAL_ATTRIBUTE_OWNER ABSL_ATTRIBUTE_OWNER // Deprecated
// ABSL_ATTRIBUTE_TRIVIAL_ABI // ABSL_ATTRIBUTE_TRIVIAL_ABI
// Indicates that a type is "trivially relocatable" -- meaning it can be // Indicates that a type is "trivially relocatable" -- meaning it can be
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment