[llvm-commits] [patch] AlignAs fixes

David Blaikie dblaikie at gmail.com
Wed Aug 29 08:56:53 PDT 2012


Updated based on feedback from IRC. Updated some comments, made Clang
use the standard feature rather than the __attribute__, removed some
unused template definitions.

On Tue, Aug 28, 2012 at 3:56 PM, David Blaikie <dblaikie at gmail.com> wrote:
> Here's an attempt to fix the incorrect/non-portable code in AlignAs.h
> and its unit test.
>
> We were previously trying to align typedefs, which isn't valid in
> C++11. Even attempting to use alignas correctly won't work on any
> compiler other than Clang anyway, even those (such as GCC 4.7)
> reporting C++11 compliance through the __cplusplus macro value.
>
> So instead:
> for __GNUC__, use __attribute__((aligned(x))) of a char
> for __cplusplus == 201103L || __has_feature(cxx_alignas), use alignas
> on a char (this code path isn't actually tested at the moment since
> clang reports __GNUC__ so it hits the first case)
> for _MSC_VER, use __declspec(align(x)) on a char
>
> This doesn't try to align a typedef as we were doing before, so I cut
> a few test cases & extra types out of the test file - this doesn't
> change the implementation much because we were stuffing a variable of
> the typedef'd type in an anonymous struct anyway - so now we just use
> the template with the aligned member directly.
>
> Yes/no/maybe? (I haven't actually looked at the code to see if this is
> producing correct code - just updated the test cases fairly
> mechanically & checked that they pass)
>
> - David
-------------- next part --------------
A non-text attachment was scrubbed...
Name: alignas.diff
Type: application/octet-stream
Size: 10521 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120829/2a39c49d/attachment.obj>


More information about the llvm-commits mailing list