[clang] [Clang][UnsafeBufferUsage] Warn about two-arg string_view constructors. (PR #180471)

Rohan Jacob-Rao via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 19 09:00:51 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<
----------------
rohanjr wrote:

I see, thanks. I'll defer to @pjalwadi to decide the separation in this case.

More generally, there are a number of unsafe buffer usage flags (currently 6 starting at https://clang.llvm.org/docs/DiagnosticsReference.html#wunsafe-buffer-usage). In the end, I expect we want users to enable some combination of them to achieve the full "unsafe buffer usage" check. This seems possible in the current infrastructure, since there are other flags which "control" other flags, e.g. https://clang.llvm.org/docs/DiagnosticsReference.html#wc-11-compat-pedantic. Is that how you imagine the end state as well? 

https://github.com/llvm/llvm-project/pull/180471


More information about the cfe-commits mailing list