From a265adaddb3049b854cf659ef089bfc9b2d973b5 Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Mon, 30 Jul 2018 15:46:57 -0700 Subject: [PATCH] Enable clang-tidy for headers Change-Id: Id5acfb264ac57c09cc1a7d8ab512eb7c6bfc40f1 --- src/external/tng_io/BuildTNG.cmake | 2 +- src/external/vmd_molfile/molfile_plugin.h | 10 +- src/external/vmd_molfile/vmdplugin.h | 2 +- src/gromacs/CMakeLists.txt | 6 +- src/gromacs/awh/awh.h | 4 +- src/gromacs/awh/bias.h | 2 +- src/gromacs/awh/biasstate.cpp | 6 +- src/gromacs/awh/biasstate.h | 2 +- src/gromacs/awh/correlationgrid.h | 4 +- src/gromacs/awh/pointstate.h | 12 +-- src/gromacs/correlationfunctions/expfit.h | 2 +- src/gromacs/domdec/domdec_internal.h | 2 +- src/gromacs/domdec/domdec_struct.h | 2 +- src/gromacs/domdec/ga2la.h | 4 - src/gromacs/domdec/hash.h | 2 +- src/gromacs/ewald/pme-gpu-internal.h | 2 +- src/gromacs/ewald/pme-gpu-program.h | 2 +- src/gromacs/ewald/pme-internal.h | 2 +- src/gromacs/ewald/pme.h | 2 +- src/gromacs/fileio/gmxfio-xdr.h | 20 ++-- src/gromacs/fileio/readinp.h | 7 +- src/gromacs/fileio/tngio.h | 4 +- src/gromacs/fileio/trxio.h | 2 +- src/gromacs/gmxana/gstat.h | 2 +- src/gromacs/gmxlib/nrnb.h | 2 +- src/gromacs/gmxpreprocess/grompp-impl.h | 2 +- src/gromacs/gpu_utils/gpu_macros.h | 2 +- src/gromacs/listed-forces/pairs.h | 2 +- src/gromacs/math/units.h | 6 +- src/gromacs/math/vectypes.h | 4 +- src/gromacs/mdlib/constr.h | 2 +- src/gromacs/mdlib/groupcoord.h | 14 +-- src/gromacs/mdlib/main.h | 2 +- src/gromacs/mdlib/mdatoms.h | 2 +- src/gromacs/mdlib/mdrun.h | 4 - .../nbnxn_kernels/nbnxn_kernel_ref_outer.h | 8 +- .../simd_4xn/nbnxn_kernel_simd_4xn_inner.h | 6 +- src/gromacs/mdlib/nbnxn_pairlist.h | 2 +- src/gromacs/mdlib/nbnxn_search.h | 2 +- src/gromacs/mdrunutility/handlerestart.h | 2 +- src/gromacs/mdtypes/awh-correlation-history.h | 8 +- src/gromacs/mdtypes/awh-history.h | 11 +- src/gromacs/mdtypes/energyhistory.h | 11 +- src/gromacs/mdtypes/forcerec.h | 2 +- src/gromacs/mdtypes/group.h | 4 +- src/gromacs/mdtypes/inputrec.h | 2 +- src/gromacs/options/basicoptions.h | 8 +- src/gromacs/options/optionstoragetemplate.h | 18 ++-- src/gromacs/pbcutil/pbc.h | 2 +- .../random/tabulatednormaldistribution.cpp | 5 +- .../random/tabulatednormaldistribution.h | 10 +- src/gromacs/random/threefry.h | 2 - src/gromacs/selection/parsetree.h | 16 +-- src/gromacs/selection/scanner_internal.h | 6 +- src/gromacs/selection/selection.h | 10 +- src/gromacs/selection/selmethod.cpp | 100 +++++++++--------- .../impl_x86_avx_256_simd_double.h | 10 +- .../impl_x86_avx_256_simd_float.h | 10 +- src/gromacs/simd/simd.h | 2 +- src/gromacs/simd/simd_memory.h | 6 +- src/gromacs/tables/splineutil.h | 4 +- src/gromacs/taskassignment/decidegpuusage.h | 44 ++++---- src/gromacs/timing/wallcycle.h | 2 +- src/gromacs/topology/idef.h | 2 +- src/gromacs/topology/ifunc.h | 2 +- src/gromacs/topology/topology.h | 2 +- src/gromacs/trajectory/energyframe.h | 2 +- src/gromacs/trajectory/trajectoryframe.h | 2 +- src/gromacs/utility/allocator.h | 6 +- src/gromacs/utility/arrayref.h | 2 +- src/gromacs/utility/arraysize.h | 2 +- src/gromacs/utility/basedefinitions.h | 14 ++- src/gromacs/utility/classhelpers.h | 6 +- src/gromacs/utility/fatalerror.h | 2 +- src/gromacs/utility/keyvaluetree.h | 4 +- src/gromacs/utility/logger.h | 5 +- src/gromacs/utility/nodelete.h | 4 +- src/gromacs/utility/variant.h | 18 +--- 78 files changed, 263 insertions(+), 270 deletions(-) diff --git a/src/external/tng_io/BuildTNG.cmake b/src/external/tng_io/BuildTNG.cmake index 0b70c4d99f..e3810a1771 100644 --- a/src/external/tng_io/BuildTNG.cmake +++ b/src/external/tng_io/BuildTNG.cmake @@ -71,7 +71,7 @@ function(add_tng_io_library NAME) target_include_directories(${_build_target} PRIVATE $ $) - target_include_directories(${NAME} INTERFACE + target_include_directories(${NAME} SYSTEM INTERFACE $ $) diff --git a/src/external/vmd_molfile/molfile_plugin.h b/src/external/vmd_molfile/molfile_plugin.h index 52b550dee0..1a251c3778 100644 --- a/src/external/vmd_molfile/molfile_plugin.h +++ b/src/external/vmd_molfile/molfile_plugin.h @@ -87,11 +87,11 @@ OTHER DEALINGS WITH THE SOFTWARE. /* File plugin symbolic constants for better code readability */ #define MOLFILE_SUCCESS 0 /**< succeeded in reading file */ -#define MOLFILE_EOF -1 /**< end of file */ -#define MOLFILE_ERROR -1 /**< error reading/opening a file */ -#define MOLFILE_NOSTRUCTUREDATA -2 /**< no structure data in this file */ +#define MOLFILE_EOF (-1) /**< end of file */ +#define MOLFILE_ERROR (-1) /**< error reading/opening a file */ +#define MOLFILE_NOSTRUCTUREDATA (-2) /**< no structure data in this file */ -#define MOLFILE_NUMATOMS_UNKNOWN -1 /**< unknown number of atoms */ +#define MOLFILE_NUMATOMS_UNKNOWN (-1) /**< unknown number of atoms */ #define MOLFILE_NUMATOMS_NONE 0 /**< no atoms in this file type */ /** @@ -103,7 +103,7 @@ OTHER DEALINGS WITH THE SOFTWARE. #define MOLFILE_MAXWAVEPERTS 25 /**< maximum number of wavefunctions * per timestep */ -#define MOLFILE_QM_STATUS_UNKNOWN -1 +#define MOLFILE_QM_STATUS_UNKNOWN (-1) #define MOLFILE_QM_OPT_CONVERGED 0 #define MOLFILE_QM_SCF_NOT_CONV 1 #define MOLFILE_QM_OPT_NOT_CONV 2 diff --git a/src/external/vmd_molfile/vmdplugin.h b/src/external/vmd_molfile/vmdplugin.h index 895bf14023..62ec64b083 100644 --- a/src/external/vmd_molfile/vmdplugin.h +++ b/src/external/vmd_molfile/vmdplugin.h @@ -203,7 +203,7 @@ typedef struct { /*@{*/ /** Error return code for use in the plugin registration and init functions */ #define VMDPLUGIN_SUCCESS 0 -#define VMDPLUGIN_ERROR -1 +#define VMDPLUGIN_ERROR (-1) /*@}*/ /** diff --git a/src/gromacs/CMakeLists.txt b/src/gromacs/CMakeLists.txt index ec2876c840..b1fba8987b 100644 --- a/src/gromacs/CMakeLists.txt +++ b/src/gromacs/CMakeLists.txt @@ -346,10 +346,14 @@ if (GMX_CLANG_TIDY) "-readability-implicit-bool-conversion" #TODO: Remove gmx_bool "modernize-use-nullptr" "modernize-use-emplace" "modernize-make-unique" "modernize-make-shared" + "cppcoreguidelines-*" "-cppcoreguidelines-pro-*" + "-cppcoreguidelines-owning-memory" + "-cppcoreguidelines-no-malloc" + "-cppcoreguidelines-special-member-functions" #in conflict with Wunused-member-function ) string(REPLACE ";" "," CLANG_TIDY_CHECKS "${CLANG_TIDY_CHECKS}") set_target_properties(libgromacs PROPERTIES CXX_CLANG_TIDY - "${CLANG_TIDY_EXE};--checks=${CLANG_TIDY_CHECKS};-warnings-as-errors=*;-fix") + "${CLANG_TIDY_EXE};--checks=${CLANG_TIDY_CHECKS};-warnings-as-errors=*;-header-filter=.*") endif() gmx_write_installed_header_list() diff --git a/src/gromacs/awh/awh.h b/src/gromacs/awh/awh.h index 7bbc2a97aa..dd8618af58 100644 --- a/src/gromacs/awh/awh.h +++ b/src/gromacs/awh/awh.h @@ -273,8 +273,8 @@ prepareAwhModule(FILE *fplog, t_state *stateGlobal, const t_commrec *commRecord, const gmx_multisim_t *multiSimRecord, - const bool startingFromCheckpoint, - const bool usingShellParticles, + bool startingFromCheckpoint, + bool usingShellParticles, const std::string &biasInitFilename, pull_t *pull_work); diff --git a/src/gromacs/awh/bias.h b/src/gromacs/awh/bias.h index 2e3a8c5798..8f395bb17b 100644 --- a/src/gromacs/awh/bias.h +++ b/src/gromacs/awh/bias.h @@ -332,7 +332,7 @@ class Bias { GMX_RELEASE_ASSERT(forceCorrelationGrid_ != nullptr, "forceCorrelationGrid() should only be called with a valid force correlation object"); - return *forceCorrelationGrid_.get(); + return *forceCorrelationGrid_; } /*! \brief Return the number of data blocks that have been prepared for writing. diff --git a/src/gromacs/awh/biasstate.cpp b/src/gromacs/awh/biasstate.cpp index b526ebee07..173f095637 100644 --- a/src/gromacs/awh/biasstate.cpp +++ b/src/gromacs/awh/biasstate.cpp @@ -224,7 +224,7 @@ double biasedLogWeightFromPoint(const std::vector &dimParams, double pointBias, const awh_dvec value) { - double logWeight = c_largeNegativeExponent; + double logWeight = detail::c_largeNegativeExponent; /* Only points in the target reigon have non-zero weight */ if (points[pointIndex].inTargetRegion()) @@ -1050,7 +1050,7 @@ void BiasState::updateFreeEnergyAndAddSamplesToHistogram(const std::vector 0.5*c_largePositiveExponent) + if (std::abs(points_[globalIndex].freeEnergy()) > 0.5*detail::c_largePositiveExponent) { needToNormalizeFreeEnergy = true; break; @@ -1185,7 +1185,7 @@ double BiasState::updateProbabilityWeightsAndConvolvedBias(const std::vector(weightData + i); diff --git a/src/gromacs/awh/biasstate.h b/src/gromacs/awh/biasstate.h index 5fd7ccd204..ecd73e32d3 100644 --- a/src/gromacs/awh/biasstate.h +++ b/src/gromacs/awh/biasstate.h @@ -490,7 +490,7 @@ class BiasState * * \param[out] pmf Array(ref) to be filled with the PMF values, should have the same size as the bias grid. */ - void getPmf(gmx::ArrayRef) const; + void getPmf(gmx::ArrayRef /*pmf*/) const; /*! \brief Returns the current coordinate state. */ diff --git a/src/gromacs/awh/correlationgrid.h b/src/gromacs/awh/correlationgrid.h index ecfb5288d7..5d3456b44b 100644 --- a/src/gromacs/awh/correlationgrid.h +++ b/src/gromacs/awh/correlationgrid.h @@ -120,7 +120,7 @@ class CorrelationGrid */ int tensorSize() const { - GMX_RELEASE_ASSERT(tensors_.size() > 0, "Should only call tensorSize on a valid grid"); + GMX_RELEASE_ASSERT(!tensors_.empty(), "Should only call tensorSize on a valid grid"); return tensors_[0].blockDataList()[0].correlationIntegral().size(); } @@ -129,7 +129,7 @@ class CorrelationGrid */ int blockDataListSize() const { - GMX_RELEASE_ASSERT(tensors_.size() > 0, "Should only call tensorSize on a valid grid"); + GMX_RELEASE_ASSERT(!tensors_.empty(), "Should only call tensorSize on a valid grid"); return tensors_[0].blockDataList().size(); } diff --git a/src/gromacs/awh/pointstate.h b/src/gromacs/awh/pointstate.h index aad5ee2641..414d644ba0 100644 --- a/src/gromacs/awh/pointstate.h +++ b/src/gromacs/awh/pointstate.h @@ -61,16 +61,16 @@ namespace gmx { -namespace +namespace detail { //! A value that can be passed to exp() with result 0, also with SIMD -static constexpr double c_largeNegativeExponent = -10000.0; +constexpr double c_largeNegativeExponent = -10000.0; //! The largest acceptable positive exponent for variables that are passed to exp(). -static constexpr double c_largePositiveExponent = 700.0; +constexpr double c_largePositiveExponent = 700.0; -} // namepace +} // namepace detail /*! \internal * \brief The state of a coordinate point. @@ -155,7 +155,7 @@ class PointState { target_ = 0; /* the bias = log(target) + const = -infty */ - bias_ = c_largeNegativeExponent; + bias_ = detail::c_largeNegativeExponent; } /*! \brief Return the free energy. */ @@ -379,7 +379,7 @@ class PointState double df = -std::log(weighthistSampled/weighthistTarget); freeEnergy_ += df; - GMX_RELEASE_ASSERT(std::abs(freeEnergy_) < c_largePositiveExponent, + GMX_RELEASE_ASSERT(std::abs(freeEnergy_) < detail::c_largePositiveExponent, "Very large free energy differences or badly normalized free energy in AWH update."); } diff --git a/src/gromacs/correlationfunctions/expfit.h b/src/gromacs/correlationfunctions/expfit.h index e18fa13826..73da32fd90 100644 --- a/src/gromacs/correlationfunctions/expfit.h +++ b/src/gromacs/correlationfunctions/expfit.h @@ -97,7 +97,7 @@ int sffn2effn(const char **sffn); * \param[in] x The value of x * \return the value of the fit */ -double fit_function(const int eFitFn, const double parm[], const double x); +double fit_function(int eFitFn, const double parm[], double x); /*! \brief * Use Levenberg-Marquardt method to fit to a nfitparm parameter exponential diff --git a/src/gromacs/domdec/domdec_internal.h b/src/gromacs/domdec/domdec_internal.h index 819a2d4b48..87432ae05a 100644 --- a/src/gromacs/domdec/domdec_internal.h +++ b/src/gromacs/domdec/domdec_internal.h @@ -382,7 +382,7 @@ struct dd_comm_setup_work_t * All arrays are indexed with 0 to dd->ndim (not Cartesian indexing), * unless stated otherwise. */ -struct gmx_domdec_comm_t +struct gmx_domdec_comm_t // NOLINT (clang-analyzer-optin.performance.Padding) { /* PME and Cartesian communicator stuff */ int npmedecompdim; /**< The number of decomposition dimensions for PME, 0: no PME */ diff --git a/src/gromacs/domdec/domdec_struct.h b/src/gromacs/domdec/domdec_struct.h index f923190ddc..47b7460d71 100644 --- a/src/gromacs/domdec/domdec_struct.h +++ b/src/gromacs/domdec/domdec_struct.h @@ -126,7 +126,7 @@ struct gmx_ddbox_t { }; -struct gmx_domdec_t { +struct gmx_domdec_t { //NOLINT(clang-analyzer-optin.performance.Padding) /* The DD particle-particle nodes only */ /* The communication setup within the communicator all * defined in dd->comm in domdec.c diff --git a/src/gromacs/domdec/ga2la.h b/src/gromacs/domdec/ga2la.h index 9ef7c8958a..7cb23f320d 100644 --- a/src/gromacs/domdec/ga2la.h +++ b/src/gromacs/domdec/ga2la.h @@ -251,8 +251,6 @@ static inline void ga2la_del(gmx_ga2la_t *ga2la, int a_gl) ind = ga2la->lal[ind].next; } while (ind >= 0); - - return; } /*! \brief Change the local atom for present ga2la entry for global atom a_gl @@ -284,8 +282,6 @@ static inline void ga2la_change_la(gmx_ga2la_t *ga2la, int a_gl, int a_loc) ind = ga2la->lal[ind].next; } while (ind >= 0); - - return; } /*! \brief Returns if the global atom a_gl available locally diff --git a/src/gromacs/domdec/hash.h b/src/gromacs/domdec/hash.h index 34871a8317..a082a9d940 100644 --- a/src/gromacs/domdec/hash.h +++ b/src/gromacs/domdec/hash.h @@ -54,7 +54,7 @@ #include //! Forward declation -static void gmx_hash_resize(gmx_hash_t *, int); +static void gmx_hash_resize(gmx_hash_t * /*hash*/, int /*nkey_used_estimate*/); /*! \internal \brief Hashing key-generation helper struct */ struct gmx_hash_e_t diff --git a/src/gromacs/ewald/pme-gpu-internal.h b/src/gromacs/ewald/pme-gpu-internal.h index cbfc4ecb55..cb6371f2d3 100644 --- a/src/gromacs/ewald/pme-gpu-internal.h +++ b/src/gromacs/ewald/pme-gpu-internal.h @@ -415,7 +415,7 @@ GPU_FUNC_QUALIFIER void pme_gpu_spread(const PmeGpu *GPU_FUNC_ARGUMENT(pmeGpu */ void pme_gpu_3dfft(const PmeGpu *pmeGpu, enum gmx_fft_direction direction, - const int gridIndex); + int gridIndex); /*! \libinternal \brief * A GPU Fourier space solving function. diff --git a/src/gromacs/ewald/pme-gpu-program.h b/src/gromacs/ewald/pme-gpu-program.h index 0cd8b1a747..76045e32bf 100644 --- a/src/gromacs/ewald/pme-gpu-program.h +++ b/src/gromacs/ewald/pme-gpu-program.h @@ -74,6 +74,6 @@ using PmeGpuProgramHandle = const PmeGpuProgram *; /*! \brief * Factory function used to build persistent PME GPU program for the device at once. */ -PmeGpuProgramStorage buildPmeGpuProgram(const gmx_device_info_t *); +PmeGpuProgramStorage buildPmeGpuProgram(const gmx_device_info_t * /*deviceInfo*/); #endif diff --git a/src/gromacs/ewald/pme-internal.h b/src/gromacs/ewald/pme-internal.h index 3b200f41da..9dcfdf38c8 100644 --- a/src/gromacs/ewald/pme-internal.h +++ b/src/gromacs/ewald/pme-internal.h @@ -229,7 +229,7 @@ struct pme_spline_work; struct pme_solve_work_t; /*! \brief Master PME data structure */ -struct gmx_pme_t { +struct gmx_pme_t { //NOLINT(clang-analyzer-optin.performance.Padding) int ndecompdim; /* The number of decomposition dimensions */ int nodeid; /* Our nodeid in mpi->mpi_comm */ int nodeid_major; diff --git a/src/gromacs/ewald/pme.h b/src/gromacs/ewald/pme.h index 0e3cf61391..5f6e83f717 100644 --- a/src/gromacs/ewald/pme.h +++ b/src/gromacs/ewald/pme.h @@ -240,7 +240,7 @@ void gmx_pme_receive_f(const t_commrec *cr, * \param[in] nAtoms The number of particles. * \param[in] charges The pointer to the array of particle charges. */ -void gmx_pme_reinit_atoms(const gmx_pme_t *pme, const int nAtoms, const real *charges); +void gmx_pme_reinit_atoms(const gmx_pme_t *pme, int nAtoms, const real *charges); /* A block of PME GPU functions */ diff --git a/src/gromacs/fileio/gmxfio-xdr.h b/src/gromacs/fileio/gmxfio-xdr.h index 402ea39501..bb9a6333d6 100644 --- a/src/gromacs/fileio/gmxfio-xdr.h +++ b/src/gromacs/fileio/gmxfio-xdr.h @@ -110,16 +110,16 @@ gmx_bool gmx_fio_ndoe_string(struct t_fileio *fio, char *item[], int n, /* convenience macros */ #define gmx_fio_write_string(fio, item) gmx_fio_writee_string(fio, item, (#item), __FILE__, __LINE__) -#define gmx_fio_do_real(fio, item) gmx_fio_doe_real(fio, &item, (#item), __FILE__, __LINE__) -#define gmx_fio_do_float(fio, item) gmx_fio_doe_float(fio, &item, (#item), __FILE__, __LINE__) -#define gmx_fio_do_double(fio, item) gmx_fio_doe_double(fio, &item, (#item), __FILE__, __LINE__) -#define gmx_fio_do_gmx_bool(fio, item) gmx_fio_doe_gmx_bool(fio, &item, (#item), __FILE__, __LINE__) -#define gmx_fio_do_int(fio, item) gmx_fio_doe_int(fio, &item, (#item), __FILE__, __LINE__) -#define gmx_fio_do_int64(fio, item) gmx_fio_doe_int64(fio, &item, (#item), __FILE__, __LINE__) -#define gmx_fio_do_uchar(fio, item) gmx_fio_doe_uchar(fio, &item, (#item), __FILE__, __LINE__) -#define gmx_fio_do_ushort(fio, item) gmx_fio_doe_ushort(fio, &item, (#item), __FILE__, __LINE__) -#define gmx_fio_do_rvec(fio, item) gmx_fio_doe_rvec(fio, &item, (#item), __FILE__, __LINE__) -#define gmx_fio_do_ivec(fio, item) gmx_fio_doe_ivec(fio, &item, (#item), __FILE__, __LINE__) +#define gmx_fio_do_real(fio, item) gmx_fio_doe_real(fio, &(item), (#item), __FILE__, __LINE__) +#define gmx_fio_do_float(fio, item) gmx_fio_doe_float(fio, &(item), (#item), __FILE__, __LINE__) +#define gmx_fio_do_double(fio, item) gmx_fio_doe_double(fio, &(item), (#item), __FILE__, __LINE__) +#define gmx_fio_do_gmx_bool(fio, item) gmx_fio_doe_gmx_bool(fio, &(item), (#item), __FILE__, __LINE__) +#define gmx_fio_do_int(fio, item) gmx_fio_doe_int(fio, &(item), (#item), __FILE__, __LINE__) +#define gmx_fio_do_int64(fio, item) gmx_fio_doe_int64(fio, &(item), (#item), __FILE__, __LINE__) +#define gmx_fio_do_uchar(fio, item) gmx_fio_doe_uchar(fio, &(item), (#item), __FILE__, __LINE__) +#define gmx_fio_do_ushort(fio, item) gmx_fio_doe_ushort(fio, &(item), (#item), __FILE__, __LINE__) +#define gmx_fio_do_rvec(fio, item) gmx_fio_doe_rvec(fio, &(item), (#item), __FILE__, __LINE__) +#define gmx_fio_do_ivec(fio, item) gmx_fio_doe_ivec(fio, &(item), (#item), __FILE__, __LINE__) #define gmx_fio_do_string(fio, item) gmx_fio_doe_string(fio, item, (#item), __FILE__, __LINE__) diff --git a/src/gromacs/fileio/readinp.h b/src/gromacs/fileio/readinp.h index fa3a8e0724..7a1e1f3216 100644 --- a/src/gromacs/fileio/readinp.h +++ b/src/gromacs/fileio/readinp.h @@ -40,6 +40,7 @@ #include #include +#include #include #include "gromacs/utility/arrayref.h" @@ -71,8 +72,8 @@ struct t_inpfile bObsolete_(bObsolete), bSet_(bSet), bHandledAsKeyValueTree_(bHandledAsKeyValueTree), - name_(name), - value_(value), + name_(std::move(name)), + value_(std::move(value)), inp_count_(inp_count) { } @@ -137,7 +138,7 @@ int get_eint(std::vector *inp, const char *name, int def, int64_t get_eint64(std::vector *inp, const char *name, int64_t def, - warninp_t); + warninp_t /*wi*/); double get_ereal(std::vector *inp, const char *name, double def, warninp_t wi); diff --git a/src/gromacs/fileio/tngio.h b/src/gromacs/fileio/tngio.h index 9af0a7f27c..7e3ad37351 100644 --- a/src/gromacs/fileio/tngio.h +++ b/src/gromacs/fileio/tngio.h @@ -117,7 +117,7 @@ void gmx_tng_prepare_low_prec_writing(gmx_tng_trajectory_t tng, * The pointers tng, x, v, f may be NULL, which triggers not writing * (that component). box can only be NULL if x is also NULL. */ void gmx_fwrite_tng(gmx_tng_trajectory_t tng, - const gmx_bool bUseLossyCompression, + gmx_bool bUseLossyCompression, int64_t step, real elapsedPicoSeconds, real lambda, @@ -169,7 +169,7 @@ void gmx_write_tng_from_trxframe(gmx_tng_trajectory_t output, * the number of all other molecules to 0. Works similar to a * selection group. */ void gmx_tng_setup_atom_subgroup(gmx_tng_trajectory_t tng, - const int nind, + int nind, const int *ind, const char *name); diff --git a/src/gromacs/fileio/trxio.h b/src/gromacs/fileio/trxio.h index ee035a0fd8..eec2af65a3 100644 --- a/src/gromacs/fileio/trxio.h +++ b/src/gromacs/fileio/trxio.h @@ -105,7 +105,7 @@ trjtools_gmx_prepare_tng_writing(const char *filename, char filemode, t_trxstatus *in, const char *infile, - const int natoms, + int natoms, const struct gmx_mtop_t *mtop, const int *index, const char *index_group_name); diff --git a/src/gromacs/gmxana/gstat.h b/src/gromacs/gmxana/gstat.h index 8959b01446..3e0a7d0270 100644 --- a/src/gromacs/gmxana/gstat.h +++ b/src/gromacs/gmxana/gstat.h @@ -58,7 +58,7 @@ enum { #define NHISTO 360 #define NONCHI 3 -#define MAXCHI edMax-NONCHI +#define MAXCHI (edMax-NONCHI) #define NROT 4 /* number of rotamers: 1=g(-), 2=t, 3=g(+), 0=other */ typedef struct { diff --git a/src/gromacs/gmxlib/nrnb.h b/src/gromacs/gmxlib/nrnb.h index 124ee5f733..7f7e48bd46 100644 --- a/src/gromacs/gmxlib/nrnb.h +++ b/src/gromacs/gmxlib/nrnb.h @@ -42,7 +42,7 @@ #include "gromacs/utility/basedefinitions.h" -#define eNR_NBKERNEL_NONE -1 +#define eNR_NBKERNEL_NONE (-1) enum { diff --git a/src/gromacs/gmxpreprocess/grompp-impl.h b/src/gromacs/gmxpreprocess/grompp-impl.h index e8484de27b..cf1fd66e8c 100644 --- a/src/gromacs/gmxpreprocess/grompp-impl.h +++ b/src/gromacs/gmxpreprocess/grompp-impl.h @@ -79,7 +79,7 @@ typedef struct { real &c2() { return c[2]; } } t_param; -typedef struct { +typedef struct { // NOLINT (clang-analyzer-optin.performance.Padding) int nr; /* The number of bonds in this record */ int maxnr; /* The amount of elements in the array */ t_param *param; /* Array of parameters (dim: nr or nr*nr) */ diff --git a/src/gromacs/gpu_utils/gpu_macros.h b/src/gromacs/gpu_utils/gpu_macros.h index e9d597a754..fcfc156fad 100644 --- a/src/gromacs/gpu_utils/gpu_macros.h +++ b/src/gromacs/gpu_utils/gpu_macros.h @@ -48,7 +48,7 @@ #define REAL_FUNC_TERM_WITH_RETURN(arg) ; #define NULL_FUNC_QUALIFIER gmx_unused static -#define NULL_FUNC_ARGUMENT(arg) /*arg*/ +#define NULL_FUNC_ARGUMENT(arg) arg gmx_unused #define NULL_FUNC_TERM {} #define NULL_FUNC_TERM_WITH_RETURN(arg) { return (arg); } diff --git a/src/gromacs/listed-forces/pairs.h b/src/gromacs/listed-forces/pairs.h index 8d2ee0a5bc..88af8347c4 100644 --- a/src/gromacs/listed-forces/pairs.h +++ b/src/gromacs/listed-forces/pairs.h @@ -65,7 +65,7 @@ do_pairs(int ftype, int nbonds, const t_iatom iatoms[], const t_iparams iparams[ const rvec x[], rvec4 f[], rvec fshift[], const struct t_pbc *pbc, const struct t_graph *g, const real *lambda, real *dvdl, const t_mdatoms *md, const t_forcerec *fr, - const gmx_bool computeForcesOnly, gmx_grppairener_t *grppener, + gmx_bool computeForcesOnly, gmx_grppairener_t *grppener, int *global_atom_index); #endif diff --git a/src/gromacs/math/units.h b/src/gromacs/math/units.h index 69eb52bc40..aec8ab16a6 100644 --- a/src/gromacs/math/units.h +++ b/src/gromacs/math/units.h @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. - * Copyright (c) 2012,2014,2015, by the GROMACS development team, led by + * Copyright (c) 2012,2014,2015,2018, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -72,7 +72,7 @@ extern "C" { #define EPSILON0_SI (8.854187817e-12) /* F/m, NIST 2010 CODATA */ /* Epsilon in our MD units: (e^2 / Na (kJ nm)) == (e^2 mol/(kJ nm)) */ -#define EPSILON0 (EPSILON0_SI*NANO*KILO)/(E_CHARGE*E_CHARGE*AVOGADRO) +#define EPSILON0 ((EPSILON0_SI*NANO*KILO)/(E_CHARGE*E_CHARGE*AVOGADRO)) #define SPEED_OF_LIGHT (2.99792458E05) /* nm/ps, NIST 2010 CODATA */ #define ATOMICMASS_keV (931494.061) /* Atomic mass in keV, NIST 2010 CODATA */ @@ -81,7 +81,7 @@ extern "C" { #define RYDBERG (1.0973731568539e-02) /* nm^-1, NIST 2010 CODATA */ #define ONE_4PI_EPS0 (1.0/(4.0*M_PI*EPSILON0)) -#define FACEL 10.0*ONE_4PI_EPS0 +#define FACEL (10.0*ONE_4PI_EPS0) /* Pressure in MD units is: * 1 bar = 1e5 Pa = 1e5 kg m^-1 s^-2 = 1e-28 kg nm^-1 ps^-2 = 1e-28 / AMU amu nm^1 ps ^2 diff --git a/src/gromacs/math/vectypes.h b/src/gromacs/math/vectypes.h index 3622a65cc3..53dc475223 100644 --- a/src/gromacs/math/vectypes.h +++ b/src/gromacs/math/vectypes.h @@ -116,9 +116,9 @@ class BasicVector //! Default copy assignment operator. BasicVector &operator=(const BasicVector &v) = default; //! Default move constructor. - BasicVector(BasicVector &&src) = default; + BasicVector(BasicVector &&src) noexcept = default; //! Default move assignment operator. - BasicVector &operator=(BasicVector &&v) = default; + BasicVector &operator=(BasicVector &&v) noexcept = default; //! Indexing operator to make the class work as the raw array. ValueType &operator[](int i) { return x_[i]; } //! Indexing operator to make the class work as the raw array. diff --git a/src/gromacs/mdlib/constr.h b/src/gromacs/mdlib/constr.h index 524bb28b7b..d7a8b4a743 100644 --- a/src/gromacs/mdlib/constr.h +++ b/src/gromacs/mdlib/constr.h @@ -251,7 +251,7 @@ int countFlexibleConstraints(const t_ilist *ilist, /*! \brief Macro for getting the constraint iatoms for a constraint number con * which comes from a list where F_CONSTR and F_CONSTRNC constraints * are concatenated. */ -#define constr_iatomptr(nconstr, iatom_constr, iatom_constrnc, con) ((con) < (nconstr) ? (iatom_constr)+(con)*3 : (iatom_constrnc)+(con-nconstr)*3) +#define constr_iatomptr(nconstr, iatom_constr, iatom_constrnc, con) ((con) < (nconstr) ? (iatom_constr)+(con)*3 : (iatom_constrnc)+((con)-(nconstr))*3) /*! \brief Returns whether there are inter charge group constraints */ bool inter_charge_group_constraints(const gmx_mtop_t &mtop); diff --git a/src/gromacs/mdlib/groupcoord.h b/src/gromacs/mdlib/groupcoord.h index bdbf8bee30..fa6f4974e5 100644 --- a/src/gromacs/mdlib/groupcoord.h +++ b/src/gromacs/mdlib/groupcoord.h @@ -79,7 +79,7 @@ extern "C" { */ extern void dd_make_local_group_indices(gmx_ga2la_t *ga2la, - const int nr, int anrs[], int *nr_loc, + int nr, int anrs[], int *nr_loc, int *anrs_loc[], int *nalloc_loc, int coll_ind[]); @@ -128,8 +128,8 @@ extern void dd_make_local_group_indices(gmx_ga2la_t *ga2la, * the group becomes whole (optional). */ extern void communicate_group_positions(const t_commrec *cr, rvec *xcoll, ivec *shifts, - ivec *extra_shifts, const gmx_bool bNS, - const rvec *x_loc, const int nr, const int nr_loc, + ivec *extra_shifts, gmx_bool bNS, + const rvec *x_loc, int nr, int nr_loc, const int *anrs_loc, const int *coll_ind, rvec *xcoll_old, matrix box); @@ -145,7 +145,7 @@ extern void communicate_group_positions(const t_commrec *cr, rvec *xcoll, ivec * * \param[out] center The (weighted) center of the positions. * */ -extern void get_center(rvec x[], real weight[], const int nr, rvec center); +extern void get_center(rvec x[], real weight[], int nr, rvec center); /*! \brief Calculates the sum of the positions x locally. @@ -161,7 +161,7 @@ extern void get_center(rvec x[], real weight[], const int nr, rvec center); * \return Sum of weights. * */ -extern double get_sum_of_positions(rvec x[], real weight[], const int nr, dvec dsumvec); +extern double get_sum_of_positions(rvec x[], real weight[], int nr, dvec dsumvec); /*! \brief Calculates the global center of all local arrays x. @@ -195,7 +195,7 @@ extern void get_center_comm(const t_commrec *cr, rvec x_loc[], real weight_loc[] * \param[in] transvec Translation vector to be added to all positions. * */ -extern void translate_x(rvec x[], const int nr, const rvec transvec); +extern void translate_x(rvec x[], int nr, const rvec transvec); /*! \brief Rotate positions. @@ -207,7 +207,7 @@ extern void translate_x(rvec x[], const int nr, const rvec transvec); * \param[in] rmat Rotation matrix to operate on all positions. * */ -extern void rotate_x(rvec x[], const int nr, matrix rmat); +extern void rotate_x(rvec x[], int nr, matrix rmat); #ifdef __cplusplus } diff --git a/src/gromacs/mdlib/main.h b/src/gromacs/mdlib/main.h index 0122f0a749..8c575693b1 100644 --- a/src/gromacs/mdlib/main.h +++ b/src/gromacs/mdlib/main.h @@ -51,7 +51,7 @@ struct t_commrec; struct t_filenm; void gmx_log_open(const char *fn, const t_commrec *cr, - gmx_bool bAppendFiles, FILE**); + gmx_bool bAppendFiles, FILE** /*fplog*/); /* Open the log file, if necessary (nprocs > 1) the logfile name is * communicated around the ring. */ diff --git a/src/gromacs/mdlib/mdatoms.h b/src/gromacs/mdlib/mdatoms.h index aef6361948..b8ecf61345 100644 --- a/src/gromacs/mdlib/mdatoms.h +++ b/src/gromacs/mdlib/mdatoms.h @@ -94,7 +94,7 @@ class MDAtoms //! Builder function. friend std::unique_ptr makeMDAtoms(FILE *fp, const gmx_mtop_t &mtop, const t_inputrec &ir, - const bool rankHasPmeGpuTask); + bool rankHasPmeGpuTask); }; //! Builder function for MdAtomsWrapper. diff --git a/src/gromacs/mdlib/mdrun.h b/src/gromacs/mdlib/mdrun.h index 3eef882681..ba9bb78605 100644 --- a/src/gromacs/mdlib/mdrun.h +++ b/src/gromacs/mdlib/mdrun.h @@ -139,14 +139,10 @@ struct MdrunOptions globalCommunicationInterval(-1), reproducible(FALSE), writeConfout(TRUE), - continuationOptions(), - checkpointOptions(), numStepsCommandline(-2), maximumHoursToRun(-1), - timingOptions(), tunePme(TRUE), ntompOptionIsSet(FALSE), - imdOptions(), verbose(FALSE), verboseStepPrintInterval(100) { diff --git a/src/gromacs/mdlib/nbnxn_kernels/nbnxn_kernel_ref_outer.h b/src/gromacs/mdlib/nbnxn_kernels/nbnxn_kernel_ref_outer.h index c68cb3a00c..323aa139f5 100644 --- a/src/gromacs/mdlib/nbnxn_kernels/nbnxn_kernel_ref_outer.h +++ b/src/gromacs/mdlib/nbnxn_kernels/nbnxn_kernel_ref_outer.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2012,2013,2014,2015,2017, by the GROMACS development team, led by + * Copyright (c) 2012,2013,2014,2015,2017,2018, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -81,12 +81,12 @@ void #ifndef CALC_ENERGIES -NBK_FUNC_NAME(_F) +NBK_FUNC_NAME(_F) // NOLINT(misc-definitions-in-headers) #else #ifndef ENERGY_GROUPS -NBK_FUNC_NAME(_VF) +NBK_FUNC_NAME(_VF) // NOLINT(misc-definitions-in-headers) #else -NBK_FUNC_NAME(_VgrpF) +NBK_FUNC_NAME(_VgrpF) // NOLINT(misc-definitions-in-headers) #endif #endif #undef NBK_FUNC_NAME diff --git a/src/gromacs/mdlib/nbnxn_kernels/simd_4xn/nbnxn_kernel_simd_4xn_inner.h b/src/gromacs/mdlib/nbnxn_kernels/simd_4xn/nbnxn_kernel_simd_4xn_inner.h index a3169fe83b..5bc77035f0 100644 --- a/src/gromacs/mdlib/nbnxn_kernels/simd_4xn/nbnxn_kernel_simd_4xn_inner.h +++ b/src/gromacs/mdlib/nbnxn_kernels/simd_4xn/nbnxn_kernel_simd_4xn_inner.h @@ -840,7 +840,7 @@ #endif /* LJ_CUT */ #ifdef LJ_FORCE_SWITCH -#define v_fswitch_r(rsw, rsw2, c0, c3, c4) fma(fma(c4, rsw, c3), (rsw2 * rsw), c0) +#define v_fswitch_r(rsw, rsw2, c0, c3, c4) fma(fma((c4), (rsw), (c3)), ((rsw2) * (rsw)), (c0)) SimdReal VLJ6_S0 = c6_S0 * fma(sixth_S, rinvsix_S0, v_fswitch_r(rsw_S0, rsw2_S0, p6_6cpot_S, p6_vc3_S, p6_vc4_S)); SimdReal VLJ6_S1 = c6_S1 * fma(sixth_S, rinvsix_S1, v_fswitch_r(rsw_S1, rsw2_S1, p6_6cpot_S, p6_vc3_S, p6_vc4_S)); @@ -884,8 +884,8 @@ SimdReal sw_S3, dsw_S3; #endif -#define switch_r(rsw, rsw2, c3, c4, c5) fma(fma(fma(c5, rsw, c4), rsw, c3), (rsw2 * rsw), one_S) -#define dswitch_r(rsw, rsw2, c2, c3, c4) (fma(fma(c4, rsw, c3), rsw, c2) * rsw2) +#define switch_r(rsw, rsw2, c3, c4, c5) fma(fma(fma(c5, rsw, c4), rsw, c3), ((rsw2) * (rsw)), one_S) +#define dswitch_r(rsw, rsw2, c2, c3, c4) (fma(fma(c4, rsw, c3), rsw, c2) * (rsw2)) sw_S0 = switch_r(rsw_S0, rsw2_S0, swV3_S, swV4_S, swV5_S); dsw_S0 = dswitch_r(rsw_S0, rsw2_S0, swF2_S, swF3_S, swF4_S); diff --git a/src/gromacs/mdlib/nbnxn_pairlist.h b/src/gromacs/mdlib/nbnxn_pairlist.h index 57422c192d..df36cade83 100644 --- a/src/gromacs/mdlib/nbnxn_pairlist.h +++ b/src/gromacs/mdlib/nbnxn_pairlist.h @@ -278,7 +278,7 @@ enum { ljcrGEOM, ljcrLB, ljcrNONE, ljcrNR }; -typedef struct nbnxn_atomdata_t { +typedef struct nbnxn_atomdata_t { //NOLINT(clang-analyzer-optin.performance.Padding) nbnxn_alloc_t *alloc; nbnxn_free_t *free; int ntype; /* The number of different atom types */ diff --git a/src/gromacs/mdlib/nbnxn_search.h b/src/gromacs/mdlib/nbnxn_search.h index f34fa12425..2ff9f90726 100644 --- a/src/gromacs/mdlib/nbnxn_search.h +++ b/src/gromacs/mdlib/nbnxn_search.h @@ -72,7 +72,7 @@ void nbnxn_init_pairlist_set(nbnxn_pairlist_set_t *nbl_list, * for the number of equally sized lists is below min_ci_balanced. * With perturbed particles, also a group scheme style nbl_fep list is made. */ -void nbnxn_make_pairlist(const nbnxn_search_t nbs, +void nbnxn_make_pairlist(nbnxn_search_t nbs, nbnxn_atomdata_t *nbat, const t_blocka *excl, real rlist, diff --git a/src/gromacs/mdrunutility/handlerestart.h b/src/gromacs/mdrunutility/handlerestart.h index dd6a3b350d..919e95a10d 100644 --- a/src/gromacs/mdrunutility/handlerestart.h +++ b/src/gromacs/mdrunutility/handlerestart.h @@ -95,7 +95,7 @@ struct t_filenm; void handleRestart(t_commrec *cr, const gmx_multisim_t *ms, gmx_bool bTryToAppendFiles, - const int NFILE, + int NFILE, t_filenm fnm[], bool *bDoAppendFiles, bool *bStartFromCpt); diff --git a/src/gromacs/mdtypes/awh-correlation-history.h b/src/gromacs/mdtypes/awh-correlation-history.h index 8e8a92c4fa..b0d8b58231 100644 --- a/src/gromacs/mdtypes/awh-correlation-history.h +++ b/src/gromacs/mdtypes/awh-correlation-history.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2015,2016,2017, by the GROMACS development team, led by + * Copyright (c) 2015,2016,2017,2018, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -75,9 +75,9 @@ struct CorrelationBlockDataHistory struct CorrelationGridHistory { /* These counts here since we curently need them for initializing the correlation grid when reading a checkpoint */ - int numCorrelationTensors; /**< Number correlation tensors in the grid (equal to the number of points). */ - int tensorSize; /**< The number of stored correlation matrix elements. */ - int blockDataListSize; /**< To be able to increase the block length later on, data is saved for several block lengths for each element. */ + int numCorrelationTensors = 0; /**< Number correlation tensors in the grid (equal to the number of points). */ + int tensorSize = 0; /**< The number of stored correlation matrix elements. */ + int blockDataListSize = 0; /**< To be able to increase the block length later on, data is saved for several block lengths for each element. */ /* We store all tensor sequentially in a buffer */ std::vector blockDataBuffer; /**< Buffer that contains the correlation data. */ diff --git a/src/gromacs/mdtypes/awh-history.h b/src/gromacs/mdtypes/awh-history.h index b554830e2a..5b26d7613b 100644 --- a/src/gromacs/mdtypes/awh-history.h +++ b/src/gromacs/mdtypes/awh-history.h @@ -107,13 +107,6 @@ struct AwhBiasHistory AwhBiasStateHistory state; /**< The global state of the AWH bias. */ CorrelationGridHistory forceCorrelationGrid; /**< History for force correlation statistics. */ - - /*! \brief Constructor. */ - AwhBiasHistory() : pointState(), - state(), - forceCorrelationGrid() - { - } }; //! A collection of AWH bias history data. */ @@ -123,8 +116,8 @@ struct AwhHistory double potentialOffset; /**< The offset of the bias potential due to bias updates. */ /*! \brief Constructor. */ - AwhHistory() : bias(), - potentialOffset(0) + AwhHistory() : + potentialOffset(0) { } }; diff --git a/src/gromacs/mdtypes/energyhistory.h b/src/gromacs/mdtypes/energyhistory.h index aca74582fe..dc14e16505 100644 --- a/src/gromacs/mdtypes/energyhistory.h +++ b/src/gromacs/mdtypes/energyhistory.h @@ -70,10 +70,10 @@ class delta_h_history_t gmx_bool start_lambda_set; //! Constructor - delta_h_history_t() : dh(), - start_time(0), - start_lambda(0), - start_lambda_set(false) + delta_h_history_t() : + start_time(0), + start_lambda(0), + start_lambda_set(false) { } }; @@ -97,8 +97,7 @@ class energyhistory_t //! Constructor energyhistory_t() : nsteps(0), nsum(0), - ener_ave(), - ener_sum(), + nsteps_sim(0), nsum_sim(0), ener_sum_sim(0) diff --git a/src/gromacs/mdtypes/forcerec.h b/src/gromacs/mdtypes/forcerec.h index 92e23e9261..ea64b519ca 100644 --- a/src/gromacs/mdtypes/forcerec.h +++ b/src/gromacs/mdtypes/forcerec.h @@ -123,7 +123,7 @@ struct gmx_ewald_tab_t; struct ewald_corr_thread_t; -struct t_forcerec { +struct t_forcerec { // NOLINT (clang-analyzer-optin.performance.Padding) struct interaction_const_t *ic; /* PBC stuff */ diff --git a/src/gromacs/mdtypes/group.h b/src/gromacs/mdtypes/group.h index 82a1bb1918..fe27a71fa7 100644 --- a/src/gromacs/mdtypes/group.h +++ b/src/gromacs/mdtypes/group.h @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. - * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by + * Copyright (c) 2013,2014,2015,2018, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -83,6 +83,6 @@ typedef struct gmx_ekindata_t { t_cos_acc cosacc; /* Cosine acceleration data */ } gmx_ekindata_t; -#define GID(igid, jgid, gnr) ((igid < jgid) ? (igid*gnr+jgid) : (jgid*gnr+igid)) +#define GID(igid, jgid, gnr) (((igid) < (jgid)) ? ((igid)*(gnr)+(jgid)) : ((jgid)*(gnr)+(igid))) #endif diff --git a/src/gromacs/mdtypes/inputrec.h b/src/gromacs/mdtypes/inputrec.h index 7fb5da5914..9183e3c167 100644 --- a/src/gromacs/mdtypes/inputrec.h +++ b/src/gromacs/mdtypes/inputrec.h @@ -330,7 +330,7 @@ struct t_swapcoords gmx_swapcoords_t si_priv; }; -struct t_inputrec +struct t_inputrec // NOLINT (clang-analyzer-optin.performance.Padding) { t_inputrec(); explicit t_inputrec(const t_inputrec &) = delete; diff --git a/src/gromacs/options/basicoptions.h b/src/gromacs/options/basicoptions.h index 89a10d9d64..9cfd3bd93d 100644 --- a/src/gromacs/options/basicoptions.h +++ b/src/gromacs/options/basicoptions.h @@ -317,7 +317,7 @@ class StringOption : public OptionTemplate template MyClass &enumValue(const char *const (&values)[count]) { - GMX_ASSERT(enumValues_ == NULL, + GMX_ASSERT(enumValues_ == nullptr, "Multiple sets of enumerated values specified"); enumValues_ = values; enumValuesCount_ = count; @@ -337,7 +337,7 @@ class StringOption : public OptionTemplate */ MyClass &enumValueFromNullTerminatedArray(const char *const *values) { - GMX_ASSERT(enumValues_ == NULL, + GMX_ASSERT(enumValues_ == nullptr, "Multiple sets of enumerated values specified"); enumValues_ = values; enumValuesCount_ = -1; @@ -533,7 +533,7 @@ class EnumOption : public OptionTemplate > template EnumOption &enumValue(const char *const (&values)[count]) { - GMX_ASSERT(enumValues_ == NULL, + GMX_ASSERT(enumValues_ == nullptr, "Multiple sets of enumerated values specified"); enumValues_ = values; enumValuesCount_ = count; @@ -553,7 +553,7 @@ class EnumOption : public OptionTemplate > */ EnumOption &enumValueFromNullTerminatedArray(const char *const *values) { - GMX_ASSERT(enumValues_ == NULL, + GMX_ASSERT(enumValues_ == nullptr, "Multiple sets of enumerated values specified"); enumValues_ = values; enumValuesCount_ = -1; diff --git a/src/gromacs/options/optionstoragetemplate.h b/src/gromacs/options/optionstoragetemplate.h index c748bc303e..ed10c95e26 100644 --- a/src/gromacs/options/optionstoragetemplate.h +++ b/src/gromacs/options/optionstoragetemplate.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by + * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -332,6 +332,7 @@ class OptionStorageTemplateSimple : public OptionStorageTemplate { const_cast(this)->ensureConverterInitialized(); std::vector result; + result.reserve(values.size()); for (const auto &value : values) { result.push_back(normalizeValue(converter_.convert(value))); @@ -436,7 +437,9 @@ OptionStorageTemplate::OptionStorageTemplate(const AbstractOption &settings, template std::unique_ptr > OptionStorageTemplate::createStore( - ValueList *storeVector, T *store, int *storeCount, int initialCount) + ValueList *storeVector, T *store, + int *storeCount, // NOLINT(readability-non-const-parameter) passed non-const to OptionValueStorePlain + int initialCount) { if (storeVector != nullptr) { @@ -503,7 +506,7 @@ std::vector OptionStorageTemplate::defaultValuesAsStrings() cons if (result.empty() || (result.size() == 1 && result[0].empty())) { result.clear(); - if (defaultValueIfSet_.get() != nullptr) + if (defaultValueIfSet_ != nullptr) { result.push_back(formatSingleValue(*defaultValueIfSet_)); } @@ -523,7 +526,7 @@ template void OptionStorageTemplate::processSet() { processSetValues(&setValues_); - if (setValues_.empty() && defaultValueIfSet_.get() != nullptr) + if (setValues_.empty() && defaultValueIfSet_ != nullptr) { addValue(*defaultValueIfSet_); setFlag(efOption_HasDefaultValue); @@ -552,7 +555,6 @@ void OptionStorageTemplate::addValue(const T &value) setValues_.push_back(value); } - template void OptionStorageTemplate::commitValues() { @@ -561,14 +563,16 @@ void OptionStorageTemplate::commitValues() store_->clear(); } store_->reserve(setValues_.size()); - for (T value : setValues_) + // For bool the loop variable isn't a reference (it's its special reference type) + CLANG_DIAGNOSTIC_IGNORE(-Wrange-loop-analysis) + for (const auto &value : setValues_) { store_->append(value); } + DIAGNOSTIC_RESET; clearSet(); } - template void OptionStorageTemplate::setDefaultValue(const T &value) { diff --git a/src/gromacs/pbcutil/pbc.h b/src/gromacs/pbcutil/pbc.h index b0a29fbbea..d3570c8bfe 100644 --- a/src/gromacs/pbcutil/pbc.h +++ b/src/gromacs/pbcutil/pbc.h @@ -105,7 +105,7 @@ typedef struct t_pbc { rvec tric_vec[MAX_NTRICVEC]; } t_pbc; -#define TRICLINIC(box) (box[YY][XX] != 0 || box[ZZ][XX] != 0 || box[ZZ][YY] != 0) +#define TRICLINIC(box) ((box)[YY][XX] != 0 || (box)[ZZ][XX] != 0 || (box)[ZZ][YY] != 0) #define NTRICIMG 14 #define NCUCVERT 24 diff --git a/src/gromacs/random/tabulatednormaldistribution.cpp b/src/gromacs/random/tabulatednormaldistribution.cpp index a221cf4e9f..59c01d98a5 100644 --- a/src/gromacs/random/tabulatednormaldistribution.cpp +++ b/src/gromacs/random/tabulatednormaldistribution.cpp @@ -48,9 +48,8 @@ namespace gmx // the table in all files using it, unless the user has requested a different // precision or resolution. template<> -const std::array -TabulatedNormalDistribution::c_table_ = - TabulatedNormalDistribution::makeTable(); +const std::array +TabulatedNormalDistribution<>::c_table_ = TabulatedNormalDistribution<>::makeTable(); #else // Avoid compiler warnings about no public symbols void TabulatedNormalDistributionDummy(){} diff --git a/src/gromacs/random/tabulatednormaldistribution.h b/src/gromacs/random/tabulatednormaldistribution.h index 1ed166d761..7598cb4119 100644 --- a/src/gromacs/random/tabulatednormaldistribution.h +++ b/src/gromacs/random/tabulatednormaldistribution.h @@ -61,11 +61,11 @@ namespace gmx { -namespace +namespace detail { //! Number of bits that determines the resolution of the lookup table for the normal distribution. -const int c_TabulatedNormalDistributionDefaultBits = 14; +constexpr int c_TabulatedNormalDistributionDefaultBits = 14; } @@ -104,7 +104,7 @@ const int c_TabulatedNormalDistributionDefaultBits = 14; * return arbitrarily small/large values, but with e.g. 14 bits * the results are limited to roughly +/- 4 standard deviations. */ -template +template class TabulatedNormalDistribution { static_assert(tableBits <= 24, "Normal distribution table is limited to 24bits (64MB in single precision)"); @@ -376,10 +376,10 @@ class TabulatedNormalDistribution #if !defined(_MSC_VER) && !defined(DOXYGEN) // Declaration of template specialization template<> -const std::array TabulatedNormalDistribution::c_table_; +const std::array TabulatedNormalDistribution<>::c_table_; extern template -const std::array TabulatedNormalDistribution::c_table_; +const std::array TabulatedNormalDistribution<>::c_table_; #endif // Instantiation for all tables without specialization diff --git a/src/gromacs/random/threefry.h b/src/gromacs/random/threefry.h index 9dd2a2c4ac..5c1d428485 100644 --- a/src/gromacs/random/threefry.h +++ b/src/gromacs/random/threefry.h @@ -220,7 +220,6 @@ highBitCounter { GMX_THROW(InternalError("Random engine stream ran out of internal counter space.")); } - return; } /*! \brief Increment the internal counter in highBits by a value. @@ -277,7 +276,6 @@ highBitCounter { GMX_THROW(InternalError("Random engine stream ran out of internal counter space.")); } - return; } }; } diff --git a/src/gromacs/selection/parsetree.h b/src/gromacs/selection/parsetree.h index 287fe89b61..eb8eaa538b 100644 --- a/src/gromacs/selection/parsetree.h +++ b/src/gromacs/selection/parsetree.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2009,2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by + * Copyright (c) 2009,2010,2011,2012,2013,2014,2015,2018, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -56,6 +56,7 @@ #include #include +#include "gromacs/compat/make_unique.h" #include "gromacs/math/vec.h" #include "gromacs/math/vectypes.h" #include "gromacs/utility/gmxassert.h" @@ -110,7 +111,7 @@ class SelectionParserValue //! Allocates and initializes an empty value list. static SelectionParserValueListPointer createList() { - return SelectionParserValueListPointer(new SelectionParserValueList); + return compat::make_unique(); } /*! \brief * Allocates and initializes a value list with a single value. @@ -303,16 +304,16 @@ class SelectionParserParameter public: // Default move constructor and assignment. Only needed for old compilers. //! \cond - SelectionParserParameter(SelectionParserParameter &&o) - : name_(std::move(o.name_)), location_(std::move(o.location_)), + SelectionParserParameter(SelectionParserParameter &&o) noexcept + : name_(std::move(o.name_)), location_(o.location_), values_(std::move(o.values_)) { } - SelectionParserParameter &operator=(SelectionParserParameter &&o) + SelectionParserParameter &operator=(SelectionParserParameter &&o) noexcept { name_ = std::move(o.name_); - location_ = std::move(o.location_); + location_ = o.location_; values_ = std::move(o.values_); return *this; } @@ -321,8 +322,7 @@ class SelectionParserParameter //! Allocates and initializes an empty parameter list. static SelectionParserParameterListPointer createList() { - return SelectionParserParameterListPointer( - new SelectionParserParameterList); + return compat::make_unique(); } /*! \brief * Allocates and initializes a parsed method parameter. diff --git a/src/gromacs/selection/scanner_internal.h b/src/gromacs/selection/scanner_internal.h index 3a182f3fd5..6ee5a051b4 100644 --- a/src/gromacs/selection/scanner_internal.h +++ b/src/gromacs/selection/scanner_internal.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2009,2010,2011,2012,2014,2015,2016, by the GROMACS development team, led by + * Copyright (c) 2009,2010,2011,2012,2014,2015,2016,2018, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -136,10 +136,10 @@ typedef struct gmx_sel_lexer_t * we cannot have them here as parameter names... */ /** Internal function for cases where several tokens need to be returned. */ int -_gmx_sel_lexer_process_pending(YYSTYPE *, YYLTYPE *, gmx_sel_lexer_t *state); +_gmx_sel_lexer_process_pending(YYSTYPE * /*yylval*/, YYLTYPE *, gmx_sel_lexer_t *state); /** Internal function that processes identifier tokens. */ int - _gmx_sel_lexer_process_identifier(YYSTYPE *, YYLTYPE *, char *, size_t, + _gmx_sel_lexer_process_identifier(YYSTYPE * /*yylval*/, YYLTYPE *, char * /*yytext*/, size_t /*yyleng*/, gmx_sel_lexer_t *state); /** Internal function to add a token to the pretty-printed selection text. */ void diff --git a/src/gromacs/selection/selection.h b/src/gromacs/selection/selection.h index 80eb0900e0..f112a287d0 100644 --- a/src/gromacs/selection/selection.h +++ b/src/gromacs/selection/selection.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2009,2010,2011,2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by + * Copyright (c) 2009,2010,2011,2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -554,13 +554,13 @@ class Selection private: internal::SelectionData &data() { - GMX_ASSERT(sel_ != NULL, + GMX_ASSERT(sel_ != nullptr, "Attempted to access uninitialized selection"); return *sel_; } const internal::SelectionData &data() const { - GMX_ASSERT(sel_ != NULL, + GMX_ASSERT(sel_ != nullptr, "Attempted to access uninitialized selection"); return *sel_; } @@ -642,7 +642,7 @@ class SelectionPosition */ const rvec &v() const { - GMX_ASSERT(sel_->rawPositions_.v != NULL, + GMX_ASSERT(sel_->rawPositions_.v != nullptr, "Velocities accessed, but unavailable"); return sel_->rawPositions_.v[i_]; } @@ -653,7 +653,7 @@ class SelectionPosition */ const rvec &f() const { - GMX_ASSERT(sel_->rawPositions_.f != NULL, + GMX_ASSERT(sel_->rawPositions_.f != nullptr, "Velocities accessed, but unavailable"); return sel_->rawPositions_.f[i_]; } diff --git a/src/gromacs/selection/selmethod.cpp b/src/gromacs/selection/selmethod.cpp index 218e8d2150..3ee5a474e5 100644 --- a/src/gromacs/selection/selmethod.cpp +++ b/src/gromacs/selection/selmethod.cpp @@ -68,53 +68,6 @@ typedef struct { gmx_ana_selmethod_t *method; } t_register_method; -/** Array of selection methods defined in the library. */ -static const t_register_method smtable_def[] = { - {nullptr, &sm_cog}, - {nullptr, &sm_com}, - - {nullptr, &sm_all}, - {nullptr, &sm_none}, - {nullptr, &sm_atomnr}, - {nullptr, &sm_resnr}, - {"resid", &sm_resnr}, - {nullptr, &sm_resindex}, - {"residue", &sm_resindex}, - {nullptr, &sm_molindex}, - {"mol", &sm_molindex}, - {"molecule", &sm_molindex}, - {nullptr, &sm_atomname}, - {"name", &sm_atomname}, - {nullptr, &sm_pdbatomname}, - {"pdbname", &sm_pdbatomname}, - {nullptr, &sm_atomtype}, - {"type", &sm_atomtype}, - {nullptr, &sm_resname}, - {nullptr, &sm_insertcode}, - {nullptr, &sm_chain}, - {nullptr, &sm_mass}, - {nullptr, &sm_charge}, - {nullptr, &sm_altloc}, - {nullptr, &sm_occupancy}, - {nullptr, &sm_betafactor}, - {"beta", &sm_betafactor}, - {nullptr, &sm_x}, - {nullptr, &sm_y}, - {nullptr, &sm_z}, - - {nullptr, &sm_distance}, - {"dist", &sm_distance}, - {nullptr, &sm_mindistance}, - {"mindist", &sm_mindistance}, - {nullptr, &sm_within}, - {nullptr, &sm_insolidangle}, - {nullptr, &sm_same}, - - {nullptr, &sm_merge}, - {nullptr, &sm_plus}, - {nullptr, &sm_permute}, -}; - /*! \brief * Convenience function for reporting errors found in selection methods. */ @@ -621,9 +574,56 @@ gmx_ana_selmethod_register(gmx::SelectionParserSymbolTable *symtab, int gmx_ana_selmethod_register_defaults(gmx::SelectionParserSymbolTable *symtab) { - size_t i; - int rc; - bool bOk; + /* Array of selection methods defined in the library. */ + const t_register_method smtable_def[] = { + {nullptr, &sm_cog}, + {nullptr, &sm_com}, + + {nullptr, &sm_all}, + {nullptr, &sm_none}, + {nullptr, &sm_atomnr}, + {nullptr, &sm_resnr}, + {"resid", &sm_resnr}, + {nullptr, &sm_resindex}, + {"residue", &sm_resindex}, + {nullptr, &sm_molindex}, + {"mol", &sm_molindex}, + {"molecule", &sm_molindex}, + {nullptr, &sm_atomname}, + {"name", &sm_atomname}, + {nullptr, &sm_pdbatomname}, + {"pdbname", &sm_pdbatomname}, + {nullptr, &sm_atomtype}, + {"type", &sm_atomtype}, + {nullptr, &sm_resname}, + {nullptr, &sm_insertcode}, + {nullptr, &sm_chain}, + {nullptr, &sm_mass}, + {nullptr, &sm_charge}, + {nullptr, &sm_altloc}, + {nullptr, &sm_occupancy}, + {nullptr, &sm_betafactor}, + {"beta", &sm_betafactor}, + {nullptr, &sm_x}, + {nullptr, &sm_y}, + {nullptr, &sm_z}, + + {nullptr, &sm_distance}, + {"dist", &sm_distance}, + {nullptr, &sm_mindistance}, + {"mindist", &sm_mindistance}, + {nullptr, &sm_within}, + {nullptr, &sm_insolidangle}, + {nullptr, &sm_same}, + + {nullptr, &sm_merge}, + {nullptr, &sm_plus}, + {nullptr, &sm_permute}, + }; + + size_t i; + int rc; + bool bOk; bOk = true; for (i = 0; i < asize(smtable_def); ++i) diff --git a/src/gromacs/simd/impl_x86_avx_256/impl_x86_avx_256_simd_double.h b/src/gromacs/simd/impl_x86_avx_256/impl_x86_avx_256_simd_double.h index 66cbb7b529..302e17ffd9 100644 --- a/src/gromacs/simd/impl_x86_avx_256/impl_x86_avx_256_simd_double.h +++ b/src/gromacs/simd/impl_x86_avx_256/impl_x86_avx_256_simd_double.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2014,2015,2016,2017, by the GROMACS development team, led by + * Copyright (c) 2014,2015,2016,2017,2018, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -108,7 +108,7 @@ class SimdDIBool static inline SimdDouble gmx_simdcall -simdLoad(const double *m, SimdDoubleTag = {}) +simdLoad(const double *m, SimdDoubleTag /*unused*/ = {}) { assert(std::size_t(m) % 32 == 0); return { @@ -124,7 +124,7 @@ store(double *m, SimdDouble a) } static inline SimdDouble gmx_simdcall -simdLoadU(const double *m, SimdDoubleTag = {}) +simdLoadU(const double *m, SimdDoubleTag /*unused*/ = {}) { return { _mm256_loadu_pd(m) @@ -146,7 +146,7 @@ setZeroD() } static inline SimdDInt32 gmx_simdcall -simdLoad(const std::int32_t * m, SimdDInt32Tag) +simdLoad(const std::int32_t * m, SimdDInt32Tag /*unused*/) { assert(std::size_t(m) % 16 == 0); return { @@ -162,7 +162,7 @@ store(std::int32_t * m, SimdDInt32 a) } static inline SimdDInt32 gmx_simdcall -simdLoadU(const std::int32_t *m, SimdDInt32Tag) +simdLoadU(const std::int32_t *m, SimdDInt32Tag /*unused*/) { return { _mm_loadu_si128(reinterpret_cast(m)) diff --git a/src/gromacs/simd/impl_x86_avx_256/impl_x86_avx_256_simd_float.h b/src/gromacs/simd/impl_x86_avx_256/impl_x86_avx_256_simd_float.h index 3f537e10f9..c65023ef4d 100644 --- a/src/gromacs/simd/impl_x86_avx_256/impl_x86_avx_256_simd_float.h +++ b/src/gromacs/simd/impl_x86_avx_256/impl_x86_avx_256_simd_float.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2014,2015,2016,2017, by the GROMACS development team, led by + * Copyright (c) 2014,2015,2016,2017,2018, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -89,7 +89,7 @@ class SimdFBool }; static inline SimdFloat gmx_simdcall -simdLoad(const float *m, SimdFloatTag = {}) +simdLoad(const float *m, SimdFloatTag /*unused*/ = {}) { assert(std::size_t(m) % 32 == 0); return { @@ -105,7 +105,7 @@ store(float *m, SimdFloat a) } static inline SimdFloat gmx_simdcall -simdLoadU(const float *m, SimdFloatTag = {}) +simdLoadU(const float *m, SimdFloatTag /*unused*/ = {}) { return { _mm256_loadu_ps(m) @@ -127,7 +127,7 @@ setZeroF() } static inline SimdFInt32 gmx_simdcall -simdLoad(const std::int32_t * m, SimdFInt32Tag) +simdLoad(const std::int32_t * m, SimdFInt32Tag /*unused*/) { assert(std::size_t(m) % 32 == 0); return { @@ -143,7 +143,7 @@ store(std::int32_t * m, SimdFInt32 a) } static inline SimdFInt32 gmx_simdcall -simdLoadU(const std::int32_t *m, SimdFInt32Tag) +simdLoadU(const std::int32_t *m, SimdFInt32Tag /*unused*/) { return { _mm256_loadu_si256(reinterpret_cast(m)) diff --git a/src/gromacs/simd/simd.h b/src/gromacs/simd/simd.h index cae601e374..3c1c54b79a 100644 --- a/src/gromacs/simd/simd.h +++ b/src/gromacs/simd/simd.h @@ -703,7 +703,7 @@ load4DuplicateN(const double* f) return load(f); } static inline Simd4NDouble gmx_simdcall -loadU4NOffset(const double* f, int) +loadU4NOffset(const double* f, int /*unused*/) { return loadU(f); } diff --git a/src/gromacs/simd/simd_memory.h b/src/gromacs/simd/simd_memory.h index 89a5d64eb7..2130907ae4 100644 --- a/src/gromacs/simd/simd_memory.h +++ b/src/gromacs/simd/simd_memory.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2017, by the GROMACS development team, led by + * Copyright (c) 2017,2018, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -63,7 +63,7 @@ class SimdReference //! \brief Conversion method that will execute load operator non_const_T() const { return load(m_); } //! \brief Assignment operator that will execute store - SimdReference operator=(T o) + SimdReference operator=(T o) // NOLINT(misc-unconventional-assign-operator,cppcoreguidelines-c-copy-assignment-signature) { store(m_, o); return *this; @@ -204,7 +204,7 @@ class SimdArrayRef "Size of ArrayRef needs to be divisible by type size"); } //! \copydoc ArrayRef::ArrayRef(const EmptyArrayRef&) - SimdArrayRef(const EmptyArrayRef &) : begin_(nullptr), end_(nullptr) {} + SimdArrayRef(const EmptyArrayRef & /*unused*/) : begin_(nullptr), end_(nullptr) {} //! \copydoc ArrayRef::ArrayRef(U) templatesize() == 0) + if (multiplexedOutputData->empty()) { multiplexedOutputData->resize( inputData.size() * numTables ); } diff --git a/src/gromacs/taskassignment/decidegpuusage.h b/src/gromacs/taskassignment/decidegpuusage.h index 7e01c99eab..694024202b 100644 --- a/src/gromacs/taskassignment/decidegpuusage.h +++ b/src/gromacs/taskassignment/decidegpuusage.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2017, by the GROMACS development team, led by + * Copyright (c) 2017,2018, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -80,13 +80,13 @@ enum class TaskTarget : int * * \throws std::bad_alloc If out of memory * InconsistentInputError If the user requirements are inconsistent. */ -bool decideWhetherToUseGpusForNonbondedWithThreadMpi(const TaskTarget nonbondedTarget, +bool decideWhetherToUseGpusForNonbondedWithThreadMpi(TaskTarget nonbondedTarget, const std::vector &gpuIdsToUse, const std::vector &userGpuTaskAssignment, - const EmulateGpuNonbonded emulateGpuNonbonded, - const bool usingVerletScheme, - const bool nonbondedOnGpuIsUseful, - const int numRanksPerSimulation); + EmulateGpuNonbonded emulateGpuNonbonded, + bool usingVerletScheme, + bool nonbondedOnGpuIsUseful, + int numRanksPerSimulation); /*! \brief Decide whether this thread-MPI simulation will run * PME tasks on GPUs. @@ -108,13 +108,13 @@ bool decideWhetherToUseGpusForNonbondedWithThreadMpi(const TaskTarget n * * \throws std::bad_alloc If out of memory * InconsistentInputError If the user requirements are inconsistent. */ -bool decideWhetherToUseGpusForPmeWithThreadMpi(const bool useGpuForNonbonded, - const TaskTarget pmeTarget, +bool decideWhetherToUseGpusForPmeWithThreadMpi(bool useGpuForNonbonded, + TaskTarget pmeTarget, const std::vector &gpuIdsToUse, const std::vector &userGpuTaskAssignment, - const bool canUseGpuForPme, - const int numRanksPerSimulation, - const int numPmeRanksPerSimulation); + bool canUseGpuForPme, + int numRanksPerSimulation, + int numPmeRanksPerSimulation); /*! \brief Decide whether the simulation will try to run nonbonded * tasks on GPUs. @@ -143,12 +143,12 @@ bool decideWhetherToUseGpusForPmeWithThreadMpi(const bool useGpuFor * * \throws std::bad_alloc If out of memory * InconsistentInputError If the user requirements are inconsistent. */ -bool decideWhetherToUseGpusForNonbonded(const TaskTarget nonbondedTarget, +bool decideWhetherToUseGpusForNonbonded(TaskTarget nonbondedTarget, const std::vector &userGpuTaskAssignment, - const EmulateGpuNonbonded emulateGpuNonbonded, - const bool usingVerletScheme, - const bool nonbondedOnGpuIsUseful, - const bool gpusWereDetected); + EmulateGpuNonbonded emulateGpuNonbonded, + bool usingVerletScheme, + bool nonbondedOnGpuIsUseful, + bool gpusWereDetected); /*! \brief Decide whether the simulation will try to run tasks of * different types on GPUs. @@ -178,13 +178,13 @@ bool decideWhetherToUseGpusForNonbonded(const TaskTarget nonbondedTarg * * \throws std::bad_alloc If out of memory * InconsistentInputError If the user requirements are inconsistent. */ -bool decideWhetherToUseGpusForPme(const bool useGpuForNonbonded, - const TaskTarget pmeTarget, +bool decideWhetherToUseGpusForPme(bool useGpuForNonbonded, + TaskTarget pmeTarget, const std::vector &userGpuTaskAssignment, - const bool canUseGpuForPme, - const int numRanksPerSimulation, - const int numPmeRanksPerSimulation, - const bool gpusWereDetected); + bool canUseGpuForPme, + int numRanksPerSimulation, + int numPmeRanksPerSimulation, + bool gpusWereDetected); } diff --git a/src/gromacs/timing/wallcycle.h b/src/gromacs/timing/wallcycle.h index 90b55fed2e..63e30e09fa 100644 --- a/src/gromacs/timing/wallcycle.h +++ b/src/gromacs/timing/wallcycle.h @@ -46,7 +46,7 @@ typedef struct gmx_wallcycle *gmx_wallcycle_t; struct t_commrec; -const gmx_wallcycle_t nullWallcycle = nullptr; +static constexpr gmx_wallcycle* nullWallcycle = nullptr; enum { ewcRUN, ewcSTEP, ewcPPDURINGPME, ewcDOMDEC, ewcDDCOMMLOAD, diff --git a/src/gromacs/topology/idef.h b/src/gromacs/topology/idef.h index 096c16efa7..2c2e4f1fb1 100644 --- a/src/gromacs/topology/idef.h +++ b/src/gromacs/topology/idef.h @@ -149,7 +149,7 @@ enum { F_NRE /* This number is for the total number of energies */ }; -#define IS_RESTRAINT_TYPE(ifunc) (((ifunc == F_POSRES) || (ifunc == F_FBPOSRES) || (ifunc == F_DISRES) || (ifunc == F_RESTRBONDS) || (ifunc == F_DISRESVIOL) || (ifunc == F_ORIRES) || (ifunc == F_ORIRESDEV) || (ifunc == F_ANGRES) || (ifunc == F_ANGRESZ) || (ifunc == F_DIHRES))) +#define IS_RESTRAINT_TYPE(ifunc) ((((ifunc) == F_POSRES) || ((ifunc) == F_FBPOSRES) || ((ifunc) == F_DISRES) || ((ifunc) == F_RESTRBONDS) || ((ifunc) == F_DISRESVIOL) || ((ifunc) == F_ORIRES) || ((ifunc) == F_ORIRESDEV) || ((ifunc) == F_ANGRES) || ((ifunc) == F_ANGRESZ) || ((ifunc) == F_DIHRES))) typedef union t_iparams { diff --git a/src/gromacs/topology/ifunc.h b/src/gromacs/topology/ifunc.h index 8bca6ce563..cb8c431786 100644 --- a/src/gromacs/topology/ifunc.h +++ b/src/gromacs/topology/ifunc.h @@ -91,7 +91,7 @@ typedef real t_ifunc (int nbonds, const t_iatom iatoms[], * it not assigned to any node by the domain decompostion, the simulation * still continue, if mdrun has been told so. */ -typedef struct +typedef struct // NOLINT (clang-analyzer-optin.performance.Padding) { const char *name; /* the name of this function */ const char *longname; /* The name for printing etc. */ diff --git a/src/gromacs/topology/topology.h b/src/gromacs/topology/topology.h index fd35fb4bad..fda99e3401 100644 --- a/src/gromacs/topology/topology.h +++ b/src/gromacs/topology/topology.h @@ -119,7 +119,7 @@ typedef struct gmx_groups_t * TODO: Find a solution for ensuring that the derived data is in sync * with the primary data, possibly by converting to a class. */ -struct gmx_mtop_t +struct gmx_mtop_t //NOLINT(clang-analyzer-optin.performance.Padding) { /* Constructor */ gmx_mtop_t(); diff --git a/src/gromacs/trajectory/energyframe.h b/src/gromacs/trajectory/energyframe.h index bd23f0e90d..c83453fbb0 100644 --- a/src/gromacs/trajectory/energyframe.h +++ b/src/gromacs/trajectory/energyframe.h @@ -88,7 +88,7 @@ class EnergyFrame using MapConstIterator = MapType::const_iterator; //! Constructor EnergyFrame(const t_enxframe &enxframe, - const std::map indicesOfEnergyFields); + std::map indicesOfEnergyFields); /*! \brief Return string that helps users identify this frame, containing time and step number. * * \throws std::bad_alloc when out of memory */ diff --git a/src/gromacs/trajectory/trajectoryframe.h b/src/gromacs/trajectory/trajectoryframe.h index 03fd6c8653..65f4fef9ef 100644 --- a/src/gromacs/trajectory/trajectoryframe.h +++ b/src/gromacs/trajectory/trajectoryframe.h @@ -53,7 +53,7 @@ struct t_atoms; -typedef struct t_trxframe +typedef struct t_trxframe // NOLINT (clang-analyzer-optin.performance.Padding) { int not_ok; /* integrity flags */ gmx_bool bDouble; /* Double precision? */ diff --git a/src/gromacs/utility/allocator.h b/src/gromacs/utility/allocator.h index 3d243adb71..c8905068df 100644 --- a/src/gromacs/utility/allocator.h +++ b/src/gromacs/utility/allocator.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2017, by the GROMACS development team, led by + * Copyright (c) 2017,2018, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -133,7 +133,7 @@ class Allocator : public AllocationPolicy * it in debug mode, presumably to implement some checks. */ template - explicit Allocator(const Allocator &) {} + explicit Allocator(const Allocator & /*unused*/) {} /*! \brief Constructor * @@ -239,7 +239,7 @@ class Allocator : public AllocationPolicy */ template bool - operator==(const Allocator &) const { return std::is_same::value; } + operator==(const Allocator & /*unused*/) const { return std::is_same::value; } /*! \brief Return true if two allocators are different * diff --git a/src/gromacs/utility/arrayref.h b/src/gromacs/utility/arrayref.h index ee0ae7733e..caba999d95 100644 --- a/src/gromacs/utility/arrayref.h +++ b/src/gromacs/utility/arrayref.h @@ -146,7 +146,7 @@ class ArrayRef * used to initialize any ArrayRef, without specifying the template * type. It is not explicit to enable that usage. */ - ArrayRef(const EmptyArrayRef &) : begin_(nullptr), end_(nullptr) {} + ArrayRef(const EmptyArrayRef & /*unused*/) : begin_(nullptr), end_(nullptr) {} /*! \brief * Constructs a reference to a container or reference * diff --git a/src/gromacs/utility/arraysize.h b/src/gromacs/utility/arraysize.h index 3f973ac5d5..6963fecd89 100644 --- a/src/gromacs/utility/arraysize.h +++ b/src/gromacs/utility/arraysize.h @@ -48,7 +48,7 @@ * \ingroup module_utility */ template -constexpr int asize(T(&)[N]) +constexpr int asize(T(&/*unused*/)[N]) { static_assert(N >= 0, "Do negative size arrays exist?"); return N; diff --git a/src/gromacs/utility/basedefinitions.h b/src/gromacs/utility/basedefinitions.h index 802b0e02b9..f02b2d1ed5 100644 --- a/src/gromacs/utility/basedefinitions.h +++ b/src/gromacs/utility/basedefinitions.h @@ -168,6 +168,18 @@ using index = std::ptrdiff_t; */ #define GMX_UNUSED_VALUE(value) (void)value +#ifdef __clang__ +#define DO_PRAGMA(x) _Pragma (#x) +#define CLANG_DIAGNOSTIC_IGNORE(warning) _Pragma("clang diagnostic push") \ + DO_PRAGMA(clang diagnostic ignored #warning) +#define DIAGNOSTIC_RESET _Pragma("clang diagnostic pop") +#else +//! Ignore specified clang warning until DIAGNOSTIC_RESET +#define CLANG_DIAGNOSTIC_IGNORE(warning) +//! Reset all diagnostics to default +#define DIAGNOSTIC_RESET +#endif + #ifdef __cplusplus namespace gmx { @@ -180,7 +192,7 @@ namespace internal * \ingroup module_utility */ template -static inline void ignoreValueHelper(const T &) +static inline void ignoreValueHelper(const T & /*unused*/) { } //! \endcond diff --git a/src/gromacs/utility/classhelpers.h b/src/gromacs/utility/classhelpers.h index b24546b494..64b5757e05 100644 --- a/src/gromacs/utility/classhelpers.h +++ b/src/gromacs/utility/classhelpers.h @@ -89,10 +89,10 @@ namespace gmx #else #define GMX_DEFAULT_CONSTRUCTORS(ClassName) \ ClassName() = default; \ - ClassName &operator=(const ClassName &) = default; \ + ClassName &operator=(const ClassName &) = default; /* NOLINT(misc-macro-parentheses) */ \ ClassName(const ClassName &) = default; \ - ClassName &operator=(ClassName &&) = default; \ - ClassName(ClassName &&) = default + ClassName &operator=(ClassName &&) = default; /* NOLINT(misc-macro-parentheses) */ \ + ClassName(ClassName &&) = default /* NOLINT(misc-macro-parentheses) */ #endif /*! \brief diff --git a/src/gromacs/utility/fatalerror.h b/src/gromacs/utility/fatalerror.h index f2e948f265..8c3b6b6175 100644 --- a/src/gromacs/utility/fatalerror.h +++ b/src/gromacs/utility/fatalerror.h @@ -77,7 +77,7 @@ extern gmx_bool gmx_debug_at; * For command line programs, gmx::CommandLineModuleManager takes care * of this if the user requests debugging. */ -void gmx_init_debug(const int dbglevel, const char *dbgfile); +void gmx_init_debug(int dbglevel, const char *dbgfile); /** Returns TRUE when the program was started in debug mode */ gmx_bool bDebugMode(void); diff --git a/src/gromacs/utility/keyvaluetree.h b/src/gromacs/utility/keyvaluetree.h index 5b7ea96c08..3cf0e0848e 100644 --- a/src/gromacs/utility/keyvaluetree.h +++ b/src/gromacs/utility/keyvaluetree.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2016,2017, by the GROMACS development team, led by + * Copyright (c) 2016,2017,2018, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -248,7 +248,7 @@ class KeyValueTreeObject } } //! Assigns a deep copy of an object. - KeyValueTreeObject &operator=(KeyValueTreeObject &other) + KeyValueTreeObject &operator=(const KeyValueTreeObject &other) { KeyValueTreeObject tmp(other); std::swap(tmp.valueMap_, valueMap_); diff --git a/src/gromacs/utility/logger.h b/src/gromacs/utility/logger.h index 4f52ec6045..7baab25b02 100644 --- a/src/gromacs/utility/logger.h +++ b/src/gromacs/utility/logger.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2016,2017, by the GROMACS development team, led by + * Copyright (c) 2016,2017,2018, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -134,9 +134,10 @@ class LogWriteHelper * technique for implementing macros that allow streming information to * them (see, e.g., Google Test). */ - void operator=(const LogEntryWriter &entryWriter) + LogWriteHelper &operator=(const LogEntryWriter &entryWriter) { target_->writeEntry(entryWriter.entry_); + return *this; } private: diff --git a/src/gromacs/utility/nodelete.h b/src/gromacs/utility/nodelete.h index c2abd48132..dca5db5cf3 100644 --- a/src/gromacs/utility/nodelete.h +++ b/src/gromacs/utility/nodelete.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2015, by the GROMACS development team, led by + * Copyright (c) 2015,2018, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -63,7 +63,7 @@ template struct no_delete { //! Deleter that does nothing. - void operator()(T *) {} + void operator()(T * /*unused*/) {} }; } // namespace gmx diff --git a/src/gromacs/utility/variant.h b/src/gromacs/utility/variant.h index 9d1b37de28..088f80a9ef 100644 --- a/src/gromacs/utility/variant.h +++ b/src/gromacs/utility/variant.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2016,2017, by the GROMACS development team, led by + * Copyright (c) 2016,2017,2018, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -97,7 +97,7 @@ class Variant * method avoids copying when move-construction is possible. */ template - static Variant create(T &&value) { return Variant(std::move(value)); } + static Variant create(T &&value) { return Variant(std::forward(value)); } //! Creates an empty variant value. Variant() {} @@ -106,19 +106,9 @@ class Variant * * \throws std::bad_alloc if out of memory. */ - template - explicit Variant(const T &value) - : content_(new Content::type>(value)) - { - } - /*! \brief - * Creates a variant that holds the given value. - * - * \throws std::bad_alloc if out of memory. - */ - template + template ::value>::type> explicit Variant(T &&value) - : content_(new Content::type>(std::move(value))) + : content_(new Content::type>(std::forward(value))) { } /*! \brief -- 2.22.0