Skip to content

Commit

Permalink
Reintroduce modernize-pass-by-value check and fix. (Exawind#528)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrood-nrel authored Dec 31, 2021
1 parent 994ab5b commit d424a89
Show file tree
Hide file tree
Showing 17 changed files with 45 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions amr-wind/core/Field.H
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -360,8 +360,8 @@ public:
protected:
Field(
FieldRepo& repo,
const std::string& name,
const std::shared_ptr<FieldInfo>& finfo,
std::string name,
std::shared_ptr<FieldInfo> finfo,
const unsigned fid,
FieldState state);

Expand Down
16 changes: 11 additions & 5 deletions amr-wind/core/Field.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <utility>

#include "amr-wind/core/Field.H"
#include "amr-wind/core/FieldRepo.H"
#include "amr-wind/core/FieldFillPatchOps.H"
Expand All @@ -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)
Expand Down Expand Up @@ -84,11 +86,15 @@ void FieldInfo::copy_bc_to_device() noexcept

Field::Field(
FieldRepo& repo,
const std::string& name,
const std::shared_ptr<FieldInfo>& info,
std::string name,
std::shared_ptr<FieldInfo> 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;
Expand Down
2 changes: 1 addition & 1 deletion amr-wind/core/IntField.H
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions amr-wind/core/IntField.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
#include <utility>

#include "amr-wind/core/IntField.H"
#include "amr-wind/core/FieldRepo.H"

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)
Expand Down
2 changes: 1 addition & 1 deletion amr-wind/utilities/averaging/TimeAveraging.H
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class TimeAveraging : public PostProcessBase::Register<TimeAveraging>
public:
static std::string identifier() { return "TimeAveraging"; }

TimeAveraging(CFDSim&, const std::string&);
TimeAveraging(CFDSim&, std::string);

virtual ~TimeAveraging();

Expand Down
6 changes: 4 additions & 2 deletions amr-wind/utilities/averaging/TimeAveraging.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <utility>

#include "amr-wind/utilities/averaging/TimeAveraging.H"
#include "amr-wind/utilities/averaging/ReAveraging.H"
#include "amr-wind/CFDSim.H"
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion amr-wind/utilities/sampling/Enstrophy.H
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Enstrophy : public PostProcessBase::Register<Enstrophy>
public:
static const std::string identifier() { return "Enstrophy"; }

Enstrophy(CFDSim&, const std::string&);
Enstrophy(CFDSim&, std::string);

~Enstrophy();

Expand Down
5 changes: 3 additions & 2 deletions amr-wind/utilities/sampling/Enstrophy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
#include "amr-wind/utilities/io_utils.H"
#include "amr-wind/utilities/ncutils/nc_interface.H"
#include <AMReX_MultiFabUtil.H>
#include <utility>
#include "AMReX_ParmParse.H"
#include "amr-wind/utilities/IOManager.H"
#include "amr-wind/fvm/vorticity_mag.H"

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"))
{}
Expand Down
2 changes: 1 addition & 1 deletion amr-wind/utilities/sampling/FieldNorms.H
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class FieldNorms : public PostProcessBase::Register<FieldNorms>
public:
static const std::string identifier() { return "FieldNorms"; }

FieldNorms(CFDSim&, const std::string&);
FieldNorms(CFDSim&, std::string);

~FieldNorms();

Expand Down
5 changes: 3 additions & 2 deletions amr-wind/utilities/sampling/FieldNorms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
#include "amr-wind/utilities/io_utils.H"
#include "amr-wind/utilities/ncutils/nc_interface.H"
#include <AMReX_MultiFabUtil.H>
#include <utility>
#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;
Expand Down
2 changes: 1 addition & 1 deletion amr-wind/utilities/sampling/FreeSurface.H
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class FreeSurface : public PostProcessBase::Register<FreeSurface>
public:
static const std::string identifier() { return "FreeSurface"; }

FreeSurface(CFDSim&, const std::string&);
FreeSurface(CFDSim&, std::string);

~FreeSurface();

Expand Down
5 changes: 3 additions & 2 deletions amr-wind/utilities/sampling/FreeSurface.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#include "amr-wind/utilities/sampling/FreeSurface.H"
#include "amr-wind/utilities/io_utils.H"
#include <AMReX_MultiFabUtil.H>
#include <utility>
#include "amr-wind/utilities/ncutils/nc_interface.H"

#include "AMReX_ParmParse.H"

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;
Expand Down
2 changes: 1 addition & 1 deletion amr-wind/utilities/sampling/KineticEnergy.H
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class KineticEnergy : public PostProcessBase::Register<KineticEnergy>
public:
static const std::string identifier() { return "KineticEnergy"; }

KineticEnergy(CFDSim&, const std::string&);
KineticEnergy(CFDSim&, std::string);

~KineticEnergy();

Expand Down
5 changes: 3 additions & 2 deletions amr-wind/utilities/sampling/KineticEnergy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
#include "amr-wind/utilities/io_utils.H"
#include "amr-wind/utilities/ncutils/nc_interface.H"
#include <AMReX_MultiFabUtil.H>
#include <utility>
#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"))
{}
Expand Down
2 changes: 1 addition & 1 deletion amr-wind/utilities/sampling/Sampling.H
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Sampling : public PostProcessBase::Register<Sampling>
public:
static const std::string identifier() { return "Sampling"; }

Sampling(CFDSim&, const std::string&);
Sampling(CFDSim&, std::string);

virtual ~Sampling();

Expand Down
5 changes: 3 additions & 2 deletions amr-wind/utilities/sampling/Sampling.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <memory>
#include <utility>

#include "amr-wind/utilities/sampling/Sampling.H"
#include "amr-wind/utilities/io_utils.H"
Expand All @@ -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;
Expand Down

0 comments on commit d424a89

Please sign in to comment.