[llvm] r239431 - Use AlignOf traits to enable static_assert.

Kaelyn Takata rikka at google.com
Tue Jun 9 16:27:46 PDT 2015


FYI, this causes a build failure with -Werror and -Wenum-compare:

lib/MC/MCSymbol.cpp:32:46: error: comparison between 'enum
llvm::AlignOf<llvm::MCSymbol>::<anonymous>' and 'enum
llvm::AlignOf<llvm::MCSymbol::NameEntryStorageTy>::<anonymous>'
[-Werror=enum-compare]

On Tue, Jun 9, 2015 at 1:58 PM, Pete Cooper <peter_cooper at apple.com> wrote:

> Author: pete
> Date: Tue Jun  9 15:58:03 2015
> New Revision: 239431
>
> URL: http://llvm.org/viewvc/llvm-project?rev=239431&view=rev
> Log:
> Use AlignOf traits to enable static_assert.
>
> This is better than runtime asserts.  Thanks to David Blaikie for the help
> here.
>
> Modified:
>     llvm/trunk/lib/MC/MCSymbol.cpp
>
> Modified: llvm/trunk/lib/MC/MCSymbol.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCSymbol.cpp?rev=239431&r1=239430&r2=239431&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/MC/MCSymbol.cpp (original)
> +++ llvm/trunk/lib/MC/MCSymbol.cpp Tue Jun  9 15:58:03 2015
> @@ -28,9 +28,9 @@ void *MCSymbol::operator new(size_t s, c
>    // For safety, ensure that the alignment of a pointer is enough for an
>    // MCSymbol.  This also ensures we don't need padding between the name
> and
>    // symbol.
> -  // FIXME: Use static_assert when constexpr is supported.
> -  assert(alignOf<MCSymbol>() <= alignOf<NameEntryStorageTy>() &&
> -         "Bad alignment of MCSymbol");
> +  static_assert(AlignOf<MCSymbol>::Alignment <=
> +                AlignOf<NameEntryStorageTy>::Alignment,
> +                "Bad alignment of MCSymbol");
>    void *Storage = Ctx.allocate(Size, alignOf<NameEntryStorageTy>());
>    NameEntryStorageTy *Start = static_cast<NameEntryStorageTy*>(Storage);
>    NameEntryStorageTy *End = Start + (Name ? 1 : 0);
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150609/25e33d39/attachment.html>


More information about the llvm-commits mailing list