mirror of
https://github.com/abseil/abseil-cpp.git
synced 2026-06-04 12:07:05 +08:00
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
This commit is contained in:
committed by
Copybara-Service
parent
9ae4bb8007
commit
4b4f41e93d
@@ -219,12 +219,14 @@ class ABSL_ATTRIBUTE_VIEW Span {
|
||||
static const size_type npos = ~(size_type(0));
|
||||
|
||||
constexpr Span() noexcept : Span(nullptr, 0) {}
|
||||
constexpr Span(pointer array, size_type length) noexcept
|
||||
constexpr Span(pointer array ABSL_ATTRIBUTE_LIFETIME_BOUND,
|
||||
size_type length) noexcept
|
||||
: ptr_(array), len_(length) {}
|
||||
|
||||
// Implicit conversion constructors
|
||||
template <size_t N>
|
||||
constexpr Span(T (&a)[N]) noexcept // NOLINT(google-explicit-constructor)
|
||||
constexpr Span(T( // NOLINT(google-explicit-constructor)
|
||||
&a ABSL_ATTRIBUTE_LIFETIME_BOUND)[N]) noexcept
|
||||
: Span(a, N) {}
|
||||
|
||||
// Explicit reference constructor for a mutable `Span<T>` type. Can be
|
||||
|
||||
Reference in New Issue
Block a user