mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-20 00:08:55 +00:00
Everywhere: Slap some [[clang::lifetimebound]] where appropriate
This first pass only applies to the following two cases: - Public functions returning a view type into an object they own - Public ctors storing a view type This catches a grand total of one (1) issue, which is fixed in the previous commit.
This commit is contained in:
parent
8b3e888920
commit
4462348916
Notes:
github-actions[bot]
2025-09-01 09:12:52 +00:00
Author: https://github.com/alimpfard
Commit: 4462348916
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6028
Reviewed-by: https://github.com/gmta ✅
45 changed files with 92 additions and 83 deletions
|
@ -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; }
|
||||
|
|
|
@ -175,7 +175,7 @@ public:
|
|||
using SearchDirection = StringUtils::SearchDirection;
|
||||
[[nodiscard]] Optional<size_t> 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); }
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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<FlyString> {}) == other.m_data.raw(Badge<FlyString> {}); }
|
||||
[[nodiscard]] bool operator==(String const& other) const { return m_data == other; }
|
||||
|
|
|
@ -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 {};
|
||||
|
|
|
@ -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<StringView> const& parts_view() const { return m_parts; }
|
||||
[[nodiscard]] Vector<ByteString> parts() const;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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); }
|
||||
|
|
|
@ -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(); }
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -181,12 +181,12 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
Bytes bytes()
|
||||
Bytes bytes() LIFETIME_BOUND
|
||||
{
|
||||
return Bytes(reinterpret_cast<u8*>(this), sizeof(Storage));
|
||||
}
|
||||
|
||||
ReadonlyBytes bytes() const
|
||||
ReadonlyBytes bytes() const LIFETIME_BOUND
|
||||
{
|
||||
return ReadonlyBytes(reinterpret_cast<u8 const*>(this), sizeof(Storage));
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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() };
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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(); },
|
||||
|
|
|
@ -471,8 +471,8 @@ struct DNSKEY {
|
|||
return public_key[0];
|
||||
return static_cast<u16>(public_key[1]) | static_cast<u16>(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;
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
|
||||
virtual RefPtr<Gfx::Font> 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<void(Typeface const&)>) 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<FlyString, Vector<NonnullRefPtr<Typeface>>, AK::ASCIICaseInsensitiveFlyStringTraits> m_typeface_by_family;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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(); }
|
||||
|
|
|
@ -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<ModuleEnvironment> environment() { return m_environment; }
|
||||
|
||||
|
|
|
@ -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); }
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
Vector<ModuleWithSpecifier> 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<Program>, HostDefined* = nullptr);
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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 };
|
||||
};
|
||||
|
||||
|
|
|
@ -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<double> 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<void> set_codec_private_data(ReadonlyBytes codec_private_data)
|
||||
{
|
||||
m_codec_private_data = TRY(FixedArray<u8>::create(codec_private_data));
|
||||
|
|
|
@ -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<OneOf<StringView, ByteString> T>
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1084,7 +1084,7 @@ public:
|
|||
|
||||
void set_validation_status(ValidationStatus status, Badge<Validator>) { 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<NonnullRefPtr<Module>> parse(Stream& stream);
|
||||
|
|
|
@ -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, 1> bytes) const;
|
||||
static LittleEndian read_from(Array<ReadonlyBytes, 1> const& bytes);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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); }
|
||||
|
||||
|
|
|
@ -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); }
|
||||
|
||||
|
|
|
@ -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<StyleValue const> absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override;
|
||||
|
|
|
@ -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); }
|
||||
|
||||
|
|
|
@ -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); }
|
||||
|
||||
|
|
|
@ -178,7 +178,7 @@ public:
|
|||
|
||||
[[nodiscard]] static GC::Ref<Request> 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; }
|
||||
|
|
|
@ -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<HeaderList> 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<HeaderList> header_list() const override { return m_internal_response->header_list(); }
|
||||
|
@ -317,7 +317,7 @@ public:
|
|||
[[nodiscard]] virtual Vector<URL::URL> const& url_list() const override { return m_url_list; }
|
||||
[[nodiscard]] virtual Vector<URL::URL>& 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<HeaderList> header_list() const override { return m_header_list; }
|
||||
[[nodiscard]] virtual GC::Ptr<Body> 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<HeaderList> header_list() const override { return m_header_list; }
|
||||
[[nodiscard]] virtual GC::Ptr<Body> body() const override { return nullptr; }
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
GC::Ref<WebIDL::Promise> array_buffer();
|
||||
GC::Ref<WebIDL::Promise> bytes();
|
||||
|
||||
ReadonlyBytes raw_bytes() const { return m_byte_buffer.bytes(); }
|
||||
ReadonlyBytes raw_bytes() const LIFETIME_BOUND { return m_byte_buffer.bytes(); }
|
||||
|
||||
GC::Ref<Streams::ReadableStream> get_stream();
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue