[libcxx-commits] [PATCH] D62719: A hot fix for exclusive_scan

Mikhail Dvorskiy via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jun 6 02:43:54 PDT 2019


MikeDvorskiy updated this revision to Diff 203313.
MikeDvorskiy edited the summary of this revision.
MikeDvorskiy added a comment.
Herald added a subscriber: mgorny.

Added a negative test for exclusive_scan algorithm. It checks non-participation the algo declare in overload resolution.


Repository:
  rPSTL pstl

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62719/new/

https://reviews.llvm.org/D62719

Files:
  include/pstl/internal/glue_numeric_defs.h
  include/pstl/internal/glue_numeric_impl.h
  test/CMakeLists.txt
  test/std/numerics/numeric.ops/scan.fail.cpp


Index: test/std/numerics/numeric.ops/scan.fail.cpp
===================================================================
--- /dev/null
+++ test/std/numerics/numeric.ops/scan.fail.cpp
@@ -0,0 +1,36 @@
+// -*- C++ -*-
+//===-- scan.pass.cpp -----------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include <execution>
+#include <numeric>
+
+class CustomPolicy {
+};
+
+template<typename PolicyType>
+typename std::enable_if<!std::is_execution_policy<PolicyType>::value, void>::type
+run_algo() {
+
+    CustomPolicy policy;
+    int *first = nullptr, *last=nullptr, *result = nullptr;
+
+    std::exclusive_scan(policy, first, last, result, 0);
+    std::exclusive_scan(policy, first, last, result, 0, std::plus<int>());
+}
+
+template<typename PolicyType>
+typename std::enable_if<std::is_execution_policy<PolicyType>::value, void>::type
+run_algo() {}
+
+int32_t
+main()
+{    
+    run_algo<CustomPolicy>();
+    return 0;
+}
Index: test/CMakeLists.txt
===================================================================
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -23,7 +23,7 @@
 target_link_libraries(test_stdlib INTERFACE pstl::ParallelSTL)
 target_compile_options(test_stdlib INTERFACE -Wno-gnu-include-next)
 
-file(GLOB_RECURSE UNIT_TESTS "*.pass.cpp")
+file(GLOB_RECURSE UNIT_TESTS "*.pass.cpp" "*.fail.cpp")
 foreach(_file IN LISTS UNIT_TESTS)
     file(RELATIVE_PATH _target "${CMAKE_CURRENT_SOURCE_DIR}" "${_file}")
     string(REPLACE ".cpp" "" _target "${_target}")
Index: include/pstl/internal/glue_numeric_impl.h
===================================================================
--- include/pstl/internal/glue_numeric_impl.h
+++ include/pstl/internal/glue_numeric_impl.h
@@ -101,7 +101,7 @@
 }
 
 template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _Tp, class _BinaryOperation>
-_ForwardIterator2
+__pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2>
 exclusive_scan(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last,
                _ForwardIterator2 __result, _Tp __init, _BinaryOperation __binary_op)
 {
Index: include/pstl/internal/glue_numeric_defs.h
===================================================================
--- include/pstl/internal/glue_numeric_defs.h
+++ include/pstl/internal/glue_numeric_defs.h
@@ -57,7 +57,7 @@
                _ForwardIterator2 __result, _Tp __init);
 
 template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _Tp, class _BinaryOperation>
-_ForwardIterator2
+__pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2>
 exclusive_scan(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last,
                _ForwardIterator2 __result, _Tp __init, _BinaryOperation __binary_op);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62719.203313.patch
Type: text/x-patch
Size: 3126 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190606/8db24d57/attachment.bin>


More information about the libcxx-commits mailing list