================
@@ -804,10 +804,38 @@ Check for performance anti-patterns when using Grand 
Central Dispatch.
 
 .. _optin-performance-Padding:
 
-optin.performance.Padding
-"""""""""""""""""""""""""
+optin.performance.Padding (C, C++, ObjC)
+""""""""""""""""""""""""""""""""""""""""
 Check for excessively padded structs.
 
+This checker detects structs with excessive padding, which can lead to wasted 
memory and decreased performance. Padding bytes are added by compilers to align 
data within the struct for performance optimization or memory alignment 
purposes. However, excessive padding can significantly increase the size of the 
struct without adding useful data, leading to inefficient memory usage, cache 
misses, and decreased performance.
+
+.. code-block:: c
+
+   #include <stdio.h>
+   // #pragma pack(1) // Uncomment it to disable structure padding
+   struct TestStruct {
+       char data1;  // 1 byte
+       char data2;  // 1 byte
+       int data3;   // 4 bytes
----------------
steakhal wrote:

We usually indent code by 2 spaces in this `checkers.rst` file. Same for the 
`main` function body.
Also avoid trailing spaces in the empty lines.

https://github.com/llvm/llvm-project/pull/86411
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to