Commit fcbc2e83 authored by Jeremy Roman's avatar Jeremy Roman Committed by Commit Bot

Replace WTF::IsTriviallyDestructible with std::is_trivially_destructible.

Bug: 783060
Change-Id: I02ab0eb7aa0f540a68be1ddfc34c1b4fc16de8e2
Reviewed-on: https://chromium-review.googlesource.com/c/1347060
Commit-Queue: Yuta Kitamura <yutak@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarYuta Kitamura <yutak@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610308}
parent 1feb34d3
...@@ -77,7 +77,7 @@ template <typename T, typename Allocator> ...@@ -77,7 +77,7 @@ template <typename T, typename Allocator>
struct FinalizerTrait<WTF::ListHashSetNode<T, Allocator>> { struct FinalizerTrait<WTF::ListHashSetNode<T, Allocator>> {
STATIC_ONLY(FinalizerTrait); STATIC_ONLY(FinalizerTrait);
static const bool kNonTrivialFinalizer = static const bool kNonTrivialFinalizer =
!WTF::IsTriviallyDestructible<T>::value; !std::is_trivially_destructible<T>::value;
static void Finalize(void* obj) { static void Finalize(void* obj) {
FinalizerTraitImpl<WTF::ListHashSetNode<T, Allocator>, FinalizerTraitImpl<WTF::ListHashSetNode<T, Allocator>,
kNonTrivialFinalizer>::Finalize(obj); kNonTrivialFinalizer>::Finalize(obj);
...@@ -110,7 +110,7 @@ template <typename Table> ...@@ -110,7 +110,7 @@ template <typename Table>
struct FinalizerTrait<HeapHashTableBacking<Table>> { struct FinalizerTrait<HeapHashTableBacking<Table>> {
STATIC_ONLY(FinalizerTrait); STATIC_ONLY(FinalizerTrait);
static const bool kNonTrivialFinalizer = static const bool kNonTrivialFinalizer =
!WTF::IsTriviallyDestructible<typename Table::ValueType>::value; !std::is_trivially_destructible<typename Table::ValueType>::value;
static void Finalize(void* obj) { static void Finalize(void* obj) {
FinalizerTraitImpl<HeapHashTableBacking<Table>, FinalizerTraitImpl<HeapHashTableBacking<Table>,
kNonTrivialFinalizer>::Finalize(obj); kNonTrivialFinalizer>::Finalize(obj);
......
...@@ -390,7 +390,9 @@ void HeapVectorBacking<T, Traits>::Finalize(void* pointer) { ...@@ -390,7 +390,9 @@ void HeapVectorBacking<T, Traits>::Finalize(void* pointer) {
"HeapVectorBacking doesn't support objects that cannot be cleared as " "HeapVectorBacking doesn't support objects that cannot be cleared as "
"unused with memset or don't have a vtable"); "unused with memset or don't have a vtable");
DCHECK(!WTF::IsTriviallyDestructible<T>::value); static_assert(
!std::is_trivially_destructible<T>::value,
"Finalization of trivially destructible classes should not happen.");
HeapObjectHeader* header = HeapObjectHeader::FromPayload(pointer); HeapObjectHeader* header = HeapObjectHeader::FromPayload(pointer);
// Use the payload size as recorded by the heap to determine how many // Use the payload size as recorded by the heap to determine how many
// elements to finalize. // elements to finalize.
...@@ -417,7 +419,9 @@ void HeapVectorBacking<T, Traits>::Finalize(void* pointer) { ...@@ -417,7 +419,9 @@ void HeapVectorBacking<T, Traits>::Finalize(void* pointer) {
template <typename Table> template <typename Table>
void HeapHashTableBacking<Table>::Finalize(void* pointer) { void HeapHashTableBacking<Table>::Finalize(void* pointer) {
using Value = typename Table::ValueType; using Value = typename Table::ValueType;
DCHECK(!WTF::IsTriviallyDestructible<Value>::value); static_assert(
!std::is_trivially_destructible<Value>::value,
"Finalization of trivially destructible classes should not happen.");
HeapObjectHeader* header = HeapObjectHeader::FromPayload(pointer); HeapObjectHeader* header = HeapObjectHeader::FromPayload(pointer);
// Use the payload size as recorded by the heap to determine how many // Use the payload size as recorded by the heap to determine how many
// elements to finalize. // elements to finalize.
......
...@@ -1651,7 +1651,7 @@ void HashTable<Key, ...@@ -1651,7 +1651,7 @@ void HashTable<Key,
KeyTraits, KeyTraits,
Allocator>::DeleteAllBucketsAndDeallocate(ValueType* table, Allocator>::DeleteAllBucketsAndDeallocate(ValueType* table,
unsigned size) { unsigned size) {
if (!IsTriviallyDestructible<ValueType>::value) { if (!std::is_trivially_destructible<ValueType>::value) {
for (unsigned i = 0; i < size; ++i) { for (unsigned i = 0; i < size; ++i) {
// This code is called when the hash table is cleared or resized. We // This code is called when the hash table is cleared or resized. We
// have allocated a new backing store and we need to run the // have allocated a new backing store and we need to run the
......
...@@ -416,7 +416,7 @@ class ListHashSetNode : public ListHashSetNodeBase<ValueArg> { ...@@ -416,7 +416,7 @@ class ListHashSetNode : public ListHashSetNodeBase<ValueArg> {
void SetWasAlreadyDestructed() { void SetWasAlreadyDestructed() {
if (NodeAllocator::kIsGarbageCollected && if (NodeAllocator::kIsGarbageCollected &&
!IsTriviallyDestructible<ValueArg>::value) !std::is_trivially_destructible<ValueArg>::value)
this->prev_ = UnlinkedNodePointer(); this->prev_ = UnlinkedNodePointer();
} }
...@@ -427,7 +427,9 @@ class ListHashSetNode : public ListHashSetNodeBase<ValueArg> { ...@@ -427,7 +427,9 @@ class ListHashSetNode : public ListHashSetNodeBase<ValueArg> {
static void Finalize(void* pointer) { static void Finalize(void* pointer) {
// No need to waste time calling finalize if it's not needed. // No need to waste time calling finalize if it's not needed.
DCHECK(!IsTriviallyDestructible<ValueArg>::value); static_assert(
!std::is_trivially_destructible<ValueArg>::value,
"Finalization of trivially destructible classes should not happen.");
ListHashSetNode* self = reinterpret_cast_ptr<ListHashSetNode*>(pointer); ListHashSetNode* self = reinterpret_cast_ptr<ListHashSetNode*>(pointer);
// Check whether this node was already destructed before being unlinked // Check whether this node was already destructed before being unlinked
......
...@@ -48,14 +48,6 @@ enum WeakHandlingFlag { ...@@ -48,14 +48,6 @@ enum WeakHandlingFlag {
kWeakHandling, kWeakHandling,
}; };
template <typename T>
struct IsTriviallyDestructible {
// TODO(slangley): crbug.com/783060 - std::is_trivially_destructible behaves
// differently on across platforms.
static constexpr bool value =
__has_trivial_destructor(T) && std::is_destructible<T>::value;
};
template <typename T, typename U> template <typename T, typename U>
struct IsSubclass { struct IsSubclass {
private: private:
......
...@@ -217,7 +217,7 @@ static_assert( ...@@ -217,7 +217,7 @@ static_assert(
!std::is_trivially_default_constructible<DefaultConstructorDeleted>::value, !std::is_trivially_default_constructible<DefaultConstructorDeleted>::value,
"DefaultConstructorDeleted must not be trivially default constructible."); "DefaultConstructorDeleted must not be trivially default constructible.");
static_assert(!IsTriviallyDestructible<DestructorDeleted>::value, static_assert(!std::is_trivially_destructible<DestructorDeleted>::value,
"DestructorDeleted must not be trivially destructible."); "DestructorDeleted must not be trivially destructible.");
#define EnsurePtrConvertibleArgDecl(From, To) \ #define EnsurePtrConvertibleArgDecl(From, To) \
......
...@@ -32,7 +32,8 @@ namespace WTF { ...@@ -32,7 +32,8 @@ namespace WTF {
template <typename T> template <typename T>
struct VectorTraitsBase { struct VectorTraitsBase {
static const bool kNeedsDestruction = !IsTriviallyDestructible<T>::value; static const bool kNeedsDestruction =
!std::is_trivially_destructible<T>::value;
static constexpr bool kCanInitializeWithMemset = static constexpr bool kCanInitializeWithMemset =
std::is_trivially_default_constructible<T>::value; std::is_trivially_default_constructible<T>::value;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment