Skip to content

Clang tidy 19 support (bis) #928

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Mar 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
cebfb0c
apply clang-tidy-19 suggestions
mgovers Mar 11, 2025
f7239d1
More apply clang-tidy-19
mgovers Mar 17, 2025
ed3ace2
use std ranges equal_range
mgovers Mar 17, 2025
4602863
minor fix to deserialization
mgovers Mar 17, 2025
b043eda
fix STL header file
mgovers Mar 17, 2025
7bfa5a5
migrate to std::views + std::format
mgovers Mar 17, 2025
9d2c36b
fix
mgovers Mar 17, 2025
3b4d1fe
fix typo
mgovers Mar 17, 2025
8331341
revert std::format
mgovers Mar 17, 2025
54e4f02
Revert "revert std::format"
mgovers Mar 17, 2025
18596dc
bump minimum OSX requirement
mgovers Mar 17, 2025
15b4466
Merge remote-tracking branch 'origin/drop-manylinux-2-24' into featur…
mgovers Mar 17, 2025
98a98ec
Merge branch 'main' into feature/clang-tidy-19
mgovers Mar 18, 2025
60bf07c
fix
mgovers Mar 18, 2025
5a23869
Merge remote-tracking branch 'origin/feature/clang-tidy-19' into feat…
mgovers Mar 18, 2025
6246c4c
Merge remote-tracking branch 'origin/drop-manylinux-2-24' into featur…
mgovers Mar 18, 2025
b1378c6
use std::format for all exceptions
mgovers Mar 18, 2025
955f2d4
Merge remote-tracking branch 'origin/fix/macos-bump' into feature/cla…
mgovers Mar 19, 2025
5dc8be6
use simple std::views, use simple std::format
mgovers Mar 19, 2025
df91dd6
Merge remote-tracking branch 'origin/feature/use-std-views' into feat…
mgovers Mar 19, 2025
4c8798c
fix compilation + clang-tidy for benchmark
mgovers Mar 19, 2025
383a51c
Merge branch 'main' into feature/clang-tidy-19
mgovers Mar 19, 2025
ae5f97c
resolve forward iterator by value instead of const&
mgovers Mar 20, 2025
88e07b1
fix forgotten std::format
mgovers Mar 21, 2025
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
7 changes: 7 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Checks: '
-*,
boost-*,
-boost-use-ranges,
bugprone-*,
-bugprone-easily-swappable-parameters,
-bugprone-exception-escape,
Expand Down Expand Up @@ -55,6 +56,8 @@ readability-*,
-readability-function-cognitive-complexity,
-readability-identifier-length,
-readability-magic-numbers,
-readability-math-missing-parentheses,
-readability-redundant-member-init,
-bugprone-unchecked-optional-access,
'

Expand All @@ -64,4 +67,8 @@ WarningsAsErrors: '*'
HeaderFilterRegex: '.*'

FormatStyle: file

CheckOptions:
- key: performance-unnecessary-value-param.AllowedTypes
- value: 'ForwardIterator'
...
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,9 @@ template <dataset_type_tag dataset_type_> class Dataset {
throw DatasetError{"Cannot have duplicated components!\n"};
}
check_uniform_integrity(elements_per_scenario, total_elements);
dataset_info_.component_info.push_back(
{&dataset_info_.dataset->get_component(component), elements_per_scenario, total_elements});
dataset_info_.component_info.push_back({.component = &dataset_info_.dataset->get_component(component),
.elements_per_scenario = elements_per_scenario,
.total_elements = total_elements});
buffers_.push_back(Buffer{});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ template <class T> struct DefaultErrorVisitor : DefaultNullVisitor {
bool throw_error() { throw SerializationError{(static_cast<T&>(*this)).get_err_msg()}; }

std::string get_err_msg() { return std::string{T::static_err_msg}; }

private:
DefaultErrorVisitor() = default;
friend T; // CRTP compliance
};

struct visit_map_t;
Expand Down Expand Up @@ -238,6 +242,8 @@ struct MapArrayVisitor : DefaultErrorVisitor<MapArrayVisitor<map_array>> {
assert(size == 0);
return true;
}

MapArrayVisitor() = default;
};

struct StringVisitor : DefaultErrorVisitor<StringVisitor> {
Expand All @@ -248,6 +254,8 @@ struct StringVisitor : DefaultErrorVisitor<StringVisitor> {
str = {v, size};
return true;
}

StringVisitor() = default;
};

struct BoolVisitor : DefaultErrorVisitor<BoolVisitor> {
Expand All @@ -258,6 +266,8 @@ struct BoolVisitor : DefaultErrorVisitor<BoolVisitor> {
value = v;
return true;
}

BoolVisitor() = default;
};

template <class T> struct ValueVisitor;
Expand All @@ -282,6 +292,8 @@ template <std::integral T> struct ValueVisitor<T> : DefaultErrorVisitor<ValueVis
value = static_cast<T>(v);
return true;
}

ValueVisitor(T& v) : DefaultErrorVisitor<ValueVisitor<T>>{}, value{v} {}
};

template <> struct ValueVisitor<double> : DefaultErrorVisitor<ValueVisitor<double>> {
Expand All @@ -306,6 +318,8 @@ template <> struct ValueVisitor<double> : DefaultErrorVisitor<ValueVisitor<doubl
value = v;
return true;
}

ValueVisitor(double& v) : DefaultErrorVisitor<ValueVisitor<double>>{}, value{v} {}
};

template <> struct ValueVisitor<RealValue<asymmetric_t>> : DefaultErrorVisitor<ValueVisitor<RealValue<asymmetric_t>>> {
Expand Down Expand Up @@ -357,6 +371,8 @@ template <> struct ValueVisitor<RealValue<asymmetric_t>> : DefaultErrorVisitor<V
value[idx] = v;
return true;
}

ValueVisitor(RealValue<asymmetric_t>& v) : DefaultErrorVisitor<ValueVisitor<RealValue<asymmetric_t>>>{}, value{v} {}
};

} // namespace detail
Expand Down Expand Up @@ -659,7 +675,8 @@ class Deserializer {
size_t const scenario_offset = offset_;
// skip all the real content but check if it has map
bool const has_map = parse_skip_check_map();
count_per_scenario.push_back({component_key_, component_size, scenario_offset, has_map});
count_per_scenario.push_back(
{.component = component_key_, .size = component_size, .offset = scenario_offset, .has_map = has_map});
}
component_key_ = {};
return count_per_scenario;
Expand Down Expand Up @@ -708,8 +725,8 @@ class Deserializer {
elements_per_scenario * batch_size; // multiply
handler.add_component_info(component_key_, elements_per_scenario, total_elements);
// check if all scenarios only contain array data
bool const only_values_in_data = std::none_of(component_byte_meta.cbegin(), component_byte_meta.cend(),
[](auto const& x) { return x.has_map; });
bool const only_values_in_data =
std::ranges::none_of(component_byte_meta, [](auto const& x) { return x.has_map; });
msg_data_offsets_.push_back(std::move(component_byte_meta));
// enable attribute indications if possible
if (only_values_in_data) {
Expand Down Expand Up @@ -943,7 +960,7 @@ class Deserializer {

ctype_func_selector(attribute.ctype, [&buffer_view, &component, &attribute, this]<class T> {
ValueVisitor<T> visitor{
{}, attribute.get_attribute<T>(component.advance_ptr(buffer_view.buffer->data, buffer_view.idx))};
attribute.get_attribute<T>(component.advance_ptr(buffer_view.buffer->data, buffer_view.idx))};
msgpack::parse(data_, size_, offset_, visitor);
});
}
Expand All @@ -954,7 +971,7 @@ class Deserializer {
assert(buffer.meta_attribute != nullptr);

ctype_func_selector(buffer.meta_attribute->ctype, [&buffer, &idx, this]<class T> {
ValueVisitor<T> visitor{{}, *(reinterpret_cast<T*>(buffer.data) + idx)};
ValueVisitor<T> visitor{*(reinterpret_cast<T*>(buffer.data) + idx)};
msgpack::parse(data_, size_, offset_, visitor);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,19 @@ struct MapArray {
bool begin{true};
};

struct JsonConverter : msgpack::null_visitor {
template <typename T> struct NullVisitor : msgpack::null_visitor {
private:
NullVisitor() = default;
friend T; // CRTP compliance
};

struct JsonConverter : NullVisitor<JsonConverter> {
static constexpr char sep_char = ' ';

Idx indent{};
Idx max_indent_level{};
std::stringstream ss{}; // NOLINT(readability-redundant-member-init)
std::stack<MapArray> map_array{}; // NOLINT(readability-redundant-member-init)
std::stringstream ss{};
std::stack<MapArray> map_array{};

void print_indent() {
if (indent < 0) {
Expand Down Expand Up @@ -194,6 +200,9 @@ struct JsonConverter : msgpack::null_visitor {
ss << '}';
return true;
}

JsonConverter(Idx indent_, Idx max_indent_level_)
: NullVisitor<JsonConverter>{}, indent{indent_}, max_indent_level{max_indent_level_} {}
};

} // namespace json_converter
Expand Down Expand Up @@ -380,7 +389,7 @@ class Serializer {
std::string const& get_json(bool use_compact_list, Idx indent) {
if (json_buffer_.empty() || (use_compact_list_ != use_compact_list) || (json_indent_ != indent)) {
Idx const max_indent_level = dataset_handler_.is_batch() ? 4 : 3;
json_converter::JsonConverter visitor{{}, indent, max_indent_level};
json_converter::JsonConverter visitor{indent, max_indent_level};
auto const msgpack_data = get_msgpack(use_compact_list);
msgpack::parse(msgpack_data.data(), msgpack_data.size(), visitor);
json_buffer_ = visitor.ss.str();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct Idx2D {
};

struct Idx2DHash {
std::size_t operator()(const Idx2D& idx) const {
std::size_t operator()(Idx2D const& idx) const {
size_t const h1 = std::hash<Idx>{}(idx.group);
size_t const h2 = std::hash<Idx>{}(idx.pos);
return h1 ^ (h2 << 1);
Expand Down
Loading
Loading