Skip to content

Commit 72cd08f

Browse files
committed
update to clang-format-21
1 parent 236e519 commit 72cd08f

File tree

23 files changed

+595
-606
lines changed

23 files changed

+595
-606
lines changed

.github/workflows/lint_and_format_check.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: Run clang-format
3030
uses: jidicula/clang-format-action@6cd220de46c89139a0365edae93eee8eb30ca8fe # v4.16.0
3131
with:
32-
clang-format-version: '17'
32+
clang-format-version: '21'
3333
fallback-style: 'Google'
3434

3535
- uses: chartboost/ruff-action@e18ae971ccee1b2d7bbef113930f00c670b78da4 # v1.0.0
@@ -39,7 +39,7 @@ jobs:
3939

4040
- name: Run clang-tidy
4141
run: >
42-
cmake -B build -DADA_TESTING=ON -DCMAKE_CXX_CLANG_TIDY=clang-tidy-17 &&
42+
cmake -B build -DADA_TESTING=ON -DCMAKE_CXX_CLANG_TIDY=clang-tidy-21 &&
4343
cmake --build build -j=4
4444
env:
45-
CXX: clang++-17
45+
CXX: clang++-21

benchmarks/competitors/servo-url/servo_url.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ struct Url;
1616

1717
extern "C" {
1818

19-
Url *parse_url(const char *raw_input, size_t raw_input_length);
19+
Url* parse_url(const char* raw_input, size_t raw_input_length);
2020

21-
void free_url(Url *raw);
21+
void free_url(Url* raw);
2222

23-
const char *parse_url_to_href(const char *raw_input, size_t raw_input_length);
23+
const char* parse_url_to_href(const char* raw_input, size_t raw_input_length);
2424

25-
void free_string(const char *);
25+
void free_string(const char*);
2626
} // extern "C"
2727

2828
} // namespace servo_url

benchmarks/model_bench.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "performancecounters/event_counter.h"
1010
event_collector collector;
1111

12-
bool file_exists(const char *filename) {
12+
bool file_exists(const char* filename) {
1313
namespace fs = std::filesystem;
1414
std::filesystem::path f{filename};
1515
if (std::filesystem::exists(filename)) {
@@ -33,7 +33,7 @@ std::string read_file(std::string filename) {
3333
return out;
3434
}
3535

36-
std::vector<std::string> split_string(const std::string &str) {
36+
std::vector<std::string> split_string(const std::string& str) {
3737
auto result = std::vector<std::string>{};
3838
std::stringstream ss{str};
3939
for (std::string line; std::getline(ss, line, '\n');) {
@@ -65,7 +65,7 @@ struct stat_numbers {
6565
bool has_search = false;
6666
};
6767

68-
size_t count_ascii_bytes(const std::string &s) {
68+
size_t count_ascii_bytes(const std::string& s) {
6969
size_t counter = 0;
7070
for (uint8_t c : s) {
7171
if (c < 128) {
@@ -77,7 +77,7 @@ size_t count_ascii_bytes(const std::string &s) {
7777

7878
template <class result_type = ada::url_aggregator>
7979
std::vector<stat_numbers> collect_values(
80-
const std::vector<std::string> &url_examples, size_t trials) {
80+
const std::vector<std::string>& url_examples, size_t trials) {
8181
std::vector<stat_numbers> numbers(url_examples.size());
8282
for (size_t i = 0; i < url_examples.size(); i++) {
8383
numbers[i].url_string = url_examples[i];
@@ -96,7 +96,7 @@ std::vector<stat_numbers> collect_values(
9696
}
9797
volatile size_t href_size = 0;
9898
for (size_t i = 0; i < trials; i++) {
99-
for (stat_numbers &n : numbers) {
99+
for (stat_numbers& n : numbers) {
100100
std::atomic_thread_fence(std::memory_order_acquire);
101101
collector.start();
102102
ada::result<result_type> url = ada::parse<result_type>(n.url_string);
@@ -112,12 +112,12 @@ std::vector<stat_numbers> collect_values(
112112
}
113113

114114
#ifdef ADA_URL_FILE
115-
const char *default_file = ADA_URL_FILE;
115+
const char* default_file = ADA_URL_FILE;
116116
#else
117-
const char *default_file = nullptr;
117+
const char* default_file = nullptr;
118118
#endif
119119

120-
std::vector<std::string> init_data(const char *input = default_file) {
120+
std::vector<std::string> init_data(const char* input = default_file) {
121121
std::vector<std::string> input_urls;
122122
if (input == nullptr) {
123123
return input_urls;
@@ -133,7 +133,7 @@ std::vector<std::string> init_data(const char *input = default_file) {
133133
return input_urls;
134134
}
135135

136-
void print(const stat_numbers &n) {
136+
void print(const stat_numbers& n) {
137137
std::cout << std::setw(15) << n.url_string.size() << ",";
138138
std::cout << std::setw(15) << n.counters.best.cycles() << "," << std::setw(15)
139139
<< size_t(n.counters.cycles()) << ",";
@@ -238,13 +238,13 @@ void print(const std::vector<stat_numbers> numbers) {
238238

239239
std::cout << std::endl;
240240

241-
for (const stat_numbers &n : numbers) {
241+
for (const stat_numbers& n : numbers) {
242242
print(n);
243243
std::cout << std::endl;
244244
}
245245
}
246246

247-
int main(int argc, char **argv) {
247+
int main(int argc, char** argv) {
248248
std::vector<std::string> input_urls;
249249
if (argc == 1) {
250250
input_urls = init_data();

benchmarks/performancecounters/linux-perf-events.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class LinuxEvents {
7676
}
7777
}
7878

79-
inline void end(std::vector<unsigned long long> &results) {
79+
inline void end(std::vector<unsigned long long>& results) {
8080
if (fd != -1) {
8181
if (ioctl(fd, PERF_EVENT_IOC_DISABLE, PERF_IOC_FLAG_GROUP) == -1) {
8282
report_error("ioctl(PERF_EVENT_IOC_DISABLE)");
@@ -100,6 +100,6 @@ class LinuxEvents {
100100
bool is_working() { return working; }
101101

102102
private:
103-
void report_error(const std::string &) { working = false; }
103+
void report_error(const std::string&) { working = false; }
104104
};
105105
#endif

benchmarks/wpt_bench.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ enum {
1111
ALL_URLS = -1,
1212
};
1313

14-
size_t init_data(const char *source, int which_url) {
14+
size_t init_data(const char* source, int which_url) {
1515
ondemand::parser parser;
1616
std::vector<std::pair<std::string, std::string>> answer;
1717

@@ -66,15 +66,15 @@ size_t init_data(const char *source, int which_url) {
6666
}
6767

6868
template <class result>
69-
static void BasicBench_AdaURL(benchmark::State &state) {
69+
static void BasicBench_AdaURL(benchmark::State& state) {
7070
// volatile to prevent optimizations.
7171
volatile size_t href_size = 0;
7272

7373
for (auto _ : state) {
74-
for (const std::pair<std::string, std::string> &url_strings :
74+
for (const std::pair<std::string, std::string>& url_strings :
7575
url_examples) {
7676
ada::result<result> base;
77-
result *base_ptr = nullptr;
77+
result* base_ptr = nullptr;
7878
if (!url_strings.second.empty()) {
7979
base = ada::parse<result>(url_strings.second);
8080
if (base) {
@@ -94,10 +94,10 @@ static void BasicBench_AdaURL(benchmark::State &state) {
9494
for (size_t i = 0; i < N; i++) {
9595
std::atomic_thread_fence(std::memory_order_acquire);
9696
collector.start();
97-
for (const std::pair<std::string, std::string> &url_strings :
97+
for (const std::pair<std::string, std::string>& url_strings :
9898
url_examples) {
9999
ada::result<result> base;
100-
result *base_ptr = nullptr;
100+
result* base_ptr = nullptr;
101101
if (!url_strings.second.empty()) {
102102
base = ada::parse<result>(url_strings.second);
103103
if (base) {
@@ -153,13 +153,13 @@ BENCHMARK(BasicBench_AdaURL_url_aggregator);
153153

154154
#include <upa/url.h>
155155

156-
static void BasicBench_whatwg(benchmark::State &state) {
156+
static void BasicBench_whatwg(benchmark::State& state) {
157157
volatile size_t success{};
158158
for (auto _ : state) {
159-
for (const std::pair<std::string, std::string> &url_strings :
159+
for (const std::pair<std::string, std::string>& url_strings :
160160
url_examples) {
161161
upa::url base;
162-
upa::url *base_ptr = nullptr;
162+
upa::url* base_ptr = nullptr;
163163
if (!url_strings.second.empty()) {
164164
if (upa::success(base.parse(url_strings.second, nullptr))) {
165165
base_ptr = &base;
@@ -176,10 +176,10 @@ static void BasicBench_whatwg(benchmark::State &state) {
176176
for (size_t i = 0; i < N; i++) {
177177
std::atomic_thread_fence(std::memory_order_acquire);
178178
collector.start();
179-
for (const std::pair<std::string, std::string> &url_strings :
179+
for (const std::pair<std::string, std::string>& url_strings :
180180
url_examples) {
181181
upa::url base;
182-
upa::url *base_ptr = nullptr;
182+
upa::url* base_ptr = nullptr;
183183
if (!url_strings.second.empty()) {
184184
if (upa::success(base.parse(url_strings.second, nullptr))) {
185185
base_ptr = &base;
@@ -227,7 +227,7 @@ static void BasicBench_whatwg(benchmark::State &state) {
227227
BENCHMARK(BasicBench_whatwg);
228228
#endif // ADA_url_whatwg_ENABLED
229229

230-
int main(int argc, char **argv) {
230+
int main(int argc, char** argv) {
231231
int which_url = ALL_URLS;
232232
if (argc > 3 && std::string_view(argv[2]) == "--select") {
233233
which_url = std::atoi(argv[3]);

fuzz/can_parse.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "ada.cpp"
77
#include "ada.h"
88

9-
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
9+
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
1010
FuzzedDataProvider fdp(data, size);
1111
std::string source = fdp.ConsumeRandomLengthString(256);
1212
std::string base_source = fdp.ConsumeRandomLengthString(256);

fuzz/idna.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "ada.cpp"
77
#include "ada.h"
88

9-
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
9+
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
1010
FuzzedDataProvider fdp(data, size);
1111
std::string source = fdp.ConsumeRandomLengthString(256);
1212

fuzz/parse.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#include "ada.cpp"
88
#include "ada.h"
99

10-
bool is_valid_utf8_string(const char *buf, size_t len) {
11-
const uint8_t *data = reinterpret_cast<const uint8_t *>(buf);
10+
bool is_valid_utf8_string(const char* buf, size_t len) {
11+
const uint8_t* data = reinterpret_cast<const uint8_t*>(buf);
1212
uint64_t pos = 0;
1313
uint32_t code_point = 0;
1414
while (pos < len) {
@@ -91,7 +91,7 @@ bool is_valid_utf8_string(const char *buf, size_t len) {
9191
return true;
9292
}
9393

94-
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
94+
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
9595
FuzzedDataProvider fdp(data, size);
9696
std::string source = fdp.ConsumeRandomLengthString(256);
9797

fuzz/url_search_params.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "ada.cpp"
77
#include "ada.h"
88

9-
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
9+
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
1010
FuzzedDataProvider fdp(data, size);
1111
std::string source = fdp.ConsumeRandomLengthString(256);
1212
std::string base_source = fdp.ConsumeRandomLengthString(256);

include/ada/common_defs.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040
#endif
4141

4242
// Align to N-byte boundary
43-
#define ADA_ROUNDUP_N(a, n) (((a) + ((n)-1)) & ~((n)-1))
44-
#define ADA_ROUNDDOWN_N(a, n) ((a) & ~((n)-1))
43+
#define ADA_ROUNDUP_N(a, n) (((a) + ((n) - 1)) & ~((n) - 1))
44+
#define ADA_ROUNDDOWN_N(a, n) ((a) & ~((n) - 1))
4545

46-
#define ADA_ISALIGNED_N(ptr, n) (((uintptr_t)(ptr) & ((n)-1)) == 0)
46+
#define ADA_ISALIGNED_N(ptr, n) (((uintptr_t)(ptr) & ((n) - 1)) == 0)
4747

4848
#if defined(ADA_REGULAR_VISUAL_STUDIO)
4949

0 commit comments

Comments
 (0)