Skip to content

[CXX Safe Buffer] Update the documentation for unsafe_buffer_usage attribute #135087

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

malavikasamak
Copy link
Contributor

Update the documentation for the unsafe_buffer_usage attribute to capture the new behavior introduced by #125671

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Apr 9, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 9, 2025

@llvm/pr-subscribers-clang

Author: Malavika Samak (malavikasamak)

Changes

Update the documentation for the unsafe_buffer_usage attribute to capture the new behavior introduced by #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 --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

@malavikasamak malavikasamak changed the title [CXX Safe Buffer] Update the safe buffer attribute documentation [CXX Safe Buffer] Update the documentation for unsafe_buffer_usage attribute Apr 9, 2025
@malavikasamak malavikasamak force-pushed the msamak-update-sb-documentation branch from c3fbfd7 to edbdfa6 Compare April 9, 2025 22:12
@malavikasamak malavikasamak merged commit 9102ccd into llvm:main Apr 10, 2025
12 checks passed
var-const pushed a commit to ldionne/llvm-project that referenced this pull request Apr 17, 2025
…tribute (llvm#135087)

Update the documentation for the unsafe_buffer_usage attribute to
capture the new behavior introduced by
llvm#125671

Co-authored-by: MalavikaSamak <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants