1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00
llvm-mirror/unittests
James Player 6207a8299f Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable
Current code breaks this version of MSVC due to a mismatch between `std::is_trivially_copyable` and `llvm::is_trivially_copyable` for `std::pair` instantiations.  Hence I was attempting to use `std::is_trivially_copyable` to set `llvm::is_trivially_copyable<T>::value`.

I spent some time root causing an `llvm::Optional` build error on MSVC 16.8.3 related to the change described above:

```
62>C:\src\ocg_llvm\llvm-project\llvm\include\llvm/ADT/BreadthFirstIterator.h(96,12): error C2280: 'llvm::Optional<std::pair<std::pair<unsigned int,llvm::Graph<4>::NodeSubset> *,llvm::Optional<llvm::Graph<4>::ChildIterator>>> &llvm::Optional<std::pair<std::pair<unsigned int,llvm::Graph<4>::NodeSubset> *,llvm::Optional<llvm::Graph<4>::ChildIterator>>>::operator =(const llvm::Optional<std::pair<std::pair<unsigned int,llvm::Graph<4>::NodeSubset> *,llvm::Optional<llvm::Graph<4>::ChildIterator>>> &)': attempting to reference a deleted function (compiling source file C:\src\ocg_llvm\llvm-project\llvm\unittests\ADT\BreadthFirstIteratorTest.cpp)
...
```
The "trivial" specialization of `optional_detail::OptionalStorage` assumes that the value type is trivially copy constructible and trivially copy assignable. The specialization is invoked based on a check of `is_trivially_copyable` alone, which does not imply both `is_trivially_copy_assignable` and `is_trivially_copy_constructible` are true.

[[ https://en.cppreference.com/w/cpp/named_req/TriviallyCopyable | According to the spec ]], a deleted assignment operator does not make `is_trivially_copyable` false. So I think all these properties need to be checked explicitly in order to specialize `OptionalStorage` to the "trivial" version:
```
/// Storage for any type.
template <typename T, bool = std::is_trivially_copy_constructible<T>::value
                          && std::is_trivially_copy_assignable<T>::value>
class OptionalStorage {
```
Above fixed my build break in MSVC, but I think we need to explicitly check `is_trivially_copy_constructible` too since it might be possible the copy constructor is deleted.  Also would be ideal to move over to `std::is_trivially_copyable` instead of the `llvm` namespace verson.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D93510
2021-01-16 09:37:04 -05:00
..
ADT Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable 2021-01-16 09:37:04 -05:00
Analysis [ValueTracking] Fix one s/dyn_cast/dyn_cast_or_null/ 2021-01-13 13:39:53 +01:00
AsmParser
BinaryFormat
Bitcode
Bitstream Switch from llvm::is_trivially_copyable to std::is_trivially_copyable 2020-12-02 22:02:48 -08:00
CodeGen [MIPatternMatch] Add m_OneNonDBGUse 2021-01-15 10:18:46 -08:00
DebugInfo
Demangle
ExecutionEngine [Orc] Add a unit test for asynchronous definition generation. 2021-01-13 14:23:36 +11:00
FileCheck
Frontend [docs][unittest][Go][StackProtector] Migrate deprecated DebugInfo::get to DILocation::get 2020-12-15 14:17:04 -08:00
FuzzMutate
InterfaceStub
IR Fixup Asserts+!AbiBreakingChecks fallout from db33f85c7124 2021-01-07 14:18:19 -08:00
LineEditor
Linker
MC
MI [AMDGPU] Add _e64 suffix to VOP3 Insts 2021-01-12 18:33:18 -05:00
Object [llvm-readelf/obj] - Add support of multiple SHT_SYMTAB_SHNDX sections. 2021-01-13 11:36:43 +03:00
ObjectYAML
Option [clang][cli] Specify KeyPath prefixes via TableGen classes 2021-01-15 08:42:59 +01:00
Passes
ProfileData
Remarks
Support Re-land [Support] On Windows, take the affinity mask into account 2021-01-14 17:03:22 -05:00
TableGen
Target [WebAssembly] Update basic EH instructions for the new spec 2021-01-09 01:48:06 -08:00
TextAPI [YAML] Use correct source location for unknown key errors. 2020-12-11 16:34:06 +00:00
tools [llvm-exegesis][PowerPC] Add more register classes 2020-12-04 15:02:12 +00:00
Transforms [VPlan] Unify value/recipe printing after VPDef transition. 2021-01-11 14:42:46 +00:00
XRay
CMakeLists.txt
unittest.cfg.in