]> granicus.if.org Git - llvm/commit
Re-commit rL353927, patch included
authorSerge Guelton <sguelton@redhat.com>
Wed, 13 Feb 2019 18:12:04 +0000 (18:12 +0000)
committerSerge Guelton <sguelton@redhat.com>
Wed, 13 Feb 2019 18:12:04 +0000 (18:12 +0000)
commit3637405f12571ef952feb8a6084bbd95804ca9cb
tree2135b9ae62e153df375e9f212b021c0d04755878
parent9483ee997b90a9be80f13bb38ee7ee29ef566546
Re-commit rL353927, patch included

Make llvm::Optional<T> trivially copyable when T is trivially copyable

This is an ever-recurring issue (see https://bugs.llvm.org/show_bug.cgi?id=39427 and https://bugs.llvm.org/show_bug.cgi?id=35978)
but I believe that thanks to https://reviews.llvm.org/D54472 we can now ship a decent implementation of this.

Basically the fact that llvm::is_trivially_copyable has a consistent behavior across compilers should prevent any ABI issue,
and using in-place new instead of memcpy should keep compiler bugs away.

This patch is slightly different from the original revision https://reviews.llvm.org/rL353927 but achieves the same goal. It just avoids
going through std::conditional which may the code more explicit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353962 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/ADT/Optional.h
unittests/ADT/OptionalTest.cpp