From 3fa38a14acca2ee81b2ee724d2bf1197d20494cf Mon Sep 17 00:00:00 2001 From: Roger Ferrer Ibanez Date: Wed, 8 Mar 2017 14:00:44 +0000 Subject: Honor __unaligned in codegen for declarations and expressions This patch honors the unaligned type qualifier (currently available through he keyword __unaligned and -fms-extensions) in CodeGen. In the current form the patch affects declarations and expressions. It does not affect fields of classes. Differential Revision: https://reviews.llvm.org/D30166 llvm-svn: 297276 --- clang/lib/CodeGen/CodeGenFunction.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp') diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index bad963b6fa3..5f793f8e775 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -149,6 +149,8 @@ CharUnits CodeGenFunction::getNaturalTypeAlignment(QualType T, Alignment = CGM.getClassPointerAlignment(RD); } else { Alignment = getContext().getTypeAlignInChars(T); + if (T.getQualifiers().hasUnaligned()) + Alignment = CharUnits::One(); } // Cap to the global maximum type alignment unless the alignment -- cgit v1.2.3