[PATCH] D18483: NFC: static_assert instead of comment

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 25 15:03:16 PDT 2016


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/bccbc439/attachment.html>


More information about the llvm-commits mailing list