[clang] [CXX Safe Buffer] Update the safe buffer attribute documentation (PR #135087)

via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 9 14:43:39 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Malavika Samak (malavikasamak)

<details>
<summary>Changes</summary>

Update the documentation for the unsafe_buffer_usage attribute to capture the new behavior introduced by https://github.com/llvm/llvm-project/pull/125671

---
Full diff: https://github.com/llvm/llvm-project/pull/135087.diff


1 Files Affected:

- (modified) clang/include/clang/Basic/AttrDocs.td (+5-3) 


``````````diff
diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td
index c8b371280e35d..1546d849f6856 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -7517,9 +7517,11 @@ the field it is attached to, and it may also lead to emission of automatic fix-i
 hints which would help the user replace the use of unsafe functions(/fields) with safe
 alternatives, though the attribute can be used even when the fix can't be automated.
 
-* Attribute attached to functions: The attribute does not suppress
-  ``-Wunsafe-buffer-usage`` inside the function to which it is attached.
-  These warnings still need to be addressed.
+* Attribute attached to functions: The attribute suppresses all the
+  ``-Wunsafe-buffer-usage`` warnings inside the function to which it is attached, since
+  it is now classified as an unsafe function. The attribute must be placed judiciously
+  as there won't be any warning for unsafe operations within the function and this can
+  also cause it to mask new usafe operations introduced in the future.
 
   The attribute is warranted even if the only way a function can overflow
   the buffer is by violating the function's preconditions. For example, it

``````````

</details>


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


More information about the cfe-commits mailing list