]> granicus.if.org Git - llvm/commit
[NFC] Make Optional<T> trivially copyable when T is trivially copyable
authorSerge Guelton <sguelton@redhat.com>
Mon, 18 Feb 2019 12:07:12 +0000 (12:07 +0000)
committerSerge Guelton <sguelton@redhat.com>
Mon, 18 Feb 2019 12:07:12 +0000 (12:07 +0000)
commitb6d8f1d922903b62102a610043b9045d742e8c4a
treeee049b4430047f1433797ab4dd737fdfecbf60e6
parent846a9882992511cc0d34aaa1b031becec3bcd80d
[NFC] Make Optional<T> trivially copyable when T is trivially copyable

This is a follow-up to r354246 and a reimplementation of https://reviews.llvm.org/D57097?id=186600
that should not trigger any UB thanks to the use of an union.

This may still be subject to the problem solved by std::launder, but I'm unsure how it interacts whith union.
/me plans to revert if this triggers any relevant bot failure. At least this validates in Release mode with
clang 6.0.1 and gcc 4.8.5.

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