diff --git a/AK/ByteBuffer.h b/AK/ByteBuffer.h index 3bf92f6374b..aedae598720 100644 --- a/AK/ByteBuffer.h +++ b/AK/ByteBuffer.h @@ -147,14 +147,14 @@ public: # pragma GCC diagnostic pop #endif - [[nodiscard]] Bytes bytes() + [[nodiscard]] Bytes bytes() LIFETIME_BOUND { return { data(), size() }; } - [[nodiscard]] ReadonlyBytes bytes() const { return { data(), size() }; } + [[nodiscard]] ReadonlyBytes bytes() const LIFETIME_BOUND { return { data(), size() }; } - [[nodiscard]] AK::Bytes span() { return { data(), size() }; } - [[nodiscard]] AK::ReadonlyBytes span() const { return { data(), size() }; } + [[nodiscard]] AK::Bytes span() LIFETIME_BOUND { return { data(), size() }; } + [[nodiscard]] AK::ReadonlyBytes span() const LIFETIME_BOUND { return { data(), size() }; } [[nodiscard]] u8* offset_pointer(size_t offset) { return data() + offset; } [[nodiscard]] u8 const* offset_pointer(size_t offset) const { return data() + offset; } @@ -243,7 +243,7 @@ public: } /// Like get_bytes_for_writing, but crashes if allocation fails. - Bytes must_get_bytes_for_writing(size_t length) + Bytes must_get_bytes_for_writing(size_t length) LIFETIME_BOUND { return MUST(get_bytes_for_writing(length)); } @@ -306,8 +306,8 @@ public: __builtin_memset(data(), 0, m_size); } - operator Bytes() { return bytes(); } - operator ReadonlyBytes() const { return bytes(); } + operator Bytes() LIFETIME_BOUND { return bytes(); } + operator ReadonlyBytes() const LIFETIME_BOUND { return bytes(); } ALWAYS_INLINE size_t capacity() const { return m_inline ? inline_capacity : m_outline_capacity; } ALWAYS_INLINE bool is_inline() const { return m_inline; } diff --git a/AK/ByteString.h b/AK/ByteString.h index 21cbfe65f27..09756f574ed 100644 --- a/AK/ByteString.h +++ b/AK/ByteString.h @@ -175,7 +175,7 @@ public: using SearchDirection = StringUtils::SearchDirection; [[nodiscard]] Optional find_any_of(StringView needles, SearchDirection direction = SearchDirection::Forward) const { return StringUtils::find_any_of(*this, needles, direction); } - [[nodiscard]] StringView find_last_split_view(char separator) const& { return view().find_last_split_view(separator); } + [[nodiscard]] StringView find_last_split_view(char separator) const& LIFETIME_BOUND { return view().find_last_split_view(separator); } [[nodiscard]] StringView find_last_split_view(char separator) const&& = delete; [[nodiscard]] ByteString substring(size_t start, size_t length) const; @@ -194,7 +194,7 @@ public: [[nodiscard]] bool copy_characters_to_buffer(char* buffer, size_t buffer_size) const; - [[nodiscard]] ALWAYS_INLINE ReadonlyBytes bytes() const& { return m_impl->bytes(); } + [[nodiscard]] ALWAYS_INLINE ReadonlyBytes bytes() const& LIFETIME_BOUND { return m_impl->bytes(); } [[nodiscard]] ALWAYS_INLINE ReadonlyBytes bytes() const&& = delete; [[nodiscard]] ALWAYS_INLINE char const& operator[](size_t i) const @@ -283,7 +283,7 @@ public: return vformatted(fmtstr.view(), variadic_format_parameters); } - [[nodiscard]] StringView view() const& { return { characters(), length() }; } + [[nodiscard]] StringView view() const& LIFETIME_BOUND { return { characters(), length() }; } [[nodiscard]] StringView view() const&& = delete; [[nodiscard]] ByteString replace(StringView needle, StringView replacement, ReplaceMode replace_mode = ReplaceMode::All) const { return StringUtils::replace(*this, needle, replacement, replace_mode); } diff --git a/AK/ByteStringImpl.h b/AK/ByteStringImpl.h index 484de6e9187..ed368264bdd 100644 --- a/AK/ByteStringImpl.h +++ b/AK/ByteStringImpl.h @@ -42,8 +42,8 @@ public: // Includes NUL-terminator. char const* characters() const { return &m_inline_buffer[0]; } - ALWAYS_INLINE ReadonlyBytes bytes() const { return { characters(), length() }; } - ALWAYS_INLINE StringView view() const { return { characters(), length() }; } + ALWAYS_INLINE ReadonlyBytes bytes() const LIFETIME_BOUND { return { characters(), length() }; } + ALWAYS_INLINE StringView view() const LIFETIME_BOUND { return { characters(), length() }; } char const& operator[](size_t i) const { diff --git a/AK/FlyString.h b/AK/FlyString.h index ef0c2575145..b941e129fcf 100644 --- a/AK/FlyString.h +++ b/AK/FlyString.h @@ -40,8 +40,8 @@ public: String to_string() const; [[nodiscard]] Utf8View code_points() const; - [[nodiscard]] ReadonlyBytes bytes() const { return m_data.bytes(); } - [[nodiscard]] StringView bytes_as_string_view() const { return m_data.bytes(); } + [[nodiscard]] ReadonlyBytes bytes() const LIFETIME_BOUND { return m_data.bytes(); } + [[nodiscard]] StringView bytes_as_string_view() const LIFETIME_BOUND { return m_data.bytes(); } [[nodiscard]] ALWAYS_INLINE bool operator==(FlyString const& other) const { return m_data.raw(Badge {}) == other.m_data.raw(Badge {}); } [[nodiscard]] bool operator==(String const& other) const { return m_data == other; } diff --git a/AK/Function.h b/AK/Function.h index 3f929da1391..b58067b75c9 100644 --- a/AK/Function.h +++ b/AK/Function.h @@ -100,7 +100,7 @@ public: clear(false); } - [[nodiscard]] ReadonlyBytes raw_capture_range() const + [[nodiscard]] ReadonlyBytes raw_capture_range() const LIFETIME_BOUND { if (!m_size) return {}; diff --git a/AK/LexicalPath.h b/AK/LexicalPath.h index a3a57df6334..be80595325a 100644 --- a/AK/LexicalPath.h +++ b/AK/LexicalPath.h @@ -32,10 +32,10 @@ public: ByteString const& string() const { return m_string; } - StringView dirname() const { return m_dirname; } - StringView basename(StripExtension s = StripExtension::No) const { return s == StripExtension::No ? m_basename : m_title; } - StringView title() const { return m_title; } - StringView extension() const { return m_extension; } + StringView dirname() const LIFETIME_BOUND { return m_dirname; } + StringView basename(StripExtension s = StripExtension::No) const LIFETIME_BOUND { return s == StripExtension::No ? m_basename : m_title; } + StringView title() const LIFETIME_BOUND { return m_title; } + StringView extension() const LIFETIME_BOUND { return m_extension; } Vector const& parts_view() const { return m_parts; } [[nodiscard]] Vector parts() const; diff --git a/AK/Platform.h b/AK/Platform.h index e0e08b4331c..1000e7f4724 100644 --- a/AK/Platform.h +++ b/AK/Platform.h @@ -256,6 +256,15 @@ # define AK_COMPACT_EMPTY_BASES #endif +#if defined(LIFETIME_BOUND) +# undef LIFETIME_BOUND +#endif +#if defined(AK_COMPILER_CLANG) +# define LIFETIME_BOUND [[clang::lifetimebound]] +#else +# define LIFETIME_BOUND +#endif + // GCC doesn't have __has_feature but clang does #ifndef __has_feature # define __has_feature(...) 0 diff --git a/AK/SourceGenerator.h b/AK/SourceGenerator.h index 367445eef16..27e5fe146de 100644 --- a/AK/SourceGenerator.h +++ b/AK/SourceGenerator.h @@ -68,7 +68,7 @@ public: [[nodiscard]] MappingType clone_mapping() const { return MUST(m_mapping.clone()); } - StringView as_string_view() const { return m_builder.string_view(); } + StringView as_string_view() const LIFETIME_BOUND { return m_builder.string_view(); } void append(StringView pattern) { diff --git a/AK/String.h b/AK/String.h index 6aa9ea51195..5e2f481ccf6 100644 --- a/AK/String.h +++ b/AK/String.h @@ -144,7 +144,7 @@ public: [[nodiscard]] bool is_empty() const { return byte_count() == 0; } // Returns a StringView covering the full length of the string. Note that iterating this will go byte-at-a-time, not code-point-at-a-time. - [[nodiscard]] StringView bytes_as_string_view() const& { return StringView(bytes()); } + [[nodiscard]] StringView bytes_as_string_view() const& LIFETIME_BOUND { return StringView(bytes()); } [[nodiscard]] StringView bytes_as_string_view() const&& = delete; [[nodiscard]] size_t count(StringView needle) const { return StringUtils::count(bytes_as_string_view(), needle); } diff --git a/AK/StringBase.h b/AK/StringBase.h index 55b8f8860e8..a1989b9df62 100644 --- a/AK/StringBase.h +++ b/AK/StringBase.h @@ -17,7 +17,7 @@ struct ShortString { static constexpr ShortString create_empty(); static constexpr ShortString create_with_byte_count(size_t byte_count); - ReadonlyBytes bytes() const; + ReadonlyBytes bytes() const LIFETIME_BOUND; size_t byte_count() const; // NOTE: This is the byte count shifted left 1 step and or'ed with a 1 (the SHORT_STRING_FLAG) @@ -71,7 +71,7 @@ public: // Returns the underlying UTF-8 encoded bytes. // NOTE: There is no guarantee about null-termination. - [[nodiscard]] ReadonlyBytes bytes() const; + [[nodiscard]] ReadonlyBytes bytes() const LIFETIME_BOUND; [[nodiscard]] u32 hash() const; [[nodiscard]] size_t byte_count() const; [[nodiscard]] ALWAYS_INLINE size_t length_in_code_units() const { return byte_count(); } diff --git a/AK/StringData.h b/AK/StringData.h index 47287ada731..51ea994815d 100644 --- a/AK/StringData.h +++ b/AK/StringData.h @@ -83,7 +83,7 @@ public: } // NOTE: There is no guarantee about null-termination. - ReadonlyBytes bytes() const + ReadonlyBytes bytes() const LIFETIME_BOUND { if (m_substring) { auto const& data = substring_data(); @@ -92,7 +92,7 @@ public: return { &m_bytes_or_substring_data[0], m_byte_count }; } - StringView bytes_as_string_view() const { return { bytes() }; } + StringView bytes_as_string_view() const LIFETIME_BOUND { return { bytes() }; } bool operator==(StringData const& other) const { diff --git a/AK/StringView.h b/AK/StringView.h index 10f50d20f89..8cf3157f200 100644 --- a/AK/StringView.h +++ b/AK/StringView.h @@ -45,10 +45,10 @@ public: { } - StringView(ByteBuffer const&); - StringView(String const&); - StringView(FlyString const&); - StringView(ByteString const&); + StringView(LIFETIME_BOUND ByteBuffer const&); + StringView(LIFETIME_BOUND String const&); + StringView(LIFETIME_BOUND FlyString const&); + StringView(LIFETIME_BOUND ByteString const&); explicit StringView(ByteBuffer&&) = delete; explicit StringView(String&&) = delete; diff --git a/AK/UFixedBigInt.h b/AK/UFixedBigInt.h index 31cb65b6656..27f6271fd78 100644 --- a/AK/UFixedBigInt.h +++ b/AK/UFixedBigInt.h @@ -181,12 +181,12 @@ public: } } - Bytes bytes() + Bytes bytes() LIFETIME_BOUND { return Bytes(reinterpret_cast(this), sizeof(Storage)); } - ReadonlyBytes bytes() const + ReadonlyBytes bytes() const LIFETIME_BOUND { return ReadonlyBytes(reinterpret_cast(this), sizeof(Storage)); } diff --git a/AK/Utf16FlyString.h b/AK/Utf16FlyString.h index eeb43320baf..44b702c2abe 100644 --- a/AK/Utf16FlyString.h +++ b/AK/Utf16FlyString.h @@ -34,11 +34,11 @@ public: Utf16FlyString(Utf16String const&); - [[nodiscard]] ALWAYS_INLINE Utf16View view() const { return m_data.utf16_view(); } + [[nodiscard]] ALWAYS_INLINE Utf16View view() const LIFETIME_BOUND { return m_data.utf16_view(); } ALWAYS_INLINE explicit operator Utf16String() const { return to_utf16_string(); } - ALWAYS_INLINE operator Utf16View() const& { return view(); } + ALWAYS_INLINE operator Utf16View() const& LIFETIME_BOUND { return view(); } explicit operator Utf16View() const&& = delete; ALWAYS_INLINE Utf16String to_utf16_string() const diff --git a/AK/Utf16StringBase.h b/AK/Utf16StringBase.h index 5957bdb919f..8c1af29a513 100644 --- a/AK/Utf16StringBase.h +++ b/AK/Utf16StringBase.h @@ -53,7 +53,7 @@ public: destroy_string(); } - ALWAYS_INLINE operator Utf16View() const& { return utf16_view(); } + ALWAYS_INLINE operator Utf16View() const& LIFETIME_BOUND { return utf16_view(); } explicit operator Utf16View() const&& = delete; [[nodiscard]] ALWAYS_INLINE String to_utf8(AllowLonelySurrogates allow_lonely_surrogates = AllowLonelySurrogates::Yes) const @@ -71,7 +71,7 @@ public: return MUST(utf16_view().to_byte_string(allow_lonely_surrogates)); } - [[nodiscard]] ALWAYS_INLINE StringView ascii_view() const& + [[nodiscard]] ALWAYS_INLINE StringView ascii_view() const& LIFETIME_BOUND { if (has_short_ascii_storage()) return short_ascii_string_without_union_member_assertion().bytes(); @@ -81,7 +81,7 @@ public: return {}; } - [[nodiscard]] ALWAYS_INLINE Utf16View utf16_view() const& + [[nodiscard]] ALWAYS_INLINE Utf16View utf16_view() const& LIFETIME_BOUND { if (has_short_ascii_storage()) return Utf16View { ascii_view().characters_without_null_termination(), length_in_code_units() }; @@ -223,12 +223,12 @@ public: [[nodiscard]] ALWAYS_INLINE Utf16CodePointIterator begin() const { return utf16_view().begin(); } [[nodiscard]] ALWAYS_INLINE Utf16CodePointIterator end() const { return utf16_view().end(); } - [[nodiscard]] ALWAYS_INLINE Utf16View substring_view(size_t code_unit_offset, size_t code_unit_length) const + [[nodiscard]] ALWAYS_INLINE Utf16View substring_view(size_t code_unit_offset, size_t code_unit_length) const LIFETIME_BOUND { return utf16_view().substring_view(code_unit_offset, code_unit_length); } - [[nodiscard]] ALWAYS_INLINE Utf16View substring_view(size_t code_unit_offset) const + [[nodiscard]] ALWAYS_INLINE Utf16View substring_view(size_t code_unit_offset) const LIFETIME_BOUND { return utf16_view().substring_view(code_unit_offset); } diff --git a/AK/Utf16StringData.h b/AK/Utf16StringData.h index 6573c982143..350efa158a7 100644 --- a/AK/Utf16StringData.h +++ b/AK/Utf16StringData.h @@ -96,13 +96,13 @@ public: return m_length_in_code_points; } - [[nodiscard]] ALWAYS_INLINE StringView ascii_view() const + [[nodiscard]] ALWAYS_INLINE StringView ascii_view() const LIFETIME_BOUND { ASSERT(has_ascii_storage()); return { m_ascii_data, length_in_code_units() }; } - [[nodiscard]] ALWAYS_INLINE Utf16View utf16_view() const + [[nodiscard]] ALWAYS_INLINE Utf16View utf16_view() const LIFETIME_BOUND { if (has_ascii_storage()) return { m_ascii_data, length_in_code_units() }; diff --git a/Libraries/LibCore/MappedFile.h b/Libraries/LibCore/MappedFile.h index 9f70e27c4aa..45a80eb508e 100644 --- a/Libraries/LibCore/MappedFile.h +++ b/Libraries/LibCore/MappedFile.h @@ -30,7 +30,7 @@ public: // Non-stream APIs for using MappedFile as a simple POSIX API wrapper. void* data() { return m_data; } void const* data() const { return m_data; } - ReadonlyBytes bytes() const { return { m_data, m_size }; } + ReadonlyBytes bytes() const LIFETIME_BOUND { return { m_data, m_size }; } private: explicit MappedFile(void*, size_t, Mode); diff --git a/Libraries/LibCrypto/ASN1/DER.h b/Libraries/LibCrypto/ASN1/DER.h index cdbe5864c60..0a5b9d6eb17 100644 --- a/Libraries/LibCrypto/ASN1/DER.h +++ b/Libraries/LibCrypto/ASN1/DER.h @@ -317,7 +317,7 @@ public: m_buffer_stack.empend(); } - ReadonlyBytes active_bytes() const { return m_buffer_stack.last().bytes(); } + ReadonlyBytes active_bytes() const LIFETIME_BOUND { return m_buffer_stack.last().bytes(); } ByteBuffer finish() { VERIFY(m_buffer_stack.size() == 1); diff --git a/Libraries/LibCrypto/Hash/HashFunction.h b/Libraries/LibCrypto/Hash/HashFunction.h index 7ca8d7b97b2..70ceaa8c037 100644 --- a/Libraries/LibCrypto/Hash/HashFunction.h +++ b/Libraries/LibCrypto/Hash/HashFunction.h @@ -22,7 +22,7 @@ struct Digest { [[nodiscard]] ALWAYS_INLINE u8 const* immutable_data() const { return data; } [[nodiscard]] ALWAYS_INLINE size_t data_length() const { return Size; } - [[nodiscard]] ALWAYS_INLINE ReadonlyBytes bytes() const { return { immutable_data(), data_length() }; } + [[nodiscard]] ALWAYS_INLINE ReadonlyBytes bytes() const LIFETIME_BOUND { return { immutable_data(), data_length() }; } [[nodiscard]] bool operator==(Digest const& other) const = default; [[nodiscard]] bool operator!=(Digest const& other) const = default; diff --git a/Libraries/LibCrypto/Hash/HashManager.h b/Libraries/LibCrypto/Hash/HashManager.h index fb9ac9777f3..2b99b2c3a46 100644 --- a/Libraries/LibCrypto/Hash/HashManager.h +++ b/Libraries/LibCrypto/Hash/HashManager.h @@ -75,7 +75,7 @@ struct MultiHashDigestVariant { [&](auto const& value) { return value.data_length(); }); } - [[nodiscard]] ReadonlyBytes bytes() const + [[nodiscard]] ReadonlyBytes bytes() const LIFETIME_BOUND { return m_digest.visit( [&](Empty const&) -> ReadonlyBytes { VERIFY_NOT_REACHED(); }, diff --git a/Libraries/LibDNS/Message.h b/Libraries/LibDNS/Message.h index 7f471d5b392..1719755d1cf 100644 --- a/Libraries/LibDNS/Message.h +++ b/Libraries/LibDNS/Message.h @@ -471,8 +471,8 @@ struct DNSKEY { return public_key[0]; return static_cast(public_key[1]) | static_cast(public_key[2]) << 8; } - ReadonlyBytes public_key_rsa_exponent() const { return public_key.bytes().slice(1, public_key_rsa_exponent_length()); } - ReadonlyBytes public_key_rsa_modulus() const { return public_key.bytes().slice(1 + public_key_rsa_exponent_length()); } + ReadonlyBytes public_key_rsa_exponent() const LIFETIME_BOUND { return public_key.bytes().slice(1, public_key_rsa_exponent_length()); } + ReadonlyBytes public_key_rsa_modulus() const LIFETIME_BOUND { return public_key.bytes().slice(1 + public_key_rsa_exponent_length()); } constexpr static inline u16 FlagSecureEntryPoint = 0b1000000000000000; constexpr static inline u16 FlagZoneKey = 0b0100000000000000; diff --git a/Libraries/LibGfx/Font/PathFontProvider.h b/Libraries/LibGfx/Font/PathFontProvider.h index d14bc1cc1d8..9be1abbbb18 100644 --- a/Libraries/LibGfx/Font/PathFontProvider.h +++ b/Libraries/LibGfx/Font/PathFontProvider.h @@ -28,7 +28,7 @@ public: virtual RefPtr get_font(FlyString const& family, float point_size, unsigned weight, unsigned width, unsigned slope) override; virtual void for_each_typeface_with_family_name(FlyString const& family_name, Function) override; - virtual StringView name() const override { return m_name.bytes_as_string_view(); } + virtual StringView name() const LIFETIME_BOUND override { return m_name.bytes_as_string_view(); } private: HashMap>, AK::ASCIICaseInsensitiveFlyStringTraits> m_typeface_by_family; diff --git a/Libraries/LibGfx/Font/TypefaceSkia.h b/Libraries/LibGfx/Font/TypefaceSkia.h index 7a04fe8da57..4133d2c23d6 100644 --- a/Libraries/LibGfx/Font/TypefaceSkia.h +++ b/Libraries/LibGfx/Font/TypefaceSkia.h @@ -24,7 +24,7 @@ public: virtual u16 width() const override; virtual u8 slope() const override; - virtual ReadonlyBytes buffer() const override { return m_buffer; } + virtual ReadonlyBytes buffer() const LIFETIME_BOUND override { return m_buffer; } virtual unsigned ttc_index() const override { return m_ttc_index; } SkTypeface const* sk_typeface() const; diff --git a/Libraries/LibJS/Bytecode/BasicBlock.h b/Libraries/LibJS/Bytecode/BasicBlock.h index d9e0ff4bf87..bafa520eeb3 100644 --- a/Libraries/LibJS/Bytecode/BasicBlock.h +++ b/Libraries/LibJS/Bytecode/BasicBlock.h @@ -31,7 +31,7 @@ public: u32 index() const { return m_index; } - ReadonlyBytes instruction_stream() const { return m_buffer.span(); } + ReadonlyBytes instruction_stream() const LIFETIME_BOUND { return m_buffer.span(); } u8* data() { return m_buffer.data(); } u8 const* data() const { return m_buffer.data(); } size_t size() const { return m_buffer.size(); } diff --git a/Libraries/LibJS/Module.h b/Libraries/LibJS/Module.h index b763c2bd35c..fa61b424e20 100644 --- a/Libraries/LibJS/Module.h +++ b/Libraries/LibJS/Module.h @@ -99,7 +99,7 @@ public: Realm& realm() { return *m_realm; } Realm const& realm() const { return *m_realm; } - StringView filename() const { return m_filename; } + StringView filename() const LIFETIME_BOUND { return m_filename; } GC::Ptr environment() { return m_environment; } diff --git a/Libraries/LibJS/Runtime/Intl/Collator.h b/Libraries/LibJS/Runtime/Intl/Collator.h index d7b86f8ef61..58decc07ea6 100644 --- a/Libraries/LibJS/Runtime/Intl/Collator.h +++ b/Libraries/LibJS/Runtime/Intl/Collator.h @@ -29,15 +29,15 @@ public: Unicode::Usage usage() const { return m_usage; } void set_usage(StringView usage) { m_usage = Unicode::usage_from_string(usage); } - StringView usage_string() const { return Unicode::usage_to_string(m_usage); } + StringView usage_string() const LIFETIME_BOUND { return Unicode::usage_to_string(m_usage); } Unicode::Sensitivity sensitivity() const { return m_sensitivity; } void set_sensitivity(Unicode::Sensitivity sensitivity) { m_sensitivity = sensitivity; } - StringView sensitivity_string() const { return Unicode::sensitivity_to_string(m_sensitivity); } + StringView sensitivity_string() const LIFETIME_BOUND { return Unicode::sensitivity_to_string(m_sensitivity); } Unicode::CaseFirst case_first() const { return m_case_first; } void set_case_first(StringView case_first) { m_case_first = Unicode::case_first_from_string(case_first); } - StringView case_first_string() const { return Unicode::case_first_to_string(m_case_first); } + StringView case_first_string() const LIFETIME_BOUND { return Unicode::case_first_to_string(m_case_first); } String const& collation() const { return m_collation; } void set_collation(String collation) { m_collation = move(collation); } diff --git a/Libraries/LibJS/Script.h b/Libraries/LibJS/Script.h index 19dc04829a8..690d1de8944 100644 --- a/Libraries/LibJS/Script.h +++ b/Libraries/LibJS/Script.h @@ -44,7 +44,7 @@ public: Vector const& loaded_modules() const { return m_loaded_modules; } HostDefined* host_defined() const { return m_host_defined; } - StringView filename() const { return m_filename; } + StringView filename() const LIFETIME_BOUND { return m_filename; } private: Script(Realm&, StringView filename, NonnullRefPtr, HostDefined* = nullptr); diff --git a/Libraries/LibLine/Editor.h b/Libraries/LibLine/Editor.h index cf0c752c7da..3f96c48657b 100644 --- a/Libraries/LibLine/Editor.h +++ b/Libraries/LibLine/Editor.h @@ -249,7 +249,7 @@ public: bool is_editing() const { return m_is_editing; } - Utf32View const buffer_view() const { return { m_buffer.data(), m_buffer.size() }; } + Utf32View const buffer_view() const LIFETIME_BOUND { return { m_buffer.data(), m_buffer.size() }; } auto prohibit_input() { diff --git a/Libraries/LibLine/SuggestionManager.h b/Libraries/LibLine/SuggestionManager.h index b18d4c7e79b..e3341a21177 100644 --- a/Libraries/LibLine/SuggestionManager.h +++ b/Libraries/LibLine/SuggestionManager.h @@ -56,11 +56,11 @@ public: size_t invariant_offset { 0 }; bool allow_commit_without_listing { true }; - Utf8View text_view() const { return text.code_points(); } - Utf8View trivia_view() const { return trailing_trivia.code_points(); } - Utf8View display_trivia_view() const { return display_trivia.code_points(); } - StringView text_string() const { return text.bytes_as_string_view(); } - StringView display_trivia_string() const { return display_trivia.bytes_as_string_view(); } + Utf8View text_view() const LIFETIME_BOUND { return text.code_points(); } + Utf8View trivia_view() const LIFETIME_BOUND { return trailing_trivia.code_points(); } + Utf8View display_trivia_view() const LIFETIME_BOUND { return display_trivia.code_points(); } + StringView text_string() const LIFETIME_BOUND { return text.bytes_as_string_view(); } + StringView display_trivia_string() const LIFETIME_BOUND { return display_trivia.bytes_as_string_view(); } bool is_valid { false }; }; diff --git a/Libraries/LibMedia/Containers/Matroska/Document.h b/Libraries/LibMedia/Containers/Matroska/Document.h index 182fc61d0e0..b86dc96c9d3 100644 --- a/Libraries/LibMedia/Containers/Matroska/Document.h +++ b/Libraries/LibMedia/Containers/Matroska/Document.h @@ -27,9 +27,9 @@ class SegmentInformation { public: u64 timestamp_scale() const { return m_timestamp_scale; } void set_timestamp_scale(u64 timestamp_scale) { m_timestamp_scale = timestamp_scale; } - Utf8View muxing_app() const { return Utf8View(m_muxing_app); } + Utf8View muxing_app() const LIFETIME_BOUND { return Utf8View(m_muxing_app); } void set_muxing_app(ByteString muxing_app) { m_muxing_app = move(muxing_app); } - Utf8View writing_app() const { return Utf8View(m_writing_app); } + Utf8View writing_app() const LIFETIME_BOUND { return Utf8View(m_writing_app); } void set_writing_app(ByteString writing_app) { m_writing_app = move(writing_app); } Optional duration_unscaled() const { return m_duration_unscaled; } void set_duration_unscaled(double duration) { m_duration_unscaled.emplace(duration); } @@ -120,7 +120,7 @@ public: void set_language(FlyString const& language) { m_language = language; } FlyString codec_id() const { return m_codec_id; } void set_codec_id(FlyString const& codec_id) { m_codec_id = codec_id; } - ReadonlyBytes codec_private_data() const { return m_codec_private_data.span(); } + ReadonlyBytes codec_private_data() const LIFETIME_BOUND { return m_codec_private_data.span(); } ErrorOr set_codec_private_data(ReadonlyBytes codec_private_data) { m_codec_private_data = TRY(FixedArray::create(codec_private_data)); diff --git a/Libraries/LibMedia/DecoderError.h b/Libraries/LibMedia/DecoderError.h index 84818359467..d05461fdac4 100644 --- a/Libraries/LibMedia/DecoderError.h +++ b/Libraries/LibMedia/DecoderError.h @@ -63,12 +63,12 @@ public: } DecoderErrorCategory category() const { return m_category; } - StringView description() const + StringView description() const LIFETIME_BOUND { return m_description.visit([](StringView x) { return x; }, [](ByteString const& x) { return x.view(); }); } // For compatibility with AK::Error - StringView string_literal() const { return description(); } + StringView string_literal() const LIFETIME_BOUND { return description(); } private: template T> diff --git a/Libraries/LibSyntax/Document.h b/Libraries/LibSyntax/Document.h index b759ad60d11..c1efabd9ff7 100644 --- a/Libraries/LibSyntax/Document.h +++ b/Libraries/LibSyntax/Document.h @@ -35,7 +35,7 @@ public: ByteString to_utf8() const; - Utf32View view() const { return { code_points(), length() }; } + Utf32View view() const LIFETIME_BOUND { return { code_points(), length() }; } u32 const* code_points() const { return m_text.data(); } size_t length() const { return m_text.size(); } bool set_text(Document&, StringView); diff --git a/Libraries/LibWasm/Types.h b/Libraries/LibWasm/Types.h index ec3bdfd9361..0a1824a6fe7 100644 --- a/Libraries/LibWasm/Types.h +++ b/Libraries/LibWasm/Types.h @@ -1084,7 +1084,7 @@ public: void set_validation_status(ValidationStatus status, Badge) { set_validation_status(status); } ValidationStatus validation_status() const { return m_validation_status; } - StringView validation_error() const { return *m_validation_error; } + StringView validation_error() const LIFETIME_BOUND { return *m_validation_error; } void set_validation_error(ByteString error) { m_validation_error = move(error); } static ParseResult> parse(Stream& stream); diff --git a/Libraries/LibWasm/Wasi.h b/Libraries/LibWasm/Wasi.h index 9689fd6844a..1da615b0b71 100644 --- a/Libraries/LibWasm/Wasi.h +++ b/Libraries/LibWasm/Wasi.h @@ -84,8 +84,8 @@ public: } // This returns the internal representation. In this case, that is the value stored in little endian format. - constexpr Bytes bytes() { return Bytes { &m_value, sizeof(m_value) }; } - constexpr ReadonlyBytes bytes() const { return ReadonlyBytes { &m_value, sizeof(m_value) }; } + constexpr Bytes bytes() LIFETIME_BOUND { return Bytes { &m_value, sizeof(m_value) }; } + constexpr ReadonlyBytes bytes() const LIFETIME_BOUND { return ReadonlyBytes { &m_value, sizeof(m_value) }; } void serialize_into(Array bytes) const; static LittleEndian read_from(Array const& bytes); diff --git a/Libraries/LibWeb/CSS/StyleValues/AngleStyleValue.h b/Libraries/LibWeb/CSS/StyleValues/AngleStyleValue.h index c76793f0468..a0dae8130c7 100644 --- a/Libraries/LibWeb/CSS/StyleValues/AngleStyleValue.h +++ b/Libraries/LibWeb/CSS/StyleValues/AngleStyleValue.h @@ -24,7 +24,7 @@ public: Angle const& angle() const { return m_angle; } virtual double raw_value() const override { return m_angle.raw_value(); } - virtual StringView unit_name() const override { return m_angle.unit_name(); } + virtual StringView unit_name() const LIFETIME_BOUND override { return m_angle.unit_name(); } virtual String to_string(SerializationMode) const override; diff --git a/Libraries/LibWeb/CSS/StyleValues/FlexStyleValue.h b/Libraries/LibWeb/CSS/StyleValues/FlexStyleValue.h index c0a85367878..bc32496a68c 100644 --- a/Libraries/LibWeb/CSS/StyleValues/FlexStyleValue.h +++ b/Libraries/LibWeb/CSS/StyleValues/FlexStyleValue.h @@ -21,7 +21,7 @@ public: Flex const& flex() const { return m_flex; } virtual double raw_value() const override { return m_flex.raw_value(); } - virtual StringView unit_name() const override { return m_flex.unit_name(); } + virtual StringView unit_name() const LIFETIME_BOUND override { return m_flex.unit_name(); } virtual String to_string(SerializationMode serialization_mode) const override { return m_flex.to_string(serialization_mode); } diff --git a/Libraries/LibWeb/CSS/StyleValues/FrequencyStyleValue.h b/Libraries/LibWeb/CSS/StyleValues/FrequencyStyleValue.h index 37a8c2f154c..83295b3e610 100644 --- a/Libraries/LibWeb/CSS/StyleValues/FrequencyStyleValue.h +++ b/Libraries/LibWeb/CSS/StyleValues/FrequencyStyleValue.h @@ -24,7 +24,7 @@ public: Frequency const& frequency() const { return m_frequency; } virtual double raw_value() const override { return m_frequency.raw_value(); } - virtual StringView unit_name() const override { return m_frequency.unit_name(); } + virtual StringView unit_name() const LIFETIME_BOUND override { return m_frequency.unit_name(); } virtual String to_string(SerializationMode serialization_mode) const override { return m_frequency.to_string(serialization_mode); } diff --git a/Libraries/LibWeb/CSS/StyleValues/LengthStyleValue.h b/Libraries/LibWeb/CSS/StyleValues/LengthStyleValue.h index 5439f494d08..a7cc5e7ffcb 100644 --- a/Libraries/LibWeb/CSS/StyleValues/LengthStyleValue.h +++ b/Libraries/LibWeb/CSS/StyleValues/LengthStyleValue.h @@ -22,7 +22,7 @@ public: Length const& length() const { return m_length; } virtual double raw_value() const override { return m_length.raw_value(); } - virtual StringView unit_name() const override { return m_length.unit_name(); } + virtual StringView unit_name() const LIFETIME_BOUND override { return m_length.unit_name(); } virtual String to_string(SerializationMode serialization_mode) const override { return m_length.to_string(serialization_mode); } virtual ValueComparingNonnullRefPtr absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override; diff --git a/Libraries/LibWeb/CSS/StyleValues/ResolutionStyleValue.h b/Libraries/LibWeb/CSS/StyleValues/ResolutionStyleValue.h index 4a787db9c49..eb4d71f209c 100644 --- a/Libraries/LibWeb/CSS/StyleValues/ResolutionStyleValue.h +++ b/Libraries/LibWeb/CSS/StyleValues/ResolutionStyleValue.h @@ -21,7 +21,7 @@ public: Resolution const& resolution() const { return m_resolution; } virtual double raw_value() const override { return m_resolution.raw_value(); } - virtual StringView unit_name() const override { return m_resolution.unit_name(); } + virtual StringView unit_name() const LIFETIME_BOUND override { return m_resolution.unit_name(); } virtual String to_string(SerializationMode serialization_mode) const override { return m_resolution.to_string(serialization_mode); } diff --git a/Libraries/LibWeb/CSS/StyleValues/TimeStyleValue.h b/Libraries/LibWeb/CSS/StyleValues/TimeStyleValue.h index a9555bfa8a3..c4a3844ce1c 100644 --- a/Libraries/LibWeb/CSS/StyleValues/TimeStyleValue.h +++ b/Libraries/LibWeb/CSS/StyleValues/TimeStyleValue.h @@ -24,7 +24,7 @@ public: Time const& time() const { return m_time; } virtual double raw_value() const override { return m_time.raw_value(); } - virtual StringView unit_name() const override { return m_time.unit_name(); } + virtual StringView unit_name() const LIFETIME_BOUND override { return m_time.unit_name(); } virtual String to_string(SerializationMode serialization_mode) const override { return m_time.to_string(serialization_mode); } diff --git a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h index 6ef48a7e5bf..dd99bcdb184 100644 --- a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h +++ b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h @@ -178,7 +178,7 @@ public: [[nodiscard]] static GC::Ref create(JS::VM&); - [[nodiscard]] ReadonlyBytes method() const { return m_method; } + [[nodiscard]] ReadonlyBytes method() const LIFETIME_BOUND { return m_method; } void set_method(ByteBuffer method) { m_method = move(method); } [[nodiscard]] bool local_urls_only() const { return m_local_urls_only; } diff --git a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h index e4cea041fef..e3975c06f13 100644 --- a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h +++ b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h @@ -78,7 +78,7 @@ public: [[nodiscard]] virtual Status status() const { return m_status; } virtual void set_status(Status status) { m_status = status; } - [[nodiscard]] virtual ReadonlyBytes status_message() const { return m_status_message; } + [[nodiscard]] virtual ReadonlyBytes status_message() const LIFETIME_BOUND { return m_status_message; } virtual void set_status_message(ByteBuffer status_message) { m_status_message = move(status_message); } [[nodiscard]] virtual GC::Ref header_list() const { return m_header_list; } @@ -230,7 +230,7 @@ public: [[nodiscard]] virtual Status status() const override { return m_internal_response->status(); } virtual void set_status(Status status) override { m_internal_response->set_status(status); } - [[nodiscard]] virtual ReadonlyBytes status_message() const override { return m_internal_response->status_message(); } + [[nodiscard]] virtual ReadonlyBytes status_message() const LIFETIME_BOUND override { return m_internal_response->status_message(); } virtual void set_status_message(ByteBuffer status_message) override { m_internal_response->set_status_message(move(status_message)); } [[nodiscard]] virtual GC::Ref header_list() const override { return m_internal_response->header_list(); } @@ -317,7 +317,7 @@ public: [[nodiscard]] virtual Vector const& url_list() const override { return m_url_list; } [[nodiscard]] virtual Vector& url_list() override { return m_url_list; } [[nodiscard]] virtual Status status() const override { return 0; } - [[nodiscard]] virtual ReadonlyBytes status_message() const override { return {}; } + [[nodiscard]] virtual ReadonlyBytes status_message() const LIFETIME_BOUND override { return {}; } [[nodiscard]] virtual GC::Ref header_list() const override { return m_header_list; } [[nodiscard]] virtual GC::Ptr body() const override { return nullptr; } @@ -340,7 +340,7 @@ public: [[nodiscard]] virtual Type type() const override { return Type::OpaqueRedirect; } [[nodiscard]] virtual Status status() const override { return 0; } - [[nodiscard]] virtual ReadonlyBytes status_message() const override { return {}; } + [[nodiscard]] virtual ReadonlyBytes status_message() const LIFETIME_BOUND override { return {}; } [[nodiscard]] virtual GC::Ref header_list() const override { return m_header_list; } [[nodiscard]] virtual GC::Ptr body() const override { return nullptr; } diff --git a/Libraries/LibWeb/FileAPI/Blob.h b/Libraries/LibWeb/FileAPI/Blob.h index 8d90718e194..cbe09f56a35 100644 --- a/Libraries/LibWeb/FileAPI/Blob.h +++ b/Libraries/LibWeb/FileAPI/Blob.h @@ -53,7 +53,7 @@ public: GC::Ref array_buffer(); GC::Ref bytes(); - ReadonlyBytes raw_bytes() const { return m_byte_buffer.bytes(); } + ReadonlyBytes raw_bytes() const LIFETIME_BOUND { return m_byte_buffer.bytes(); } GC::Ref get_stream(); diff --git a/Libraries/LibWeb/MimeSniff/Resource.h b/Libraries/LibWeb/MimeSniff/Resource.h index 9b9c2bdfdc9..708540e803e 100644 --- a/Libraries/LibWeb/MimeSniff/Resource.h +++ b/Libraries/LibWeb/MimeSniff/Resource.h @@ -39,7 +39,7 @@ public: ~Resource(); MimeType const& computed_mime_type() const { return m_computed_mime_type; } - ReadonlyBytes resource_header() const { return m_resource_header; } + ReadonlyBytes resource_header() const LIFETIME_BOUND { return m_resource_header; } private: Resource(ReadonlyBytes data, bool no_sniff, MimeType&& default_computed_mime_type); diff --git a/Libraries/LibWebView/SourceHighlighter.h b/Libraries/LibWebView/SourceHighlighter.h index 3344871e5b5..39a748f67c2 100644 --- a/Libraries/LibWebView/SourceHighlighter.h +++ b/Libraries/LibWebView/SourceHighlighter.h @@ -31,7 +31,7 @@ public: } virtual ~SourceDocument() = default; - StringView text() const { return m_source; } + StringView text() const LIFETIME_BOUND { return m_source; } size_t line_count() const { return m_lines.size(); } // ^ Syntax::Document