Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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 cmake/common/clang-tidy.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"Checks": "-*, bugprone-*, -bugprone-easily-swappable-parameters,-bugprone-unchecked-optional-access, concurrency-*, modernize-*, performance-*, portability-*",
"Checks": "-*, bugprone-*, -bugprone-easily-swappable-parameters,-bugprone-unchecked-optional-access, concurrency-*,cppcoreguidelines-pro-bounds-pointer-arithmetic,
modernize-*, performance-*, portability-*",
"WarningsAsErrors": "*",
"FormatStyle": "none",
"UseColor": true
Expand Down
1 change: 1 addition & 0 deletions src/core/json/include/sourcemeta/core/json_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ template <typename T> struct PropertyHashJSON {
hash_type result;
assert(!value.empty());
// Copy starting a byte 2
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
std::memcpy(reinterpret_cast<char *>(&result) + 1, value.data(), size);
return result;
}
Expand Down
19 changes: 10 additions & 9 deletions src/core/yaml/yaml.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// See https://pyyaml.org/wiki/LibYAML for basic documentation
#include <span>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put this include after a new line after <sourcemeta/core/io.h> and put the usual // std::span comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jviotti Does the llvm clang-tidy check https://clang.llvm.org/extra/clang-tidy/checks/llvm/include-order.html serve this purpose? When I looked at it, it sounded specific to llvm project. Another pair of eyes doesn't harm.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or do we have any clang-format rule for this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the llvm clang-tidy check https://clang.llvm.org/extra/clang-tidy/checks/llvm/include-order.html serve this purpose? When I looked at it, it sounded specific to llvm project. Another pair of eyes doesn't harm.

Yeah, that'd be great. I'd be OK with removing all of these comments once we have a check that covers all of these cases and we are confident that works well.

#include <yaml.h>

#include <sourcemeta/core/io.h>
Expand Down Expand Up @@ -52,9 +53,10 @@ auto yaml_node_to_json(yaml_node_t *const node, yaml_document_t *const document)

case YAML_SEQUENCE_NODE: {
auto result{sourcemeta::core::JSON::make_array()};
for (yaml_node_item_t *item = node->data.sequence.items.start;
item < node->data.sequence.items.top; ++item) {
yaml_node_t *const child = yaml_document_get_node(document, *item);
auto item_span = std::span<yaml_node_item_t>(
node->data.sequence.items.start, node->data.sequence.items.top);
for (auto item : item_span) {
const auto child = yaml_document_get_node(document, item);
result.push_back(yaml_node_to_json(child, document));
}

Expand All @@ -63,12 +65,11 @@ auto yaml_node_to_json(yaml_node_t *const node, yaml_document_t *const document)

case YAML_MAPPING_NODE: {
auto result{sourcemeta::core::JSON::make_object()};
for (yaml_node_pair_t *pair = node->data.mapping.pairs.start;
pair < node->data.mapping.pairs.top; ++pair) {
yaml_node_t *const key_node =
yaml_document_get_node(document, pair->key);
yaml_node_t *const value_node =
yaml_document_get_node(document, pair->value);
auto pair_span = std::span<yaml_node_pair_t>(
node->data.mapping.pairs.start, node->data.mapping.pairs.top);
for (auto pair : pair_span) {
const auto key_node = yaml_document_get_node(document, pair.key);
const auto value_node = yaml_document_get_node(document, pair.value);
if (key_node && key_node->type == YAML_SCALAR_NODE) {
result.assign(reinterpret_cast<char *>(key_node->data.scalar.value),
yaml_node_to_json(value_node, document));
Expand Down
Loading