From d424a89d76069e803ff976e1279dd613f5c7264a Mon Sep 17 00:00:00 2001 From: Jon Rood Date: Thu, 30 Dec 2021 20:17:00 -0700 Subject: [PATCH] Reintroduce modernize-pass-by-value check and fix. (#528) --- .clang-tidy | 2 +- amr-wind/core/Field.H | 6 +++--- amr-wind/core/Field.cpp | 16 +++++++++++----- amr-wind/core/IntField.H | 2 +- amr-wind/core/IntField.cpp | 6 ++++-- amr-wind/utilities/averaging/TimeAveraging.H | 2 +- amr-wind/utilities/averaging/TimeAveraging.cpp | 6 ++++-- amr-wind/utilities/sampling/Enstrophy.H | 2 +- amr-wind/utilities/sampling/Enstrophy.cpp | 5 +++-- amr-wind/utilities/sampling/FieldNorms.H | 2 +- amr-wind/utilities/sampling/FieldNorms.cpp | 5 +++-- amr-wind/utilities/sampling/FreeSurface.H | 2 +- amr-wind/utilities/sampling/FreeSurface.cpp | 5 +++-- amr-wind/utilities/sampling/KineticEnergy.H | 2 +- amr-wind/utilities/sampling/KineticEnergy.cpp | 5 +++-- amr-wind/utilities/sampling/Sampling.H | 2 +- amr-wind/utilities/sampling/Sampling.cpp | 5 +++-- 17 files changed, 45 insertions(+), 30 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index a26c511338..77b909a4d3 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,5 @@ --- -Checks: 'clang-diagnostic-*,clang-analyzer-*,corecppguidelines-*,modernize-*,readability-*,-readability-magic-numbers,-readability-identifier-naming,-modernize-avoid-c-arrays,-modernize-use-trailing-return-type,-readability-named-parameter,-readability-implicit-bool-conversion,-readability-isolate-declaration,-readability-braces-around-statements,-modernize-pass-by-value,-clang-analyzer-optin.cplusplus.VirtualCall,-clang-analyzer-core.NonNullParamChecker' +Checks: 'clang-diagnostic-*,clang-analyzer-*,corecppguidelines-*,modernize-*,readability-*,-readability-magic-numbers,-readability-identifier-naming,-modernize-avoid-c-arrays,-modernize-use-trailing-return-type,-readability-named-parameter,-readability-implicit-bool-conversion,-readability-isolate-declaration,-readability-braces-around-statements,-clang-analyzer-optin.cplusplus.VirtualCall,-clang-analyzer-core.NonNullParamChecker' WarningsAsErrors: '' HeaderFilterRegex: '^((?!/amrex/Src/|/googletest/).)*$' AnalyzeTemporaryDtors: false diff --git a/amr-wind/core/Field.H b/amr-wind/core/Field.H index 39325e2376..90fdd11581 100644 --- a/amr-wind/core/Field.H +++ b/amr-wind/core/Field.H @@ -31,7 +31,7 @@ struct FieldInfo static constexpr int max_field_states = 5; FieldInfo( - const std::string& basename, + std::string basename, const int ncomp, const int ngrow, const int nstates, @@ -360,8 +360,8 @@ public: protected: Field( FieldRepo& repo, - const std::string& name, - const std::shared_ptr& finfo, + std::string name, + std::shared_ptr finfo, const unsigned fid, FieldState state); diff --git a/amr-wind/core/Field.cpp b/amr-wind/core/Field.cpp index efcb425b10..40e73e9350 100644 --- a/amr-wind/core/Field.cpp +++ b/amr-wind/core/Field.cpp @@ -1,3 +1,5 @@ +#include + #include "amr-wind/core/Field.H" #include "amr-wind/core/FieldRepo.H" #include "amr-wind/core/FieldFillPatchOps.H" @@ -8,12 +10,12 @@ namespace amr_wind { FieldInfo::FieldInfo( - const std::string& basename, + std::string basename, const int ncomp, const int ngrow, const int nstates, const FieldLoc floc) - : m_basename(basename) + : m_basename(std::move(basename)) , m_ncomp(ncomp) , m_ngrow(ngrow) , m_nstates(nstates) @@ -84,11 +86,15 @@ void FieldInfo::copy_bc_to_device() noexcept Field::Field( FieldRepo& repo, - const std::string& name, - const std::shared_ptr& info, + std::string name, + std::shared_ptr info, const unsigned fid, const FieldState state) - : m_repo(repo), m_name(name), m_info(info), m_id(fid), m_state(state) + : m_repo(repo) + , m_name(std::move(name)) + , m_info(std::move(info)) + , m_id(fid) + , m_state(state) {} Field::~Field() = default; diff --git a/amr-wind/core/IntField.H b/amr-wind/core/IntField.H index 6b3bf1e875..f60b5c1347 100644 --- a/amr-wind/core/IntField.H +++ b/amr-wind/core/IntField.H @@ -60,7 +60,7 @@ public: protected: IntField( FieldRepo& repo, - const std::string& name, + std::string name, const unsigned fid, const int ncomp = 1, const int ngrow = 1, diff --git a/amr-wind/core/IntField.cpp b/amr-wind/core/IntField.cpp index d9005138cc..1305fcec26 100644 --- a/amr-wind/core/IntField.cpp +++ b/amr-wind/core/IntField.cpp @@ -1,3 +1,5 @@ +#include + #include "amr-wind/core/IntField.H" #include "amr-wind/core/FieldRepo.H" @@ -5,13 +7,13 @@ namespace amr_wind { IntField::IntField( FieldRepo& repo, - const std::string& name, + std::string name, const unsigned fid, const int ncomp, const int ngrow, const FieldLoc floc) : m_repo(repo) - , m_name(name) + , m_name(std::move(name)) , m_id(fid) , m_ncomp(ncomp) , m_ngrow(ngrow) diff --git a/amr-wind/utilities/averaging/TimeAveraging.H b/amr-wind/utilities/averaging/TimeAveraging.H index 5046588cc7..cac4798fbc 100644 --- a/amr-wind/utilities/averaging/TimeAveraging.H +++ b/amr-wind/utilities/averaging/TimeAveraging.H @@ -51,7 +51,7 @@ class TimeAveraging : public PostProcessBase::Register public: static std::string identifier() { return "TimeAveraging"; } - TimeAveraging(CFDSim&, const std::string&); + TimeAveraging(CFDSim&, std::string); virtual ~TimeAveraging(); diff --git a/amr-wind/utilities/averaging/TimeAveraging.cpp b/amr-wind/utilities/averaging/TimeAveraging.cpp index f669a2d87f..9413b4a674 100644 --- a/amr-wind/utilities/averaging/TimeAveraging.cpp +++ b/amr-wind/utilities/averaging/TimeAveraging.cpp @@ -1,3 +1,5 @@ +#include + #include "amr-wind/utilities/averaging/TimeAveraging.H" #include "amr-wind/utilities/averaging/ReAveraging.H" #include "amr-wind/CFDSim.H" @@ -7,8 +9,8 @@ namespace amr_wind { namespace averaging { -TimeAveraging::TimeAveraging(CFDSim& sim, const std::string& label) - : m_sim(sim), m_label(label) +TimeAveraging::TimeAveraging(CFDSim& sim, std::string label) + : m_sim(sim), m_label(std::move(label)) {} TimeAveraging::~TimeAveraging() = default; diff --git a/amr-wind/utilities/sampling/Enstrophy.H b/amr-wind/utilities/sampling/Enstrophy.H index 3408e8a739..4aef604c25 100644 --- a/amr-wind/utilities/sampling/Enstrophy.H +++ b/amr-wind/utilities/sampling/Enstrophy.H @@ -19,7 +19,7 @@ class Enstrophy : public PostProcessBase::Register public: static const std::string identifier() { return "Enstrophy"; } - Enstrophy(CFDSim&, const std::string&); + Enstrophy(CFDSim&, std::string); ~Enstrophy(); diff --git a/amr-wind/utilities/sampling/Enstrophy.cpp b/amr-wind/utilities/sampling/Enstrophy.cpp index 56536e85e3..652ac87e0b 100644 --- a/amr-wind/utilities/sampling/Enstrophy.cpp +++ b/amr-wind/utilities/sampling/Enstrophy.cpp @@ -2,6 +2,7 @@ #include "amr-wind/utilities/io_utils.H" #include "amr-wind/utilities/ncutils/nc_interface.H" #include +#include #include "AMReX_ParmParse.H" #include "amr-wind/utilities/IOManager.H" #include "amr-wind/fvm/vorticity_mag.H" @@ -9,9 +10,9 @@ namespace amr_wind { namespace enstrophy { -Enstrophy::Enstrophy(CFDSim& sim, const std::string& label) +Enstrophy::Enstrophy(CFDSim& sim, std::string label) : m_sim(sim) - , m_label(label) + , m_label(std::move(label)) , m_velocity(sim.repo().get_field("velocity")) , m_density(sim.repo().get_field("density")) {} diff --git a/amr-wind/utilities/sampling/FieldNorms.H b/amr-wind/utilities/sampling/FieldNorms.H index 9b8c8db2aa..a9f5f07733 100644 --- a/amr-wind/utilities/sampling/FieldNorms.H +++ b/amr-wind/utilities/sampling/FieldNorms.H @@ -19,7 +19,7 @@ class FieldNorms : public PostProcessBase::Register public: static const std::string identifier() { return "FieldNorms"; } - FieldNorms(CFDSim&, const std::string&); + FieldNorms(CFDSim&, std::string); ~FieldNorms(); diff --git a/amr-wind/utilities/sampling/FieldNorms.cpp b/amr-wind/utilities/sampling/FieldNorms.cpp index fb0a08db68..d2c9632a84 100644 --- a/amr-wind/utilities/sampling/FieldNorms.cpp +++ b/amr-wind/utilities/sampling/FieldNorms.cpp @@ -2,14 +2,15 @@ #include "amr-wind/utilities/io_utils.H" #include "amr-wind/utilities/ncutils/nc_interface.H" #include +#include #include "AMReX_ParmParse.H" #include "amr-wind/utilities/IOManager.H" namespace amr_wind { namespace field_norms { -FieldNorms::FieldNorms(CFDSim& sim, const std::string& label) - : m_sim(sim), m_label(label) +FieldNorms::FieldNorms(CFDSim& sim, std::string label) + : m_sim(sim), m_label(std::move(label)) {} FieldNorms::~FieldNorms() = default; diff --git a/amr-wind/utilities/sampling/FreeSurface.H b/amr-wind/utilities/sampling/FreeSurface.H index cc14605b78..86b3ef397a 100644 --- a/amr-wind/utilities/sampling/FreeSurface.H +++ b/amr-wind/utilities/sampling/FreeSurface.H @@ -32,7 +32,7 @@ class FreeSurface : public PostProcessBase::Register public: static const std::string identifier() { return "FreeSurface"; } - FreeSurface(CFDSim&, const std::string&); + FreeSurface(CFDSim&, std::string); ~FreeSurface(); diff --git a/amr-wind/utilities/sampling/FreeSurface.cpp b/amr-wind/utilities/sampling/FreeSurface.cpp index 6357c90e5b..353ae54808 100644 --- a/amr-wind/utilities/sampling/FreeSurface.cpp +++ b/amr-wind/utilities/sampling/FreeSurface.cpp @@ -1,6 +1,7 @@ #include "amr-wind/utilities/sampling/FreeSurface.H" #include "amr-wind/utilities/io_utils.H" #include +#include #include "amr-wind/utilities/ncutils/nc_interface.H" #include "AMReX_ParmParse.H" @@ -8,8 +9,8 @@ namespace amr_wind { namespace free_surface { -FreeSurface::FreeSurface(CFDSim& sim, const std::string& label) - : m_sim(sim), m_label(label), m_vof(sim.repo().get_field("vof")) +FreeSurface::FreeSurface(CFDSim& sim, std::string label) + : m_sim(sim), m_label(std::move(label)), m_vof(sim.repo().get_field("vof")) { #ifdef AMREX_USE_GPU amrex::Print() << "WARNING: FreeSurface: Running on GPUs..." << std::endl; diff --git a/amr-wind/utilities/sampling/KineticEnergy.H b/amr-wind/utilities/sampling/KineticEnergy.H index 59ad6b17c7..65a43ea622 100644 --- a/amr-wind/utilities/sampling/KineticEnergy.H +++ b/amr-wind/utilities/sampling/KineticEnergy.H @@ -19,7 +19,7 @@ class KineticEnergy : public PostProcessBase::Register public: static const std::string identifier() { return "KineticEnergy"; } - KineticEnergy(CFDSim&, const std::string&); + KineticEnergy(CFDSim&, std::string); ~KineticEnergy(); diff --git a/amr-wind/utilities/sampling/KineticEnergy.cpp b/amr-wind/utilities/sampling/KineticEnergy.cpp index 564450f08f..38470b9c42 100644 --- a/amr-wind/utilities/sampling/KineticEnergy.cpp +++ b/amr-wind/utilities/sampling/KineticEnergy.cpp @@ -2,15 +2,16 @@ #include "amr-wind/utilities/io_utils.H" #include "amr-wind/utilities/ncutils/nc_interface.H" #include +#include #include "AMReX_ParmParse.H" #include "amr-wind/utilities/IOManager.H" namespace amr_wind { namespace kinetic_energy { -KineticEnergy::KineticEnergy(CFDSim& sim, const std::string& label) +KineticEnergy::KineticEnergy(CFDSim& sim, std::string label) : m_sim(sim) - , m_label(label) + , m_label(std::move(label)) , m_velocity(sim.repo().get_field("velocity")) , m_density(sim.repo().get_field("density")) {} diff --git a/amr-wind/utilities/sampling/Sampling.H b/amr-wind/utilities/sampling/Sampling.H index 639f10fe95..5af079d3d5 100644 --- a/amr-wind/utilities/sampling/Sampling.H +++ b/amr-wind/utilities/sampling/Sampling.H @@ -42,7 +42,7 @@ class Sampling : public PostProcessBase::Register public: static const std::string identifier() { return "Sampling"; } - Sampling(CFDSim&, const std::string&); + Sampling(CFDSim&, std::string); virtual ~Sampling(); diff --git a/amr-wind/utilities/sampling/Sampling.cpp b/amr-wind/utilities/sampling/Sampling.cpp index dcdb5cd5cc..365e200349 100644 --- a/amr-wind/utilities/sampling/Sampling.cpp +++ b/amr-wind/utilities/sampling/Sampling.cpp @@ -1,4 +1,5 @@ #include +#include #include "amr-wind/utilities/sampling/Sampling.H" #include "amr-wind/utilities/io_utils.H" @@ -9,8 +10,8 @@ namespace amr_wind { namespace sampling { -Sampling::Sampling(CFDSim& sim, const std::string& label) - : m_sim(sim), m_label(label) +Sampling::Sampling(CFDSim& sim, std::string label) + : m_sim(sim), m_label(std::move(label)) {} Sampling::~Sampling() = default;