Skip to content

Commit f443464

Browse files
hitonanodeweb-flow
andauthored
Introduce clang-format-14 to CI (#255)
* Apply clang-format * Add CI for clang-format * Update README.md * [auto-verifier] verify commit a979ac8 * Add clang-format CI badge * [auto-verifier] verify commit a015089 Co-authored-by: GitHub <[email protected]>
1 parent f5292f4 commit f443464

11 files changed

+307
-42
lines changed

.clang-format

+1
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ PenaltyBreakBeforeFirstCallParameter: 0
1313
PenaltyBreakFirstLessLess: 0
1414
PenaltyExcessCharacter: 10
1515
PenaltyReturnTypeOnItsOwnLine: 0
16+
SortIncludes: false

.github/workflows/formatter.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: clang-format
2+
3+
on: push
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-22.04
8+
9+
steps:
10+
- uses: actions/checkout@v3
11+
12+
# https://apt.llvm.org/
13+
- name: Install clang-format-14
14+
run: |
15+
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
16+
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-14 main'
17+
sudo apt-get update
18+
sudo apt-get install -y clang-format-14
19+
20+
- name: Check formatting
21+
run: find ./ -name "*.hpp" -o -name "*.cpp" -not -iwholename ".verify-helper*" | xargs clang-format-14 --dry-run --Werror -style=file

.verify-helper/timestamps.remote.json

+19-19
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
"graph/test/bipartite_matching(slow).test.cpp": "2020-11-21 18:08:42 +0900",
9292
"graph/test/bipartite_matching.test.cpp": "2021-11-03 21:38:41 +0900",
9393
"graph/test/bridge.test.cpp": "2022-07-19 23:53:22 +0900",
94-
"graph/test/chromatic_number.test.cpp": "2022-10-27 21:31:53 +0900",
94+
"graph/test/chromatic_number.test.cpp": "2022-11-14 22:46:56 +0900",
9595
"graph/test/cycle_detection_directed.test.cpp": "2022-01-08 20:23:44 +0900",
9696
"graph/test/directed_mst.aoj.test.cpp": "2022-01-08 20:23:44 +0900",
9797
"graph/test/dulmage_mendelsohn.yuki1615.test.cpp": "2022-01-08 20:23:44 +0900",
@@ -127,12 +127,12 @@
127127
"linear_algebra_matrix/test/linalg_aclmodint_determinant.test.cpp": "2022-05-01 02:11:54 +0900",
128128
"linear_algebra_matrix/test/linalg_bitset.test.cpp": "2022-11-06 22:51:55 +0900",
129129
"linear_algebra_matrix/test/linalg_bitset.yuki1421.test.cpp": "2022-11-06 22:51:55 +0900",
130-
"linear_algebra_matrix/test/linalg_ll_det.test.cpp": "2022-10-14 10:52:36 +0900",
131-
"linear_algebra_matrix/test/linalg_longlong.test.cpp": "2022-10-14 10:52:36 +0900",
132-
"linear_algebra_matrix/test/linalg_longlong_matmul.test.cpp": "2022-10-14 10:52:36 +0900",
130+
"linear_algebra_matrix/test/linalg_ll_det.test.cpp": "2022-11-14 22:46:56 +0900",
131+
"linear_algebra_matrix/test/linalg_longlong.test.cpp": "2022-11-14 22:46:56 +0900",
132+
"linear_algebra_matrix/test/linalg_longlong_matmul.test.cpp": "2022-11-14 22:46:56 +0900",
133133
"linear_algebra_matrix/test/linalg_min_plus_semiring.yuki1780.test.cpp": "2022-05-01 02:11:54 +0900",
134134
"linear_algebra_matrix/test/linalg_modint_determinant.test.cpp": "2022-07-12 00:34:46 +0900",
135-
"linear_algebra_matrix/test/linalg_modint_multiplication.test.cpp": "2022-10-14 10:52:36 +0900",
135+
"linear_algebra_matrix/test/linalg_modint_multiplication.test.cpp": "2022-11-14 22:46:56 +0900",
136136
"linear_algebra_matrix/test/linalg_modint_pow.test.cpp": "2022-07-12 00:34:46 +0900",
137137
"linear_algebra_matrix/test/linalg_semirings.yuki1340.test.cpp": "2022-05-01 02:11:54 +0900",
138138
"linear_algebra_matrix/test/matrix_det_dual_number.yuki1303.test.cpp": "2022-07-12 00:34:46 +0900",
@@ -142,26 +142,26 @@
142142
"number/test/arithmetic_function_totient.test.cpp": "2022-07-12 00:34:46 +0900",
143143
"number/test/binary_gcd.stress.test.cpp": "2021-08-21 15:46:09 +0900",
144144
"number/test/bs_sieve.test.cpp": "2022-01-08 20:23:44 +0900",
145-
"number/test/combination.stress.test.cpp": "2022-10-14 10:52:36 +0900",
146-
"number/test/combination.test.cpp": "2022-10-14 10:52:36 +0900",
145+
"number/test/combination.stress.test.cpp": "2022-11-14 22:46:56 +0900",
146+
"number/test/combination.test.cpp": "2022-11-14 22:46:56 +0900",
147147
"number/test/count_primes.test.cpp": "2022-01-08 20:23:44 +0900",
148148
"number/test/discrete_logarithm.test.cpp": "2020-11-18 20:25:12 +0900",
149149
"number/test/enumerate_primes.test.cpp": "2022-01-08 20:23:44 +0900",
150-
"number/test/factorize_aoj.test.cpp": "2022-10-27 21:31:53 +0900",
151-
"number/test/factorize_longlong.test.cpp": "2022-10-27 21:31:53 +0900",
150+
"number/test/factorize_aoj.test.cpp": "2022-11-14 22:46:56 +0900",
151+
"number/test/factorize_longlong.test.cpp": "2022-11-14 22:46:56 +0900",
152152
"number/test/gcd_convolution.test.cpp": "2022-07-12 00:34:46 +0900",
153153
"number/test/gen_primes.test.cpp": "2021-10-30 11:24:11 +0900",
154154
"number/test/lcm_convolution.test.cpp": "2022-07-12 00:34:46 +0900",
155-
"number/test/miller-rabin-5e7.test.cpp": "2022-10-27 21:31:53 +0900",
156-
"number/test/miller-rabin.test.cpp": "2022-10-27 21:31:53 +0900",
155+
"number/test/miller-rabin-5e7.test.cpp": "2022-11-14 22:46:56 +0900",
156+
"number/test/miller-rabin.test.cpp": "2022-11-14 22:46:56 +0900",
157157
"number/test/min_max_semiring.test.cpp": "2022-01-25 23:19:52 +0900",
158158
"number/test/montmort_number_mod.test.cpp": "2022-05-01 16:11:38 +0900",
159159
"number/test/multiple_moebius.yuki1627.test.cpp": "2022-07-12 00:34:46 +0900",
160160
"number/test/multiple_moebius.yuki886.test.cpp": "2022-07-12 00:34:46 +0900",
161161
"number/test/nimber.test.cpp": "2022-10-30 13:35:32 +0900",
162162
"number/test/prime_factorization.test.cpp": "2021-10-30 11:24:11 +0900",
163-
"number/test/primitive_root.test.cpp": "2022-10-27 21:31:53 +0900",
164-
"number/test/primitive_root_1e18.test.cpp": "2022-10-27 21:31:53 +0900",
163+
"number/test/primitive_root.test.cpp": "2022-11-14 22:46:56 +0900",
164+
"number/test/primitive_root_1e18.test.cpp": "2022-11-14 22:46:56 +0900",
165165
"number/test/sieve.stress.test.cpp": "2022-05-01 16:11:38 +0900",
166166
"number/test/sqrt_modint_runtime.test.cpp": "2022-05-01 16:11:38 +0900",
167167
"number/test/zeta_moebius_transform.test.cpp": "2022-07-12 00:34:46 +0900",
@@ -205,13 +205,13 @@
205205
"string/test/lcp.test.cpp": "2022-01-08 20:23:44 +0900",
206206
"string/test/manacher.test.cpp": "2022-01-08 20:23:44 +0900",
207207
"string/test/manacher_mp.test.cpp": "2022-01-08 20:23:44 +0900",
208-
"string/test/rolling_hash.test.cpp": "2022-10-09 12:55:12 +0900",
209-
"string/test/rolling_hash_2d.aoj.test.cpp": "2022-10-09 14:11:30 +0900",
208+
"string/test/rolling_hash.test.cpp": "2022-11-14 22:46:56 +0900",
209+
"string/test/rolling_hash_2d.aoj.test.cpp": "2022-11-14 22:46:56 +0900",
210210
"string/test/rolling_hash_lcp.test.cpp": "2022-10-09 12:55:12 +0900",
211-
"string/test/rolling_hash_mersenne61.test.cpp": "2022-10-09 12:55:12 +0900",
211+
"string/test/rolling_hash_mersenne61.test.cpp": "2022-11-14 22:46:56 +0900",
212212
"string/test/rolling_hash_w_modint.test.cpp": "2022-10-09 12:55:12 +0900",
213213
"string/test/run_enumerate_lyndon_hash.test.cpp": "2022-10-09 12:55:12 +0900",
214-
"string/test/run_enumerate_lyndon_mersenne61.test.cpp": "2022-10-09 12:55:12 +0900",
214+
"string/test/run_enumerate_lyndon_mersenne61.test.cpp": "2022-11-14 22:46:56 +0900",
215215
"string/test/run_enumerate_lyndon_rmq.test.cpp": "2022-01-08 20:23:44 +0900",
216216
"string/test/sa_count_keyword.reader.test.cpp": "2022-01-08 20:23:44 +0900",
217217
"string/test/sa_count_keyword.test.cpp": "2022-01-08 20:23:44 +0900",
@@ -221,7 +221,7 @@
221221
"tree/test/diameter.test.cpp": "2021-06-09 00:31:07 +0900",
222222
"tree/test/frequency_table_of_tree_distance.stress.test.cpp": "2022-07-12 00:34:46 +0900",
223223
"tree/test/frequency_table_of_tree_distance.test.cpp": "2022-01-08 20:23:44 +0900",
224-
"tree/test/frequency_table_of_tree_distance_ntt.test.cpp": "2022-10-14 10:52:36 +0900",
224+
"tree/test/frequency_table_of_tree_distance_ntt.test.cpp": "2022-11-14 22:46:56 +0900",
225225
"tree/test/hl_decomposition.test.cpp": "2022-01-08 20:23:44 +0900",
226226
"tree/test/jump_on_tree.test.cpp": "2022-07-31 01:04:01 +0900",
227227
"tree/test/lca.test.cpp": "2022-07-31 01:04:01 +0900",
@@ -243,5 +243,5 @@
243243
"utilities/test/kth_root_integer.test.cpp": "2021-05-01 20:55:29 +0900",
244244
"utilities/test/pow.test.cpp": "2022-07-12 00:34:46 +0900",
245245
"utilities/test/predecessor_problem.test.cpp": "2021-04-25 18:25:53 +0900",
246-
"utilities/test/product_embedding.test.cpp": "2022-06-05 22:26:04 +0900"
246+
"utilities/test/product_embedding.test.cpp": "2022-11-14 22:46:56 +0900"
247247
}

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.PHONY: format
2+
3+
format:
4+
find ./ -name "*.hpp" -o -name "*.cpp" -not -iwholename ".verify-helper*" | xargs clang-format --Werror -i -style=file

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# C++ Algorithm/Data Structure Library for Competitive Programming
22

3-
[![Actions Status](https://github.com/rsm9/cplib-cpp/workflows/verify/badge.svg)](https://github.com/rsm9/cplib-cpp/actions)
3+
[![Actions Status](https://github.com/hitonanode/cplib-cpp/workflows/verify/badge.svg)](https://github.com/hitonanode/cplib-cpp/actions)
4+
[![Actions Status](https://github.com/hitonanode/cplib-cpp/workflows/formatter/badge.svg)](https://github.com/hitonanode/cplib-cpp/actions)
45
[![hitonanode](https://img.shields.io/endpoint?url=https%3A%2F%2Fatcoder-badges.now.sh%2Fapi%2Fatcoder%2Fjson%2Fhitonanode)](https://atcoder.jp/users/hitonanode)
56
[![hitonanode](https://img.shields.io/endpoint?url=https%3A%2F%2Fatcoder-badges.now.sh%2Fapi%2Fcodeforces%2Fjson%2Fhitonanode)](https://codeforces.com/profile/hitonanode)
67

@@ -35,4 +36,4 @@ Except such snippets, the programs written by the owner of the repo is under the
3536

3637
## Formatting
3738

38-
`clang-format` is used (config file: `.clang-format`).
39+
`clang-format-14` is used to lint `.cpp` / `.hpp` files. Default configuration file is `.clang-format`. See [formatter.yml](.github/workflows/formatter.yml) for detail.

number/bare_mod_algebra.hpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ linear_congruence(const std::vector<Int> &A, const std::vector<Int> &B, const st
9999
return std::make_pair((r < 0 ? r + m : r), m);
100100
}
101101

102-
template <class Int = int, class Long = long long>
103-
Int pow_mod(Int x, long long n, Int md) {
102+
template <class Int = int, class Long = long long> Int pow_mod(Int x, long long n, Int md) {
104103
static_assert(sizeof(Int) * 2 <= sizeof(Long), "Watch out for overflow");
105104
if (md == 1) return 0;
106105
Int ans = 1;

number/factorize.hpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ inline int get_id(long long n) {
2020
return 1;
2121
} else if (n < 47636622961201)
2222
return 2;
23-
else {
24-
return 3;
25-
}
23+
else { return 3; }
2624
}
2725
} // namespace SPRP
2826

number/modint_mersenne61.hpp

+3-9
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,19 @@ class ModIntMersenne61 {
5353

5454
ModIntMersenne61 inv() const { return pow(md - 2); }
5555

56-
ModIntMersenne61 operator/(const ModIntMersenne61 &x) const {
57-
return *this * x.inv();
58-
}
56+
ModIntMersenne61 operator/(const ModIntMersenne61 &x) const { return *this * x.inv(); }
5957

6058
ModIntMersenne61 operator-() const { return ModIntMersenne61(md - _v); }
6159
ModIntMersenne61 &operator+=(const ModIntMersenne61 &x) { return *this = *this + x; }
6260
ModIntMersenne61 &operator-=(const ModIntMersenne61 &x) { return *this = *this - x; }
6361
ModIntMersenne61 &operator*=(const ModIntMersenne61 &x) { return *this = *this * x; }
6462
ModIntMersenne61 &operator/=(const ModIntMersenne61 &x) { return *this = *this / x; }
6563

66-
ModIntMersenne61 operator+(unsigned x) const {
67-
return ModIntMersenne61(this->_v + x);
68-
}
64+
ModIntMersenne61 operator+(unsigned x) const { return ModIntMersenne61(this->_v + x); }
6965

7066
bool operator==(const ModIntMersenne61 &x) const { return _v == x._v; }
7167
bool operator!=(const ModIntMersenne61 &x) const { return _v != x._v; }
72-
bool operator<(const ModIntMersenne61 &x) const {
73-
return _v < x._v;
74-
} // To use std::map
68+
bool operator<(const ModIntMersenne61 &x) const { return _v < x._v; } // To use std::map
7569

7670
template <class OStream> friend OStream &operator<<(OStream &os, const ModIntMersenne61 &x) {
7771
return os << x._v;

string/rolling_hash_2d.hpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
#include <string>
33
#include <vector>
44

5-
65
// Rolling Hash (Rabin-Karp), 2dim
76
template <typename V> struct rolling_hash_2d {
87
const V Bx, By;
9-
std::vector<V> powx, powy; // powx[i] = Bx^i
8+
std::vector<V> powx, powy; // powx[i] = Bx^i
109
std::vector<std::vector<V>> hash;
1110

1211
void gen_pow(int h, int w) {
@@ -22,8 +21,7 @@ template <typename V> struct rolling_hash_2d {
2221
return hash[x][y];
2322
}
2423

25-
template <typename Int>
26-
void build(const std::vector<std::vector<Int>> &s) {
24+
template <typename Int> void build(const std::vector<std::vector<Int>> &s) {
2725
const int H = s.size(), W = H ? s.at(0).size() : 0;
2826
gen_pow(H, W);
2927

string/test/rolling_hash.test.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_14_B"
77
using namespace std;
88

9-
template <class Hash>
10-
vector<int> solve(const string T, const string P) {
9+
template <class Hash> vector<int> solve(const string T, const string P) {
1110
rolling_hash<Hash> rh_T(T), rh_P(P);
1211
vector<int> ret;
1312
for (int l = 0; l < (int)(T.length() - P.length() + 1); l++) {

utilities/test/product_embedding.test.cpp

+251-1
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)