Closed Bug 1625138 Opened 5 years ago Closed 5 years ago

Replace most TypeTraits with <type_traits> alternatives

Categories

(Core :: MFBT, task)

task
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla76
Tracking Status
firefox76 --- fixed

People

(Reporter: anba, Assigned: anba)

References

Details

Attachments

(41 files)

47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review

TypeTraits which aren't handled in this bug:

  • IsDestructible and the TypeTraits which are transitively used from it (DeclVal, AddRvalueReference, IsVoid, FalseType, TrueType, RemoveCV, IntegralConstant, RemoveConst, RemoveVolatile). These can't be replaced with <type_traits> until the MOZ_CAN_RUN_SCRIPT checker has been updated to support std::is_destructible. [1]
  • EnableIf: bug 1606962
  • IsSame: Has too many in-tree uses, should probably be handled in a separate bug.
  • IsPod: bug 900042

[1] Using std::is_destructible reports the following errors on OSX:

[task 2020-03-25T18:39:52.026Z] 18:39:52    ERROR -  /builds/worker/fetches/clang/bin/../include/c++/v1/type_traits:2225:51: error: arguments must all be strong refs or caller's parameters when calling a function marked as MOZ_CAN_RUN_SCRIPT (including the implicit object argument).  '_VSTD::declval<_Tp1&>()' is neither.
[task 2020-03-25T18:39:52.026Z] 18:39:52     INFO -          typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type
[task 2020-03-25T18:39:52.026Z] 18:39:52     INFO -                                                    ^~~~~~~~~~~~~~~~~~~~~~~
[task 2020-03-25T18:39:52.026Z] 18:39:52     INFO -  /builds/worker/fetches/clang/bin/../include/c++/v1/__config:758:15: note: expanded from macro '_VSTD'
[task 2020-03-25T18:39:52.026Z] 18:39:52     INFO -  #define _VSTD std::_LIBCPP_ABI_NAMESPACE
[task 2020-03-25T18:39:52.026Z] 18:39:52     INFO -                ^

and

[task 2020-03-25T18:39:52.027Z] 18:39:52    ERROR -  /builds/worker/fetches/clang/bin/../include/c++/v1/type_traits:2225:51: error: functions marked as MOZ_CAN_RUN_SCRIPT can only be called from functions also marked as MOZ_CAN_RUN_SCRIPT
[task 2020-03-25T18:39:52.029Z] 18:39:52     INFO -          typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type
[task 2020-03-25T18:39:52.029Z] 18:39:52     INFO -                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[task 2020-03-25T18:39:52.029Z] 18:39:52     INFO -  /builds/worker/fetches/clang/bin/../include/c++/v1/__config:758:15: note: expanded from macro '_VSTD'
[task 2020-03-25T18:39:52.029Z] 18:39:52     INFO -  #define _VSTD std::_LIBCPP_ABI_NAMESPACE
[task 2020-03-25T18:39:52.029Z] 18:39:52     INFO -                ^
See Also: → 1625152

(In reply to André Bargull [:anba] from comment #0)

TypeTraits which aren't handled in this bug:

  • IsDestructible and the TypeTraits which are transitively used from it (DeclVal, AddRvalueReference, IsVoid, FalseType, TrueType, RemoveCV, IntegralConstant, RemoveConst, RemoveVolatile). These can't be replaced with <type_traits> until the MOZ_CAN_RUN_SCRIPT checker has been updated to support std::is_destructible. [1]
  • IsSame: Has too many in-tree uses, should probably be handled in a separate bug.

So, it looks like it's possible to replace mozilla::DeclVal with std::declval in mozilla::IsDestructible without triggering bug 1625152. That means we can actually also replace DeclVal, AddRvalueReference, IsVoid, FalseType, TrueType, RemoveCV, IntegralConstant, RemoveConst, RemoveVolatile with their <type_traits> alternatives. But when those are also replaced, I'll handle IsSame here, too, for the sake of completeness.

Summary: Replace assorted TypeTraits with <type_traits> alternatives → Replace most TypeTraits with <type_traits> alternatives

Also adds missing includes in some files, these were previously only transivitely
included through mozilla/TypeTraits.h.

Depends on D68560

Pushed by dvarga@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/733dde3fe35b Part 1: Replace mozilla::MakeSigned with std::make_signed. r=froydnj https://hg.mozilla.org/integration/autoland/rev/112b7ff16977 Part 2: Replace mozilla::AddLvalueReference with std::add_lvalue_reference. r=froydnj https://hg.mozilla.org/integration/autoland/rev/f1c42129fb0b Part 3: Replace mozilla::IsEmpty with std::is_empty. r=froydnj https://hg.mozilla.org/integration/autoland/rev/54f1de92d76e Part 4: Replace mozilla::MakeUnsigned with std::make_unsigned. r=froydnj https://hg.mozilla.org/integration/autoland/rev/847189efca00 Part 5: Replace mozilla::IsDefaultConstructible with std::is_default_constructible. r=froydnj https://hg.mozilla.org/integration/autoland/rev/ae96b293b960 Part 6: Replace mozilla::IsClass with std::is_class. r=froydnj https://hg.mozilla.org/integration/autoland/rev/a68131de6bea Part 7: Replace mozilla::IsScalar with std::is_scalar. r=froydnj https://hg.mozilla.org/integration/autoland/rev/463d286fcce9 Part 8: Replace mozilla::IsMemberPointer with std::is_member_pointer. r=froydnj https://hg.mozilla.org/integration/autoland/rev/14d9ef35878e Part 9: Replace mozilla::IsArithmetic with std::is_arithmetic. r=froydnj https://hg.mozilla.org/integration/autoland/rev/9156b33cd5ef Part 10: Replace mozilla::IsEnum with std::is_enum. r=froydnj https://hg.mozilla.org/integration/autoland/rev/f53bdabacea4 Part 11: Replace mozilla::IsConst with std::is_const. r=froydnj https://hg.mozilla.org/integration/autoland/rev/ca9941c7dc19 Part 12: Replace mozilla::IsPointer with std::is_pointer. r=froydnj https://hg.mozilla.org/integration/autoland/rev/4dd33e11fc70 Part 13: Replace mozilla::IsUnsigned with std::is_unsigned. r=froydnj https://hg.mozilla.org/integration/autoland/rev/05ebb33de1f9 Part 14: Replace mozilla::IsSigned with std::is_signed. r=froydnj https://hg.mozilla.org/integration/autoland/rev/83a01c8c31c7 Part 15: Replace mozilla::IsFloatingPoint with std::is_floating_point. r=froydnj https://hg.mozilla.org/integration/autoland/rev/8bbf59d19fa0 Part 16: Replace mozilla::IsIntegral with std::is_integral. r=froydnj https://hg.mozilla.org/integration/autoland/rev/1717b0704c0e Part 17: Replace mozilla::Decay with std::decay. r=froydnj https://hg.mozilla.org/integration/autoland/rev/c69047027239 Part 18: Replace mozilla::AddPointer with std::add_pointer. r=froydnj https://hg.mozilla.org/integration/autoland/rev/075f2316d9dd Part 19: Replace mozilla::RemoveExtent with std::remove_extent. r=froydnj https://hg.mozilla.org/integration/autoland/rev/fe17133c853f Part 20: Replace mozilla::IsVolatile with std::is_volatile. r=froydnj https://hg.mozilla.org/integration/autoland/rev/71ed5558e930 Part 21: Replace mozilla::IsFunction with std::is_function. r=froydnj https://hg.mozilla.org/integration/autoland/rev/ba1a4349471c Part 22: Replace mozilla::IsArray with std::is_array. r=froydnj https://hg.mozilla.org/integration/autoland/rev/056c1df81242 Part 23: Replace mozilla::RemovePointer with std::remove_pointer. r=froydnj https://hg.mozilla.org/integration/autoland/rev/d9345db452b3 Part 24: Replace mozilla::IsConvertible with std::is_convertible. r=froydnj https://hg.mozilla.org/integration/autoland/rev/1b923628c0e3 Part 25: Replace mozilla::RemoveReference with std::remove_reference. r=froydnj,jgilbert https://hg.mozilla.org/integration/autoland/rev/c12439823ae9 Part 26: Replace mozilla::Conditional with std::conditional. r=froydnj https://hg.mozilla.org/integration/autoland/rev/79be64101af3 Part 27: Replace mozilla::DeclVal with std::declval. r=froydnj https://hg.mozilla.org/integration/autoland/rev/f7c195e843e1 Part 28: Replace mozilla::AddRvalueReference with std::add_rvalue_reference. r=froydnj https://hg.mozilla.org/integration/autoland/rev/d62b8cbbb055 Part 30: Replace mozilla::RemoveCV with std::remove_cv. r=froydnj,jgilbert https://hg.mozilla.org/integration/autoland/rev/323db95684b7 Part 29: Replace mozilla::IsVoid with std::is_void. r=froydnj https://hg.mozilla.org/integration/autoland/rev/10643b2c4d6b Part 31: Replace mozilla::RemoveVolatile with std::remove_volatile. r=froydnj https://hg.mozilla.org/integration/autoland/rev/8e597f5deb77 Part 32: Replace mozilla::RemoveConst with std::remove_const. r=froydnj https://hg.mozilla.org/integration/autoland/rev/53733a2a5f06 Part 33: Replace mozilla::IntegralConstant with std::integral_constant. r=froydnj https://hg.mozilla.org/integration/autoland/rev/215f8c06c6d7 Part 34: Replace mozilla::FalseType with std::false_type. r=froydnj https://hg.mozilla.org/integration/autoland/rev/d1c40df1a74b Part 35: Replace mozilla::TrueType with std::true_type. r=froydnj,jgilbert https://hg.mozilla.org/integration/autoland/rev/a62dff0a7b04 Part 36: Replace mozilla::IsSame with std::is_same in mfbt/. r=froydnj https://hg.mozilla.org/integration/autoland/rev/3c82c7e7eb60 Part 37: Replace mozilla::IsSame with std::is_same in xpcom/. r=froydnj https://hg.mozilla.org/integration/autoland/rev/85b79a5f1f0b Part 38: Replace mozilla::IsSame with std::is_same in dom/. r=froydnj https://hg.mozilla.org/integration/autoland/rev/cbee2c2ada09 Part 39: Replace mozilla::IsSame with std::is_same in gfx/. r=froydnj https://hg.mozilla.org/integration/autoland/rev/43badf8b568e Part 40: Replace remaining mozilla::IsSame with std::is_same. r=froydnj https://hg.mozilla.org/integration/autoland/rev/29693da8f958 Part 41: Remove no longer needed includes for mozilla/TypeTraits. r=froydnj

https://hg.mozilla.org/mozilla-central/rev/733dde3fe35b
https://hg.mozilla.org/mozilla-central/rev/112b7ff16977
https://hg.mozilla.org/mozilla-central/rev/f1c42129fb0b
https://hg.mozilla.org/mozilla-central/rev/54f1de92d76e
https://hg.mozilla.org/mozilla-central/rev/847189efca00
https://hg.mozilla.org/mozilla-central/rev/ae96b293b960
https://hg.mozilla.org/mozilla-central/rev/a68131de6bea
https://hg.mozilla.org/mozilla-central/rev/463d286fcce9
https://hg.mozilla.org/mozilla-central/rev/14d9ef35878e
https://hg.mozilla.org/mozilla-central/rev/9156b33cd5ef
https://hg.mozilla.org/mozilla-central/rev/f53bdabacea4
https://hg.mozilla.org/mozilla-central/rev/ca9941c7dc19
https://hg.mozilla.org/mozilla-central/rev/4dd33e11fc70
https://hg.mozilla.org/mozilla-central/rev/05ebb33de1f9
https://hg.mozilla.org/mozilla-central/rev/83a01c8c31c7
https://hg.mozilla.org/mozilla-central/rev/8bbf59d19fa0
https://hg.mozilla.org/mozilla-central/rev/1717b0704c0e
https://hg.mozilla.org/mozilla-central/rev/c69047027239
https://hg.mozilla.org/mozilla-central/rev/075f2316d9dd
https://hg.mozilla.org/mozilla-central/rev/fe17133c853f
https://hg.mozilla.org/mozilla-central/rev/71ed5558e930
https://hg.mozilla.org/mozilla-central/rev/ba1a4349471c
https://hg.mozilla.org/mozilla-central/rev/056c1df81242
https://hg.mozilla.org/mozilla-central/rev/d9345db452b3
https://hg.mozilla.org/mozilla-central/rev/1b923628c0e3
https://hg.mozilla.org/mozilla-central/rev/c12439823ae9
https://hg.mozilla.org/mozilla-central/rev/79be64101af3
https://hg.mozilla.org/mozilla-central/rev/f7c195e843e1
https://hg.mozilla.org/mozilla-central/rev/d62b8cbbb055
https://hg.mozilla.org/mozilla-central/rev/323db95684b7
https://hg.mozilla.org/mozilla-central/rev/10643b2c4d6b
https://hg.mozilla.org/mozilla-central/rev/8e597f5deb77
https://hg.mozilla.org/mozilla-central/rev/53733a2a5f06
https://hg.mozilla.org/mozilla-central/rev/215f8c06c6d7
https://hg.mozilla.org/mozilla-central/rev/d1c40df1a74b
https://hg.mozilla.org/mozilla-central/rev/a62dff0a7b04
https://hg.mozilla.org/mozilla-central/rev/3c82c7e7eb60
https://hg.mozilla.org/mozilla-central/rev/85b79a5f1f0b
https://hg.mozilla.org/mozilla-central/rev/cbee2c2ada09
https://hg.mozilla.org/mozilla-central/rev/43badf8b568e
https://hg.mozilla.org/mozilla-central/rev/29693da8f958

Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla76

Thank you for doing this, anba!

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: