[libcxx] r305292 - Fix bug 33389 - __is_transparent check requires too much

Marshall Clow via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 13 07:34:58 PDT 2017


Author: marshall
Date: Tue Jun 13 09:34:58 2017
New Revision: 305292

URL: http://llvm.org/viewvc/llvm-project?rev=305292&view=rev
Log:
Fix bug 33389 - __is_transparent check requires too much

Modified:
    libcxx/trunk/include/__functional_base
    libcxx/trunk/test/std/containers/associative/map/map.ops/count0.pass.cpp
    libcxx/trunk/test/std/containers/associative/map/map.ops/equal_range0.pass.cpp
    libcxx/trunk/test/std/containers/associative/map/map.ops/find0.pass.cpp
    libcxx/trunk/test/std/containers/associative/map/map.ops/lower_bound0.pass.cpp
    libcxx/trunk/test/std/containers/associative/map/map.ops/upper_bound0.pass.cpp
    libcxx/trunk/test/std/containers/associative/multimap/multimap.ops/count0.pass.cpp
    libcxx/trunk/test/std/containers/associative/multimap/multimap.ops/equal_range0.pass.cpp
    libcxx/trunk/test/std/containers/associative/multimap/multimap.ops/find0.pass.cpp
    libcxx/trunk/test/std/containers/associative/multimap/multimap.ops/lower_bound0.pass.cpp
    libcxx/trunk/test/std/containers/associative/multimap/multimap.ops/upper_bound0.pass.cpp
    libcxx/trunk/test/support/is_transparent.h

Modified: libcxx/trunk/include/__functional_base
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__functional_base?rev=305292&r1=305291&r2=305292&view=diff
==============================================================================
--- libcxx/trunk/include/__functional_base (original)
+++ libcxx/trunk/include/__functional_base Tue Jun 13 09:34:58 2017
@@ -548,16 +548,13 @@ template <class _Tp> void cref(const _Tp
 #endif
 
 #if _LIBCPP_STD_VER > 11
-template <class _Tp1, class _Tp2 = void>
-struct __is_transparent
-{
-private:
-    struct __two {char __lx; char __lxx;};
-    template <class _Up> static __two __test(...);
-    template <class _Up> static char __test(typename _Up::is_transparent* = 0);
-public:
-    static const bool value = sizeof(__test<_Tp1>(0)) == 1;
-};
+template <class _Tp, class, class = void>
+struct __is_transparent : false_type {};
+
+template <class _Tp, class _Up>
+struct __is_transparent<_Tp, _Up,  
+                        typename __void_t<typename _Tp::is_transparent>::type>
+   : true_type {};
 #endif
 
 // allocator_arg_t

Modified: libcxx/trunk/test/std/containers/associative/map/map.ops/count0.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/map/map.ops/count0.pass.cpp?rev=305292&r1=305291&r2=305292&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/associative/map/map.ops/count0.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/associative/map/map.ops/count0.pass.cpp Tue Jun 13 09:34:58 2017
@@ -28,7 +28,12 @@
 
 int main()
 {
+    {
     typedef std::map<int, double, transparent_less> M;
-
     M().count(C2Int{5});
+    }
+    {
+    typedef std::map<int, double, transparent_less_not_referenceable> M;
+    M().count(C2Int{5});
+    }
 }

Modified: libcxx/trunk/test/std/containers/associative/map/map.ops/equal_range0.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/map/map.ops/equal_range0.pass.cpp?rev=305292&r1=305291&r2=305292&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/associative/map/map.ops/equal_range0.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/associative/map/map.ops/equal_range0.pass.cpp Tue Jun 13 09:34:58 2017
@@ -28,7 +28,12 @@
 
 int main()
 {
+    {
     typedef std::map<int, double, transparent_less> M;
-
     M().equal_range(C2Int{5});
+    }
+    {
+    typedef std::map<int, double, transparent_less_not_referenceable> M;
+    M().equal_range(C2Int{5});
+    }
 }

Modified: libcxx/trunk/test/std/containers/associative/map/map.ops/find0.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/map/map.ops/find0.pass.cpp?rev=305292&r1=305291&r2=305292&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/associative/map/map.ops/find0.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/associative/map/map.ops/find0.pass.cpp Tue Jun 13 09:34:58 2017
@@ -28,7 +28,12 @@
 
 int main()
 {
+    {
     typedef std::map<int, double, transparent_less> M;
-
     M().find(C2Int{5});
+    }
+    {
+    typedef std::map<int, double, transparent_less_not_referenceable> M;
+    M().find(C2Int{5});
+    }
 }

Modified: libcxx/trunk/test/std/containers/associative/map/map.ops/lower_bound0.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/map/map.ops/lower_bound0.pass.cpp?rev=305292&r1=305291&r2=305292&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/associative/map/map.ops/lower_bound0.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/associative/map/map.ops/lower_bound0.pass.cpp Tue Jun 13 09:34:58 2017
@@ -28,7 +28,12 @@
 
 int main()
 {
+    {
     typedef std::map<int, double, transparent_less> M;
-
     M().lower_bound(C2Int{5});
+    }
+    {
+    typedef std::map<int, double, transparent_less_not_referenceable> M;
+    M().lower_bound(C2Int{5});
+    }
 }

Modified: libcxx/trunk/test/std/containers/associative/map/map.ops/upper_bound0.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/map/map.ops/upper_bound0.pass.cpp?rev=305292&r1=305291&r2=305292&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/associative/map/map.ops/upper_bound0.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/associative/map/map.ops/upper_bound0.pass.cpp Tue Jun 13 09:34:58 2017
@@ -28,7 +28,12 @@
 
 int main()
 {
+    {
     typedef std::map<int, double, transparent_less> M;
-
     M().upper_bound(C2Int{5});
+    }
+    {
+    typedef std::map<int, double, transparent_less_not_referenceable> M;
+    M().upper_bound(C2Int{5});
+    }
 }

Modified: libcxx/trunk/test/std/containers/associative/multimap/multimap.ops/count0.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multimap/multimap.ops/count0.pass.cpp?rev=305292&r1=305291&r2=305292&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/associative/multimap/multimap.ops/count0.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/associative/multimap/multimap.ops/count0.pass.cpp Tue Jun 13 09:34:58 2017
@@ -28,7 +28,12 @@
 
 int main()
 {
+    {
     typedef std::multimap<int, double, transparent_less> M;
-
     M().count(C2Int{5});
+    }
+    {
+    typedef std::multimap<int, double, transparent_less_not_referenceable> M;
+    M().count(C2Int{5});
+    }
 }

Modified: libcxx/trunk/test/std/containers/associative/multimap/multimap.ops/equal_range0.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multimap/multimap.ops/equal_range0.pass.cpp?rev=305292&r1=305291&r2=305292&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/associative/multimap/multimap.ops/equal_range0.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/associative/multimap/multimap.ops/equal_range0.pass.cpp Tue Jun 13 09:34:58 2017
@@ -28,7 +28,12 @@
 
 int main()
 {
+    {
     typedef std::multimap<int, double, transparent_less> M;
-
     M().equal_range(C2Int{5});
+    }
+    {
+    typedef std::multimap<int, double, transparent_less_not_referenceable> M;
+    M().equal_range(C2Int{5});
+    }
 }

Modified: libcxx/trunk/test/std/containers/associative/multimap/multimap.ops/find0.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multimap/multimap.ops/find0.pass.cpp?rev=305292&r1=305291&r2=305292&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/associative/multimap/multimap.ops/find0.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/associative/multimap/multimap.ops/find0.pass.cpp Tue Jun 13 09:34:58 2017
@@ -28,7 +28,12 @@
 
 int main()
 {
+    {
     typedef std::multimap<int, double, transparent_less> M;
-
     M().find(C2Int{5});
+    }
+    {
+    typedef std::multimap<int, double, transparent_less_not_referenceable> M;
+    M().find(C2Int{5});
+    }
 }

Modified: libcxx/trunk/test/std/containers/associative/multimap/multimap.ops/lower_bound0.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multimap/multimap.ops/lower_bound0.pass.cpp?rev=305292&r1=305291&r2=305292&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/associative/multimap/multimap.ops/lower_bound0.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/associative/multimap/multimap.ops/lower_bound0.pass.cpp Tue Jun 13 09:34:58 2017
@@ -28,7 +28,12 @@
 
 int main()
 {
+    {
     typedef std::multimap<int, double, transparent_less> M;
-
     M().lower_bound(C2Int{5});
+    }
+    {
+    typedef std::multimap<int, double, transparent_less_not_referenceable> M;
+    M().lower_bound(C2Int{5});
+    }
 }

Modified: libcxx/trunk/test/std/containers/associative/multimap/multimap.ops/upper_bound0.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multimap/multimap.ops/upper_bound0.pass.cpp?rev=305292&r1=305291&r2=305292&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/associative/multimap/multimap.ops/upper_bound0.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/associative/multimap/multimap.ops/upper_bound0.pass.cpp Tue Jun 13 09:34:58 2017
@@ -28,7 +28,12 @@
 
 int main()
 {
+    {
     typedef std::multimap<int, double, transparent_less> M;
-
     M().upper_bound(C2Int{5});
+    }
+    {
+    typedef std::multimap<int, double, transparent_less_not_referenceable> M;
+    M().upper_bound(C2Int{5});
+    }
 }

Modified: libcxx/trunk/test/support/is_transparent.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/is_transparent.h?rev=305292&r1=305291&r2=305292&view=diff
==============================================================================
--- libcxx/trunk/test/support/is_transparent.h (original)
+++ libcxx/trunk/test/support/is_transparent.h Tue Jun 13 09:34:58 2017
@@ -22,7 +22,17 @@ struct transparent_less
     noexcept(noexcept(std::forward<T>(t) < std::forward<U>(u)))
     -> decltype      (std::forward<T>(t) < std::forward<U>(u))
         { return      std::forward<T>(t) < std::forward<U>(u); }
-    typedef void is_transparent;  // correct
+    using is_transparent = void;  // correct
+};
+
+struct transparent_less_not_referenceable
+{
+    template <class T, class U>
+    constexpr auto operator()(T&& t, U&& u) const
+    noexcept(noexcept(std::forward<T>(t) < std::forward<U>(u)))
+    -> decltype      (std::forward<T>(t) < std::forward<U>(u))
+        { return      std::forward<T>(t) < std::forward<U>(u); }
+    using is_transparent = void () const &;  // it's a type; a weird one, but a type
 };
 
 struct transparent_less_no_type
@@ -33,7 +43,7 @@ struct transparent_less_no_type
     -> decltype      (std::forward<T>(t) < std::forward<U>(u))
         { return      std::forward<T>(t) < std::forward<U>(u); }
 private:
-//    typedef void is_transparent;  // error - should exist
+//    using is_transparent = void;  // error - should exist
 };
 
 struct transparent_less_private
@@ -44,7 +54,7 @@ struct transparent_less_private
     -> decltype      (std::forward<T>(t) < std::forward<U>(u))
         { return      std::forward<T>(t) < std::forward<U>(u); }
 private:
-    typedef void is_transparent;  // error - should be accessible
+    using is_transparent = void;  // error - should be accessible
 };
 
 struct transparent_less_not_a_type




More information about the cfe-commits mailing list