[clang] [Clang][UnsafeBufferUsage] Warn about two-arg string_view constructors. (PR #180471)
Ziqing Luo via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 17 22:18:29 PST 2026
================
@@ -13559,6 +13549,9 @@ def note_safe_buffer_usage_suggestions_disabled : Note<
def warn_unsafe_buffer_usage_in_container : Warning<
"the two-parameter std::span construction is unsafe as it can introduce mismatch between buffer size and the bound information">,
InGroup<UnsafeBufferUsageInContainer>, DefaultIgnore;
+def warn_unsafe_buffer_usage_in_string_view : Warning<
----------------
ziqingluo-90 wrote:
The original idea is to let `warn_unsafe_buffer_usage_in_container` to cover both unsafe constructors of `std::span` and `std::string_view`, so we used the word "container" here (even though it is not very precise).
I suggest you use `warn_unsafe_buffer_usage_in_container` for both warnings and use `warn_unsafe_buffer_usage_in_string_view` to suppress the new warning for a smooth transition.
https://github.com/llvm/llvm-project/pull/180471
More information about the cfe-commits
mailing list