Skip to content

Commit

Permalink
Clang tidy CI test: add performance-unnecessary-* checks to clang-tid…
Browse files Browse the repository at this point in the history
…y CI test (#4136)

* clang-tidy CI test: add performance-unnecessary-* checks

* fixed issues

* address issues found with clang-tidy

* address issues found with clang-tidy

* change name for clarity

* fixed bug

* address issues found with clang-tidy

* fix issue found with clang-tidy

* fix bug

* remove file apparently added due to merge conflict

* fix bug

* fix bug

* addressed all issues found with clang-tidy

* fix issues found with clang-tidy

* revert space deletion

* fix variable name

* fix issues found with clang-tidy

* fix some residual issues found with clang-tidy

* Update Source/Diagnostics/BTDiagnostics.H

Co-authored-by: David Grote <dpgrote@lbl.gov>

---------

Co-authored-by: David Grote <dpgrote@lbl.gov>
  • Loading branch information
lucafedeli88 and dpgrote authored Apr 1, 2024
1 parent 72800ea commit a5d5432
Show file tree
Hide file tree
Showing 102 changed files with 209 additions and 210 deletions.
2 changes: 0 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ Checks: '
-modernize-use-trailing-return-type,
mpi-*,
performance-*,
-performance-unnecessary-copy-initialization,
-performance-unnecessary-value-param,
portability-*,
readability-*,
-readability-convert-member-functions-to-static,
Expand Down
6 changes: 3 additions & 3 deletions Source/Diagnostics/BTD_Plotfile_Header_Impl.H
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,12 @@ class BTDMultiFabHeaderImpl
*/
void SetBox (int ibox, amrex::Box ba_box) { m_ba.set(ibox, ba_box); }
/** Set Fab name of the ith fab to be written in the multifab Header file.*/
void SetFabName (int ifab, std::string fodPrefix, std::string FabName,
void SetFabName (int ifab, const std::string& fodPrefix, const std::string& FabName,
int FabHead);
/** Set minimum value of all the components for the ith fab. */
void SetMinVal (int ifab, amrex::Vector<amrex::Real> minval);
void SetMinVal (int ifab, const amrex::Vector<amrex::Real>& minval);
/** Set maximum value of all the components for the ith fab. */
void SetMaxVal (int ifab, amrex::Vector<amrex::Real> maxval);
void SetMaxVal (int ifab, const amrex::Vector<amrex::Real>& maxval);
private:
/** Header file path */
std::string m_Header_path;
Expand Down
6 changes: 3 additions & 3 deletions Source/Diagnostics/BTD_Plotfile_Header_Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ BTDMultiFabHeaderImpl::ResizeFabData ()
}

void
BTDMultiFabHeaderImpl::SetFabName (int ifab, std::string fodPrefix, std::string FabName,
BTDMultiFabHeaderImpl::SetFabName (int ifab, const std::string& fodPrefix, const std::string& FabName,
int FabHead)
{
m_FabOnDiskPrefix[ifab] = fodPrefix;
Expand All @@ -333,13 +333,13 @@ BTDMultiFabHeaderImpl::SetFabName (int ifab, std::string fodPrefix, std::string
}

void
BTDMultiFabHeaderImpl::SetMinVal (int ifab, amrex::Vector<amrex::Real> minval)
BTDMultiFabHeaderImpl::SetMinVal (int ifab, const amrex::Vector<amrex::Real>& minval)
{
CopyVec(m_minval[ifab], minval);
}

void
BTDMultiFabHeaderImpl::SetMaxVal (int ifab, amrex::Vector<amrex::Real> maxval)
BTDMultiFabHeaderImpl::SetMaxVal (int ifab, const amrex::Vector<amrex::Real>& maxval)
{
CopyVec(m_maxval[ifab], maxval);
}
Expand Down
22 changes: 11 additions & 11 deletions Source/Diagnostics/BTDiagnostics.H
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class BTDiagnostics final : public Diagnostics
{
public:

BTDiagnostics (int i, std::string name);
BTDiagnostics (int i, const std::string& name);

private:
/** Whether to plot raw (i.e., NOT cell-centered) fields */
Expand Down Expand Up @@ -375,26 +375,26 @@ private:
/** Interleave lab-frame meta-data of the buffers to be consistent
* with the merged plotfile lab-frame data.
*/
void InterleaveBufferAndSnapshotHeader ( std::string buffer_Header,
std::string snapshot_Header);
void InterleaveBufferAndSnapshotHeader (const std::string& buffer_Header,
const std::string& snapshot_Header);
/** Interleave meta-data of the buffer multifabs to be consistent
* with the merged plotfile lab-frame data.
*/
void InterleaveFabArrayHeader (std::string Buffer_FabHeader_path,
std::string snapshot_FabHeader_path,
std::string newsnapshot_FabFilename);
void InterleaveFabArrayHeader (const std::string& Buffer_FabHeader_path,
const std::string& snapshot_FabHeader_path,
const std::string& newsnapshot_FabFilename);
/** Interleave lab-frame metadata of the species header file in the buffers to
* be consistent with the merged plotfile lab-frame data
*/
void InterleaveSpeciesHeader(std::string buffer_species_Header_path,
std::string snapshot_species_Header_path,
std::string species_name, int new_data_index);
void InterleaveSpeciesHeader(const std::string& buffer_species_Header_path,
const std::string& snapshot_species_Header_path,
const std::string& species_name, int new_data_index);

/** Interleave lab-frame metadata of the particle header file in the buffers to
* be consistent with the merged plotfile lab-frame data
*/
void InterleaveParticleDataHeader( std::string buffer_ParticleHdrFilename,
std::string snapshot_ParticleHdrFilename);
void InterleaveParticleDataHeader(const std::string& buffer_ParticleHdrFilename,
const std::string& snapshot_ParticleHdrFilename);
/** Initialize particle functors for each species to compute the back-transformed
lab-frame data. */
void InitializeParticleFunctors () override;
Expand Down
24 changes: 12 additions & 12 deletions Source/Diagnostics/BTDiagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ namespace
constexpr int permission_flag_rwxrxrx = 0755;
}

BTDiagnostics::BTDiagnostics (int i, std::string name)
: Diagnostics(i, name)
BTDiagnostics::BTDiagnostics (int i, const std::string& name)
: Diagnostics{i, name}
{
ReadParameters();
}
Expand Down Expand Up @@ -1290,8 +1290,8 @@ void BTDiagnostics::MergeBuffersForPlotfile (int i_snapshot)
}

void
BTDiagnostics::InterleaveBufferAndSnapshotHeader ( std::string buffer_Header_path,
std::string snapshot_Header_path)
BTDiagnostics::InterleaveBufferAndSnapshotHeader ( const std::string& buffer_Header_path,
const std::string& snapshot_Header_path)
{
BTDPlotfileHeaderImpl snapshot_HeaderImpl(snapshot_Header_path);
snapshot_HeaderImpl.ReadHeaderData();
Expand Down Expand Up @@ -1335,9 +1335,9 @@ BTDiagnostics::InterleaveBufferAndSnapshotHeader ( std::string buffer_Header_pat


void
BTDiagnostics::InterleaveFabArrayHeader (std::string Buffer_FabHeader_path,
std::string snapshot_FabHeader_path,
std::string newsnapshot_FabFilename)
BTDiagnostics::InterleaveFabArrayHeader(const std::string& Buffer_FabHeader_path,
const std::string& snapshot_FabHeader_path,
const std::string& newsnapshot_FabFilename)
{
BTDMultiFabHeaderImpl snapshot_FabHeader(snapshot_FabHeader_path);
snapshot_FabHeader.ReadMultiFabHeader();
Expand Down Expand Up @@ -1365,9 +1365,9 @@ BTDiagnostics::InterleaveFabArrayHeader (std::string Buffer_FabHeader_path,
}

void
BTDiagnostics::InterleaveSpeciesHeader(std::string buffer_species_Header_path,
std::string snapshot_species_Header_path,
std::string species_name, const int new_data_index)
BTDiagnostics::InterleaveSpeciesHeader(const std::string& buffer_species_Header_path,
const std::string& snapshot_species_Header_path,
const std::string& species_name, const int new_data_index)
{
BTDSpeciesHeaderImpl BufferSpeciesHeader(buffer_species_Header_path,
species_name);
Expand All @@ -1389,8 +1389,8 @@ BTDiagnostics::InterleaveSpeciesHeader(std::string buffer_species_Header_path,
}

void
BTDiagnostics::InterleaveParticleDataHeader(std::string buffer_ParticleHdrFilename,
std::string snapshot_ParticleHdrFilename)
BTDiagnostics::InterleaveParticleDataHeader(const std::string& buffer_ParticleHdrFilename,
const std::string& snapshot_ParticleHdrFilename)
{
BTDParticleDataHeaderImpl BufferParticleHeader(buffer_ParticleHdrFilename);
BufferParticleHeader.ReadHeader();
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/BoundaryScrapingDiagnostics.H
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public:
* @param i index of diagnostics in MultiDiagnostics::alldiags
* @param name diagnostics name in the inputs file
*/
BoundaryScrapingDiagnostics (int i, std::string name);
BoundaryScrapingDiagnostics (int i, const std::string& name);

private:
/** Read relevant parameters for BoundaryScraping */
Expand Down
4 changes: 2 additions & 2 deletions Source/Diagnostics/BoundaryScrapingDiagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

using namespace amrex::literals;

BoundaryScrapingDiagnostics::BoundaryScrapingDiagnostics (int i, std::string name)
: Diagnostics(i, name)
BoundaryScrapingDiagnostics::BoundaryScrapingDiagnostics (int i, const std::string& name)
: Diagnostics{i, name}
{
ReadParameters();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public:
* \param[in] ncomp Number of component of mf_src to cell-center in dst multifab.
*/
ParticleReductionFunctor(const amrex::MultiFab * mf_src, int lev,
amrex::IntVect crse_ratio, std::string fn_str,
amrex::IntVect crse_ratio, const std::string& fn_str,
int ispec, bool do_average,
bool do_filter, std::string filter_str,
bool do_filter, const std::string& filter_str,
int ncomp=1);

/** \brief Compute the average of the function m_map_fn over each grid cell.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
using namespace amrex::literals;

ParticleReductionFunctor::ParticleReductionFunctor (const amrex::MultiFab* mf_src, const int lev,
const amrex::IntVect crse_ratio, const std::string fn_str,
const amrex::IntVect crse_ratio, const std::string& fn_str,
const int ispec, const bool do_average,
const bool do_filter, const std::string filter_str, const int ncomp)
const bool do_filter, const std::string& filter_str, const int ncomp)
: ComputeDiagFunctor(ncomp, crse_ratio), m_lev(lev), m_ispec(ispec), m_do_average(do_average), m_do_filter(do_filter)
{
// mf_src will not be used, let's make sure it's null.
Expand Down
4 changes: 2 additions & 2 deletions Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ WriteZeroRawMF( const MultiFab& F, const DistributionMapping& dm,
* coarse and fine patch to have the same shape.
*/
void
WriteCoarseVector( const std::string field_name,
WriteCoarseVector( const std::string& field_name,
const MultiFab* Fx_cp,
const MultiFab* Fy_cp,
const MultiFab* Fz_cp,
Expand Down Expand Up @@ -519,7 +519,7 @@ WriteCoarseVector( const std::string field_name,
* coarse and fine patch to have the same shape.
*/
void
WriteCoarseScalar( const std::string field_name,
WriteCoarseScalar( const std::string& field_name,
const MultiFab* F_cp,
const MultiFab* F_fp,
const DistributionMapping& dm,
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/FlushFormats/FlushFormatSensei.H
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public:
* \param[in] amr_mesh an AmrMesh instance
* \param[in] diag_name ParmParse scope string.
*/
FlushFormatSensei (amrex::AmrMesh *amr_mesh, std::string diag_name);
FlushFormatSensei (amrex::AmrMesh *amr_mesh, const std::string& diag_name);

/** Do in-situ visualization for field and particle data */
void WriteToFile (
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/FlushFormats/FlushFormatSensei.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#endif

FlushFormatSensei::FlushFormatSensei (amrex::AmrMesh *amr_mesh,
std::string diag_name) :
const std::string& diag_name) :
m_amr_mesh(amr_mesh)
{
#ifndef AMREX_USE_SENSEI_INSITU
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/FullDiagnostics.H
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class FullDiagnostics final : public Diagnostics
{
public:
FullDiagnostics (int i, std::string name);
FullDiagnostics (int i, const std::string& name);
private:
/** Read user-requested parameters for full diagnostics */
void ReadParameters ();
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/FullDiagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

using namespace amrex::literals;

FullDiagnostics::FullDiagnostics (int i, std::string name):
FullDiagnostics::FullDiagnostics (int i, const std::string& name):
Diagnostics{i, name},
m_solver_deposits_current{
(WarpX::electromagnetic_solver_id != ElectromagneticSolverAlgo::None) ||
Expand Down
3 changes: 2 additions & 1 deletion Source/Diagnostics/ParticleDiag/ParticleDiag.H
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
class ParticleDiag
{
public:
ParticleDiag(std::string diag_name, std::string name, WarpXParticleContainer* pc, PinnedMemoryParticleContainer *pinned_pc = nullptr);
ParticleDiag(const std::string& diag_name, const std::string& name,
WarpXParticleContainer* pc, PinnedMemoryParticleContainer *pinned_pc = nullptr);
[[nodiscard]] WarpXParticleContainer* getParticleContainer() const { return m_pc; }
[[nodiscard]] PinnedMemoryParticleContainer* getPinnedParticleContainer() const { return m_pinned_pc; }
[[nodiscard]] std::string getSpeciesName() const { return m_name; }
Expand Down
6 changes: 4 additions & 2 deletions Source/Diagnostics/ParticleDiag/ParticleDiag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@

using namespace amrex;

ParticleDiag::ParticleDiag(std::string diag_name, std::string name, WarpXParticleContainer* pc, PinnedMemoryParticleContainer* pinned_pc)
: m_diag_name(diag_name), m_name(name), m_pc(pc), m_pinned_pc(pinned_pc)
ParticleDiag::ParticleDiag(
const std::string& diag_name, const std::string& name,
WarpXParticleContainer* pc, PinnedMemoryParticleContainer* pinned_pc):
m_diag_name(diag_name), m_name(name), m_pc(pc), m_pinned_pc(pinned_pc)
{
//variable to set m_plot_flags size
const int plot_flag_size = pc->NumRealComps();
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/ReducedDiags/BeamRelevant.H
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public:
* constructor
* @param[in] rd_name reduced diags names
*/
BeamRelevant(std::string rd_name);
BeamRelevant(const std::string& rd_name);

/// name of beam species
std::string m_beam_name;
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/ReducedDiags/BeamRelevant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
using namespace amrex;

// constructor
BeamRelevant::BeamRelevant (std::string rd_name)
BeamRelevant::BeamRelevant (const std::string& rd_name)
: ReducedDiags{rd_name}
{
// read beam name
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/ReducedDiags/ChargeOnEB.H
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public:
* constructor
* @param[in] rd_name reduced diags names
*/
ChargeOnEB (std::string rd_name);
ChargeOnEB (const std::string& rd_name);

/**
* This function computes the charge at the surface of the EB:
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/ReducedDiags/ChargeOnEB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
using namespace amrex;

// constructor
ChargeOnEB::ChargeOnEB (std::string rd_name)
ChargeOnEB::ChargeOnEB (const std::string& rd_name)
: ReducedDiags{rd_name}
{
// Only 3D is working for now
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/ReducedDiags/ColliderRelevant.H
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public:
* constructor
* @param[in] rd_name reduced diags names
*/
ColliderRelevant(std::string rd_name);
ColliderRelevant(const std::string& rd_name);

/// name of the two colliding species
std::vector<std::string> m_beam_name;
Expand Down
4 changes: 2 additions & 2 deletions Source/Diagnostics/ReducedDiags/ColliderRelevant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@

using namespace amrex;

ColliderRelevant::ColliderRelevant (std::string rd_name)
: ReducedDiags{std::move(rd_name)}
ColliderRelevant::ColliderRelevant (const std::string& rd_name)
: ReducedDiags{rd_name}
{
// read colliding species names - must be 2
const amrex::ParmParse pp_rd_name(m_rd_name);
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/ReducedDiags/FieldEnergy.H
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public:
* constructor
* @param[in] rd_name reduced diags names
*/
FieldEnergy(std::string rd_name);
FieldEnergy(const std::string& rd_name);

/**
* This function computes the field energy (EF):
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/ReducedDiags/FieldEnergy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
using namespace amrex;

// constructor
FieldEnergy::FieldEnergy (std::string rd_name)
FieldEnergy::FieldEnergy (const std::string& rd_name)
: ReducedDiags{rd_name}
{

Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/ReducedDiags/FieldMaximum.H
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public:
* constructor
* @param[in] rd_name reduced diags names
*/
FieldMaximum(std::string rd_name);
FieldMaximum(const std::string& rd_name);

/**
* This function computes the maximum value of Ex, Ey, Ez, |E|, Bx, By, Bz and |B|
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/ReducedDiags/FieldMaximum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
using namespace amrex;

// constructor
FieldMaximum::FieldMaximum (std::string rd_name)
FieldMaximum::FieldMaximum (const std::string& rd_name)
: ReducedDiags{rd_name}
{
// RZ coordinate is not working
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/ReducedDiags/FieldMomentum.H
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public:
*
* \param[in] rd_name reduced diags names
*/
FieldMomentum(std::string rd_name);
FieldMomentum(const std::string& rd_name);

/**
* \brief This function computes the electromagnetic momentum,
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/ReducedDiags/FieldMomentum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

using namespace amrex;

FieldMomentum::FieldMomentum (std::string rd_name)
FieldMomentum::FieldMomentum (const std::string& rd_name)
: ReducedDiags{rd_name}
{
// RZ coordinate is not working
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/ReducedDiags/FieldProbe.H
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public:
* constructor
* @param[in] rd_name reduced diags names
*/
FieldProbe (std::string rd_name);
FieldProbe (const std::string& rd_name);

/**
* This function assins test/data particles to constructed environemnt
Expand Down
Loading

0 comments on commit a5d5432

Please sign in to comment.