Fix all warnings with clang-tidy 6 without OpenMP.
OpenMP+clang-tidy has issue: #37442
Change-Id: I2380f63ba1d7541cf230fb99d53e42f7f515986a
set_property(GLOBAL PROPERTY GMX_INSTALLED_HEADERS)
set_property(GLOBAL PROPERTY GMX_AVX_512_SOURCE)
+add_library(libgromacs_external OBJECT "")
+if (BUILD_SHARED_LIBS)
+ set_target_properties(libgromacs_external PROPERTIES POSITION_INDEPENDENT_CODE true)
+endif()
+
function (_gmx_add_files_to_property PROPERTY)
foreach (_file ${ARGN})
if (IS_ABSOLUTE "${_file}")
#target_link_libraries(gmx ${GMX_EXTRA_LIBRARIES} ${THREAD_MPI_LIB})
tmpi_get_source_list(THREAD_MPI_SOURCES ${CMAKE_SOURCE_DIR}/src/external/thread_mpi/src)
-list(APPEND LIBGROMACS_SOURCES ${THREAD_MPI_SOURCES})
+target_sources(libgromacs_external PRIVATE ${THREAD_MPI_SOURCES})
configure_file(version.h.cmakein version.h)
gmx_install_headers(
gmx_configure_version_file(
utility/baseversion-gen.c.cmakein ${GENERATED_VERSION_FILE}
REMOTE_HASH)
-list(APPEND LIBGROMACS_SOURCES ${GENERATED_VERSION_FILE})
+list(APPEND LIBGROMACS_SOURCES ${GENERATED_VERSION_FILE}
+ $<TARGET_OBJECTS:libgromacs_external>)
# Mark some shared GPU implementation files to compile with CUDA if needed
if (GMX_USE_CUDA)
gmx_manage_lmfit()
target_link_libraries(libgromacs PRIVATE lmfit)
+if (GMX_CLANG_TIDY)
+ find_program(CLANG_TIDY_EXE NAMES "clang-tidy"
+ DOC "Path to clang-tidy executable")
+ if(NOT CLANG_TIDY_EXE)
+ message(ERROR "clang-tidy not found.")
+ endif()
+ if(CMAKE_VERSION VERSION_LESS "3.6")
+ message(ERROR "clang-tidy support requires cmake 3.6.")
+ endif()
+ set_target_properties(libgromacs PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};--checks=-clang-analyzer-security.insecureAPI.strcpy,-clang-analyzer-core.NullDereference;-warnings-as-errors=*")
+endif()
+
gmx_write_installed_header_list()
# Only install the library in mdrun-only mode if it is actually necessary
/*
* 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.
int indexLinear,
awh_ivec indexMulti)
{
- awh_ivec numPointsDim;
-
- for (int d = 0; d < grid.numDimensions(); d++)
+ awh_ivec numPointsDim;
+ const int numDimensions = grid.numDimensions();
+ for (int d = 0; d < numDimensions; d++)
{
numPointsDim[d] = grid.axis(d).numPoints();
}
- linearArrayIndexToMultiDim(indexLinear, grid.numDimensions(), numPointsDim, indexMulti);
+ linearArrayIndexToMultiDim(indexLinear, numDimensions, numPointsDim, indexMulti);
}
int i, j, jmax, nf_int;
gmx_bool bPrint;
+ GMX_ASSERT(effnNparams(fitfn) < static_cast<int>(sizeof(fitparm)/sizeof(double)),
+ "Fitting function with more than 3 parameters not supported!");
bPrint = bVerbose || bDebugMode();
if (bPrint)
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 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.
};
#define NTPSS asize(tpss)
-typedef struct
+typedef struct // NOLINT(clang-analyzer-optin.performance.Padding)
{
int ftype;
const char *ext;
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 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.
}
}
}
+ /* apparently, dx and dy are incremented one more time
+ as the loops terminate: we correct this here */
+ dy--;
}
- /* apparently, dx and dy are incremented one more time
- as the loops terminate: we correct this here */
dx--;
- dy--;
/* if we skipped equal on both sides, only skip one residue
to allow for single mutations of residues... */
if (bFF)
bEdge_xjj, bEdge_yjj) \
default(shared)
{ /* Start of parallel region */
-#if !defined __clang_analyzer__ // clang complains about unused value.
- threadNr = gmx_omp_get_thread_num();
-#endif
-
+ if (bOMP)
+ {
+ threadNr = gmx_omp_get_thread_num();
+ }
do
{
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 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.
"Last residue in helix" }
};
- typedef struct {
+ typedef struct { //NOLINT(clang-analyzer-optin.performance.Padding)
FILE *fp, *fp2;
gmx_bool bfp2;
const char *filenm;
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 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.
#define NKC 6
#define NKC0 4
-int kset_c[NKC+1] = { 0, 3, 9, 13, 16, 19, NK };
+static const int kset_c[NKC+1] = { 0, 3, 9, 13, 16, 19, NK };
-rvec v0[NK] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {1, 1, 0}, {1, -1, 0}, {1, 0, 1}, {1, 0, -1}, {0, 1, 1}, {0, 1, -1}, {1, 1, 1}, {1, 1, -1}, {1, -1, 1}, {-1, 1, 1}, {2, 0, 0}, {0, 2, 0}, {0, 0, 2}, {3, 0, 0}, {0, 3, 0}, {0, 0, 3}, {4, 0, 0}, {0, 4, 0}, {0, 0, 4}};
-rvec v1[NK] = {{0, 1, 0}, {0, 0, 1}, {1, 0, 0}, {0, 0, 1}, {0, 0, 1}, {0, 1, 0}, {0, 1, 0}, {1, 0, 0}, {1, 0, 0}, {1, -1, 0}, {1, -1, 0}, {1, 0, -1}, { 0, 1, -1}, {0, 1, 0}, {0, 0, 1}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {1, 0, 0}};
-rvec v2[NK] = {{0, 0, 1}, {1, 0, 0}, {0, 1, 0}, {1, -1, 0}, {1, 1, 0}, {1, 0, -1}, {1, 0, 1}, {0, 1, -1}, {0, 1, 1}, {1, 1, -2}, {1, 1, 2}, {1, 2, 1}, { 2, 1, 1}, {0, 0, 1}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {1, 0, 0}, {0, 1, 0}};
+rvec v0[NK] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {1, 1, 0}, {1, -1, 0}, {1, 0, 1}, {1, 0, -1}, {0, 1, 1}, {0, 1, -1}, {1, 1, 1}, {1, 1, -1}, {1, -1, 1}, {-1, 1, 1}, {2, 0, 0}, {0, 2, 0}, {0, 0, 2}, {3, 0, 0}, {0, 3, 0}, {0, 0, 3}, {4, 0, 0}, {0, 4, 0}, {0, 0, 4}};
+rvec v1[NK] = {{0, 1, 0}, {0, 0, 1}, {1, 0, 0}, {0, 0, 1}, {0, 0, 1}, {0, 1, 0}, {0, 1, 0}, {1, 0, 0}, {1, 0, 0}, {1, -1, 0}, {1, -1, 0}, {1, 0, -1}, { 0, 1, -1}, {0, 1, 0}, {0, 0, 1}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {1, 0, 0}};
+rvec v2[NK] = {{0, 0, 1}, {1, 0, 0}, {0, 1, 0}, {1, -1, 0}, {1, 1, 0}, {1, 0, -1}, {1, 0, 1}, {0, 1, -1}, {0, 1, 1}, {1, 1, -2}, {1, 1, 2}, {1, 2, 1}, { 2, 1, 1}, {0, 0, 1}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {1, 0, 0}, {0, 1, 0}};
static void process_tcaf(int nframes, real dt, int nkc, real **tc, rvec *kfac,
real rho, real wt, const char *fn_trans,
nkc = NKC0;
}
nk = kset_c[nkc];
+ GMX_ASSERT(nk >= 16, "Has to be over 16 because nkc is either NKC or NKC0.");
ntc = nk*NPK;
sprintf(title, "Velocity Autocorrelation Function for %s", grpname);
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2017, by the GROMACS development team, led by
+ * Copyright (c) 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.
#include "gromacs/utility/dir_separator.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/futil.h"
+#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/smalloc.h"
typedef struct {
bIfndef = (strcmp(dname, "ifndef") == 0);
if (bIfdef || bIfndef)
{
+ GMX_RELEASE_ASSERT(dval, "#ifdef/#ifndef requires an argument");
if ((handle->nifdef > 0) && (handle->ifdefs[handle->nifdef-1] != eifTRUE))
{
handle->nifdef++;
/* Check for include statements */
if (strcmp(dname, "include") == 0)
{
+ GMX_RELEASE_ASSERT(dval, "#include requires an argument");
len = -1;
i0 = 0;
for (i1 = 0; (i1 < strlen(dval)); i1++)
/* #define statement */
if (strcmp(dname, "define") == 0)
{
+ GMX_RELEASE_ASSERT(dval, "#define requires an argument");
/* Split it into name and value. */
ptr = dval;
while ((*ptr != '\0') && !isspace(*ptr))
/* #undef statement */
if (strcmp(dname, "undef") == 0)
{
+ GMX_RELEASE_ASSERT(dval, "#undef requires an argument");
snew(name, strlen(dval)+1);
sscanf(dval, "%s", name);
for (i = 0; (i < ndef); i++)
if (equalEitherForwardOrBackward(bParams, testParams))
{
GMX_ASSERT(nrfp <= MAXFORCEPARAM, "This is ensured in other places, but we need this assert to keep the clang analyzer happy");
- // TODO consider improving the following code by using:
- // bool identicalParameters = std::equal(bt->param[i].c, bt->param[i].c + nrfp, b->c);
- bool identicalParameters = true;
- for (int j = 0; (j < nrfp); j++)
- {
- identicalParameters = identicalParameters && (bt->param[i].c[j] == b->c[j]);
- }
+ const bool identicalParameters = std::equal(bt->param[i].c, bt->param[i].c + nrfp, b->c);
if (!bAllowRepeat || identicalParameters)
{
/*! \brief struct for passing all data required for a function type */
typedef struct {
- int ftype; /**< the function type index */
const t_ilist *il; /**< pointer to t_ilist entry corresponding to ftype */
+ int ftype; /**< the function type index */
int nat; /**< nr of atoms involved in a single ftype interaction */
} ilist_data_t;
memmin = mem_p->zmin+0.1*(mem_p->zmax-mem_p->zmin);
memmax = mem_p->zmax-0.1*(mem_p->zmax-mem_p->zmin);
+ //NOLINTNEXTLINE(clang-analyzer-security.FloatLoopCounter)
for (x = pos_ins->xmin[XX]; x < pos_ins->xmax[XX]; x += dx)
{
+ //NOLINTNEXTLINE(clang-analyzer-security.FloatLoopCounter)
for (y = pos_ins->xmin[YY]; y < pos_ins->xmax[YY]; y += dy)
{
c = 0;
/*
* 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.
SimdReal shZ_S = SimdReal(shiftvec[ish3 + 2]);
#if UNROLLJ <= 4
- int sci = ci*STRIDE;
- int scix = sci*DIM;
+ int scix = ci*STRIDE*DIM;
#else
- int sci = (ci >> 1)*STRIDE;
- int scix = sci*DIM + (ci & 1)*(STRIDE >> 1);
- sci += (ci & 1)*(STRIDE >> 1);
+ int scix = (ci >> 1)*STRIDE*DIM + (ci & 1)*(STRIDE >> 1);
#endif
/* Load i atom data */
/*
* 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.
SimdReal shZ_S = SimdReal(shiftvec[ish3 + 2]);
#if UNROLLJ <= 4
- int sci = ci*STRIDE;
- int scix = sci*DIM;
+ int scix = ci*STRIDE*DIM;
#else
- int sci = (ci >> 1)*STRIDE;
- int scix = sci*DIM + (ci & 1)*(STRIDE >> 1);
- sci += (ci & 1)*(STRIDE >> 1);
+ int scix = (ci >> 1)*STRIDE*DIM + (ci & 1)*(STRIDE >> 1);
#endif
/* Load i atom data */
double minFail = newRange.second;
double maxFail = newRange.first;
+ // NOLINTNEXTLINE(clang-analyzer-security.FloatLoopCounter)
for (double x = newRange.first; x <= newRange.second; x += dx)
{
double analyticalDerivative = derivative(x);
double dx = (newRange.second - newRange.first) / points;
double minQuotient = GMX_REAL_MAX;
+ // NOLINTNEXTLINE(clang-analyzer-security.FloatLoopCounter)
for (double x = newRange.first; x <= newRange.second; x += dx)
{
minQuotient = std::min(minQuotient, quotientOfFunctionAndSecondDerivative(f(x-h), f(x), f(x+h), h));
double dx = (newRange.second - newRange.first) / points;
double minQuotient = GMX_REAL_MAX;
+ // NOLINTNEXTLINE(clang-analyzer-security.FloatLoopCounter)
for (double x = newRange.first; x <= newRange.second; x += dx)
{
minQuotient = std::min(minQuotient, quotientOfFunctionAndThirdDerivative(f(x-2*h), f(x-h), f(x), f(x+h), f(x+2*h), h));
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 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.
}
/*! \brief
- * Cata necessary to construct a single (protein) index group in
+ * Data necessary to construct a single (protein) index group in
* analyse_prot().
*/
-typedef struct gmx_help_make_index_group
+typedef struct gmx_help_make_index_group // NOLINT(clang-analyzer-optin.performance.Padding)
{
/** The set of atom names that will be used to form this index group */
const char **defining_atomnames;