Skip to content

Commit 1d6ebdf

Browse files
committed
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
1 parent bd726d2 commit 1d6ebdf

File tree

16 files changed

+39
-38
lines changed

16 files changed

+39
-38
lines changed

llvm/docs/ProgrammersManual.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,7 @@ SmallVector has grown a few other minor advantages over std::vector, causing
15301530
#. std::vector is exception-safe, and some implementations have pessimizations
15311531
that copy elements when SmallVector would move them.
15321532

1533-
#. SmallVector understands ``llvm::is_trivially_copyable<Type>`` and uses realloc aggressively.
1533+
#. SmallVector understands ``std::is_trivially_copyable<Type>`` and uses realloc aggressively.
15341534

15351535
#. Many LLVM APIs take a SmallVectorImpl as an out parameter (see the note
15361536
below).

llvm/include/llvm/ADT/DenseMap.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,8 @@ class DenseMapBase : public DebugEpochBase {
426426
setNumEntries(other.getNumEntries());
427427
setNumTombstones(other.getNumTombstones());
428428

429-
if (is_trivially_copyable<KeyT>::value &&
430-
is_trivially_copyable<ValueT>::value)
429+
if (std::is_trivially_copyable<KeyT>::value &&
430+
std::is_trivially_copyable<ValueT>::value)
431431
memcpy(reinterpret_cast<void *>(getBuckets()), other.getBuckets(),
432432
getNumBuckets() * sizeof(BucketT));
433433
else

llvm/include/llvm/ADT/STLExtras.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1428,7 +1428,7 @@ template <typename T>
14281428
// is trivially copyable.
14291429
using sort_trivially_copyable = conjunction<
14301430
std::is_pointer<T>,
1431-
is_trivially_copyable<typename std::iterator_traits<T>::value_type>>;
1431+
std::is_trivially_copyable<typename std::iterator_traits<T>::value_type>>;
14321432
} // namespace detail
14331433

14341434
// Provide wrappers to std::sort which shuffle the elements before sorting

llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,10 @@ struct GloballyHashedType {
171171
return Hashes;
172172
}
173173
};
174-
#if defined(_MSC_VER)
175-
// is_trivially_copyable is not available in older versions of libc++, but it is
176-
// available in all supported versions of MSVC, so at least this gives us some
177-
// coverage.
178174
static_assert(std::is_trivially_copyable<GloballyHashedType>::value,
179175
"GloballyHashedType must be trivially copyable so that we can "
180176
"reinterpret_cast arrays of hash data to arrays of "
181177
"GloballyHashedType");
182-
#endif
183178
} // namespace codeview
184179

185180
template <> struct DenseMapInfo<codeview::LocallyHashedType> {

llvm/tools/llvm-diff/DifferenceEngine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class PriorityQueue {
6767
unsigned NewSize = Storage.size() - 1;
6868
if (NewSize) {
6969
// Move the slot at the end to the beginning.
70-
if (is_trivially_copyable<T>::value)
70+
if (std::is_trivially_copyable<T>::value)
7171
Storage[0] = Storage[NewSize];
7272
else
7373
std::swap(Storage[0], Storage[NewSize]);

llvm/unittests/ADT/ArrayRefTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ TEST(ArrayRefTest, makeArrayRefFromStdArray) {
262262
}
263263
}
264264

265-
static_assert(is_trivially_copyable<ArrayRef<int>>::value,
265+
static_assert(std::is_trivially_copyable<ArrayRef<int>>::value,
266266
"trivially copyable");
267267

268268
} // end anonymous namespace

llvm/unittests/ADT/ImmutableListTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ TEST_F(ImmutableListTest, LongListOrderingTest) {
267267
ASSERT_EQ(6, i);
268268
}
269269

270-
static_assert(is_trivially_copyable<ImmutableList<Wrapper<long>>>::value,
270+
static_assert(std::is_trivially_copyable<ImmutableList<Wrapper<long>>>::value,
271271
"trivially copyable");
272272

273273
} // namespace

llvm/unittests/ADT/OptionalTest.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
using namespace llvm;
1919

20-
static_assert(is_trivially_copyable<Optional<int>>::value,
21-
"trivially copyable");
20+
static_assert(std::is_trivially_copyable<Optional<int>>::value,
21+
"trivially copyable");
2222

23-
static_assert(is_trivially_copyable<Optional<std::array<int, 3>>>::value,
23+
static_assert(std::is_trivially_copyable<Optional<std::array<int, 3>>>::value,
2424
"trivially copyable");
2525

2626
void OptionalWorksInConstexpr() {
@@ -66,8 +66,8 @@ unsigned NonDefaultConstructible::Destructions = 0;
6666
unsigned NonDefaultConstructible::CopyAssignments = 0;
6767

6868
static_assert(
69-
!is_trivially_copyable<Optional<NonDefaultConstructible>>::value,
70-
"not trivially copyable");
69+
!std::is_trivially_copyable<Optional<NonDefaultConstructible>>::value,
70+
"not trivially copyable");
7171

7272
// Test fixture
7373
class OptionalTest : public testing::Test {
@@ -227,9 +227,8 @@ struct MultiArgConstructor {
227227
};
228228
unsigned MultiArgConstructor::Destructions = 0;
229229

230-
static_assert(
231-
!is_trivially_copyable<Optional<MultiArgConstructor>>::value,
232-
"not trivially copyable");
230+
static_assert(!std::is_trivially_copyable<Optional<MultiArgConstructor>>::value,
231+
"not trivially copyable");
233232

234233
TEST_F(OptionalTest, Emplace) {
235234
MultiArgConstructor::ResetCounts();
@@ -278,7 +277,7 @@ unsigned MoveOnly::MoveConstructions = 0;
278277
unsigned MoveOnly::Destructions = 0;
279278
unsigned MoveOnly::MoveAssignments = 0;
280279

281-
static_assert(!is_trivially_copyable<Optional<MoveOnly>>::value,
280+
static_assert(!std::is_trivially_copyable<Optional<MoveOnly>>::value,
282281
"not trivially copyable");
283282

284283
TEST_F(OptionalTest, MoveOnlyNull) {
@@ -382,7 +381,7 @@ struct Immovable {
382381
unsigned Immovable::Constructions = 0;
383382
unsigned Immovable::Destructions = 0;
384383

385-
static_assert(!is_trivially_copyable<Optional<Immovable>>::value,
384+
static_assert(!std::is_trivially_copyable<Optional<Immovable>>::value,
386385
"not trivially copyable");
387386

388387
TEST_F(OptionalTest, ImmovableEmplace) {

llvm/unittests/ADT/PointerIntPairTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ TEST(PointerIntPairTest, GetSet) {
6262
EXPECT_EQ(&s, Pair2.getPointer());
6363
EXPECT_EQ(E::Case3, Pair2.getInt());
6464

65-
static_assert(is_trivially_copyable<PointerIntPair<S *, 2, E>>::value,
65+
static_assert(std::is_trivially_copyable<PointerIntPair<S *, 2, E>>::value,
6666
"trivially copyable");
6767
}
6868

@@ -101,7 +101,7 @@ TEST(PointerIntPairTest, ManyUnusedBits) {
101101
(int)PointerLikeTypeTraits<decltype(pair)>::NumLowBitsAvailable);
102102

103103
static_assert(
104-
is_trivially_copyable<
104+
std::is_trivially_copyable<
105105
PointerIntPair<Fixnum31, 1, bool, FixnumPointerTraits>>::value,
106106
"trivially copyable");
107107
}

llvm/unittests/ADT/StringRefTest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,7 @@ TEST(StringRefTest, GTestPrinter) {
10871087
EXPECT_EQ(R"("foo")", ::testing::PrintToString(StringRef("foo")));
10881088
}
10891089

1090-
static_assert(is_trivially_copyable<StringRef>::value, "trivially copyable");
1090+
static_assert(std::is_trivially_copyable<StringRef>::value,
1091+
"trivially copyable");
10911092

10921093
} // end anonymous namespace

0 commit comments

Comments
 (0)