[clang] [Clang][analyzer] add documentation for optin performance padding (padding checker) #73675 (PR #86411)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 23 14:07:36 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: None (komalverma04)
<details>
<summary>Changes</summary>
# Added documentation for optin.performance.Padding.
- Performance package has `PaddingChecker` checker.
- It checks for excessively padded structs.
- It has one option that is `AllowedPad`, an integer option.
- It's default value is 24 bytes.
- Reports are generated when padding exceeds `AllowedPad`.
## Purpose
The purpose of this pull request is to improve the clarity and completeness of the documentation for PaddingChecker in the optin.performance.Padding checker.
Closes #<!-- -->73675
---
Full diff: https://github.com/llvm/llvm-project/pull/86411.diff
2 Files Affected:
- (modified) clang/docs/analyzer/checkers.rst (+20-2)
- (modified) clang/include/clang/StaticAnalyzer/Checkers/Checkers.td (+1-1)
``````````diff
diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index fe211514914272..64b09bc6ecd1d8 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -804,10 +804,28 @@ Check for performance anti-patterns when using Grand Central Dispatch.
.. _optin-performance-Padding:
-optin.performance.Padding
-"""""""""""""""""""""""""
+optin.performance.Padding (PaddingChecker)
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Check for excessively padded structs.
+.. code-block:: objc
+
+ struct TestStruct {
+ int data1; // 4 bytes
+ char data2; // 1 byte
+ char padding[27]; // 27 bytes of padding
+ }; // Total size: 32 bytes
+
+ void TestFunction() {
+ struct TestStruct struct1; // Warning is generated due to excessive padding.
+ }
+
+ // Reports are only generated if the excessive padding exceeds 'AllowedPad' in bytes.
+
+ // AllowedPad: Default Value: 24 bytes
+
+ Usage: `AllowedPad=<value>`
+
.. _optin-portability-UnixAPI:
optin.portability.UnixAPI
diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 686e5e99f4a62c..c0e4e9a70c2ef3 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -908,7 +908,7 @@ def PaddingChecker : Checker<"Padding">,
"24",
Released>
]>,
- Documentation<NotDocumented>;
+ Documentation<HasDocumentation>;
} // end: "padding"
``````````
</details>
https://github.com/llvm/llvm-project/pull/86411
More information about the cfe-commits
mailing list