Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/dev/clang-tidy-fixes-2026-04.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@
- [x] [modernize-avoid-c-arrays](https://clang.llvm.org/extra/clang-tidy/checks/modernize/avoid-c-arrays.html) (17)
- _a.k.a._ [cppcoreguidelines-avoid-c-arrays](https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/avoid-c-arrays.html)
- [PR #745](https://github.com/Framework-R-D/phlex/pull/745)
- [ ] [modernize-avoid-c-style-cast](https://clang.llvm.org/extra/clang-tidy/checks/modernize/avoid-c-style-cast.html) (82)
- [x] [modernize-avoid-c-style-cast](https://clang.llvm.org/extra/clang-tidy/checks/modernize/avoid-c-style-cast.html) (82)
- [PR #771](https://github.com/Framework-R-D/phlex/pull/771)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
- [ ] [modernize-concat-nested-namespaces](https://clang.llvm.org/extra/clang-tidy/checks/modernize/concat-nested-namespaces.html) (1)
- [x] [modernize-make-shared](https://clang.llvm.org/extra/clang-tidy/checks/modernize/make-shared.html) (1)
- [PR #746](https://github.com/Framework-R-D/phlex/pull/746)
Expand Down
3 changes: 2 additions & 1 deletion form/root_storage/root_rfield_read_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ namespace form::detail::experimental {
createView(type);
}

if (id >= (int)m_reader->GetNEntries())
if (id >= static_cast<int>(m_reader->GetNEntries())) {
return false;
}

//Using RNTupleView<> to read instead of reusing REntry gives us full schema evolution support: the ROOT feature that lets us read files with an old class version into a new class version's memory.
auto buffer = m_view->GetField().CreateObject<void>(); //PHLEX gets ownership of this memory
Expand Down
6 changes: 2 additions & 4 deletions form/storage/storage_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ namespace {
if (components.empty()) {
return false;
}
for (auto const& [key, value] : components) {
(void)key;
for (auto const& [_, value] : components) {
if (value != 0) {
return false;
}
Expand Down Expand Up @@ -356,8 +355,7 @@ std::vector<std::string> StorageReader::listIndices(

std::vector<std::string> result;
result.reserve(ordered.size());
for (auto const& [entry, index_string] : ordered) {
(void)entry;
for (auto const& [_, index_string] : ordered) {
result.push_back(index_string);
}
return result;
Expand Down
2 changes: 1 addition & 1 deletion phlex/model/index_generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace phlex {
return *this;
}

void operator++(int) { (void)++(*this); }
void operator++(int) { ++(*this); }

value_type const& operator*() const noexcept { return coroutine_.promise().current_; }
value_type const* operator->() const noexcept
Expand Down
4 changes: 2 additions & 2 deletions phlex/utilities/resource_usage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ namespace {
auto const [secs, microsecs] = used.ru_utime;
// ru_maxrss is a POSIX field inside a GCC __extension__ union in <sys/resource.h>;
// no user-controlled alternative exists.
return {.elapsed_time = double(secs) + (double(microsecs) / 1e6),
return {.elapsed_time = static_cast<double>(secs) + (static_cast<double>(microsecs) / 1e6),
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access)
.max_rss = double(used.ru_maxrss) / mem_denominator};
.max_rss = static_cast<double>(used.ru_maxrss) / mem_denominator};
}
}

Expand Down
19 changes: 10 additions & 9 deletions plugins/python/src/configwrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static PyObject* pcm_subscript(py_config_map* pycmap, PyObject* pykey)
pyvalue = PyTuple_New(*cvalue_size);
// We can use std::views::enumerate once the AppleClang C++ STL supports it.
for (Py_ssize_t i = 0; i < *cvalue_size; ++i) {
PyObject* item = PyLong_FromLong((long)cvalue[i]);
PyObject* item = PyLong_FromLong(static_cast<long>(cvalue[i]));
PyTuple_SetItem(pyvalue, i, item);
}
} else if (k.first == boost::json::kind::int64) {
Expand Down Expand Up @@ -148,8 +148,8 @@ static PyObject* pcm_subscript(py_config_map* pycmap, PyObject* pykey)
pyvalue = PyTuple_New(*cvalue_size);
// We can use std::views::enumerate once the AppleClang C++ STL supports it.
for (Py_ssize_t i = 0; i < *cvalue_size; ++i) {
PyObject* item =
PyUnicode_FromStringAndSize(cvalue[i].c_str(), (Py_ssize_t)cvalue[i].size());
PyObject* item = PyUnicode_FromStringAndSize(cvalue[i].c_str(),
static_cast<Py_ssize_t>(cvalue[i].size()));
PyTuple_SetItem(pyvalue, i, item);
}
} else if (k.first == boost::json::kind::object) {
Expand All @@ -164,8 +164,8 @@ static PyObject* pcm_subscript(py_config_map* pycmap, PyObject* pykey)
for (Py_ssize_t i = 0; i < *cvalue_size; ++i) {
PyObject* item = PyDict_New();
for (auto const& kv : cvalue[i]) {
PyObject* val =
PyUnicode_FromStringAndSize(kv.second.c_str(), (Py_ssize_t)kv.second.size());
PyObject* val = PyUnicode_FromStringAndSize(kv.second.c_str(),
static_cast<Py_ssize_t>(kv.second.size()));
PyDict_SetItemString(item, kv.first.c_str(), val);
Py_DECREF(val);
}
Expand All @@ -178,7 +178,7 @@ static PyObject* pcm_subscript(py_config_map* pycmap, PyObject* pykey)
} else {
if (k.first == boost::json::kind::bool_) {
auto cvalue = pycmap->ph_config->get<bool>(ckey);
pyvalue = PyBool_FromLong((long)cvalue);
pyvalue = PyBool_FromLong(static_cast<long>(cvalue));
} else if (k.first == boost::json::kind::int64) {
auto cvalue = pycmap->ph_config->get<std::int64_t>(ckey);
// Note Python3.14 is expected to add PyLong_FromInt64
Expand All @@ -192,13 +192,14 @@ static PyObject* pcm_subscript(py_config_map* pycmap, PyObject* pykey)
pyvalue = PyFloat_FromDouble(cvalue);
} else if (k.first == boost::json::kind::string) {
auto const& cvalue = pycmap->ph_config->get<std::string>(ckey);
pyvalue = PyUnicode_FromStringAndSize(cvalue.c_str(), (Py_ssize_t)cvalue.size());
pyvalue =
PyUnicode_FromStringAndSize(cvalue.c_str(), static_cast<Py_ssize_t>(cvalue.size()));
} else if (k.first == boost::json::kind::object) {
auto cvalue = pycmap->ph_config->get<std::map<std::string, std::string>>(ckey);
pyvalue = PyDict_New();
for (auto const& kv : cvalue) {
PyObject* val =
PyUnicode_FromStringAndSize(kv.second.c_str(), (Py_ssize_t)kv.second.size());
PyObject* val = PyUnicode_FromStringAndSize(kv.second.c_str(),
static_cast<Py_ssize_t>(kv.second.size()));
PyDict_SetItemString(pyvalue, kv.first.c_str(), val);
Py_DECREF(val);
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/python/src/dciwrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ PyObject* phlex::experimental::wrap_dci(data_cell_index const& dci)
// simple forwarding methods
static PyObject* dci_number(py_data_cell_index* pydci)
{
return PyLong_FromLong((long)pydci->ph_dci->number());
return PyLong_FromLong(static_cast<long>(pydci->ph_dci->number()));
}

// PyMethodDef arrays must be non-const; tp_methods in PyTypeObject takes a non-const pointer.
Expand Down
2 changes: 1 addition & 1 deletion plugins/python/src/dyncall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void phlex::experimental::dyncall(void* fn, dcarg& result, dcargs_t& args, int v
// because libffi is, and that yields a plethora of warnings from clang-tidy,
// none of which warrant actual changes.
// NOLINTBEGIN
std::size_t nargs = (std::size_t)args.size();
std::size_t nargs = args.size();

auto t = std::make_unique<ffi_type*[]>(nargs);
auto p = std::make_unique<void*[]>(nargs);
Expand Down
26 changes: 13 additions & 13 deletions plugins/python/src/modulewrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ namespace {
PyGILRAII gil;

dcarg result{nullptr};
dyncall((void*)m_ccallback, result, argsv, 1);
dyncall(m_ccallback, result, argsv, 1);

std::string error_msg;
if (!result.get<PyObject*>()) {
Expand Down Expand Up @@ -227,7 +227,7 @@ namespace {
argsv.reserve(sizeof...(Is));
(argsv.push_back(args), ...);

dyncall((void*)m_ccallback, result, argsv);
dyncall(m_ccallback, result, argsv);
// TODO: error reporting?

if constexpr (!std::is_void_v<RT>) {
Expand Down Expand Up @@ -337,7 +337,7 @@ namespace {
for (Py_ssize_t i = 0; i < len; ++i) {
PyObject* item = items[i]; // borrowed reference
if (!PyUnicode_Check(item)) {
PyErr_Format(PyExc_TypeError, "item %d must be a string", (int)i);
PyErr_Format(PyExc_TypeError, "item %d must be a string", static_cast<int>(i));
break;
}

Expand Down Expand Up @@ -512,9 +512,9 @@ namespace {
// fail to pass float -> bool; the problem is rounding (0.1 -> 0 -> False)
if (!(l == 0 || l == 1) || PyFloat_Check(pyobject)) {
PyErr_SetString(PyExc_ValueError, "boolean value should be bool, or integer 1 or 0");
return (bool)-1;
return static_cast<bool>(-1);
Comment thread
knoepfel marked this conversation as resolved.
}
return (bool)l;
return static_cast<bool>(l);
}

long pylong_as_strictlong(PyObject* pyobject)
Expand All @@ -535,15 +535,15 @@ namespace {
}

PyErr_SetString(PyExc_TypeError, "int/long conversion expects a signed integer object");
return (long)-1;
return static_cast<long>(-1);
}

unsigned long pylong_or_int_as_ulong(PyObject* pyobject)
{
// convert <pybject> to C++ unsigned long, with bounds checking, allow int -> ulong.
if (PyFloat_Check(pyobject)) {
PyErr_SetString(PyExc_TypeError, "can\'t convert float to unsigned long");
return (unsigned long)-1;
return static_cast<unsigned long>(-1);
Comment thread
knoepfel marked this conversation as resolved.
}

// accept numpy unsigned integer scalars (uint8, uint16, uint32, uint64)
Expand All @@ -557,14 +557,14 @@ namespace {
}

unsigned long ul = PyLong_AsUnsignedLong(pyobject);
if (ul == (unsigned long)-1 && PyErr_Occurred() && PyLong_Check(pyobject)) {
if (ul == static_cast<unsigned long>(-1) && PyErr_Occurred() && PyLong_Check(pyobject)) {
PyErr_Clear();
long i = PyLong_AS_LONG(pyobject);
if (0 <= i) {
ul = (unsigned long)i;
ul = static_cast<unsigned long>(i);
} else {
PyErr_SetString(PyExc_ValueError, "can\'t convert negative value to unsigned long");
return (unsigned long)-1;
return static_cast<unsigned long>(-1);
Comment thread
knoepfel marked this conversation as resolved.
}
}

Expand Down Expand Up @@ -805,7 +805,7 @@ static PyObject* parse_args(PyObject* args,
}

// set concurrency, or the default of serial if not set
nconcur = nconcur_ > 0 ? (concurrency)nconcur_ : concurrency::serial;
nconcur = nconcur_ > 0 ? concurrency(nconcur_) : concurrency::serial;

// retrieve function name
if (!pyname) {
Expand Down Expand Up @@ -1042,7 +1042,7 @@ static PyObject* md_transform(py_phlex_module* mod, PyObject* args, PyObject* kw
std::vector<std::string> input_types;
std::vector<std::string> output_suffixes;
std::vector<std::string> output_types;
auto nconcur = (concurrency)-1;
concurrency nconcur(-1);
PyObject* callable = parse_args(
args, kwds, cname, input_selectors, input_types, output_suffixes, output_types, nconcur);

Expand Down Expand Up @@ -1190,7 +1190,7 @@ static PyObject* md_observe(py_phlex_module* mod, PyObject* args, PyObject* kwds
std::vector<std::string> input_types;
std::vector<std::string> output_suffixes;
std::vector<std::string> output_types;
auto nconcur = (concurrency)-1;
concurrency nconcur(-1);
PyObject* callable = parse_args(
args, kwds, cname, input_selectors, input_types, output_suffixes, output_types, nconcur);

Expand Down
2 changes: 1 addition & 1 deletion plugins/python/src/pymodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ static bool initialize()
// Python interpreter will not happen atm.
static std::atomic<bool> gil_released{false};
if (!gil_released.exchange(true)) {
(void)PyEval_SaveThread(); // state not saved, as no place to restore
PyEval_SaveThread(); // state not saved, as no place to restore
}

return true;
Expand Down
7 changes: 4 additions & 3 deletions test/form/form_source_extra_types.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "form/form_source_type_registry.hpp"
#include "phlex/module.hpp"

#include <utility>

using namespace phlex;

namespace {
Expand All @@ -23,9 +25,8 @@ namespace {
}
}

PHLEX_REGISTER_ALGORITHMS(m, config)
PHLEX_REGISTER_ALGORITHMS(m)
{
(void)m;
(void)config;
std::ignore = m;
register_extra_form_types_once();
}
7 changes: 5 additions & 2 deletions test/product_selecting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ using namespace std::string_literals;

namespace {
// Provider functions
int provide_idx(data_cell_index const& dci) { return int(dci.number()); }
int provide_idx(data_cell_index const& dci) { return static_cast<int>(dci.number()); }
int provide_number(data_cell_index const&) { return 3; }
double provide_temperature(data_cell_index const& dci) { return double(dci.number()) * 100.0; }
double provide_temperature(data_cell_index const& dci)
{
return static_cast<double>(dci.number()) * 100.0;
}
std::string provide_name(data_cell_index const& dci)
{
return fmt::format("John the {}th", dci.number());
Expand Down
2 changes: 1 addition & 1 deletion test/type_distinction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace {

auto triple(int x) { return 3 * x; }

auto square(int x) { return std::tuple{x * x, double((x * x) + 0.5)}; }
auto square(int x) { return std::tuple{x * x, ((x * x) + 0.5)}; }

int id(int x) { return x; }

Expand Down
Loading