Skip to content
Open
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 @@ -146,7 +146,8 @@
- [PR #591](https://github.com/Framework-R-D/phlex/pull/591)
- [x] [readability-avoid-const-params-in-decls](https://clang.llvm.org/extra/clang-tidy/checks/readability/avoid-const-params-in-decls.html) (7)
- [PR #747](https://github.com/Framework-R-D/phlex/pull/747)
- [ ] [readability-braces-around-statements](https://clang.llvm.org/extra/clang-tidy/checks/readability/braces-around-statements.html) (74)
- [x] [readability-braces-around-statements](https://clang.llvm.org/extra/clang-tidy/checks/readability/braces-around-statements.html) (74)
- [PR #762](https://github.com/Framework-R-D/phlex/pull/762)
- [ ] [readability-const-return-type](https://clang.llvm.org/extra/clang-tidy/checks/readability/const-return-type.html) (1)
- [ ] [readability-container-contains](https://clang.llvm.org/extra/clang-tidy/checks/readability/container-contains.html) (7)
- [x] [readability-container-size-empty](https://clang.llvm.org/extra/clang-tidy/checks/readability/container-size-empty.html) (3)
Expand Down
3 changes: 2 additions & 1 deletion form/form/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ namespace {
auto const_lookup(const MAP_LIKE& map, typename MAP_LIKE::key_type const& key)
{
auto const found = map.find(key);
if (found != map.end())
if (found != map.end()) {
return found->second;
}
return decltype(found->second)();
}
}
Expand Down
3 changes: 2 additions & 1 deletion form/form/form_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ namespace form::experimental {
std::vector<product_with_name> const& products)
{

if (products.empty())
if (products.empty()) {
return;
}

auto it = m_product_to_config.find(products[0].label);
if (it == m_product_to_config.end()) {
Expand Down
3 changes: 2 additions & 1 deletion form/persistence/persistence_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ namespace form::detail::experimental {
form::experimental::config::ItemConfig const& config, std::string const& label)
{
auto const& items = config.getItems();
if (label == "index")
if (label == "index") {
return (items.empty())
? std::nullopt
: std::make_optional(
*items
.begin()); //emulate how FORM did this before Phlex PR #22. Will be fixed in a future FORM update.
}

return config.findItem(label);
}
Expand Down
24 changes: 16 additions & 8 deletions form/storage/storage_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,17 @@ int StorageReader::getIndex(Token const& token,
m_files.insert({token.fileName(), createFile(token.technology(), token.fileName(), 'i')})
.first;
for (auto const& [key, value] :
get_file_table(settings, token.technology(), token.fileName()))
get_file_table(settings, token.technology(), token.fileName())) {
file->second->setAttribute(key, value);
}
}
cont = m_read_containers
.insert({key, createReadContainer(token.technology(), token.containerName())})
.first;
for (auto const& [key, value] :
get_container_table(settings, token.technology(), token.containerName()))
get_container_table(settings, token.technology(), token.containerName())) {
cont->second->setAttribute(key, value);
}
cont->second->setFile(file->second);
}
auto const& type = typeid(std::string);
Expand Down Expand Up @@ -286,16 +288,18 @@ void StorageReader::prime(Token const& token,
m_files.insert({token.fileName(), createFile(token.technology(), token.fileName(), 'i')})
.first;
for (auto const& [key, value] :
get_file_table(settings, token.technology(), token.fileName()))
get_file_table(settings, token.technology(), token.fileName())) {
file->second->setAttribute(key, value);
}
}
cont = m_read_containers
.insert({key, createReadContainer(token.technology(), token.containerName())})
.first;
cont->second->setFile(file->second);
for (auto const& [key, value] :
get_container_table(settings, token.technology(), token.containerName()))
get_container_table(settings, token.technology(), token.containerName())) {
cont->second->setAttribute(key, value);
}
}
cont->second->prime(type);
}
Expand All @@ -313,15 +317,17 @@ std::vector<std::string> StorageReader::listIndices(
m_files.insert({token.fileName(), createFile(token.technology(), token.fileName(), 'i')})
.first;
for (auto const& [key, value] :
get_file_table(settings, token.technology(), token.fileName()))
get_file_table(settings, token.technology(), token.fileName())) {
file->second->setAttribute(key, value);
}
}
cont = m_read_containers
.insert({key, createReadContainer(token.technology(), token.containerName())})
.first;
for (auto const& [key, value] :
get_container_table(settings, token.technology(), token.containerName()))
get_container_table(settings, token.technology(), token.containerName())) {
cont->second->setAttribute(key, value);
}
cont->second->setFile(file->second);
}

Expand Down Expand Up @@ -371,16 +377,18 @@ void StorageReader::readContainer(Token const& token,
m_files.insert({token.fileName(), createFile(token.technology(), token.fileName(), 'i')})
.first;
for (auto const& [key, value] :
get_file_table(settings, token.technology(), token.fileName()))
get_file_table(settings, token.technology(), token.fileName())) {
file->second->setAttribute(key, value);
}
}
cont = m_read_containers
.insert({key, createReadContainer(token.technology(), token.containerName())})
.first;
cont->second->setFile(file->second);
for (auto const& [key, value] :
get_container_table(settings, token.technology(), token.containerName()))
get_container_table(settings, token.technology(), token.containerName())) {
cont->second->setAttribute(key, value);
}
}
cont->second->read(token.id(), data, type);
return;
Expand Down
6 changes: 4 additions & 2 deletions form/storage/storage_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ void StorageWriter::createContainers(
.insert({plcmnt->fileName(), createFile(plcmnt->technology(), plcmnt->fileName(), 'o')})
.first;
for (auto const& [key, value] :
get_file_table(settings, plcmnt->technology(), plcmnt->fileName()))
get_file_table(settings, plcmnt->technology(), plcmnt->fileName())) {
file->second->setAttribute(key, value);
}
}
// Create and bind container to file
auto container = createWriteContainer(plcmnt->technology(), plcmnt->containerName());
Expand All @@ -93,8 +94,9 @@ void StorageWriter::createContainers(
}

for (auto const& [key, value] :
get_container_table(settings, plcmnt->technology(), plcmnt->containerName()))
get_container_table(settings, plcmnt->technology(), plcmnt->containerName())) {
container->setAttribute(key, value);
}
container->setFile(file->second);
container->setupWrite(*type);
}
Expand Down
3 changes: 2 additions & 1 deletion phlex/app/load_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ namespace phlex::detail {
// Called during single-threaded graph construction
char const* plugin_path_ptr =
std::getenv("PHLEX_PLUGIN_PATH"); // NOLINT(concurrency-mt-unsafe)
if (!plugin_path_ptr)
if (!plugin_path_ptr) {
throw std::runtime_error("PHLEX_PLUGIN_PATH has not been set.");
}

std::vector<std::string> subdirs;
boost::split(subdirs, plugin_path_ptr, boost::is_any_of(":"));
Expand Down
3 changes: 2 additions & 1 deletion phlex/model/data_cell_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ namespace phlex {

bool data_cell_index::operator==(data_cell_index const& other) const
{
if (depth_ != other.depth_)
if (depth_ != other.depth_) {
return false;
}
auto const same_numbers = number_ == other.number_;
if (not parent_) {
return same_numbers;
Expand Down
21 changes: 14 additions & 7 deletions plugins/python/src/configwrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ PyObject* phlex::experimental::wrap_configuration(configuration const& config)
static py_config_map* pcm_new(PyTypeObject* subtype, PyObject*, PyObject*)
{
auto* pcm = reinterpret_cast<py_config_map*>(subtype->tp_alloc(subtype, 0));
if (!pcm)
if (!pcm) {
return nullptr;
}

pcm->ph_config_cache = PyDict_New();

Expand Down Expand Up @@ -91,8 +92,9 @@ static PyObject* pcm_subscript(py_config_map* pycmap, PyObject* pykey)
if (k.first == boost::json::kind::bool_) {
auto const& cvalue = pycmap->ph_config->get<std::vector<bool>>(ckey);
auto const cvalue_size = checked_tuple_size(cvalue.size());
if (!cvalue_size)
if (!cvalue_size) {
return nullptr;
}
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) {
Expand All @@ -102,8 +104,9 @@ static PyObject* pcm_subscript(py_config_map* pycmap, PyObject* pykey)
} else if (k.first == boost::json::kind::int64) {
auto const& cvalue = pycmap->ph_config->get<std::vector<std::int64_t>>(ckey);
auto const cvalue_size = checked_tuple_size(cvalue.size());
if (!cvalue_size)
if (!cvalue_size) {
return nullptr;
}
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) {
Expand All @@ -114,8 +117,9 @@ static PyObject* pcm_subscript(py_config_map* pycmap, PyObject* pykey)
} else if (k.first == boost::json::kind::uint64) {
auto const& cvalue = pycmap->ph_config->get<std::vector<std::uint64_t>>(ckey);
auto const cvalue_size = checked_tuple_size(cvalue.size());
if (!cvalue_size)
if (!cvalue_size) {
return nullptr;
}
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) {
Expand All @@ -126,8 +130,9 @@ static PyObject* pcm_subscript(py_config_map* pycmap, PyObject* pykey)
} else if (k.first == boost::json::kind::double_) {
auto const& cvalue = pycmap->ph_config->get<std::vector<double>>(ckey);
auto const cvalue_size = checked_tuple_size(cvalue.size());
if (!cvalue_size)
if (!cvalue_size) {
return nullptr;
}
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) {
Expand All @@ -137,8 +142,9 @@ static PyObject* pcm_subscript(py_config_map* pycmap, PyObject* pykey)
} else if (k.first == boost::json::kind::string) {
auto const& cvalue = pycmap->ph_config->get<std::vector<std::string>>(ckey);
auto const cvalue_size = checked_tuple_size(cvalue.size());
if (!cvalue_size)
if (!cvalue_size) {
return nullptr;
}
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) {
Expand All @@ -150,8 +156,9 @@ static PyObject* pcm_subscript(py_config_map* pycmap, PyObject* pykey)
auto const& cvalue =
pycmap->ph_config->get<std::vector<std::map<std::string, std::string>>>(ckey);
auto const cvalue_size = checked_tuple_size(cvalue.size());
if (!cvalue_size)
if (!cvalue_size) {
return nullptr;
}
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) {
Expand Down
52 changes: 30 additions & 22 deletions plugins/python/src/dyncall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,30 @@ using namespace phlex::experimental;
phlex::experimental::dcarg phlex::experimental::dcarg::from_str(std::string const& stype)
{
// only types currently used in modulewrap are added, not all ffi types
if (stype == "bool")
if (stype == "bool") {
return dcarg(false);
if (stype == "int32_t")
}
if (stype == "int32_t") {
return dcarg(static_cast<std::int32_t>(0));
else if (stype == "uint32_t")
}
if (stype == "uint32_t") {
return dcarg(static_cast<std::uint32_t>(0));
else if (stype == "int64_t")
}
if (stype == "int64_t") {
return dcarg(static_cast<ph_long_t>(0));
else if (stype == "uint64_t")
}
if (stype == "uint64_t") {
return dcarg(static_cast<ph_ulong_t>(0));
else if (stype == "float")
}
if (stype == "float") {
return dcarg(0.0f);
else if (stype == "double")
}
if (stype == "double") {
return dcarg(0.0);
else if (stype == "void")
}
if (stype == "void") {
return dcarg{};

}
throw std::invalid_argument("unknown type string: " + stype);
}

Expand Down Expand Up @@ -60,32 +67,33 @@ namespace {
// with each type on its own line, however, rather than combining the
// two in a single predicate as a special case
// NOLINTBEGIN(bugprone-branch-clone)
if constexpr (std::is_same_v<T, std::monostate>)
if constexpr (std::is_same_v<T, std::monostate>) {
return &ffi_type_void;
else if constexpr (std::is_same_v<T, void*>)
} else if constexpr (std::is_same_v<T, void*>) {
return &ffi_type_pointer;
else if constexpr (std::is_same_v<T, bool>)
} else if constexpr (std::is_same_v<T, bool>) {
return &ffi_type_uint8;
else if constexpr (std::is_same_v<T, std::int8_t>)
} else if constexpr (std::is_same_v<T, std::int8_t>) {
return &ffi_type_sint8;
else if constexpr (std::is_same_v<T, std::uint8_t>)
} else if constexpr (std::is_same_v<T, std::uint8_t>) {
return &ffi_type_uint8;
else if constexpr (std::is_same_v<T, std::int16_t>)
} else if constexpr (std::is_same_v<T, std::int16_t>) {
return &ffi_type_sint16;
else if constexpr (std::is_same_v<T, std::uint16_t>)
} else if constexpr (std::is_same_v<T, std::uint16_t>) {
return &ffi_type_uint16;
else if constexpr (std::is_same_v<T, std::int32_t>)
} else if constexpr (std::is_same_v<T, std::int32_t>) {
return &ffi_type_sint32;
else if constexpr (std::is_same_v<T, std::uint32_t>)
} else if constexpr (std::is_same_v<T, std::uint32_t>) {
return &ffi_type_uint32;
else if constexpr (std::is_same_v<T, ph_long_t>)
} else if constexpr (std::is_same_v<T, ph_long_t>) {
return &ffi_type_sint64;
else if constexpr (std::is_same_v<T, ph_ulong_t>)
} else if constexpr (std::is_same_v<T, ph_ulong_t>) {
return &ffi_type_uint64;
else if constexpr (std::is_same_v<T, float>)
} else if constexpr (std::is_same_v<T, float>) {
return &ffi_type_float;
else if constexpr (std::is_same_v<T, double>)
} else if constexpr (std::is_same_v<T, double>) {
return &ffi_type_double;
}
// NOLINTEND(bugprone-branch-clone)
},
d.m_value);
Expand Down
3 changes: 2 additions & 1 deletion plugins/python/src/errorwrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ bool phlex::experimental::msg_from_py_error(std::string& msg, bool check_error)
PyGILRAII g;

if (check_error) {
if (!PyErr_Occurred())
if (!PyErr_Occurred()) {
return false;
}
}

#if PY_VERSION_HEX < 0x30c000000
Expand Down
3 changes: 2 additions & 1 deletion plugins/python/src/lifelinewrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ static py_lifeline_t* ll_new(PyTypeObject* pytype, PyObject*, PyObject*)

static int ll_traverse(py_lifeline_t* pyobj, visitproc visit, void* args)
{
if (pyobj->m_view)
if (pyobj->m_view) {
visit(pyobj->m_view, args);
}
return 0;
}

Expand Down
Loading
Loading