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:
Ali Mohammad Pur 2025-08-30 08:18:47 +02:00 committed by Jelle Raaijmakers
parent 8b3e888920
commit 4462348916
Notes: github-actions[bot] 2025-09-01 09:12:52 +00:00
45 changed files with 92 additions and 83 deletions

View file

@ -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));

View file

@ -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>