[clang] [attributes][-Wunsafe-buffer-usage] Support adding unsafe_buffer_usage attribute to struct fields (PR #101585)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 2 10:58:56 PDT 2024
================
@@ -6763,15 +6763,18 @@ attribute requires a string literal argument to identify the handle being releas
def UnsafeBufferUsageDocs : Documentation {
let Category = DocCatFunction;
let Content = [{
-The attribute ``[[clang::unsafe_buffer_usage]]`` should be placed on functions
-that need to be avoided as they are prone to buffer overflows. It is designed to
-work together with the off-by-default compiler warning ``-Wunsafe-buffer-usage``
-to help codebases transition away from raw pointer based buffer management,
-in favor of safer abstractions such as C++20 ``std::span``. The attribute causes
-``-Wunsafe-buffer-usage`` to warn on every use of the function, and it may
-enable ``-Wunsafe-buffer-usage`` to emit automatic fix-it hints
-which would help the user replace such unsafe functions with safe
-alternatives, though the attribute can be used even when the fix can't be automated.
+The attribute ``[[clang::unsafe_buffer_usage]]`` should be placed on functions or
+struct fields that are buffers, that must to be avoided as they are prone to
+buffer overflows. It is designed to work together with the off-by-default compiler
+warning ``-Wunsafe-buffer-usage``to help codebases transition away from raw pointer
+based buffer management, in favor of safer abstractions such as C++20 ``std::span``.
+The attribute causes ``-Wunsafe-buffer-usage`` to warn on every use of the function or
+the field it is attached to, and it may enable ``-Wunsafe-buffer-usage`` to emit
----------------
jkorous-apple wrote:
I'm afraid it is not clear (from a user perspective) what is meant by "enable ``-Wunsafe-buffer-usage`` to emit ...".
Maybe that's an implementation detail and we don't need to inform the user?
Or maybe we can somehow simplify the message?
https://github.com/llvm/llvm-project/pull/101585
More information about the cfe-commits
mailing list