[clang] [ABITest] Use _Alignof instead of __alignof__ for ABI alignment (PR #179031)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 31 04:51:11 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: puneeth_aditya_5656 (mugiwaraluffy56)
<details>
<summary>Changes</summary>
`__alignof__` returns the "preferred" alignment, which can differ from the actual ABI required alignment on some architectures. This can give misleading results in the generated layout tests when testing ABI compatibility.
Use `_Alignof` (C11 standard keyword) instead, which returns the actual ABI required alignment.
Fixes #<!-- -->179007.
---
Full diff: https://github.com/llvm/llvm-project/pull/179031.diff
1 Files Affected:
- (modified) clang/utils/ABITest/ABITestGen.py (+1-1)
``````````diff
diff --git a/clang/utils/ABITest/ABITestGen.py b/clang/utils/ABITest/ABITestGen.py
index 119b3299ffa60..6dcf75f69ea8b 100755
--- a/clang/utils/ABITest/ABITestGen.py
+++ b/clang/utils/ABITest/ABITestGen.py
@@ -306,7 +306,7 @@ def printSizeOfType(self, prefix, name, t, output=None, indent=2):
def printAlignOfType(self, prefix, name, t, output=None, indent=2):
print(
- '%*sprintf("%s: __alignof__(%s) = %%ld\\n", (long)__alignof__(%s));'
+ '%*sprintf("%s: alignof(%s) = %%ld\\n", (long)_Alignof(%s));'
% (indent, "", prefix, name, name),
file=output,
)
``````````
</details>
https://github.com/llvm/llvm-project/pull/179031
More information about the cfe-commits
mailing list