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

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


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

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

>From c3fbfd791d0c2f6d9ed0825fd2a043d3319da058 Mon Sep 17 00:00:00 2001
From: MalavikaSamak <malavika2 at apple.com>
Date: Wed, 9 Apr 2025 14:31:06 -0700
Subject: [PATCH] Update the documentation for the unsafe_buffer_usage
 attribute to capture the new beahvior introduced by
 https://github.com/llvm/llvm-project/pull/125671

---
 clang/include/clang/Basic/AttrDocs.td | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

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



More information about the cfe-commits mailing list