Enable clang-tidy for headers
authorRoland Schulz <roland.schulz@intel.com>
Mon, 30 Jul 2018 22:46:57 +0000 (15:46 -0700)
committerRoland Schulz <roland.schulz@intel.com>
Sat, 11 Aug 2018 23:30:39 +0000 (16:30 -0700)
Change-Id: Id5acfb264ac57c09cc1a7d8ab512eb7c6bfc40f1

78 files changed:
src/external/tng_io/BuildTNG.cmake
src/external/vmd_molfile/molfile_plugin.h
src/external/vmd_molfile/vmdplugin.h
src/gromacs/CMakeLists.txt
src/gromacs/awh/awh.h
src/gromacs/awh/bias.h
src/gromacs/awh/biasstate.cpp
src/gromacs/awh/biasstate.h
src/gromacs/awh/correlationgrid.h
src/gromacs/awh/pointstate.h
src/gromacs/correlationfunctions/expfit.h
src/gromacs/domdec/domdec_internal.h
src/gromacs/domdec/domdec_struct.h
src/gromacs/domdec/ga2la.h
src/gromacs/domdec/hash.h
src/gromacs/ewald/pme-gpu-internal.h
src/gromacs/ewald/pme-gpu-program.h
src/gromacs/ewald/pme-internal.h
src/gromacs/ewald/pme.h
src/gromacs/fileio/gmxfio-xdr.h
src/gromacs/fileio/readinp.h
src/gromacs/fileio/tngio.h
src/gromacs/fileio/trxio.h
src/gromacs/gmxana/gstat.h
src/gromacs/gmxlib/nrnb.h
src/gromacs/gmxpreprocess/grompp-impl.h
src/gromacs/gpu_utils/gpu_macros.h
src/gromacs/listed-forces/pairs.h
src/gromacs/math/units.h
src/gromacs/math/vectypes.h
src/gromacs/mdlib/constr.h
src/gromacs/mdlib/groupcoord.h
src/gromacs/mdlib/main.h
src/gromacs/mdlib/mdatoms.h
src/gromacs/mdlib/mdrun.h
src/gromacs/mdlib/nbnxn_kernels/nbnxn_kernel_ref_outer.h
src/gromacs/mdlib/nbnxn_kernels/simd_4xn/nbnxn_kernel_simd_4xn_inner.h
src/gromacs/mdlib/nbnxn_pairlist.h
src/gromacs/mdlib/nbnxn_search.h
src/gromacs/mdrunutility/handlerestart.h
src/gromacs/mdtypes/awh-correlation-history.h
src/gromacs/mdtypes/awh-history.h
src/gromacs/mdtypes/energyhistory.h
src/gromacs/mdtypes/forcerec.h
src/gromacs/mdtypes/group.h
src/gromacs/mdtypes/inputrec.h
src/gromacs/options/basicoptions.h
src/gromacs/options/optionstoragetemplate.h
src/gromacs/pbcutil/pbc.h
src/gromacs/random/tabulatednormaldistribution.cpp
src/gromacs/random/tabulatednormaldistribution.h
src/gromacs/random/threefry.h
src/gromacs/selection/parsetree.h
src/gromacs/selection/scanner_internal.h
src/gromacs/selection/selection.h
src/gromacs/selection/selmethod.cpp
src/gromacs/simd/impl_x86_avx_256/impl_x86_avx_256_simd_double.h
src/gromacs/simd/impl_x86_avx_256/impl_x86_avx_256_simd_float.h
src/gromacs/simd/simd.h
src/gromacs/simd/simd_memory.h
src/gromacs/tables/splineutil.h
src/gromacs/taskassignment/decidegpuusage.h
src/gromacs/timing/wallcycle.h
src/gromacs/topology/idef.h
src/gromacs/topology/ifunc.h
src/gromacs/topology/topology.h
src/gromacs/trajectory/energyframe.h
src/gromacs/trajectory/trajectoryframe.h
src/gromacs/utility/allocator.h
src/gromacs/utility/arrayref.h
src/gromacs/utility/arraysize.h
src/gromacs/utility/basedefinitions.h
src/gromacs/utility/classhelpers.h
src/gromacs/utility/fatalerror.h
src/gromacs/utility/keyvaluetree.h
src/gromacs/utility/logger.h
src/gromacs/utility/nodelete.h
src/gromacs/utility/variant.h

index 0b70c4d99f2629ec90d0738e7894de96d4f934f1..e3810a17717eaab06ba1862f829698c347480e93 100644 (file)
@@ -71,7 +71,7 @@ function(add_tng_io_library NAME)
     target_include_directories(${_build_target} PRIVATE
                                $<BUILD_INTERFACE:${TNG_ROOT_SOURCE_DIR}/include>
                                $<BUILD_INTERFACE:${TNG_ROOT_BINARY_DIR}/include>)
-    target_include_directories(${NAME} INTERFACE
+    target_include_directories(${NAME} SYSTEM INTERFACE
                                $<BUILD_INTERFACE:${TNG_ROOT_SOURCE_DIR}/include>
                                $<BUILD_INTERFACE:${TNG_ROOT_BINARY_DIR}/include>)
 
index 52b550dee073c354fe3048f261d44d8cf014f47e..1a251c377838f741de6e778d1e84ddb2638fd522 100644 (file)
@@ -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
index 895bf14023f0fbc5a6bf44d7df6b1f4d08e9774b..62ec64b0838d1161bd9eb2d3e34a0355292044b4 100644 (file)
@@ -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)
 /*@}*/
 
 /** 
index ec2876c840389f5fd49974c0e1eeb533cf204bd1..b1fba8987bf35620a8248dbc892b4b2d4067bd56 100644 (file)
@@ -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()
index 7bbc2a97aa9afffce3e957efe1063ea3a7329f47..dd8618af58a981550ef13b915f5c51377bb9e8e7 100644 (file)
@@ -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);
 
index 2e3a8c57981f7f0b2cfae9576170fca9ed0af6c8..8f395bb17b245e223a9abea542ef35bb50b7d0da 100644 (file)
@@ -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.
index b526ebee07d0295da2789e67236f68cda169de93..173f0956378e59ac3f7da324e849d685968488c6 100644 (file)
@@ -224,7 +224,7 @@ double biasedLogWeightFromPoint(const std::vector<DimParams>  &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<DimPa
            the free energy values grow less than 0.5*c_largePositiveExponent in a return time to this
            neighborhood. For reasonable update sizes it's unlikely that this requirement would be
            broken. */
-        if (std::abs(points_[globalIndex].freeEnergy()) > 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<Dim
             else
             {
                 /* Pad with values that don't affect the result */
-                (*weight)[n] = c_largeNegativeExponent;
+                (*weight)[n] = detail::c_largeNegativeExponent;
             }
         }
         PackType weightPack = load<PackType>(weightData + i);
index 5fd7ccd204ae2695f7dce0c65d1153849694e62c..ecd73e32d38a379456dd0b77123d5fdd944796b6 100644 (file)
@@ -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<float>) const;
+        void getPmf(gmx::ArrayRef<float> /*pmf*/) const;
 
         /*! \brief Returns the current coordinate state.
          */
index ecfb5288d7684b76714a79f83afa9f20bde727c9..5d3456b44bccefe18c90df1085aca4472bde77ef 100644 (file)
@@ -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();
         }
index aad5ee264141b9e56b8f92f05b007d31d8c1e8a4..414d644ba0884c8e1328a81ce4569698939ccd8f 100644 (file)
 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.");
         }
 
index e18fa13826ad579607852892f84921a8c7a5c3e4..73da32fd902bd77ee7ba4f6031eb4be9599a0ad6 100644 (file)
@@ -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
index 819a2d4b48c2612ac3ca32b4ea7300368e7d4fb8..87432ae05a52c29cc94321aef315c482c94e8832 100644 (file)
@@ -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 */
index f923190ddc71c2d161044f821c1410b3fbc2ea46..47b7460d71ed4402ac23e9306e8e9de7ec978d9f 100644 (file)
@@ -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
index 9ef7c8958a368bac21875065f5465db5ab6300b8..7cb23f320d7ad89356e5cb859d438d7025006c1b 100644 (file)
@@ -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
index 34871a831712b34ca57ad3b849b3c44a91a0ec96..a082a9d9409835c94d790e0d6cea4f8151485915 100644 (file)
@@ -54,7 +54,7 @@
 #include <cstdio>
 
 //! 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
index cbfc4ecb55fec6e6bceaacefe8fb1355d9e3c989..cb6371f2d3a2a56b9f9b7079ab1715b968dd3790 100644 (file)
@@ -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.
index 0cd8b1a747f0f27bbbc240c435e132c41c9c1b9a..76045e32bff207eaf5b99e90d36853d61f138034 100644 (file)
@@ -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
index 3b200f41da2f662737c93df7fb3d89ef297367da..9dcfdf38c84f081266fc8807a753969d7bf4ceeb 100644 (file)
@@ -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;
index 0e3cf61391aceb40276b5926db61221c8aba837f..5f6e83f7175d271ab82cd0f777ecf73222e5959f 100644 (file)
@@ -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 */
 
index 402ea395012ab6406b67f7e19dfe85f41cb10b46..bb9a6333d6d3df2365ae52c00639a8c43c548473 100644 (file)
@@ -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__)
 
 
index fa3a8e07246322d1777a651fad267299398a370a..7a1e1f3216171c35385c2a69609514b61c740d51 100644 (file)
@@ -40,6 +40,7 @@
 #include <cstring>
 
 #include <string>
+#include <utility>
 #include <vector>
 
 #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<t_inpfile> *inp, const char *name, int def,
 
 int64_t get_eint64(std::vector<t_inpfile> *inp,
                    const char *name, int64_t def,
-                   warninp_t);
+                   warninp_t /*wi*/);
 
 double get_ereal(std::vector<t_inpfile> *inp, const char *name, double def,
                  warninp_t wi);
index 9af0a7f27c8cda79054c0adfed99c7e2f5fe30c9..7e3ad3735164d90e80f95fad9d5a747c125103e6 100644 (file)
@@ -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);
 
index ee035a0fd8a95c1624be08e598f4235d9d1bbc8e..eec2af65a3ee4d542b8e66dcf25a3aa05ff59b3e 100644 (file)
@@ -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);
index 8959b01446d6c9cc7a0b5224863fb3c4130876c9..3e0a7d02709b3520f8065b68bf3166dd79bf817b 100644 (file)
@@ -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 {
index 124ee5f73354e31faaaefc3e4b2c4496a10b5bbb..7f7e48bd46113b2ca37bcb580e1c00196f798e8f 100644 (file)
@@ -42,7 +42,7 @@
 
 #include "gromacs/utility/basedefinitions.h"
 
-#define eNR_NBKERNEL_NONE -1
+#define eNR_NBKERNEL_NONE (-1)
 
 enum
 {
index e8484de27b41970cfe532025b529c86c3201607b..cf1fd66e8c6793430678d57c5be0c5e3acc3b042 100644 (file)
@@ -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) */
index e9d597a7548e0e4f3e095786b0351e3d1c573b9c..fcfc156fad06ceb4188508d3f29361ceb8bc4c6e 100644 (file)
@@ -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); }
 
index 8d2ee0a5bc9d581c4fe9da18cc8f6c51901b8169..88af8347c4ca50460884b7febe5569095fd6b1fc 100644 (file)
@@ -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
index 69eb52bc40afd53abd792a005a15ddc540944dc7..aec8ab16a64455038102cc4b07228344a8e27434 100644 (file)
@@ -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
index 3622a65cc3cc14f36f6e0f66bc08213d32833294..53dc475223765115620cbbe1572fbaae06bc3dd5 100644 (file)
@@ -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.
index 524bb28b7bd1432f75473d3ae3392501fdec9acb..d7a8b4a7431c91217f1b9027fe0a11653c51e5ad 100644 (file)
@@ -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);
index bdbf8bee30aea76b107e8788b314d10357a00ce9..fa6f4974e50fa5d7e7d5c0a05b45b5805ff3e855 100644 (file)
@@ -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
 }
index 0122f0a74905fac9109fc1b06f7128984326ce02..8c575693b121b59a1befb1db86e6ecf94da6f3b6 100644 (file)
@@ -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.
  */
index aef6361948657778f4c4426796dfee2a59be6b5d..b8ecf61345ad1119ad0fb731143325434012ec0a 100644 (file)
@@ -94,7 +94,7 @@ class MDAtoms
         //! Builder function.
         friend std::unique_ptr<MDAtoms>
         makeMDAtoms(FILE *fp, const gmx_mtop_t &mtop, const t_inputrec &ir,
-                    const bool rankHasPmeGpuTask);
+                    bool rankHasPmeGpuTask);
 };
 
 //! Builder function for MdAtomsWrapper.
index 3eef88268123bea5674665e6747adf8fec891a08..ba9bb7860553b3a64d7a7e527aad81d4f18a3f87 100644 (file)
@@ -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)
     {
index c68cb3a00c7d292864ec5371936b650819138284..323aa139f55b564c65eb33963e2a024070a4b797 100644 (file)
@@ -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.
 
 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
index a3169fe83b8fc5ec30499ac758f37cca30b115d5..5bc77035f06a264a12efa5bf396becc1d3904f50 100644 (file)
 #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));
         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);
index 57422c192dc32c1cd0f3f396d0c4d2109688527d..df36cade831b2a0e4fedd77d7303be1bf3acbc3e 100644 (file)
@@ -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                 */
index f34fa124254cb225d0a3d923665dcb7cf5c7093e..2ff9f90726e03f2a75f6a865001413c3ddb192b5 100644 (file)
@@ -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,
index dd6a3b350dd24448fe222beef0bb5445c429ba0c..919e95a10d20a4353931e47698e88e395711d9a7 100644 (file)
@@ -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);
index 8e8a92c4fa110c0a6b930b866fdc47a422f83d85..b0d8b58231bf6be862b96b13744cccfc1950dd9c 100644 (file)
@@ -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<CorrelationBlockDataHistory> blockDataBuffer; /**< Buffer that contains the correlation data. */
index b554830e2a34282c50d7f0e03943941465cc5186..5b26d7613b232b12beae7a95a2d6654593a67c2b 100644 (file)
@@ -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)
     {
     }
 };
index aca74582fe52e64d677a424995c419d8e65c9fb6..dc14e1650584d2ab6bd8973b36e2f7b16d7b7854 100644 (file)
@@ -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)
index 92e23e92619dcaa8ec20ba967700c1ff0dd954e8..ea64b519ca181c50815c61e674cd951e0a59fe66 100644 (file)
@@ -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 */
index 82a1bb191829c9f9e195fb57792bf0791abb6577..fe27a71fa77c24658e4165dc4f2a615be06d19c6 100644 (file)
@@ -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
index 7fb5da591430cc7914d1b64c7783804be91a2c9f..9183e3c167a09d185786f52f7482ef7db9c945fa 100644 (file)
@@ -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;
index 89a10d9d64c940a6837472bd9754068fc533e62b..9cfd3bd93d2016c0daffbbb560b5601389b0407b 100644 (file)
@@ -317,7 +317,7 @@ class StringOption : public OptionTemplate<std::string, StringOption>
         template <size_t count>
         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<std::string, StringOption>
          */
         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<EnumType, EnumOption<EnumType> >
         template <size_t count>
         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<EnumType, EnumOption<EnumType> >
          */
         EnumOption &enumValueFromNullTerminatedArray(const char *const *values)
         {
-            GMX_ASSERT(enumValues_ == NULL,
+            GMX_ASSERT(enumValues_ == nullptr,
                        "Multiple sets of enumerated values specified");
             enumValues_      = values;
             enumValuesCount_ = -1;
index c748bc303e6ecd61632c536dee345d680ed58ff9..ed10c95e26c19eb059091fbeca8cf2a24da8eb2a 100644 (file)
@@ -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<T>
         {
             const_cast<MyBase *>(this)->ensureConverterInitialized();
             std::vector<Variant> result;
+            result.reserve(values.size());
             for (const auto &value : values)
             {
                 result.push_back(normalizeValue(converter_.convert(value)));
@@ -436,7 +437,9 @@ OptionStorageTemplate<T>::OptionStorageTemplate(const AbstractOption &settings,
 
 template <typename T>
 std::unique_ptr<IOptionValueStore<T> > OptionStorageTemplate<T>::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<std::string> OptionStorageTemplate<T>::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 <typename T>
 void OptionStorageTemplate<T>::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<T>::addValue(const T &value)
     setValues_.push_back(value);
 }
 
-
 template <typename T>
 void OptionStorageTemplate<T>::commitValues()
 {
@@ -561,14 +563,16 @@ void OptionStorageTemplate<T>::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 <typename T>
 void OptionStorageTemplate<T>::setDefaultValue(const T &value)
 {
index b0a29fbbea76b5c35ff49e022ea3a4d6b1eb45b8..d3570c8bfe5d698e7cd721544f091a15e9d01dbb 100644 (file)
@@ -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
index a221cf4e9f7f575e3b0cf211e5d3b0e44614bda1..59c01d98a5e136fe1180863fc2335feabe543234 100644 (file)
@@ -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<real, 1<<c_TabulatedNormalDistributionDefaultBits>
-TabulatedNormalDistribution<real, c_TabulatedNormalDistributionDefaultBits>::c_table_ =
-    TabulatedNormalDistribution<real, c_TabulatedNormalDistributionDefaultBits>::makeTable();
+const std::array<real, 1<<detail::c_TabulatedNormalDistributionDefaultBits>
+TabulatedNormalDistribution<>::c_table_ = TabulatedNormalDistribution<>::makeTable();
 #else
 // Avoid compiler warnings about no public symbols
 void TabulatedNormalDistributionDummy(){}
index 1ed166d76111c9ab0d96de7dcb0e95f6a645b621..7598cb4119dd42b9b6622f261fd4cec7d248c95d 100644 (file)
 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<class RealType = real, unsigned int tableBits = c_TabulatedNormalDistributionDefaultBits>
+template<class RealType = real, unsigned int tableBits = detail::c_TabulatedNormalDistributionDefaultBits>
 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<real, 1<<c_TabulatedNormalDistributionDefaultBits> TabulatedNormalDistribution<real, c_TabulatedNormalDistributionDefaultBits>::c_table_;
+const std::array<real, 1<<detail::c_TabulatedNormalDistributionDefaultBits> TabulatedNormalDistribution<>::c_table_;
 
 extern template
-const std::array<real, 1<<c_TabulatedNormalDistributionDefaultBits> TabulatedNormalDistribution<real, c_TabulatedNormalDistributionDefaultBits>::c_table_;
+const std::array<real, 1<<detail::c_TabulatedNormalDistributionDefaultBits> TabulatedNormalDistribution<>::c_table_;
 #endif
 
 // Instantiation for all tables without specialization
index 9dd2a2c4acb46f503d476775e33d109df118a0e9..5c1d4284856e3511141ea034cd2e4b7a236f9882 100644 (file)
@@ -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;
     }
 };
 }
index 287fe89b6132f2e06f7bbc193ce213e07776a39e..eb8eaa538bc16301f533f9c33f93a19d22c092b7 100644 (file)
@@ -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 <memory>
 #include <string>
 
+#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<SelectionParserValueList>();
         }
         /*! \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<SelectionParserParameterList>();
         }
         /*! \brief
          * Allocates and initializes a parsed method parameter.
index 3a182f3fd5bb06313662f69dafe3e92eb967af86..6ee5a051b4a3f031e72f84b15519cfbdc8361452 100644 (file)
@@ -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
index 80eb0900e0c038e387bb4578280a178b736df0b4..f112a287d0332688883ff0767b2e3fe3fc81f083 100644 (file)
@@ -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_];
         }
index 218e8d215045853288283d943d76d7d48d68cf7a..3ee5a474e5e3661b91473ca6189112ff245384db 100644 (file)
@@ -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)
index 66cbb7b5291939fdc237db1023f2c6fc619b4342..302e17ffd9b4834d2ebaaa65def12f807594fbf9 100644 (file)
@@ -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<const __m128i *>(m))
index 3f537e10f9b787d3cf435d201480ac1517b06915..c65023ef4d8a520e0142b9e52c788ce0f3dffb0d 100644 (file)
@@ -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<const __m256i *>(m))
index cae601e374116d8fd12f08221fbc17092a35c91e..3c1c54b79a8449f9d1b1b5bab2e2abe6a42bbba4 100644 (file)
@@ -703,7 +703,7 @@ load4DuplicateN(const double* f)
     return load<Simd4NDouble>(f);
 }
 static inline Simd4NDouble gmx_simdcall
-loadU4NOffset(const double* f, int)
+loadU4NOffset(const double* f, int /*unused*/)
 {
     return loadU<Simd4NDouble>(f);
 }
index 89a5d64eb7976f12b18b3283ca048aa0be80d7d5..2130907ae4f6aa70060652de8438670ec54d66ca 100644 (file)
@@ -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<non_const_T>(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)
         template<typename U,
                  typename = typename std::enable_if<
index 77b2a160f9841fde1cc06eaca0eee0e6a8d3ffea..8a58486c9de071181c1cecb92d5f11b27bac61d9 100644 (file)
@@ -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.
@@ -297,7 +297,7 @@ fillMultiplexedTableData(const T           inputData,
                          std::size_t       numTables,
                          std::size_t       thisTableIndex)
 {
-    if (multiplexedOutputData->size() == 0)
+    if (multiplexedOutputData->empty())
     {
         multiplexedOutputData->resize( inputData.size() * numTables );
     }
index 7e01c99eabf3e9f01fb8dd62396125b4a27a08a3..694024202b282a47044e6f3cc258130b81f6947f 100644 (file)
@@ -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<int>   &gpuIdsToUse,
                                                      const std::vector<int>   &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<int> &gpuIdsToUse,
                                                const std::vector<int> &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<int>    &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<int> &userGpuTaskAssignment,
-                                  const bool              canUseGpuForPme,
-                                  const int               numRanksPerSimulation,
-                                  const int               numPmeRanksPerSimulation,
-                                  const bool              gpusWereDetected);
+                                  bool                    canUseGpuForPme,
+                                  int                     numRanksPerSimulation,
+                                  int                     numPmeRanksPerSimulation,
+                                  bool                    gpusWereDetected);
 
 }
 
index 90b55fed2e2f7d1172e06d665ca8451d477e6bfa..63e30e09faa98f80175c2db3d4bf3df8d5b7dbf6 100644 (file)
@@ -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,
index 096c16efa7e77edc1898cff876b81df7dd343e0d..2c2e4f1fb19d0291a78080cfb9ab92512ef1c4ea 100644 (file)
@@ -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
 {
index 8bca6ce563e8c0e65c358a8e3097180cda72e818..cb8c4317864a033374e83ebbb333462a2dc4f4e6 100644 (file)
@@ -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.                   */
index fd35fb4bad0176c18c6610bb26c0636cf9735c4b..fda99e34017ed6cc3d3838286e514ee04d62ba16 100644 (file)
@@ -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();
index bd23f0e90d5e48aced9f60156a4f6cd8f258db87..c83453fbb023e0486515a1ef3423bcf787714af0 100644 (file)
@@ -88,7 +88,7 @@ class EnergyFrame
         using MapConstIterator = MapType::const_iterator;
         //! Constructor
         EnergyFrame(const t_enxframe &enxframe,
-                    const std::map<std::string, int> indicesOfEnergyFields);
+                    std::map<std::string, int> indicesOfEnergyFields);
         /*! \brief Return string that helps users identify this frame, containing time and step number.
          *
          * \throws std::bad_alloc  when out of memory */
index 03fd6c86534e5cc203e6a219a25eae59b66d29a3..65f4fef9efe5d09d0981980c01e8c11eb92e6eaf 100644 (file)
@@ -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?                */
index 3d243adb7142b2aed977372fae54dc904342f733..c8905068dfd6e204bbfde3442f33239f2372e720 100644 (file)
@@ -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 <class U>
-        explicit Allocator(const Allocator<U, AllocationPolicy> &) {}
+        explicit Allocator(const Allocator<U, AllocationPolicy> & /*unused*/) {}
 
         /*! \brief Constructor
          *
@@ -239,7 +239,7 @@ class Allocator : public AllocationPolicy
          */
         template<class T2>
         bool
-        operator==(const Allocator<T2, AllocationPolicy> &) const { return std::is_same<T, T2>::value; }
+        operator==(const Allocator<T2, AllocationPolicy> & /*unused*/) const { return std::is_same<T, T2>::value; }
 
         /*! \brief Return true if two allocators are different
          *
index ee0ae7733e5d8ff9c9da70eb84530fd6729cf37f..caba999d9592fbb0b115f6777257c27f8ef391fe 100644 (file)
@@ -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
          *
index 3f973ac5d5037595e8492d261d078fbb683be703..6963fecd89b1bbbc0e686cab068411ca37512606 100644 (file)
@@ -48,7 +48,7 @@
  * \ingroup module_utility
  */
 template <typename T, int N>
-constexpr int asize(T(&)[N])
+constexpr int asize(T(&/*unused*/)[N])
 {
     static_assert(N >= 0, "Do negative size arrays exist?");
     return N;
index 802b0e02b9bb834c947d19bacac2f73a5c9bf793..f02b2d1ed59a4fa55498bd9645fec54b1f8e7350 100644 (file)
@@ -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 <typename T>
-static inline void ignoreValueHelper(const T &)
+static inline void ignoreValueHelper(const T & /*unused*/)
 {
 }
 //! \endcond
index b24546b4942a2439d3ac8844f59552e2ae3bc4f6..64b5757e05acddcf7538651ee0cf2c371959d5db 100644 (file)
@@ -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
index f2e948f2653bab279fe8ff10b1af316037d7423c..8c3b6b6175f6332a4612f7ff46013bcd224aff03 100644 (file)
@@ -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);
index 5b7ea96c088d335289ed1dde13c88d6c76a52059..3cf0e0848e239dfd41bfed2320c19cd245b8df35 100644 (file)
@@ -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_);
index 4f52ec6045c181a8b9cf188b45d3e9c67a77b656..7baab25b02e75b33fefe8735f17c31b085f5af24 100644 (file)
@@ -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:
index c2abd481322e56dfc74490dfe1d41a91d88d902b..dca5db5cf39c4558e86cf352d53c9278817cfbb8 100644 (file)
@@ -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 <class T>
 struct no_delete
 {
     //! Deleter that does nothing.
-    void operator()(T *) {}
+    void operator()(T * /*unused*/) {}
 };
 
 } // namespace gmx
index 9d1b37de28a752e37be25b34dd4e2c27b4aeb332..088f80a9ef72861a73af27cc4d98be1cc7917771 100644 (file)
@@ -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 <typename T>
-        static Variant create(T &&value) { return Variant(std::move(value)); }
+        static Variant create(T &&value) { return Variant(std::forward<T>(value)); }
 
         //! Creates an empty variant value.
         Variant() {}
@@ -106,19 +106,9 @@ class Variant
          *
          * \throws std::bad_alloc if out of memory.
          */
-        template <typename T>
-        explicit Variant(const T &value)
-            : content_(new Content<typename std::decay<T>::type>(value))
-        {
-        }
-        /*! \brief
-         * Creates a variant that holds the given value.
-         *
-         * \throws std::bad_alloc if out of memory.
-         */
-        template <typename T>
+        template <typename T, typename = typename std::enable_if<!std::is_same<T, Variant>::value>::type>
         explicit Variant(T &&value)
-            : content_(new Content<typename std::decay<T>::type>(std::move(value)))
+            : content_(new Content<typename std::decay<T>::type>(std::forward<T>(value)))
         {
         }
         /*! \brief