[clang] aligned attribute doc (PR #195278)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon May 4 08:31:28 PDT 2026


================
@@ -10000,3 +9983,46 @@ different languages to coexist on the same call stack while each interpreting
 exceptions according to their own rules.
   }];
 }
+
+def AlignedDocs : Documentation {
+  let Category = DocCatDecl;
+  let Heading = "aligned";
+  let Content = [{
+The ``aligned`` attribute specifies a minimum alignment (in bytes) for a 
----------------
AaronBallman wrote:

Setting the heading to "aligned" and only talking about `aligned` is a bit of an issue because this documents multiple attributes with different names:
```
 let Spellings = [GCC<"aligned">, Declspec<"align">, CustomKeyword<"alignas">,
                   CustomKeyword<"_Alignas">];
```
I believe there are subtle differences between `__attribute__((aligned))`, `alignas`/`_Alignas`, and `__declspec(align)`, so I think the documentation should explain more about those differences. I would recommend looking for uses of the accessors:
```
  let Accessors = [Accessor<"isGNU", [GCC<"aligned">]>,
                   Accessor<"isC11", [CustomKeyword<"_Alignas">]>,
                   Accessor<"isAlignas", [CustomKeyword<"alignas">,
                                          CustomKeyword<"_Alignas">]>,
                   Accessor<"isDeclspec",[Declspec<"align">]>];
```
elsewhere in the code base, because it points out the places where we have an `AlignedAttr` which has potential behavioral differences, such as in https://github.com/llvm/llvm-project/blob/ca1f6cb61e9cfc71f8f0353ab552dc198a387d47/clang/lib/Sema/SemaDecl.cpp#L2775

That said, if I'm asking for extensive research, that could be done in a follow-up PR.

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


More information about the cfe-commits mailing list