set(CLANG_TIDY_CHECKS
"-clang-analyzer-security.insecureAPI.strcpy"
"bugprone-*" "misc-*" "readability-*" "performance-*" "mpi-*"
- "-misc-misplaced-widening-cast"
"-misc-incorrect-roundings" #TODO: #2562
"-readability-else-after-return"
"-readability-inconsistent-declaration-parameter-name"
else
{
time_unit_t time_unit
- = static_cast<time_unit_t>(impl_->settings_.timeUnit() + 1);
+ = static_cast<time_unit_t>(impl_->settings_.timeUnit() + 1); // NOLINT(misc-misplaced-widening-cast)
xvg_format_t xvg_format
= (impl_->settings_.plotFormat() > 0
? static_cast<xvg_format_t>(impl_->settings_.plotFormat())
/* set program name, command line, and default values for output options */
output_env_init(oenv, gmx::getProgramContext(),
- (time_unit_t)(timeUnit + 1), bView,
+ (time_unit_t)(timeUnit + 1), bView, // NOLINT(misc-misplaced-widening-cast)
(xvg_format_t)(xvgFormat + 1), 0);
/* Extract Time info from arguments */
ns += spac->spas[d][1].a.size();
nr += spac->spas[d][1].nrecv;
}
- if (static_cast<size_t>(vbuf_fac*ns) > spac->vbuf.size())
+ if (vbuf_fac*ns > gmx::index(spac->vbuf.size()))
{
spac->vbuf.resize(vbuf_fac*ns);
}
- if (vbuf_fac == 2 && static_cast<size_t>(vbuf_fac*nr) > spac->vbuf2.size())
+ if (vbuf_fac == 2 && vbuf_fac*nr > gmx::index(spac->vbuf2.size()))
{
spac->vbuf2.resize(vbuf_fac*nr);
}
std::vector<int> &cggl_flag = comm->cggl_flag[mc];
/* TODO: See if we can use push_back instead */
- if (static_cast<size_t>((ncg[mc] + 1)*DD_CGIBS) > cggl_flag.size())
+ if ((ncg[mc] + 1)*DD_CGIBS > gmx::index(cggl_flag.size()))
{
cggl_flag.resize((ncg[mc] + 1)*DD_CGIBS);
}
else
{
/* Reallocate the buffers if necessary */
- if (static_cast<size_t>((ncg[mc] + 1)*DD_CGIBS) > comm->cggl_flag[mc].size())
+ if ((ncg[mc] + 1)*DD_CGIBS > gmx::index(comm->cggl_flag[mc].size()))
{
comm->cggl_flag[mc].resize((ncg[mc] + 1)*DD_CGIBS);
}
}
/* make room for the data */
- if (s->ndu_alloc < (size_t)(s->ndu + blk->sub[2].nr) )
+ if (gmx::index(s->ndu_alloc) < s->ndu + blk->sub[2].nr)
{
s->ndu_alloc += (s->ndu_alloc < (size_t)blk->sub[2].nr) ?
blk->sub[2].nr*2 : s->ndu_alloc;
}
/* Make sure the work array for sorting is large enough */
- if (static_cast<size_t>(ncz_max*grid->na_sc*SGSF) > nbs->work[0].sortBuffer.size())
+ if (ncz_max*grid->na_sc*SGSF > gmx::index(nbs->work[0].sortBuffer.size()))
{
for (nbnxn_search_work_t &work : nbs->work)
{
ngid = nbat->nenergrp;
- if (static_cast<std::size_t>(ngid*gridj->na_cj) > sizeof(gid_cj)*8)
+ if (ngid*gridj->na_cj > gmx::index(sizeof(gid_cj)*8))
{
gmx_fatal(FARGS, "The Verlet scheme with %dx%d kernels and free-energy only supports up to %d energy groups",
gridi->na_c, gridj->na_cj, (sizeof(gid_cj)*8)/gridj->na_cj);
return;
}
time_unit_t time_unit
- = static_cast<time_unit_t>(settings_.timeUnit() + 1);
+ = static_cast<time_unit_t>(settings_.timeUnit() + 1); // NOLINT(misc-misplaced-widening-cast)
output_env_init(&oenv_, getProgramContext(), time_unit, FALSE, exvgNONE, 0);
int frflags = settings_.frflags();
#include <inttypes.h>
#endif
+#if defined __cplusplus
+#include <cstddef>
+#endif
+
/*! \brief
* Boolean type for use in \Gromacs C code.
*
/** Number of gmx_bool values. */
#define BOOL_NR 2
+#if defined __cplusplus
+namespace gmx
+{
+/*! \brief Integer type for indexing into arrays or vectors
+ *
+ * Same as ptrdiff_t.
+ */
+using index = std::ptrdiff_t;
+}
+#endif
+
/*! \name Fixed-width integer types
*
* These types and macros provide the equivalent of 32- and 64-bit integer