From b57b0dbebd56dac69d702e508af188e059db9c19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C5=91rinc?= Date: Thu, 3 Sep 2026 16:02:36 -0700 Subject: [PATCH] util: annotate `Split` input lifetime `Split` can return views into its input, but annotating its old reference warns for lvalue strings. Take the span by value so Clang follows the backing storage. `Split` copies results but can still warn, while `SplitString` is unaffected. --- src/util/string.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/string.h b/src/util/string.h index fd0255d1625..b2be2e7f644 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -117,7 +117,7 @@ void ReplaceAll(std::string& in_out, std::string_view search, std::string_view s * - 3) */ template > -std::vector Split(const std::span& sp, std::string_view separators, bool include_sep = false) +std::vector Split(std::span sp LIFETIMEBOUND, std::string_view separators, bool include_sep = false) { std::vector ret; auto it = sp.begin(); @@ -145,7 +145,7 @@ std::vector Split(const std::span& sp, std::string_view separator * "foo(bar(1),2),3) on ',' will return {"foo(bar(1)", "2)", "3)"}. */ template > -std::vector Split(const std::span& sp, char sep, bool include_sep = false) +std::vector Split(std::span sp LIFETIMEBOUND, char sep, bool include_sep = false) { return Split(sp, std::string_view{&sep, 1}, include_sep); }