mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 05:05:11 +00:00
style: clang-tidy: modernize-use-using (#2645)
* style: clang-tidy: modernize-use-using * style: more clang-tidy checking Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
This commit is contained in:
parent
06b673a0da
commit
b72cebeb22
7
.github/workflows/format.yml
vendored
7
.github/workflows/format.yml
vendored
@ -35,7 +35,12 @@ jobs:
|
||||
run: apt-get update && apt-get install -y python3-dev python3-pytest
|
||||
|
||||
- name: Configure
|
||||
run: cmake -S . -B build -DCMAKE_CXX_CLANG_TIDY="$(which clang-tidy);--warnings-as-errors=*"
|
||||
run: >
|
||||
cmake -S . -B build
|
||||
-DCMAKE_CXX_CLANG_TIDY="$(which clang-tidy);--warnings-as-errors=*"
|
||||
-DDOWNLOAD_EIGEN=ON
|
||||
-DDOWNLOAD_CATCH=ON
|
||||
-DCMAKE_CXX_STANDARD=17
|
||||
|
||||
- name: Build
|
||||
run: cmake --build build -j 2
|
||||
|
@ -1240,7 +1240,7 @@ template <typename StringType, bool IsView = false> struct string_caster {
|
||||
#endif
|
||||
}
|
||||
|
||||
object utfNbytes = reinterpret_steal<object>(PyUnicode_AsEncodedString(
|
||||
auto utfNbytes = reinterpret_steal<object>(PyUnicode_AsEncodedString(
|
||||
load_src.ptr(), UTF_N == 8 ? "utf-8" : UTF_N == 16 ? "utf-16" : "utf-32", nullptr));
|
||||
if (!utfNbytes) { PyErr_Clear(); return false; }
|
||||
|
||||
|
@ -32,7 +32,7 @@ PYBIND11_NAMESPACE_BEGIN(detail)
|
||||
|
||||
template <typename type> class duration_caster {
|
||||
public:
|
||||
typedef typename type::rep rep;
|
||||
using rep = typename type::rep;
|
||||
using period = typename type::period;
|
||||
|
||||
using days = std::chrono::duration<uint_fast32_t, std::ratio<86400>>;
|
||||
|
@ -494,7 +494,7 @@ using std::make_index_sequence;
|
||||
#else
|
||||
template<size_t ...> struct index_sequence { };
|
||||
template<size_t N, size_t ...S> struct make_index_sequence_impl : make_index_sequence_impl <N - 1, N - 1, S...> { };
|
||||
template<size_t ...S> struct make_index_sequence_impl <0, S...> { typedef index_sequence<S...> type; };
|
||||
template<size_t ...S> struct make_index_sequence_impl <0, S...> { using type = index_sequence<S...>; };
|
||||
template<size_t N> using make_index_sequence = typename make_index_sequence_impl<N>::type;
|
||||
#endif
|
||||
|
||||
|
@ -432,7 +432,7 @@ public:
|
||||
if (!need_copy) {
|
||||
// We don't need a converting copy, but we also need to check whether the strides are
|
||||
// compatible with the Ref's stride requirements
|
||||
Array aref = reinterpret_borrow<Array>(src);
|
||||
auto aref = reinterpret_borrow<Array>(src);
|
||||
|
||||
if (aref && (!need_writeable || aref.writeable())) {
|
||||
fits = props::conformable(aref);
|
||||
@ -539,9 +539,9 @@ public:
|
||||
|
||||
template<typename Type>
|
||||
struct type_caster<Type, enable_if_t<is_eigen_sparse<Type>::value>> {
|
||||
typedef typename Type::Scalar Scalar;
|
||||
typedef remove_reference_t<decltype(*std::declval<Type>().outerIndexPtr())> StorageIndex;
|
||||
typedef typename Type::Index Index;
|
||||
using Scalar = typename Type::Scalar;
|
||||
using StorageIndex = remove_reference_t<decltype(*std::declval<Type>().outerIndexPtr())>;
|
||||
using Index = typename Type::Index;
|
||||
static constexpr bool rowMajor = Type::IsRowMajor;
|
||||
|
||||
bool load(handle src, bool) {
|
||||
|
@ -772,7 +772,7 @@ public:
|
||||
int(new_shape->size())
|
||||
};
|
||||
// try to resize, set ordering param to -1 cause it's not used anyway
|
||||
object new_array = reinterpret_steal<object>(
|
||||
auto new_array = reinterpret_steal<object>(
|
||||
detail::npy_api::get().PyArray_Resize_(m_ptr, &d, int(refcheck), -1)
|
||||
);
|
||||
if (!new_array) throw error_already_set();
|
||||
|
@ -1842,7 +1842,7 @@ template <return_value_policy Policy = return_value_policy::reference_internal,
|
||||
typename ValueType = decltype(*std::declval<Iterator>()),
|
||||
typename... Extra>
|
||||
iterator make_iterator(Iterator first, Sentinel last, Extra &&... extra) {
|
||||
typedef detail::iterator_state<Iterator, Sentinel, false, Policy> state;
|
||||
using state = detail::iterator_state<Iterator, Sentinel, false, Policy>;
|
||||
|
||||
if (!detail::get_type_info(typeid(state), false)) {
|
||||
class_<state>(handle(), "iterator", pybind11::module_local())
|
||||
|
@ -116,9 +116,9 @@ TEST_SUBMODULE(copy_move_policies, m) {
|
||||
r += py::cast<MoveOrCopyInt>(o).value; /* moves */
|
||||
r += py::cast<MoveOnlyInt>(o).value; /* moves */
|
||||
r += py::cast<CopyOnlyInt>(o).value; /* copies */
|
||||
MoveOrCopyInt m1(py::cast<MoveOrCopyInt>(o)); /* moves */
|
||||
MoveOnlyInt m2(py::cast<MoveOnlyInt>(o)); /* moves */
|
||||
CopyOnlyInt m3(py::cast<CopyOnlyInt>(o)); /* copies */
|
||||
auto m1(py::cast<MoveOrCopyInt>(o)); /* moves */
|
||||
auto m2(py::cast<MoveOnlyInt>(o)); /* moves */
|
||||
auto m3(py::cast<CopyOnlyInt>(o)); /* copies */
|
||||
r += m1.value + m2.value + m3.value;
|
||||
|
||||
return r;
|
||||
|
@ -61,8 +61,9 @@ double get_elem(Eigen::Ref<const Eigen::MatrixXd> m) { return m(2, 1); };
|
||||
// reference is referencing rows/columns correctly).
|
||||
template <typename MatrixArgType> Eigen::MatrixXd adjust_matrix(MatrixArgType m) {
|
||||
Eigen::MatrixXd ret(m);
|
||||
for (int c = 0; c < m.cols(); c++) for (int r = 0; r < m.rows(); r++)
|
||||
ret(r, c) += 10*r + 100*c;
|
||||
for (int c = 0; c < m.cols(); c++)
|
||||
for (int r = 0; r < m.rows(); r++)
|
||||
ret(r, c) += 10*r + 100*c; // NOLINT(clang-analyzer-core.uninitialized.Assign)
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -255,7 +256,7 @@ TEST_SUBMODULE(eigen, m) {
|
||||
m.def("dense_copy_r", [](const DenseMatrixR &m) -> DenseMatrixR { return m; });
|
||||
m.def("dense_copy_c", [](const DenseMatrixC &m) -> DenseMatrixC { return m; });
|
||||
// test_sparse, test_sparse_signature
|
||||
m.def("sparse_r", [mat]() -> SparseMatrixR { return Eigen::SparseView<Eigen::MatrixXf>(mat); });
|
||||
m.def("sparse_r", [mat]() -> SparseMatrixR { return Eigen::SparseView<Eigen::MatrixXf>(mat); }); //NOLINT(clang-analyzer-core.uninitialized.UndefReturn)
|
||||
m.def("sparse_c", [mat]() -> SparseMatrixC { return Eigen::SparseView<Eigen::MatrixXf>(mat); });
|
||||
m.def("sparse_copy_r", [](const SparseMatrixR &m) -> SparseMatrixR { return m; });
|
||||
m.def("sparse_copy_c", [](const SparseMatrixC &m) -> SparseMatrixC { return m; });
|
||||
|
@ -4,7 +4,7 @@ if("${PYTHON_MODULE_EXTENSION}" MATCHES "pypy" OR "${Python_INTERPRETER_ID}" STR
|
||||
return()
|
||||
endif()
|
||||
|
||||
find_package(Catch 2.13.0)
|
||||
find_package(Catch 2.13.2)
|
||||
|
||||
if(CATCH_FOUND)
|
||||
message(STATUS "Building interpreter tests using Catch v${CATCH_VERSION}")
|
||||
|
Loading…
Reference in New Issue
Block a user