[clang] [CUDA][HIP] Fix std::is_invocable (PR #70369)

Yaxun Liu via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 26 17:53:20 PDT 2023


================
@@ -283,12 +283,18 @@ set(cuda_wrapper_files
   cuda_wrappers/cmath
   cuda_wrappers/complex
   cuda_wrappers/new
+  cuda_wrappers/type_traits
 )
 
 set(cuda_wrapper_bits_files
   cuda_wrappers/bits/shared_ptr_base.h
   cuda_wrappers/bits/basic_string.h
   cuda_wrappers/bits/basic_string.tcc
+  cuda_wrappers/bits/move.h
+)
+
+set(cuda_wrapper_utility_files
+  cuda_wrappers/__utility/swap.h
----------------
yxsamliu wrote:

> If we need to wrap them because they may be included before `<type_traits>`, then we must apply the same approach to all headers transitively included by `<type_traits>`. Otherwise we'd risk including them with/without `force_cuda_host_device` applied to them depending on whether they get included before or after type_traits.

You are right. For libstdc++, <type_traits> include the following headers:

. /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/type_traits
.. /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/x86_64-linux-gnu/c++/12/bits/c++config.h
... /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/x86_64-linux-gnu/c++/12/bits/os_defines.h
.... /usr/include/features.h
..... /usr/include/features-time64.h
...... /usr/include/x86_64-linux-gnu/bits/wordsize.h
...... /usr/include/x86_64-linux-gnu/bits/timesize.h
....... /usr/include/x86_64-linux-gnu/bits/wordsize.h
..... /usr/include/stdc-predef.h
..... /usr/include/x86_64-linux-gnu/sys/cdefs.h
...... /usr/include/x86_64-linux-gnu/bits/wordsize.h
...... /usr/include/x86_64-linux-gnu/bits/long-double.h
..... /usr/include/x86_64-linux-gnu/gnu/stubs.h
...... /usr/include/x86_64-linux-gnu/gnu/stubs-64.h
... /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/x86_64-linux-gnu/c++/12/bits/cpu_defines.h
... /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/pstl/pstl_config.h

Only bits/c++config.h needs to be wrapped. All others are macros.

For libc++, <type_traits> includes the following headers:

. /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/type_traits
.. /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/x86_64-linux-gnu/c++/12/bits/c++config.h
... /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/x86_64-linux-gnu/c++/12/bits/os_defines.h
.... /usr/include/features.h
..... /usr/include/features-time64.h
...... /usr/include/x86_64-linux-gnu/bits/wordsize.h
...... /usr/include/x86_64-linux-gnu/bits/timesize.h
....... /usr/include/x86_64-linux-gnu/bits/wordsize.h
..... /usr/include/stdc-predef.h
..... /usr/include/x86_64-linux-gnu/sys/cdefs.h
...... /usr/include/x86_64-linux-gnu/bits/wordsize.h
...... /usr/include/x86_64-linux-gnu/bits/long-double.h
..... /usr/include/x86_64-linux-gnu/gnu/stubs.h
...... /usr/include/x86_64-linux-gnu/gnu/stubs-64.h
... /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/x86_64-linux-gnu/c++/12/bits/cpu_defines.h
... /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/pstl/pstl_config.h
yaxunl at budlnx6:~/git/llvm2/assert$ bin/clang -stdlib=libc++ -c a.cpp -H
. /usr/include/c++/v1/type_traits
.. /usr/include/c++/v1/__assert
... /usr/include/c++/v1/__config
.... /usr/include/c++/v1/__config_site
.... /usr/include/features.h
..... /usr/include/features-time64.h
...... /usr/include/x86_64-linux-gnu/bits/wordsize.h
...... /usr/include/x86_64-linux-gnu/bits/timesize.h
....... /usr/include/x86_64-linux-gnu/bits/wordsize.h
..... /usr/include/stdc-predef.h
..... /usr/include/x86_64-linux-gnu/sys/cdefs.h
...... /usr/include/x86_64-linux-gnu/bits/wordsize.h
...... /usr/include/x86_64-linux-gnu/bits/long-double.h
..... /usr/include/x86_64-linux-gnu/gnu/stubs.h
...... /usr/include/x86_64-linux-gnu/gnu/stubs-64.h
... /usr/include/c++/v1/__verbose_abort
.... /usr/include/c++/v1/__availability
.. /usr/include/c++/v1/__functional/invoke.h
... /usr/include/c++/v1/__type_traits/add_lvalue_reference.h
.... /usr/include/c++/v1/__type_traits/is_referenceable.h
..... /usr/include/c++/v1/__type_traits/integral_constant.h
..... /usr/include/c++/v1/__type_traits/is_same.h
... /usr/include/c++/v1/__type_traits/apply_cv.h
.... /usr/include/c++/v1/__type_traits/is_const.h
.... /usr/include/c++/v1/__type_traits/is_volatile.h
.... /usr/include/c++/v1/__type_traits/remove_reference.h
..... /usr/include/c++/v1/cstddef
...... /usr/include/c++/v1/__type_traits/enable_if.h
...... /usr/include/c++/v1/__type_traits/is_integral.h
....... /usr/include/c++/v1/__type_traits/remove_cv.h
........ /usr/include/c++/v1/__type_traits/remove_const.h
........ /usr/include/c++/v1/__type_traits/remove_volatile.h
...... /usr/include/c++/v1/stddef.h
....... /home/yaxunl/git/llvm2/assert/lib/clang/18/include/stddef.h
........ /home/yaxunl/git/llvm2/assert/lib/clang/18/include/__stddef_ptrdiff_t.h
........ /home/yaxunl/git/llvm2/assert/lib/clang/18/include/__stddef_size_t.h
........ /home/yaxunl/git/llvm2/assert/lib/clang/18/include/__stddef_wchar_t.h
........ /home/yaxunl/git/llvm2/assert/lib/clang/18/include/__stddef_null.h
........ /home/yaxunl/git/llvm2/assert/lib/clang/18/include/__stddef_nullptr_t.h
........ /home/yaxunl/git/llvm2/assert/lib/clang/18/include/__stddef_max_align_t.h
........ /home/yaxunl/git/llvm2/assert/lib/clang/18/include/__stddef_offsetof.h
...... /usr/include/c++/v1/version
... /usr/include/c++/v1/__type_traits/conditional.h
... /usr/include/c++/v1/__type_traits/decay.h
.... /usr/include/c++/v1/__type_traits/add_pointer.h
.... /usr/include/c++/v1/__type_traits/is_array.h
.... /usr/include/c++/v1/__type_traits/is_function.h
..... /usr/include/c++/v1/__type_traits/is_reference.h
.... /usr/include/c++/v1/__type_traits/remove_extent.h
... /usr/include/c++/v1/__type_traits/is_base_of.h
... /usr/include/c++/v1/__type_traits/is_core_convertible.h
... /usr/include/c++/v1/__type_traits/is_member_function_pointer.h
... /usr/include/c++/v1/__type_traits/is_member_object_pointer.h
... /usr/include/c++/v1/__type_traits/is_reference_wrapper.h
... /usr/include/c++/v1/__type_traits/is_void.h
... /usr/include/c++/v1/__type_traits/nat.h
... /usr/include/c++/v1/__utility/declval.h
... /usr/include/c++/v1/__utility/forward.h
.. /usr/include/c++/v1/__type_traits/add_const.h
.. /usr/include/c++/v1/__type_traits/add_cv.h
.. /usr/include/c++/v1/__type_traits/add_rvalue_reference.h
.. /usr/include/c++/v1/__type_traits/add_volatile.h
.. /usr/include/c++/v1/__type_traits/aligned_storage.h
... /usr/include/c++/v1/__type_traits/type_list.h
.. /usr/include/c++/v1/__type_traits/aligned_union.h
.. /usr/include/c++/v1/__type_traits/alignment_of.h
.. /usr/include/c++/v1/__type_traits/common_reference.h
... /usr/include/c++/v1/__type_traits/common_type.h
.... /usr/include/c++/v1/__type_traits/remove_cvref.h
.... /usr/include/c++/v1/__type_traits/void_t.h
... /usr/include/c++/v1/__type_traits/copy_cv.h
... /usr/include/c++/v1/__type_traits/copy_cvref.h
... /usr/include/c++/v1/__type_traits/is_convertible.h
.. /usr/include/c++/v1/__type_traits/conjunction.h
.. /usr/include/c++/v1/__type_traits/disjunction.h
.. /usr/include/c++/v1/__type_traits/extent.h
.. /usr/include/c++/v1/__type_traits/has_unique_object_representation.h
... /usr/include/c++/v1/__type_traits/remove_all_extents.h
.. /usr/include/c++/v1/__type_traits/has_virtual_destructor.h
.. /usr/include/c++/v1/__type_traits/is_abstract.h
.. /usr/include/c++/v1/__type_traits/is_aggregate.h
.. /usr/include/c++/v1/__type_traits/is_arithmetic.h
... /usr/include/c++/v1/__type_traits/is_floating_point.h
.. /usr/include/c++/v1/__type_traits/is_assignable.h
.. /usr/include/c++/v1/__type_traits/is_bounded_array.h
.. /usr/include/c++/v1/__type_traits/is_callable.h
.. /usr/include/c++/v1/__type_traits/is_class.h
... /usr/include/c++/v1/__type_traits/is_union.h
.. /usr/include/c++/v1/__type_traits/is_compound.h
... /usr/include/c++/v1/__type_traits/is_fundamental.h
.... /usr/include/c++/v1/__type_traits/is_null_pointer.h
.. /usr/include/c++/v1/__type_traits/is_constant_evaluated.h
.. /usr/include/c++/v1/__type_traits/is_constructible.h
.. /usr/include/c++/v1/__type_traits/is_copy_assignable.h
.. /usr/include/c++/v1/__type_traits/is_copy_constructible.h
.. /usr/include/c++/v1/__type_traits/is_default_constructible.h
.. /usr/include/c++/v1/__type_traits/is_destructible.h
.. /usr/include/c++/v1/__type_traits/is_empty.h
.. /usr/include/c++/v1/__type_traits/is_enum.h
.. /usr/include/c++/v1/__type_traits/is_final.h
.. /usr/include/c++/v1/__type_traits/is_literal_type.h
.. /usr/include/c++/v1/__type_traits/is_member_pointer.h
.. /usr/include/c++/v1/__type_traits/is_move_assignable.h
.. /usr/include/c++/v1/__type_traits/is_move_constructible.h
.. /usr/include/c++/v1/__type_traits/is_nothrow_assignable.h
.. /usr/include/c++/v1/__type_traits/is_nothrow_constructible.h
.. /usr/include/c++/v1/__type_traits/is_nothrow_convertible.h
... /usr/include/c++/v1/__type_traits/lazy.h
.. /usr/include/c++/v1/__type_traits/is_nothrow_copy_assignable.h
.. /usr/include/c++/v1/__type_traits/is_nothrow_copy_constructible.h
.. /usr/include/c++/v1/__type_traits/is_nothrow_default_constructible.h
.. /usr/include/c++/v1/__type_traits/is_nothrow_destructible.h
... /usr/include/c++/v1/__type_traits/is_scalar.h
.... /usr/include/c++/v1/__type_traits/is_pointer.h
.. /usr/include/c++/v1/__type_traits/is_nothrow_move_assignable.h
.. /usr/include/c++/v1/__type_traits/is_nothrow_move_constructible.h
.. /usr/include/c++/v1/__type_traits/is_object.h
.. /usr/include/c++/v1/__type_traits/is_pod.h
.. /usr/include/c++/v1/__type_traits/is_polymorphic.h
.. /usr/include/c++/v1/__type_traits/is_scoped_enum.h
... /usr/include/c++/v1/__type_traits/underlying_type.h
.. /usr/include/c++/v1/__type_traits/is_signed.h
.. /usr/include/c++/v1/__type_traits/is_standard_layout.h
.. /usr/include/c++/v1/__type_traits/is_trivial.h
.. /usr/include/c++/v1/__type_traits/is_trivially_assignable.h
.. /usr/include/c++/v1/__type_traits/is_trivially_constructible.h
.. /usr/include/c++/v1/__type_traits/is_trivially_copy_assignable.h
.. /usr/include/c++/v1/__type_traits/is_trivially_copy_constructible.h
.. /usr/include/c++/v1/__type_traits/is_trivially_copyable.h
.. /usr/include/c++/v1/__type_traits/is_trivially_default_constructible.h
.. /usr/include/c++/v1/__type_traits/is_trivially_destructible.h
.. /usr/include/c++/v1/__type_traits/is_trivially_move_assignable.h
.. /usr/include/c++/v1/__type_traits/is_trivially_move_constructible.h
.. /usr/include/c++/v1/__type_traits/is_unbounded_array.h
.. /usr/include/c++/v1/__type_traits/is_unsigned.h
.. /usr/include/c++/v1/__type_traits/make_signed.h
.. /usr/include/c++/v1/__type_traits/make_unsigned.h
.. /usr/include/c++/v1/__type_traits/negation.h
.. /usr/include/c++/v1/__type_traits/rank.h
.. /usr/include/c++/v1/__type_traits/remove_pointer.h
.. /usr/include/c++/v1/__type_traits/type_identity.h
.. /usr/include/c++/v1/cstdint
... /usr/include/c++/v1/stdint.h
.... /home/yaxunl/git/llvm2/assert/lib/clang/18/include/stdint.h
..... /usr/include/stdint.h
...... /usr/include/x86_64-linux-gnu/bits/libc-header-start.h
...... /usr/include/x86_64-linux-gnu/bits/types.h
....... /usr/include/x86_64-linux-gnu/bits/wordsize.h
....... /usr/include/x86_64-linux-gnu/bits/timesize.h
........ /usr/include/x86_64-linux-gnu/bits/wordsize.h
....... /usr/include/x86_64-linux-gnu/bits/typesizes.h
....... /usr/include/x86_64-linux-gnu/bits/time64.h
...... /usr/include/x86_64-linux-gnu/bits/wchar.h
...... /usr/include/x86_64-linux-gnu/bits/wordsize.h
...... /usr/include/x86_64-linux-gnu/bits/stdint-intn.h
...... /usr/include/x86_64-linux-gnu/bits/stdint-uintn.h

Only `__verbose_abort` needs to be wrapped.

https://github.com/llvm/llvm-project/pull/70369


More information about the cfe-commits mailing list