[PATCH] D18483: NFC: static_assert instead of comment

JF Bastien via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 25 20:44:53 PDT 2016


On Fri, Mar 25, 2016 at 3:37 PM, David Blaikie <dblaikie at gmail.com> wrote:

> Ah, fair enough then - carry on. (consider this code review approval if
> you like (I'm by no means a code owner in this particular corner, but would
> be comfortable enough committing similar changes myself))
>

No worries, I just figured I should open a PR in case anyone had a better
idea than mine. The fix seemed strictly better than a comment, but hey it's
Friday! I'll commit tomorrow if not :-)


On Fri, Mar 25, 2016 at 3:33 PM, JF Bastien <jfb at chromium.org> wrote:
>
>> It's not available in libstdc++ before GCC 5.1.
>> On Mar 25, 2016 3:03 PM, "David Blaikie" <dblaikie at gmail.com> wrote:
>>
>>> Could/should we be using a standard trait (std::is_trivially_copyable)?
>>>
>>> On Fri, Mar 25, 2016 at 3:00 PM, JF Bastien via llvm-commits <
>>> llvm-commits at lists.llvm.org> wrote:
>>>
>>>> jfb created this revision.
>>>> jfb added a subscriber: llvm-commits.
>>>>
>>>> isPodLike is as close as we have for is_trivially_copyable.
>>>>
>>>> http://reviews.llvm.org/D18483
>>>>
>>>> Files:
>>>>   lib/CodeGen/MachineInstr.cpp
>>>>
>>>> Index: lib/CodeGen/MachineInstr.cpp
>>>> ===================================================================
>>>> --- lib/CodeGen/MachineInstr.cpp
>>>> +++ lib/CodeGen/MachineInstr.cpp
>>>> @@ -38,6 +38,7 @@
>>>>  #include "llvm/Support/ErrorHandling.h"
>>>>  #include "llvm/Support/MathExtras.h"
>>>>  #include "llvm/Support/raw_ostream.h"
>>>> +#include "llvm/Support/type_traits.h"
>>>>  #include "llvm/Target/TargetInstrInfo.h"
>>>>  #include "llvm/Target/TargetMachine.h"
>>>>  #include "llvm/Target/TargetRegisterInfo.h"
>>>> @@ -757,7 +758,8 @@
>>>>    if (MRI)
>>>>      return MRI->moveOperands(Dst, Src, NumOps);
>>>>
>>>> -  // MachineOperand is a trivially copyable type so we can just use
>>>> memmove.
>>>> +  static_assert(isPodLike<MachineOperand>::value,
>>>> +                "must be trivially copyable to memmove");
>>>>    std::memmove(Dst, Src, NumOps * sizeof(MachineOperand));
>>>>  }
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> llvm-commits mailing list
>>>> llvm-commits at lists.llvm.org
>>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>>>
>>>>
>>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160325/745bd97e/attachment.html>


More information about the llvm-commits mailing list