[libcxx-commits] [libcxx] e137fb6 - [clang][libcxx] renames `__remove_reference`

Christopher Di Bella via libcxx-commits libcxx-commits at lists.llvm.org
Mon Aug 22 16:16:17 PDT 2022


Author: Christopher Di Bella
Date: 2022-08-22T23:15:10Z
New Revision: e137fb6fb85b41978814e64eae652d05688bcca5

URL: https://github.com/llvm/llvm-project/commit/e137fb6fb85b41978814e64eae652d05688bcca5
DIFF: https://github.com/llvm/llvm-project/commit/e137fb6fb85b41978814e64eae652d05688bcca5.diff

LOG: [clang][libcxx] renames `__remove_reference`

libc++ prior to LLVM 15 has a bug in it due to it excluding
`remove_reference_t` when `__remove_reference` is available as a
compiler built-in. This went unnoticed until D116203 because it wasn't
available in any compiler.

To work around this, we're renaming `__remove_reference` to
`__remove_reference_t`.

TEST=Tested locally, tested using emscripten

Added: 
    

Modified: 
    clang/include/clang/Basic/TransformTypeTraits.def
    clang/test/CodeGenCXX/mangle.cpp
    clang/test/SemaCXX/libstdcxx_transform_type_traits_hack.cpp
    clang/test/SemaCXX/type-traits.cpp
    libcxx/include/__type_traits/remove_reference.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/TransformTypeTraits.def b/clang/include/clang/Basic/TransformTypeTraits.def
index 9389effc6d835..e27a2719a9680 100644
--- a/clang/include/clang/Basic/TransformTypeTraits.def
+++ b/clang/include/clang/Basic/TransformTypeTraits.def
@@ -22,7 +22,7 @@ TRANSFORM_TYPE_TRAIT_DEF(RemoveCV, remove_cv)
 TRANSFORM_TYPE_TRAIT_DEF(RemoveCVRef, remove_cvref)
 TRANSFORM_TYPE_TRAIT_DEF(RemoveExtent, remove_extent)
 TRANSFORM_TYPE_TRAIT_DEF(RemovePointer, remove_pointer)
-TRANSFORM_TYPE_TRAIT_DEF(RemoveReference, remove_reference)
+TRANSFORM_TYPE_TRAIT_DEF(RemoveReference, remove_reference_t)
 TRANSFORM_TYPE_TRAIT_DEF(RemoveRestrict, remove_restrict)
 TRANSFORM_TYPE_TRAIT_DEF(RemoveVolatile, remove_volatile)
 TRANSFORM_TYPE_TRAIT_DEF(EnumUnderlyingType, underlying_type)

diff  --git a/clang/test/CodeGenCXX/mangle.cpp b/clang/test/CodeGenCXX/mangle.cpp
index 708b492a2ebed..84315591a4977 100644
--- a/clang/test/CodeGenCXX/mangle.cpp
+++ b/clang/test/CodeGenCXX/mangle.cpp
@@ -1163,9 +1163,9 @@ template <typename T> void f14(T, __remove_pointer(T)) {}
 template void f14<int>(int, __remove_pointer(int));
 // CHECK-LABEL: @_ZN6test553f14IiEEvT_u16__remove_pointerIS1_E
 
-template <typename T> void f15(T, __remove_reference(T)) {}
-template void f15<int>(int, __remove_reference(int));
-// CHECK-LABEL: @_ZN6test553f15IiEEvT_u18__remove_referenceIS1_E
+template <typename T> void f15(T, __remove_reference_t(T)) {}
+template void f15<int>(int, __remove_reference_t(int));
+// CHECK-LABEL: @_ZN6test553f15IiEEvT_u20__remove_reference_tIS1_E
 
 template <typename T> void f16(T, __remove_volatile(T)) {}
 template void f16<int>(int, __remove_volatile(int));

diff  --git a/clang/test/SemaCXX/libstdcxx_transform_type_traits_hack.cpp b/clang/test/SemaCXX/libstdcxx_transform_type_traits_hack.cpp
index 5032c3ad00e4d..fc38b424fc242 100644
--- a/clang/test/SemaCXX/libstdcxx_transform_type_traits_hack.cpp
+++ b/clang/test/SemaCXX/libstdcxx_transform_type_traits_hack.cpp
@@ -49,9 +49,9 @@ template <class T>
 using H = Same<__add_rvalue_reference<T>, __add_rvalue_reference<T>>;
 
 template <class T>
-using __remove_reference = int; // expected-warning{{keyword '__remove_reference' will be made available as an identifier here}}
+using __remove_reference_t = int; // expected-warning{{keyword '__remove_reference_t' will be made available as an identifier here}}
 template <class T>
-using I = Same<__remove_reference<T>, __remove_reference<T>>;
+using I = Same<__remove_reference_t<T>, __remove_reference_t<T>>;
 
 template <class T>
 using __remove_cvref = int; // expected-warning{{keyword '__remove_cvref' will be made available as an identifier here}}

diff  --git a/clang/test/SemaCXX/type-traits.cpp b/clang/test/SemaCXX/type-traits.cpp
index f54ae0eb2c578..ab2a9f74090a4 100644
--- a/clang/test/SemaCXX/type-traits.cpp
+++ b/clang/test/SemaCXX/type-traits.cpp
@@ -3157,7 +3157,7 @@ void add_rvalue_reference() {
   static_assert(__is_same(add_rvalue_reference_t<int (S::*)()>, int(S::* &&)()), "");
 }
 
-template <class T> using remove_reference_t = __remove_reference(T);
+template <class T> using remove_reference_t = __remove_reference_t(T);
 
 void check_remove_reference() {
   static_assert(__is_same(remove_reference_t<void>, void), "");

diff  --git a/libcxx/include/__type_traits/remove_reference.h b/libcxx/include/__type_traits/remove_reference.h
index 7ea7fa52ecc59..023b36cbc2cf6 100644
--- a/libcxx/include/__type_traits/remove_reference.h
+++ b/libcxx/include/__type_traits/remove_reference.h
@@ -18,16 +18,16 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if __has_builtin(__remove_reference)
+#if __has_builtin(__remove_reference_t)
 template <class _Tp>
 struct remove_reference {
-  using type _LIBCPP_NODEBUG = __remove_reference(_Tp);
+  using type _LIBCPP_NODEBUG = __remove_reference_t(_Tp);
 };
 #else
 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference        {typedef _LIBCPP_NODEBUG _Tp type;};
 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&>  {typedef _LIBCPP_NODEBUG _Tp type;};
 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _LIBCPP_NODEBUG _Tp type;};
-#endif // __has_builtin(__remove_reference)
+#endif // __has_builtin(__remove_reference_t)
 
 #if _LIBCPP_STD_VER > 11
 template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;


        


More information about the libcxx-commits mailing list