From 16215850f0c62db7b8aba598ea48dc18f8c031d4 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Mon, 9 Jan 2023 09:45:16 -0500 Subject: [PATCH] Update clang-tidy checks for recent clang versions --- .clang-tidy | 3 ++- bundled/.clang-tidy | 2 +- include/deal.II/base/mpi_consensus_algorithms.h | 2 +- include/deal.II/base/parameter_handler.h | 1 + .../numerics/data_out_dof_data.templates.h | 2 +- source/base/qprojector.cc | 2 +- source/distributed/tria_base.cc | 1 + source/dofs/dof_tools.cc | 4 ++-- source/fe/mapping_q.cc | 2 +- source/grid/grid_generator.cc | 16 ++++++++-------- source/grid/grid_tools.cc | 2 +- source/lac/sparsity_tools.cc | 5 ++--- source/multigrid/mg_transfer_internal.cc | 8 ++++++-- source/numerics/time_dependent.cc | 8 ++++---- 14 files changed, 32 insertions(+), 26 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 7532f07a2e..8c31e2638a 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -19,12 +19,13 @@ Checks: > -*, cppcoreguidelines-pro-type-static-cast-downcast, - google-readability-casting, + cppcoreguidelines-pro-type-cstyle-cast, modernize-*, -modernize-avoid-c-arrays, -modernize-concat-nested-namespaces, -modernize-pass-by-value, -modernize-raw-string-literal, + -modernize-return-braced-init-list, -modernize-use-auto, -modernize-use-default-member-init, -modernize-use-nodiscard, diff --git a/bundled/.clang-tidy b/bundled/.clang-tidy index eb40a98a77..9c0625aeff 100644 --- a/bundled/.clang-tidy +++ b/bundled/.clang-tidy @@ -2,5 +2,5 @@ # bundled/. Clang-tidy fails if nothing is chosen, so we just enable a single # harmless warning: -Checks: "-*,misc-sizeof-container" +Checks: "-*,misc-definitions-in-headers" diff --git a/include/deal.II/base/mpi_consensus_algorithms.h b/include/deal.II/base/mpi_consensus_algorithms.h index 066d4ec08c..6667de2826 100644 --- a/include/deal.II/base/mpi_consensus_algorithms.h +++ b/include/deal.II/base/mpi_consensus_algorithms.h @@ -1561,7 +1561,7 @@ namespace Utilities // MPI deadlock. Abort with a reasonable error message instead. try { - std::rethrow_exception(std::move(exception)); + std::rethrow_exception(exception); } catch (ExceptionBase &exc) { diff --git a/include/deal.II/base/parameter_handler.h b/include/deal.II/base/parameter_handler.h index 2ca043f297..f9935bb0e2 100644 --- a/include/deal.II/base/parameter_handler.h +++ b/include/deal.II/base/parameter_handler.h @@ -2299,6 +2299,7 @@ ParameterHandler::save(Archive &ar, const unsigned int) const std::vector descriptions; + descriptions.reserve(patterns.size()); for (const auto &pattern : patterns) descriptions.push_back(pattern->description()); diff --git a/include/deal.II/numerics/data_out_dof_data.templates.h b/include/deal.II/numerics/data_out_dof_data.templates.h index 71d069885a..f203ae74a1 100644 --- a/include/deal.II/numerics/data_out_dof_data.templates.h +++ b/include/deal.II/numerics/data_out_dof_data.templates.h @@ -1935,7 +1935,7 @@ DataOut_DoFData:: ExcMessage("The DoF handler attached to the current output vector " "does not have any degrees of freedom, so it is not " "possible to output DoF data in this context.")); - const std::string name = names[0]; + const std::string &name = names[0]; const unsigned int n_components = dof_handler->get_fe(0).n_components(); deduced_names.resize(n_components); if (n_components > 1) diff --git a/source/base/qprojector.cc b/source/base/qprojector.cc index 3c95d1c1cf..cafd48cf3d 100644 --- a/source/base/qprojector.cc +++ b/source/base/qprojector.cc @@ -891,7 +891,7 @@ QProjector<3>::project_to_all_faces(const ReferenceCell & reference_cell, { SubQuadrature mutation; - const auto quadrature_f = + const auto &quadrature_f = quadrature[quadrature.size() == 1 ? 0 : face]; switch (i) { diff --git a/source/distributed/tria_base.cc b/source/distributed/tria_base.cc index 9da27f9752..1ee351481e 100644 --- a/source/distributed/tria_base.cc +++ b/source/distributed/tria_base.cc @@ -302,6 +302,7 @@ namespace parallel // Utilities::MPI::compute_set_union) std::vector reference_cells_ui; + reference_cells_ui.reserve(this->reference_cells.size()); for (const auto &i : this->reference_cells) reference_cells_ui.push_back(static_cast(i)); diff --git a/source/dofs/dof_tools.cc b/source/dofs/dof_tools.cc index 252705cced..dd307b18bd 100644 --- a/source/dofs/dof_tools.cc +++ b/source/dofs/dof_tools.cc @@ -2757,7 +2757,7 @@ namespace DoFTools // all duplicates are ignored for (unsigned int i = 0; i < patch.size(); ++i) { - const typename DoFHandler::active_cell_iterator cell = + const typename DoFHandler::active_cell_iterator &cell = patch[i]; Assert(cell->is_artificial() == false, ExcMessage("This function can not be called with cells that are " @@ -2788,7 +2788,7 @@ namespace DoFTools // all duplicates are ignored for (unsigned int i = 0; i < patch.size(); ++i) { - const typename DoFHandler::active_cell_iterator cell = + const typename DoFHandler::active_cell_iterator &cell = patch[i]; Assert(cell->is_artificial() == false, ExcMessage("This function can not be called with cells that are " diff --git a/source/fe/mapping_q.cc b/source/fe/mapping_q.cc index c55cae5e07..9760fb508d 100644 --- a/source/fe/mapping_q.cc +++ b/source/fe/mapping_q.cc @@ -123,7 +123,7 @@ MappingQ::InternalData::initialize( // in all directions if (tensor_product_quadrature) { - const std::array, dim> quad_array = + const std::array, dim> &quad_array = q.get_tensor_basis(); for (unsigned int i = 1; i < dim && tensor_product_quadrature; ++i) { diff --git a/source/grid/grid_generator.cc b/source/grid/grid_generator.cc index 497d9506fd..e1eed6e292 100644 --- a/source/grid/grid_generator.cc +++ b/source/grid/grid_generator.cc @@ -5505,14 +5505,14 @@ namespace GridGenerator { const double height = initial_height + height_increment * rep; - vertices.emplace_back(Point<3>(-d, height, -d)); - vertices.emplace_back(Point<3>(d, height, -d)); - vertices.emplace_back(Point<3>(-a, height, -a)); - vertices.emplace_back(Point<3>(a, height, -a)); - vertices.emplace_back(Point<3>(-a, height, a)); - vertices.emplace_back(Point<3>(a, height, a)); - vertices.emplace_back(Point<3>(-d, height, d)); - vertices.emplace_back(Point<3>(d, height, d)); + vertices.emplace_back(-d, height, -d); + vertices.emplace_back(d, height, -d); + vertices.emplace_back(-a, height, -a); + vertices.emplace_back(a, height, -a); + vertices.emplace_back(-a, height, a); + vertices.emplace_back(a, height, a); + vertices.emplace_back(-d, height, d); + vertices.emplace_back(d, height, d); } // Turn cylinder such that y->x diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index 61f11d7902..29461a2d23 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -5043,7 +5043,7 @@ namespace GridTools cell_ptr != distorted_cells.distorted_cells.end(); ++cell_ptr) { - const typename Triangulation::cell_iterator cell = + const typename Triangulation::cell_iterator &cell = *cell_ptr; Assert(!cell->is_active(), diff --git a/source/lac/sparsity_tools.cc b/source/lac/sparsity_tools.cc index 54835e47d8..e5bc4b8668 100644 --- a/source/lac/sparsity_tools.cc +++ b/source/lac/sparsity_tools.cc @@ -621,9 +621,8 @@ namespace SparsityTools DynamicSparsityPattern::size_type next_free_number = 0; // enumerate the first round dofs - for (DynamicSparsityPattern::size_type i = 0; i != last_round_dofs.size(); - ++i) - new_indices[last_round_dofs[i]] = next_free_number++; + for (unsigned int last_round_dof : last_round_dofs) + new_indices[last_round_dof] = next_free_number++; // now do as many steps as needed to renumber all dofs while (true) diff --git a/source/multigrid/mg_transfer_internal.cc b/source/multigrid/mg_transfer_internal.cc index f442e6b9e6..fe4e35562a 100644 --- a/source/multigrid/mg_transfer_internal.cc +++ b/source/multigrid/mg_transfer_internal.cc @@ -24,6 +24,8 @@ #include +#include + DEAL_II_NAMESPACE_OPEN namespace internal @@ -449,8 +451,10 @@ namespace internal ghosted_dofs.index_within_set( target_partitioner->local_to_global( copy_indices_global_mine(1, i))); - target_partitioner.reset(new Utilities::MPI::Partitioner( - locally_owned, ghosted_dofs, communicator)); + target_partitioner = + std::make_shared(locally_owned, + ghosted_dofs, + communicator); } } diff --git a/source/numerics/time_dependent.cc b/source/numerics/time_dependent.cc index ab5e754514..4726c3f6e8 100644 --- a/source/numerics/time_dependent.cc +++ b/source/numerics/time_dependent.cc @@ -928,11 +928,11 @@ TimeStepBase_Tria::refine_grid(const RefinementData refinement_data) (sweep_no >= refinement_flags.correction_relaxations.size() ? refinement_flags.correction_relaxations.back() : refinement_flags.correction_relaxations[sweep_no]); - for (unsigned int r = 0; r != relaxations.size(); ++r) - if (n_active_cells < relaxations[r].first) + for (const auto &relaxation : relaxations) + if (n_active_cells < relaxation.first) { - delta_up *= relaxations[r].second; - delta_down *= relaxations[r].second; + delta_up *= relaxation.second; + delta_down *= relaxation.second; break; } -- 2.39.5