[clang] [ABITest] Use _Alignof instead of __alignof__ for ABI alignment (PR #179031)

via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 31 05:55:50 PST 2026


https://github.com/mugiwaraluffy56 updated https://github.com/llvm/llvm-project/pull/179031

>From 2790ecd3e25f22275c1c71fbefc022379d314621 Mon Sep 17 00:00:00 2001
From: mugiwaraluffy56 <myakampuneeth at gmail.com>
Date: Sat, 31 Jan 2026 18:19:42 +0530
Subject: [PATCH] [ABITest] Use _Alignof instead of __alignof__ for ABI
 alignment

__alignof__ returns the 'preferred' alignment which may differ from
the actual ABI-required alignment on some architectures. This can
give misleading results in generated layout tests.

Use _Alignof (C11 standard) instead, which returns the actual
ABI-required alignment of a type.

Fixes #179007.
---
 clang/utils/ABITest/ABITestGen.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/utils/ABITest/ABITestGen.py b/clang/utils/ABITest/ABITestGen.py
index 119b3299ffa60..6770ef2a9bf87 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,
         )



More information about the cfe-commits mailing list