Skip to content

Commit

Permalink
Merge pull request #379 from seoklab/clang-tools-19
Browse files Browse the repository at this point in the history
chore(dev): bump clang-tools version to v19
  • Loading branch information
jnooree authored Oct 17, 2024
2 parents 8855a84 + 85adc91 commit 456f4d8
Show file tree
Hide file tree
Showing 15 changed files with 472 additions and 464 deletions.
3 changes: 2 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Require clang-tidy v15
---
Checks: "-*,abseil-*,boost-*,bugprone-*,clang-*,concurrency-*,cppcoreguidelines-*,google-*,misc-*,modernize-*,openmp-*,performance-*,portability-*,readability-*,-bugprone-assignment-in-if-condition,-bugprone-easily-swappable-parameters,-cppcoreguidelines-avoid-do-while,-cppcoreguidelines-avoid-c-arrays,-cppcoreguidelines-init-variables,-cppcoreguidelines-narrowing-conversions,-cppcoreguidelines-pro-*,-cppcoreguidelines-rvalue-reference-param-not-moved,-cppcoreguidelines-use-default-member-init,-google-explicit-constructor,-misc-no-recursion,-modernize-avoid-c-arrays,-modernize-return-braced-init-list,-modernize-loop-convert,-modernize-concat-nested-namespaces,-modernize-pass-by-value,-modernize-raw-string-literal,-modernize-use-trailing-return-type,-modernize-use-auto,-modernize-use-default-member-init,-modernize-use-emplace,-modernize-use-equals-delete,-modernize-use-nodiscard,-readability-isolate-declaration,-readability-identifier-length,-readability-qualified-auto,-*-magic-numbers"
Checks: "-*,abseil-*,boost-*,bugprone-*,clang-*,concurrency-*,cppcoreguidelines-*,google-*,misc-*,modernize-*,openmp-*,performance-*,portability-*,readability-*,-boost-use-ranges,-bugprone-assignment-in-if-condition,-bugprone-crtp-constructor-accessibility,-bugprone-easily-swappable-parameters,-clang-analyzer-optin.core.EnumCastOutOfRange,-cppcoreguidelines-avoid-do-while,-cppcoreguidelines-avoid-c-arrays,-cppcoreguidelines-init-variables,-cppcoreguidelines-narrowing-conversions,-cppcoreguidelines-pro-*,-cppcoreguidelines-rvalue-reference-param-not-moved,-cppcoreguidelines-use-default-member-init,-google-explicit-constructor,-misc-no-recursion,-modernize-avoid-c-arrays,-modernize-return-braced-init-list,-modernize-loop-convert,-modernize-concat-nested-namespaces,-modernize-pass-by-value,-modernize-raw-string-literal,-modernize-use-trailing-return-type,-modernize-use-auto,-modernize-use-default-member-init,-modernize-use-emplace,-modernize-use-equals-delete,-modernize-use-nodiscard,-performance-enum-size,-readability-isolate-declaration,-readability-identifier-length,-readability-qualified-auto,-readability-math-missing-parentheses,-readability-avoid-nested-conditional-operator,-*-magic-numbers"
FormatStyle: "file"
# If these flags are updated, .clangd should be updated as well
ExtraArgsBefore:
Expand All @@ -24,6 +24,7 @@ ExtraArgsBefore:
- -Wno-unused-macros
- -Wno-disabled-macro-expansion
- -Wno-unsafe-buffer-usage
- -Wno-switch-default
- -fno-sanitize=all
CheckOptions:
- key: bugprone-stringview-nullptr.IncludeStyle
Expand Down
7 changes: 7 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ CompileFlags:
- -Wno-unused-macros
- -Wno-disabled-macro-expansion
- -Wno-unsafe-buffer-usage
- -Wno-switch-default
Remove:
- "-fsanitize=*"
- "-flto*"
Expand All @@ -43,3 +44,9 @@ InlayHints:
Enabled: Yes
ParameterNames: Yes
DeducedTypes: Yes
---
If:
PathMatch: "third_party/.*"
Diagnostics:
Suppress: "*"
UnusedIncludes: None
2 changes: 1 addition & 1 deletion .github/workflows/_run-clang-tools.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
default: false
version:
type: string
default: "17"
default: "19"

defaults:
run:
Expand Down
2 changes: 1 addition & 1 deletion include/nuri/core/geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ auto cdist(const ML1 &a, const ML2 &b) {
}

namespace internal {
constexpr inline double safe_normalizer(double sqn, double eps = 1e-12) {
constexpr double safe_normalizer(double sqn, double eps = 1e-12) {
return sqn > eps ? 1 / std::sqrt(sqn) : 0;
}

Expand Down
14 changes: 7 additions & 7 deletions include/nuri/core/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -1003,8 +1003,8 @@ NodesErased Graph<NT, ET>::erase_nodes(Iterator begin, Iterator end) {
// E = O(V).
if (begin == end) {
return {
{num_nodes(), {}},
{num_edges(), {}},
{ num_nodes(), {} },
{ num_edges(), {} },
};
}

Expand All @@ -1028,7 +1028,7 @@ NodesErased Graph<NT, ET>::erase_nodes(Iterator begin, Iterator end) {
auto edge_info =
erase_nodes_common(node_keep, first_erased_id, erase_trailing);
return {
{erase_trailing ? first_erased_id : -1, std::move(node_keep)},
{ erase_trailing ? first_erased_id : -1, std::move(node_keep) },
std::move(edge_info),
};
}
Expand All @@ -1044,8 +1044,8 @@ NodesErased Graph<NT, ET>::erase_nodes(const const_iterator begin,
// This will also handle size() == 0 case correctly.
if (begin >= end) {
return {
{num_nodes(), {}},
{num_edges(), {}},
{ num_nodes(), {} },
{ num_edges(), {} },
};
}

Expand Down Expand Up @@ -1073,7 +1073,7 @@ NodesErased Graph<NT, ET>::erase_nodes(const const_iterator begin,
auto edge_info =
erase_nodes_common(node_keep, first_erased_id, erase_trailing);
return {
{erase_trailing ? first_erased_id : -1, std::move(node_keep)},
{ erase_trailing ? first_erased_id : -1, std::move(node_keep) },
std::move(edge_info),
};
}
Expand Down Expand Up @@ -2170,7 +2170,7 @@ class Subgraph {
* @note If the node is already in the subgraph, this is a no-op. If the
* node id is out of range, the behavior is undefined.
*/
void add_node(int id) { return nodes_.insert(id); }
void add_node(int id) { nodes_.insert(id); }

/**
* @brief Add nodes to the subgraph
Expand Down
4 changes: 2 additions & 2 deletions src/algo/rings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,9 @@ namespace {
}

template <class MoleculeLike, class Iter>
auto make_dst_iterator(Iter it) {
auto make_dst_iterator(Iter &&it) {
return internal::make_transform_iterator<
extract_did<typename MoleculeLike::Neighbor>>(it);
extract_did<typename MoleculeLike::Neighbor>>(std::forward<Iter>(it));
}

template <class MoleculeLike, class Pred>
Expand Down
10 changes: 5 additions & 5 deletions src/core/geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,14 @@ namespace {
kTol = 1e-2, kEps = 1e-8, kEps2 = 1e-16;

constexpr int kIp2[2][2] = {
{0, 1},
{1, 2},
{ 0, 1 },
{ 1, 2 },
};

constexpr int kIp3[3][3] = {
{0, 1, 3},
{1, 2, 4},
{3, 4, 5},
{ 0, 1, 3 },
{ 1, 2, 4 },
{ 3, 4, 5 },
};
constexpr int kIp2312[] = { 1, 2, 0, 1 };

Expand Down
2 changes: 1 addition & 1 deletion src/fmt/mol2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ SubstructInfo resolve_substructs(const Molecule &mol) {
struct NameMapEntry {
int first_idx;
int count = 1;
std::string safe_name = {};
std::string safe_name = {}; // NOLINT(readability-redundant-member-init)
};

template <class C, class NameFunc>
Expand Down
11 changes: 6 additions & 5 deletions src/fmt/pdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ struct PDBAtomInfoTemplate {
std::string_view name;
int atomic_number;
int implicit_hydrogens;
std::string_view altname {};
std::string_view altname {}; // NOLINT(readability-redundant-member-init)
constants::Hybridization hyb = constants::kSP3;
int formal_charge = 0;
bool conjugated = false;
Expand Down Expand Up @@ -1597,7 +1597,7 @@ class AtomicLine {
public:
AtomicLine(std::string_view line, int serial)
: serial_(serial), line_(line), id_ {
{safe_atoi(slice(line_, 22, 26)), line_[21], line_[26]},
{ safe_atoi(slice(line_, 22, 26)), line_[21], line_[26] },
slice_strip(line_, 11, 16)
} {
ABSL_DCHECK(line.size() >= 47) << "Invalid ATOM/HETATM record: " << line;
Expand Down Expand Up @@ -2042,9 +2042,10 @@ void update_substructures(Molecule &mol, std::vector<Substructure> &subs,
for (int i = 0; i < atom_data.size(); ++i) {
ResidueId id = atom_data[i].first().id().res;

auto [cit, _] = insert_sorted(chains, { id.chain, {} }, [](auto a, auto b) {
return a.first < b.first;
});
auto [cit, _] = insert_sorted(chains, { id.chain, {} },
[](const auto &a, const auto &b) {
return a.first < b.first;
});
cit->second.push_back(i);
}

Expand Down
3 changes: 1 addition & 2 deletions src/fmt/sdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ struct HeaderReadResult {
static HeaderReadResult failure() { return HeaderReadResult(); }

static HeaderReadResult success(int version, int natoms, int nbonds) {
return HeaderReadResult(static_cast<int>(version), static_cast<int>(natoms),
static_cast<int>(nbonds));
return HeaderReadResult(version, natoms, nbonds);
}

int version() const { return version_; }
Expand Down
2 changes: 1 addition & 1 deletion src/fmt/smiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ void handle_ring(Ctx &ctx, int ring_idx) {
const char bond_data = x3::get<last_bond_data_tag>(ctx);
RingMap &map = x3::get<ring_map_tag>(ctx);
auto [it, is_new] = map.insert({
ring_idx, {bond_data, current_idx}
ring_idx, { bond_data, current_idx }
});

// New ring index, nothing to do.
Expand Down
4 changes: 2 additions & 2 deletions test/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Project NuriKit - Copyright 2023 SNU Compbio Lab.
# SPDX-License-Identifier: Apache-2.0
#
Checks: "-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-owning-memory,-cppcoreguidelines-special-member-functions,-readability-function-cognitive-complexity,-readability-identifier-naming,-*-non-private-member-variables-in-classes"
Checks: "-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-owning-memory,-cppcoreguidelines-special-member-functions,-readability-function-cognitive-complexity,-readability-identifier-naming,-*-non-private-member-variables-in-classes,-*-macro-usage"
InheritParentConfig: true
ExtraArgs:
ExtraArgsBefore:
- -Wno-gnu-zero-variadic-macro-arguments
- -Wno-unused-member-function
118 changes: 59 additions & 59 deletions test/algo/guess_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,17 @@ class ARGTestParam: public AATestParam {

std::vector<std::pair<int, int>> bonds() const override {
return {
{0, 1},
{1, 2},
{1, 4},
{2, 3},
{2, 11},
{4, 5},
{5, 6},
{6, 7},
{7, 8},
{8, 9},
{8, 10},
{ 0, 1 },
{ 1, 2 },
{ 1, 4 },
{ 2, 3 },
{ 2, 11 },
{ 4, 5 },
{ 5, 6 },
{ 6, 7 },
{ 7, 8 },
{ 8, 9 },
{ 8, 10 },
};
}

Expand Down Expand Up @@ -206,17 +206,17 @@ class HISTestParam: public AATestParam {

std::vector<std::pair<int, int>> bonds() const override {
return {
{0, 1},
{1, 2},
{1, 4},
{2, 3},
{2, 10},
{4, 5},
{5, 6},
{5, 7},
{6, 8},
{7, 9},
{8, 9},
{ 0, 1 },
{ 1, 2 },
{ 1, 4 },
{ 2, 3 },
{ 2, 10 },
{ 4, 5 },
{ 5, 6 },
{ 5, 7 },
{ 6, 8 },
{ 7, 9 },
{ 8, 9 },
};
}

Expand Down Expand Up @@ -274,14 +274,14 @@ class PROTestParam: public AATestParam {

std::vector<std::pair<int, int>> bonds() const override {
return {
{0, 1},
{0, 6},
{1, 2},
{1, 4},
{2, 3},
{2, 7},
{4, 5},
{5, 6},
{ 0, 1 },
{ 0, 6 },
{ 1, 2 },
{ 1, 4 },
{ 2, 3 },
{ 2, 7 },
{ 4, 5 },
{ 5, 6 },
};
}

Expand Down Expand Up @@ -353,19 +353,19 @@ class TYRTestParam: public AATestParam {

std::vector<std::pair<int, int>> bonds() const override {
return {
{ 0, 1},
{ 1, 2},
{ 1, 4},
{ 2, 3},
{ 2, 12},
{ 4, 5},
{ 5, 6},
{ 5, 7},
{ 6, 8},
{ 7, 9},
{ 8, 10},
{ 9, 10},
{10, 11},
{ 0, 1 },
{ 1, 2 },
{ 1, 4 },
{ 2, 3 },
{ 2, 12 },
{ 4, 5 },
{ 5, 6 },
{ 5, 7 },
{ 6, 8 },
{ 7, 9 },
{ 8, 10 },
{ 9, 10 },
{ 10, 11 },
};
}

Expand Down Expand Up @@ -441,22 +441,22 @@ class TRPTestParam: public AATestParam {

std::vector<std::pair<int, int>> bonds() const override {
return {
{ 0, 1},
{ 1, 2},
{ 1, 4},
{ 2, 3},
{ 2, 14},
{ 4, 5},
{ 5, 6},
{ 5, 7},
{ 6, 8},
{ 7, 9},
{ 7, 10},
{ 8, 9},
{ 9, 11},
{10, 12},
{11, 13},
{12, 13},
{ 0, 1 },
{ 1, 2 },
{ 1, 4 },
{ 2, 3 },
{ 2, 14 },
{ 4, 5 },
{ 5, 6 },
{ 5, 7 },
{ 6, 8 },
{ 7, 9 },
{ 7, 10 },
{ 8, 9 },
{ 9, 11 },
{ 10, 12 },
{ 11, 13 },
{ 12, 13 },
};
}

Expand Down
Loading

0 comments on commit 456f4d8

Please sign in to comment.