mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
Switch from llvm::is_trivially_copyable to std::is_trivially_copyable
GCC<5 did not support std::is_trivially_copyable. Now LLVM builds require 5.1 we can migrate to std::is_trivially_copyable. The Optional.h change made MSVC choke (https://buildkite.com/llvm-project/premerge-checks/builds/18587#cd1bb616-ffdc-4581-9795-b42c284196de) so I leave it out for now. Differential Revision: https://reviews.llvm.org/D92514
This commit is contained in:
parent
cb92e3d61f
commit
649f05aa24
@ -1530,7 +1530,7 @@ SmallVector has grown a few other minor advantages over std::vector, causing
|
||||
#. std::vector is exception-safe, and some implementations have pessimizations
|
||||
that copy elements when SmallVector would move them.
|
||||
|
||||
#. SmallVector understands ``llvm::is_trivially_copyable<Type>`` and uses realloc aggressively.
|
||||
#. SmallVector understands ``std::is_trivially_copyable<Type>`` and uses realloc aggressively.
|
||||
|
||||
#. Many LLVM APIs take a SmallVectorImpl as an out parameter (see the note
|
||||
below).
|
||||
|
@ -426,8 +426,8 @@ protected:
|
||||
setNumEntries(other.getNumEntries());
|
||||
setNumTombstones(other.getNumTombstones());
|
||||
|
||||
if (is_trivially_copyable<KeyT>::value &&
|
||||
is_trivially_copyable<ValueT>::value)
|
||||
if (std::is_trivially_copyable<KeyT>::value &&
|
||||
std::is_trivially_copyable<ValueT>::value)
|
||||
memcpy(reinterpret_cast<void *>(getBuckets()), other.getBuckets(),
|
||||
getNumBuckets() * sizeof(BucketT));
|
||||
else
|
||||
|
@ -1428,7 +1428,7 @@ template <typename T>
|
||||
// is trivially copyable.
|
||||
using sort_trivially_copyable = conjunction<
|
||||
std::is_pointer<T>,
|
||||
is_trivially_copyable<typename std::iterator_traits<T>::value_type>>;
|
||||
std::is_trivially_copyable<typename std::iterator_traits<T>::value_type>>;
|
||||
} // namespace detail
|
||||
|
||||
// Provide wrappers to std::sort which shuffle the elements before sorting
|
||||
|
@ -171,15 +171,10 @@ struct GloballyHashedType {
|
||||
return Hashes;
|
||||
}
|
||||
};
|
||||
#if defined(_MSC_VER)
|
||||
// is_trivially_copyable is not available in older versions of libc++, but it is
|
||||
// available in all supported versions of MSVC, so at least this gives us some
|
||||
// coverage.
|
||||
static_assert(std::is_trivially_copyable<GloballyHashedType>::value,
|
||||
"GloballyHashedType must be trivially copyable so that we can "
|
||||
"reinterpret_cast arrays of hash data to arrays of "
|
||||
"GloballyHashedType");
|
||||
#endif
|
||||
} // namespace codeview
|
||||
|
||||
template <> struct DenseMapInfo<codeview::LocallyHashedType> {
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
unsigned NewSize = Storage.size() - 1;
|
||||
if (NewSize) {
|
||||
// Move the slot at the end to the beginning.
|
||||
if (is_trivially_copyable<T>::value)
|
||||
if (std::is_trivially_copyable<T>::value)
|
||||
Storage[0] = Storage[NewSize];
|
||||
else
|
||||
std::swap(Storage[0], Storage[NewSize]);
|
||||
|
@ -262,7 +262,7 @@ TEST(ArrayRefTest, makeArrayRefFromStdArray) {
|
||||
}
|
||||
}
|
||||
|
||||
static_assert(is_trivially_copyable<ArrayRef<int>>::value,
|
||||
static_assert(std::is_trivially_copyable<ArrayRef<int>>::value,
|
||||
"trivially copyable");
|
||||
|
||||
} // end anonymous namespace
|
||||
|
@ -267,7 +267,7 @@ TEST_F(ImmutableListTest, LongListOrderingTest) {
|
||||
ASSERT_EQ(6, i);
|
||||
}
|
||||
|
||||
static_assert(is_trivially_copyable<ImmutableList<Wrapper<long>>>::value,
|
||||
static_assert(std::is_trivially_copyable<ImmutableList<Wrapper<long>>>::value,
|
||||
"trivially copyable");
|
||||
|
||||
} // namespace
|
||||
|
@ -17,10 +17,10 @@
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
static_assert(is_trivially_copyable<Optional<int>>::value,
|
||||
static_assert(std::is_trivially_copyable<Optional<int>>::value,
|
||||
"trivially copyable");
|
||||
|
||||
static_assert(is_trivially_copyable<Optional<std::array<int, 3>>>::value,
|
||||
static_assert(std::is_trivially_copyable<Optional<std::array<int, 3>>>::value,
|
||||
"trivially copyable");
|
||||
|
||||
void OptionalWorksInConstexpr() {
|
||||
@ -66,7 +66,7 @@ unsigned NonDefaultConstructible::Destructions = 0;
|
||||
unsigned NonDefaultConstructible::CopyAssignments = 0;
|
||||
|
||||
static_assert(
|
||||
!is_trivially_copyable<Optional<NonDefaultConstructible>>::value,
|
||||
!std::is_trivially_copyable<Optional<NonDefaultConstructible>>::value,
|
||||
"not trivially copyable");
|
||||
|
||||
// Test fixture
|
||||
@ -227,8 +227,7 @@ struct MultiArgConstructor {
|
||||
};
|
||||
unsigned MultiArgConstructor::Destructions = 0;
|
||||
|
||||
static_assert(
|
||||
!is_trivially_copyable<Optional<MultiArgConstructor>>::value,
|
||||
static_assert(!std::is_trivially_copyable<Optional<MultiArgConstructor>>::value,
|
||||
"not trivially copyable");
|
||||
|
||||
TEST_F(OptionalTest, Emplace) {
|
||||
@ -278,7 +277,7 @@ unsigned MoveOnly::MoveConstructions = 0;
|
||||
unsigned MoveOnly::Destructions = 0;
|
||||
unsigned MoveOnly::MoveAssignments = 0;
|
||||
|
||||
static_assert(!is_trivially_copyable<Optional<MoveOnly>>::value,
|
||||
static_assert(!std::is_trivially_copyable<Optional<MoveOnly>>::value,
|
||||
"not trivially copyable");
|
||||
|
||||
TEST_F(OptionalTest, MoveOnlyNull) {
|
||||
@ -382,7 +381,7 @@ private:
|
||||
unsigned Immovable::Constructions = 0;
|
||||
unsigned Immovable::Destructions = 0;
|
||||
|
||||
static_assert(!is_trivially_copyable<Optional<Immovable>>::value,
|
||||
static_assert(!std::is_trivially_copyable<Optional<Immovable>>::value,
|
||||
"not trivially copyable");
|
||||
|
||||
TEST_F(OptionalTest, ImmovableEmplace) {
|
||||
|
@ -62,7 +62,7 @@ TEST(PointerIntPairTest, GetSet) {
|
||||
EXPECT_EQ(&s, Pair2.getPointer());
|
||||
EXPECT_EQ(E::Case3, Pair2.getInt());
|
||||
|
||||
static_assert(is_trivially_copyable<PointerIntPair<S *, 2, E>>::value,
|
||||
static_assert(std::is_trivially_copyable<PointerIntPair<S *, 2, E>>::value,
|
||||
"trivially copyable");
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ TEST(PointerIntPairTest, ManyUnusedBits) {
|
||||
(int)PointerLikeTypeTraits<decltype(pair)>::NumLowBitsAvailable);
|
||||
|
||||
static_assert(
|
||||
is_trivially_copyable<
|
||||
std::is_trivially_copyable<
|
||||
PointerIntPair<Fixnum31, 1, bool, FixnumPointerTraits>>::value,
|
||||
"trivially copyable");
|
||||
}
|
||||
|
@ -1087,6 +1087,7 @@ TEST(StringRefTest, GTestPrinter) {
|
||||
EXPECT_EQ(R"("foo")", ::testing::PrintToString(StringRef("foo")));
|
||||
}
|
||||
|
||||
static_assert(is_trivially_copyable<StringRef>::value, "trivially copyable");
|
||||
static_assert(std::is_trivially_copyable<StringRef>::value,
|
||||
"trivially copyable");
|
||||
|
||||
} // end anonymous namespace
|
||||
|
@ -91,7 +91,7 @@ TEST_F(BlockFrequencyInfoTest, Basic) {
|
||||
EXPECT_EQ(BFI.getBlockFreq(BB3).getFrequency(), BB3Freq);
|
||||
}
|
||||
|
||||
static_assert(is_trivially_copyable<bfi_detail::BlockMass>::value,
|
||||
static_assert(std::is_trivially_copyable<bfi_detail::BlockMass>::value,
|
||||
"trivially copyable");
|
||||
|
||||
} // end anonymous namespace
|
||||
|
@ -161,7 +161,7 @@ TEST(BitstreamReaderTest, shortRead) {
|
||||
}
|
||||
}
|
||||
|
||||
static_assert(is_trivially_copyable<BitCodeAbbrevOp>::value,
|
||||
static_assert(std::is_trivially_copyable<BitCodeAbbrevOp>::value,
|
||||
"trivially copyable");
|
||||
|
||||
} // end anonymous namespace
|
||||
|
@ -383,6 +383,7 @@ TEST(MachineInstrExtraInfo, RemoveExtraInfo) {
|
||||
ASSERT_FALSE(MI->getHeapAllocMarker());
|
||||
}
|
||||
|
||||
static_assert(is_trivially_copyable<MCOperand>::value, "trivially copyable");
|
||||
static_assert(std::is_trivially_copyable<MCOperand>::value,
|
||||
"trivially copyable");
|
||||
|
||||
} // end namespace
|
||||
|
@ -12,14 +12,18 @@
|
||||
#include "llvm/CodeGen/SlotIndexes.h"
|
||||
#include "llvm/CodeGen/TargetPassConfig.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include <type_traits>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
#if __has_feature(is_trivially_copyable) || (defined(__GNUC__) && __GNUC__ >= 5)
|
||||
static_assert(is_trivially_copyable<PressureChange>::value, "trivially copyable");
|
||||
static_assert(is_trivially_copyable<SDep>::value, "trivially copyable");
|
||||
static_assert(is_trivially_copyable<SDValue>::value, "trivially copyable");
|
||||
static_assert(is_trivially_copyable<SlotIndex>::value, "trivially copyable");
|
||||
static_assert(is_trivially_copyable<IdentifyingPassPtr>::value, "trivially copyable");
|
||||
static_assert(std::is_trivially_copyable<PressureChange>::value,
|
||||
"trivially copyable");
|
||||
static_assert(std::is_trivially_copyable<SDep>::value, "trivially copyable");
|
||||
static_assert(std::is_trivially_copyable<SDValue>::value, "trivially copyable");
|
||||
static_assert(std::is_trivially_copyable<SlotIndex>::value,
|
||||
"trivially copyable");
|
||||
static_assert(std::is_trivially_copyable<IdentifyingPassPtr>::value,
|
||||
"trivially copyable");
|
||||
#endif
|
||||
|
||||
|
@ -267,10 +267,11 @@ TEST(CFGBuilder, Rebuild) {
|
||||
EXPECT_TRUE(isa<SwitchInst>(B.getOrAddBlock("d")->getTerminator()));
|
||||
}
|
||||
|
||||
static_assert(is_trivially_copyable<succ_iterator>::value,
|
||||
static_assert(std::is_trivially_copyable<succ_iterator>::value,
|
||||
"trivially copyable");
|
||||
static_assert(is_trivially_copyable<const_succ_iterator>::value,
|
||||
static_assert(std::is_trivially_copyable<const_succ_iterator>::value,
|
||||
"trivially copyable");
|
||||
static_assert(is_trivially_copyable<succ_range>::value, "trivially copyable");
|
||||
static_assert(is_trivially_copyable<const_succ_range>::value,
|
||||
static_assert(std::is_trivially_copyable<succ_range>::value,
|
||||
"trivially copyable");
|
||||
static_assert(std::is_trivially_copyable<const_succ_range>::value,
|
||||
"trivially copyable");
|
||||
|
@ -562,7 +562,7 @@ TEST(ScaledNumberHelpersTest, toIntBug) {
|
||||
EXPECT_EQ(1u, (n * n).toInt<uint32_t>());
|
||||
}
|
||||
|
||||
static_assert(is_trivially_copyable<ScaledNumber<uint32_t>>::value,
|
||||
static_assert(std::is_trivially_copyable<ScaledNumber<uint32_t>>::value,
|
||||
"trivially copyable");
|
||||
|
||||
} // end namespace
|
||||
|
Loading…
x
Reference in New Issue
Block a user