Skip to content

Commit 7c6fee6

Browse files
committed
refactor: upgrade to clang-format 18
We use clang-format 9, which is quite outdated. Double the version to clang-format 18. clang-format 18 was released a few months ago. It ships in Ubuntu 24.04 which is the latest LTS release of Ubuntu. clang-format 18 is available in Homebrew, and there are pre-built Windows binaries on LLVM's GitHub releases page [1]. [1] https://github.com/llvm/llvm-project/releases/tag/llvmorg-18.1.8
1 parent 6b4539f commit 7c6fee6

30 files changed

+105
-115
lines changed

src/quick-lint-js/configuration/change-detecting-filesystem-kqueue.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -277,15 +277,12 @@ std::string vnode_event_flags_to_string(std::uint32_t flags) {
277277
const char name[13];
278278
};
279279
static constexpr Flag_Entry known_flags[] = {
280-
{NOTE_ATTRIB, "NOTE_ATTRIB"},
281-
{NOTE_DELETE, "NOTE_DELETE"},
282-
{NOTE_EXTEND, "NOTE_EXTEND"},
283-
{NOTE_LINK, "NOTE_LINK"},
284-
{NOTE_RENAME, "NOTE_RENAME"},
285-
{NOTE_REVOKE, "NOTE_REVOKE"},
286-
{NOTE_WRITE, "NOTE_WRITE"},
280+
{NOTE_ATTRIB, "NOTE_ATTRIB"}, {NOTE_DELETE, "NOTE_DELETE"},
281+
{NOTE_EXTEND, "NOTE_EXTEND"}, {NOTE_LINK, "NOTE_LINK"},
282+
{NOTE_RENAME, "NOTE_RENAME"}, {NOTE_REVOKE, "NOTE_REVOKE"},
283+
{NOTE_WRITE, "NOTE_WRITE"},
287284
#if defined(__APPLE__)
288-
{NOTE_FUNLOCK, "NOTE_FUNLOCK"},
285+
{NOTE_FUNLOCK, "NOTE_FUNLOCK"},
289286
#endif
290287
};
291288

src/quick-lint-js/container/fixed-vector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class Fixed_Vector : private Fixed_Vector_Base<T, max_size> {
148148
T &push_back(T &&value) { return this->emplace_back(std::move(value)); }
149149

150150
template <class... Args>
151-
T &emplace_back(Args &&... args) {
151+
T &emplace_back(Args &&...args) {
152152
QLJS_ASSERT(this->size() < max_size);
153153
T *slot = &this->storage_slots()[this->size_];
154154
#if QLJS_HAVE_SANITIZER_ASAN_INTERFACE_H

src/quick-lint-js/container/linked-bump-allocator.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ Linked_Bump_Allocator::Disable_Guard::~Disable_Guard() {
7777
#endif
7878
}
7979

80-
Linked_Bump_Allocator::Disable_Guard::Disable_Guard([
81-
[maybe_unused]] Linked_Bump_Allocator* alloc)
80+
Linked_Bump_Allocator::Disable_Guard::Disable_Guard(
81+
[[maybe_unused]] Linked_Bump_Allocator* alloc)
8282
#if QLJS_DEBUG_BUMP_ALLOCATOR
8383
: alloc_(alloc)
8484
#endif
@@ -137,10 +137,10 @@ bool Linked_Bump_Allocator::do_try_grow_in_place(void* array,
137137
bool have_enough_space =
138138
(alignment_padding + size) <= this->remaining_bytes_in_current_chunk();
139139
if (!have_enough_space) [[unlikely]] {
140-
this->append_chunk(maximum(size, this->default_chunk_size), align);
141-
result = this->next_allocation_;
142-
QLJS_ASSERT(is_aligned(result, align));
143-
}
140+
this->append_chunk(maximum(size, this->default_chunk_size), align);
141+
result = this->next_allocation_;
142+
QLJS_ASSERT(is_aligned(result, align));
143+
}
144144

145145
this->next_allocation_ = result + size;
146146
this->did_allocate_bytes(result, size);

src/quick-lint-js/container/vector-profiler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ class Instrumented_Vector {
249249
}
250250

251251
template <class... Args>
252-
QLJS_FORCE_INLINE value_type &emplace_back(Args &&... args) {
252+
QLJS_FORCE_INLINE value_type &emplace_back(Args &&...args) {
253253
this->data_.emplace_back(std::forward<Args>(args)...);
254254
this->add_instrumentation_entry(Vector_Instrumentation::Event::append);
255255
return this->data_.back();

src/quick-lint-js/container/vector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ class Raw_Vector {
243243
T &push_back(T &&value) { return this->emplace_back(std::move(value)); }
244244

245245
template <class... Args>
246-
T &emplace_back(Args &&... args) {
246+
T &emplace_back(Args &&...args) {
247247
if (this->capacity_end_ == this->data_end_) {
248248
this->reserve_grow_by_at_least(1);
249249
}

src/quick-lint-js/debug/find-debug-server.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,8 @@ Span<Found_Debug_Server> find_debug_servers(Monotonic_Allocator* allocator) {
575575
#endif
576576

577577
#if !QLJS_CAN_FIND_DEBUG_SERVERS
578-
Span<Found_Debug_Server> find_debug_servers([
579-
[maybe_unused]] Monotonic_Allocator* allocator) {
578+
Span<Found_Debug_Server> find_debug_servers(
579+
[[maybe_unused]] Monotonic_Allocator* allocator) {
580580
#warning "--debug-apps is not supported on this platform"
581581
return Span<Found_Debug_Server>();
582582
}

src/quick-lint-js/debug/mongoose.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ class Mongoose_Mgr {
4141

4242
template <auto member_function_pointer>
4343
mg_event_handler_t mongoose_callback() {
44-
using Self = typename Member_Function_Pointer_Traits<decltype(
45-
member_function_pointer)>::Class_Type;
44+
using Self = typename Member_Function_Pointer_Traits<
45+
decltype(member_function_pointer)>::Class_Type;
4646
return [](::mg_connection *c, int ev, void *ev_data, void *fn_data) -> void {
4747
(static_cast<Self *>(fn_data)->*member_function_pointer)(c, ev, ev_data);
4848
};

src/quick-lint-js/diag/diagnostic-types-2.h

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -788,10 +788,10 @@ struct Diag_Duplicated_Cases_In_Switch_Statement {
788788

789789
struct Diag_Fallthrough_Without_Comment_In_Switch {
790790
[[qljs::diag("E0427", Diagnostic_Severity::warning)]] //
791-
[
792-
[qljs::message("missing 'break;' or '// fallthrough' comment between "
793-
"statement and 'case'",
794-
ARG(end_of_case))]] //
791+
[[qljs::message(
792+
"missing 'break;' or '// fallthrough' comment between "
793+
"statement and 'case'",
794+
ARG(end_of_case))]] //
795795
Source_Code_Span end_of_case;
796796
};
797797

@@ -2281,10 +2281,10 @@ struct Diag_TypeScript_Delete_Cannot_Delete_Variables {
22812281

22822282
struct Diag_TypeScript_Definite_Assignment_Assertion_In_Ambient_Context {
22832283
[[qljs::diag("E0445", Diagnostic_Severity::error)]] //
2284-
[
2285-
[qljs::message("'!' (definite assignment assertion) is not allowed on "
2286-
"'declare' variables",
2287-
ARG(definite_assignment_assertion))]] //
2284+
[[qljs::message(
2285+
"'!' (definite assignment assertion) is not allowed on "
2286+
"'declare' variables",
2287+
ARG(definite_assignment_assertion))]] //
22882288
[[qljs::message("'declare' here",
22892289
ARG(declare_keyword))]] //
22902290
Source_Code_Span definite_assignment_assertion;
@@ -2309,10 +2309,10 @@ struct Diag_TypeScript_Definite_Assignment_Assertion_On_Const {
23092309

23102310
struct Diag_TypeScript_Definite_Assignment_Assertion_With_Initializer {
23112311
[[qljs::diag("E0442", Diagnostic_Severity::error)]] //
2312-
[
2313-
[qljs::message("'!' (definite assignment assertion) cannot be used with "
2314-
"an initial value",
2315-
ARG(definite_assignment_assertion))]] //
2312+
[[qljs::message(
2313+
"'!' (definite assignment assertion) cannot be used with "
2314+
"an initial value",
2315+
ARG(definite_assignment_assertion))]] //
23162316
[[qljs::message("initial value was given here",
23172317
ARG(equal))]] //
23182318
Source_Code_Span definite_assignment_assertion;
@@ -2321,10 +2321,10 @@ struct Diag_TypeScript_Definite_Assignment_Assertion_With_Initializer {
23212321

23222322
struct Diag_TypeScript_Definite_Assignment_Assertion_Without_Type_Annotation {
23232323
[[qljs::diag("E0443", Diagnostic_Severity::error)]] //
2324-
[
2325-
[qljs::message("type annotation is required when using '!' (definite "
2326-
"assignment assertion)",
2327-
ARG(definite_assignment_assertion))]] //
2324+
[[qljs::message(
2325+
"type annotation is required when using '!' (definite "
2326+
"assignment assertion)",
2327+
ARG(definite_assignment_assertion))]] //
23282328
Source_Code_Span definite_assignment_assertion;
23292329
};
23302330

@@ -2586,10 +2586,10 @@ struct Diag_TypeScript_Declare_Field_Not_Allowed_In_JavaScript {
25862586

25872587
struct Diag_TypeScript_Declare_Field_Cannot_Use_Private_Identifier {
25882588
[[qljs::diag("E0416", Diagnostic_Severity::error)]] //
2589-
[
2590-
[qljs::message("private identifiers are not allowed for 'declare' "
2591-
"fields; use 'private' instead",
2592-
ARG(private_identifier_hash))]] //
2589+
[[qljs::message(
2590+
"private identifiers are not allowed for 'declare' "
2591+
"fields; use 'private' instead",
2592+
ARG(private_identifier_hash))]] //
25932593
[[qljs::message("'declare' here", ARG(declare_keyword))]] //
25942594
Source_Code_Span private_identifier_hash;
25952595
Source_Code_Span declare_keyword;
@@ -3621,10 +3621,10 @@ struct Diag_TypeScript_Namespace_Alias_Cannot_Use_Import_Type {
36213621

36223622
struct Diag_Confusing_Let_Call {
36233623
[[qljs::diag("E0720", Diagnostic_Severity::warning)]] //
3624-
[
3625-
[qljs::message("function 'let' call may be confused for destructuring; "
3626-
"remove parentheses to declare a variable",
3627-
ARG(let_function_call))]] //
3624+
[[qljs::message(
3625+
"function 'let' call may be confused for destructuring; "
3626+
"remove parentheses to declare a variable",
3627+
ARG(let_function_call))]] //
36283628
Source_Code_Span let_function_call;
36293629
};
36303630

src/quick-lint-js/fe/expression.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class Expression_Arena {
169169
is_winkable_v<std::remove_reference_t<T>>;
170170

171171
template <class Expression, class... Args>
172-
Expression *make_expression(Args &&... args);
172+
Expression *make_expression(Args &&...args);
173173

174174
template <class T>
175175
Array_Ptr<T> make_array(Vector<T> &&);
@@ -184,7 +184,7 @@ class Expression_Arena {
184184

185185
private:
186186
template <class T, class... Args>
187-
T *allocate(Args &&... args) {
187+
T *allocate(Args &&...args) {
188188
static_assert(is_allocatable<T>);
189189
return this->allocator_.new_object<T>(std::forward<Args>(args)...);
190190
}
@@ -329,7 +329,7 @@ Derived expression_cast(const Expression &p) {
329329
}
330330

331331
template <class Expression, class... Args>
332-
Expression *Expression_Arena::make_expression(Args &&... args) {
332+
Expression *Expression_Arena::make_expression(Args &&...args) {
333333
Expression *result(this->allocate<Expression>(std::forward<Args>(args)...));
334334
static_assert(is_allocatable<Expression>);
335335
return result;

src/quick-lint-js/fe/keyword-list.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
QLJS_KEYWORD(public) \
7171
QLJS_KEYWORD(readonly) \
7272
QLJS_KEYWORD(require) \
73-
QLJS_KEYWORD(return ) \
73+
QLJS_KEYWORD(return) \
7474
QLJS_KEYWORD(satisfies) \
7575
QLJS_KEYWORD(set) \
7676
QLJS_KEYWORD(static) \

src/quick-lint-js/fe/lex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2353,7 +2353,7 @@ bool Lexer::is_identifier_byte(Char8 byte) {
23532353
switch (static_cast<std::uint8_t>(byte)) {
23542354
QLJS_CASE_DECIMAL_DIGIT:
23552355
QLJS_CASE_IDENTIFIER_START:
2356-
// clang-format off
2356+
// clang-format off
23572357
/* 0xc0 */ /* 0xc1 */ case 0xc2: case 0xc3: case 0xc4: case 0xc5: case 0xc6: case 0xc7:
23582358
case 0xc8: case 0xc9: case 0xca: case 0xcb: case 0xcc: case 0xcd: case 0xce: case 0xcf:
23592359
case 0xd0: case 0xd1: case 0xd2: case 0xd3: case 0xd4: case 0xd5: case 0xd6: case 0xd7:

src/quick-lint-js/fe/parse-class.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ std::optional<Identifier> Parser::parse_class_and_optional_name() {
127127
case Token_Type::identifier:
128128
case Token_Type::kw_yield:
129129
// TODO(#707): Disallow classes named 'yield' in generator function.
130-
class_name : {
130+
class_name: {
131131
if (this->peek().type == Token_Type::kw_let) {
132132
this->diags_.add(Diag_Cannot_Declare_Class_Named_Let{
133133
.name = this->peek().identifier_name().span()});

src/quick-lint-js/fe/parse-expression.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -518,11 +518,10 @@ Expression* Parser::parse_primary_expression(Parse_Visitor_Base& v,
518518
Expression* ast =
519519
type == Token_Type::kw_delete
520520
? this->make_expression<Expression::Delete>(child, operator_span)
521-
: type == Token_Type::kw_typeof
522-
? this->make_expression<Expression::Typeof>(child,
523-
operator_span)
524-
: this->make_expression<Expression::Unary_Operator>(
525-
child, operator_span);
521+
: type == Token_Type::kw_typeof
522+
? this->make_expression<Expression::Typeof>(child, operator_span)
523+
: this->make_expression<Expression::Unary_Operator>(child,
524+
operator_span);
526525
return ast;
527526
}
528527

@@ -1683,7 +1682,7 @@ Expression* Parser::parse_expression_remainder(Parse_Visitor_Base& v,
16831682
// x += y
16841683
// x[y] &&= z
16851684
QLJS_CASE_COMPOUND_ASSIGNMENT_OPERATOR:
1686-
QLJS_CASE_CONDITIONAL_ASSIGNMENT_OPERATOR : {
1685+
QLJS_CASE_CONDITIONAL_ASSIGNMENT_OPERATOR: {
16871686
if (!prec.math_or_logical_or_assignment) {
16881687
break;
16891688
}
@@ -3016,7 +3015,7 @@ Expression* Parser::parse_object_literal(Parse_Visitor_Base& v) {
30163015
break;
30173016
}
30183017

3019-
QLJS_CASE_RESERVED_KEYWORD_EXCEPT_AWAIT_AND_YIELD : {
3018+
QLJS_CASE_RESERVED_KEYWORD_EXCEPT_AWAIT_AND_YIELD: {
30203019
Expression* value =
30213020
this->make_expression<Expression::Missing>(key_token.span());
30223021
this->diags_.add(Diag_Missing_Value_For_Object_Literal_Entry{
@@ -3990,10 +3989,11 @@ Expression* Parser::parse_jsx_element_or_fragment(Parse_Visitor_Base& v,
39903989
.opening_tag_name =
39913990
tag_namespace
39923991
? Source_Code_Span(tag_namespace->span().begin(), tag_end)
3993-
: !tag_members.empty()
3994-
? Source_Code_Span(tag_members.front().span().begin(),
3995-
tag_end)
3996-
: tag ? tag->span() : Source_Code_Span::unit(tag_end),
3992+
: !tag_members.empty()
3993+
? Source_Code_Span(tag_members.front().span().begin(),
3994+
tag_end)
3995+
: tag ? tag->span()
3996+
: Source_Code_Span::unit(tag_end),
39973997
.closing_tag_name =
39983998
closing_tag_begin <= closing_tag_end
39993999
? Source_Code_Span(closing_tag_begin, closing_tag_end)

src/quick-lint-js/fe/parse-statement.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5012,8 +5012,7 @@ void Parser::parse_and_visit_named_exports(
50125012
goto named_export;
50135013

50145014
named_export:
5015-
QLJS_CASE_CONTEXTUAL_KEYWORD_EXCEPT_ASYNC_AND_GET_AND_SET_AND_STATIC_AND_TYPE
5016-
:
5015+
QLJS_CASE_CONTEXTUAL_KEYWORD_EXCEPT_ASYNC_AND_GET_AND_SET_AND_STATIC_AND_TYPE:
50175016
case Token_Type::identifier:
50185017
case Token_Type::kw_async:
50195018
case Token_Type::kw_get:
@@ -5701,7 +5700,7 @@ void Parser::parse_and_visit_let_bindings(
57015700

57025701
// let switch = 3; // Invalid.
57035702
// let if (x) {} // Invalid.
5704-
QLJS_CASE_RESERVED_KEYWORD_EXCEPT_AWAIT_AND_YIELD : {
5703+
QLJS_CASE_RESERVED_KEYWORD_EXCEPT_AWAIT_AND_YIELD: {
57055704
Source_Code_Span keyword_span = this->peek().span();
57065705
Lexer_Transaction transaction = this->lexer_.begin_transaction();
57075706
this->skip();

src/quick-lint-js/fe/parse.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ class Parser {
10111011

10121012
private:
10131013
template <class New_Expression, class... Args>
1014-
Expression *make_expression(Args &&... args) {
1014+
Expression *make_expression(Args &&...args) {
10151015
return this->expressions_.make_expression<New_Expression>(
10161016
std::forward<Args>(args)...);
10171017
}

src/quick-lint-js/fe/token.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,9 @@
121121
case ::quick_lint_js::Token_Type::kw_of: \
122122
case ::quick_lint_js::Token_Type::kw_satisfies
123123

124-
#define QLJS_CASE_CONTEXTUAL_KEYWORD_EXCEPT_ASYNC_AND_GET_AND_SET \
125-
QLJS_CASE_CONTEXTUAL_KEYWORD_EXCEPT_ASYNC_AND_GET_AND_SET_AND_STATIC_AND_TYPE \
126-
: \
127-
case ::quick_lint_js::Token_Type::kw_static: \
124+
#define QLJS_CASE_CONTEXTUAL_KEYWORD_EXCEPT_ASYNC_AND_GET_AND_SET \
125+
QLJS_CASE_CONTEXTUAL_KEYWORD_EXCEPT_ASYNC_AND_GET_AND_SET_AND_STATIC_AND_TYPE: \
126+
case ::quick_lint_js::Token_Type::kw_static: \
128127
case ::quick_lint_js::Token_Type::kw_type
129128

130129
// Keywords which are sometimes treated as identifiers; i.e. identifiers which

src/quick-lint-js/fe/variable-analyzer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,8 +656,8 @@ void Variable_Analyzer::propagate_variable_uses_to_parent_scope(
656656
bool consume_arguments) {
657657
// Found_Variable_Type is either Declared_Variable* or
658658
// std::optional<Global_Declared_Variable>.
659-
using Found_Variable_Type = typename std::decay_t<decltype(
660-
Parent_Scope::declared_variables)>::Found_Variable_Type;
659+
using Found_Variable_Type = typename std::decay_t<
660+
decltype(Parent_Scope::declared_variables)>::Found_Variable_Type;
661661

662662
constexpr bool parent_scope_is_global_scope =
663663
std::is_same_v<Parent_Scope, Global_Scope>;

src/quick-lint-js/io/file-canonical.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,12 @@ class Path_Canonicalizer_Base {
377377
// Extra components and trailing slashes are not allowed for regular
378378
// files, FIFOs, etc.
379379
if (!path_to_process_.empty()) {
380-
return failed_result(Canonicalizing_Path_IO_Error {
381-
.canonicalizing_path = canonical_,
380+
return failed_result(Canonicalizing_Path_IO_Error{
381+
.canonicalizing_path = canonical_,
382382
#if QLJS_HAVE_UNISTD_H
383-
.io_error = POSIX_File_IO_Error{ENOTDIR},
383+
.io_error = POSIX_File_IO_Error{ENOTDIR},
384384
#elif QLJS_HAVE_WINDOWS_H
385-
.io_error = Windows_File_IO_Error{ERROR_DIRECTORY},
385+
.io_error = Windows_File_IO_Error{ERROR_DIRECTORY},
386386
#else
387387
#error "Unsupported platform"
388388
#endif

src/quick-lint-js/io/file.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -590,10 +590,9 @@ void create_windows_junction_or_exit(const char *path, const char *target) {
590590
/*hTemplateFile=*/nullptr));
591591

592592
std::size_t reparse_data_data_size =
593-
offsetof(
594-
decltype(
595-
std::declval<::REPARSE_DATA_BUFFER>().MountPointReparseBuffer),
596-
PathBuffer) +
593+
offsetof(decltype(std::declval<::REPARSE_DATA_BUFFER>()
594+
.MountPointReparseBuffer),
595+
PathBuffer) +
597596
// SubsituteName. +1 for null terminator.
598597
(wtarget->size() + 1) * sizeof(wchar_t) +
599598
// PrintName. Empty string with null terminator.

0 commit comments

Comments
 (0)