From 7c6fee684a1c6b53a2abb433fa789f5e53aeb90d Mon Sep 17 00:00:00 2001 From: "Matthew \"strager\" Glazar" Date: Wed, 21 Aug 2024 02:48:37 -0400 Subject: [PATCH] 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 --- .../change-detecting-filesystem-kqueue.cpp | 13 ++--- src/quick-lint-js/container/fixed-vector.h | 2 +- .../container/linked-bump-allocator.cpp | 12 ++--- src/quick-lint-js/container/vector-profiler.h | 2 +- src/quick-lint-js/container/vector.h | 2 +- src/quick-lint-js/debug/find-debug-server.cpp | 4 +- src/quick-lint-js/debug/mongoose.h | 4 +- src/quick-lint-js/diag/diagnostic-types-2.h | 48 +++++++++---------- src/quick-lint-js/fe/expression.h | 6 +-- src/quick-lint-js/fe/keyword-list.h | 2 +- src/quick-lint-js/fe/lex.cpp | 2 +- src/quick-lint-js/fe/parse-class.cpp | 2 +- src/quick-lint-js/fe/parse-expression.cpp | 22 ++++----- src/quick-lint-js/fe/parse-statement.cpp | 5 +- src/quick-lint-js/fe/parse.h | 2 +- src/quick-lint-js/fe/token.h | 7 ++- src/quick-lint-js/fe/variable-analyzer.cpp | 4 +- src/quick-lint-js/io/file-canonical.cpp | 8 ++-- src/quick-lint-js/io/file.cpp | 7 ++- src/quick-lint-js/logging/trace-types.h | 12 ++--- src/quick-lint-js/port/memory-resource.cpp | 4 +- src/quick-lint-js/reflection/cxx-parser.cpp | 2 +- src/quick-lint-js/util/utf-8.cpp | 10 ++-- test/quick-lint-js/diag-matcher.h | 12 ++--- test/quick-lint-js/filesystem-test.cpp | 4 +- test/test-event-loop.cpp | 6 +-- test/test-parse-expression.cpp | 4 +- test/test-trace-reader-writer.cpp | 2 +- tools/format | 6 +-- .../coding-standards/index.ejs.html | 4 +- 30 files changed, 105 insertions(+), 115 deletions(-) diff --git a/src/quick-lint-js/configuration/change-detecting-filesystem-kqueue.cpp b/src/quick-lint-js/configuration/change-detecting-filesystem-kqueue.cpp index bdfccc6f98..38daf2cb1f 100644 --- a/src/quick-lint-js/configuration/change-detecting-filesystem-kqueue.cpp +++ b/src/quick-lint-js/configuration/change-detecting-filesystem-kqueue.cpp @@ -277,15 +277,12 @@ std::string vnode_event_flags_to_string(std::uint32_t flags) { const char name[13]; }; static constexpr Flag_Entry known_flags[] = { - {NOTE_ATTRIB, "NOTE_ATTRIB"}, - {NOTE_DELETE, "NOTE_DELETE"}, - {NOTE_EXTEND, "NOTE_EXTEND"}, - {NOTE_LINK, "NOTE_LINK"}, - {NOTE_RENAME, "NOTE_RENAME"}, - {NOTE_REVOKE, "NOTE_REVOKE"}, - {NOTE_WRITE, "NOTE_WRITE"}, + {NOTE_ATTRIB, "NOTE_ATTRIB"}, {NOTE_DELETE, "NOTE_DELETE"}, + {NOTE_EXTEND, "NOTE_EXTEND"}, {NOTE_LINK, "NOTE_LINK"}, + {NOTE_RENAME, "NOTE_RENAME"}, {NOTE_REVOKE, "NOTE_REVOKE"}, + {NOTE_WRITE, "NOTE_WRITE"}, #if defined(__APPLE__) - {NOTE_FUNLOCK, "NOTE_FUNLOCK"}, + {NOTE_FUNLOCK, "NOTE_FUNLOCK"}, #endif }; diff --git a/src/quick-lint-js/container/fixed-vector.h b/src/quick-lint-js/container/fixed-vector.h index 7dfe10bd15..783fbf0210 100644 --- a/src/quick-lint-js/container/fixed-vector.h +++ b/src/quick-lint-js/container/fixed-vector.h @@ -148,7 +148,7 @@ class Fixed_Vector : private Fixed_Vector_Base { T &push_back(T &&value) { return this->emplace_back(std::move(value)); } template - T &emplace_back(Args &&... args) { + T &emplace_back(Args &&...args) { QLJS_ASSERT(this->size() < max_size); T *slot = &this->storage_slots()[this->size_]; #if QLJS_HAVE_SANITIZER_ASAN_INTERFACE_H diff --git a/src/quick-lint-js/container/linked-bump-allocator.cpp b/src/quick-lint-js/container/linked-bump-allocator.cpp index eb1589cb7c..6ac3c82e14 100644 --- a/src/quick-lint-js/container/linked-bump-allocator.cpp +++ b/src/quick-lint-js/container/linked-bump-allocator.cpp @@ -77,8 +77,8 @@ Linked_Bump_Allocator::Disable_Guard::~Disable_Guard() { #endif } -Linked_Bump_Allocator::Disable_Guard::Disable_Guard([ - [maybe_unused]] Linked_Bump_Allocator* alloc) +Linked_Bump_Allocator::Disable_Guard::Disable_Guard( + [[maybe_unused]] Linked_Bump_Allocator* alloc) #if QLJS_DEBUG_BUMP_ALLOCATOR : alloc_(alloc) #endif @@ -137,10 +137,10 @@ bool Linked_Bump_Allocator::do_try_grow_in_place(void* array, bool have_enough_space = (alignment_padding + size) <= this->remaining_bytes_in_current_chunk(); if (!have_enough_space) [[unlikely]] { - this->append_chunk(maximum(size, this->default_chunk_size), align); - result = this->next_allocation_; - QLJS_ASSERT(is_aligned(result, align)); - } + this->append_chunk(maximum(size, this->default_chunk_size), align); + result = this->next_allocation_; + QLJS_ASSERT(is_aligned(result, align)); + } this->next_allocation_ = result + size; this->did_allocate_bytes(result, size); diff --git a/src/quick-lint-js/container/vector-profiler.h b/src/quick-lint-js/container/vector-profiler.h index c7c53684e8..bbbb1e0065 100644 --- a/src/quick-lint-js/container/vector-profiler.h +++ b/src/quick-lint-js/container/vector-profiler.h @@ -249,7 +249,7 @@ class Instrumented_Vector { } template - QLJS_FORCE_INLINE value_type &emplace_back(Args &&... args) { + QLJS_FORCE_INLINE value_type &emplace_back(Args &&...args) { this->data_.emplace_back(std::forward(args)...); this->add_instrumentation_entry(Vector_Instrumentation::Event::append); return this->data_.back(); diff --git a/src/quick-lint-js/container/vector.h b/src/quick-lint-js/container/vector.h index 9f6e8c1715..f11b9e7abe 100644 --- a/src/quick-lint-js/container/vector.h +++ b/src/quick-lint-js/container/vector.h @@ -243,7 +243,7 @@ class Raw_Vector { T &push_back(T &&value) { return this->emplace_back(std::move(value)); } template - T &emplace_back(Args &&... args) { + T &emplace_back(Args &&...args) { if (this->capacity_end_ == this->data_end_) { this->reserve_grow_by_at_least(1); } diff --git a/src/quick-lint-js/debug/find-debug-server.cpp b/src/quick-lint-js/debug/find-debug-server.cpp index 3fc7d97903..2ae3439aca 100644 --- a/src/quick-lint-js/debug/find-debug-server.cpp +++ b/src/quick-lint-js/debug/find-debug-server.cpp @@ -575,8 +575,8 @@ Span find_debug_servers(Monotonic_Allocator* allocator) { #endif #if !QLJS_CAN_FIND_DEBUG_SERVERS -Span find_debug_servers([ - [maybe_unused]] Monotonic_Allocator* allocator) { +Span find_debug_servers( + [[maybe_unused]] Monotonic_Allocator* allocator) { #warning "--debug-apps is not supported on this platform" return Span(); } diff --git a/src/quick-lint-js/debug/mongoose.h b/src/quick-lint-js/debug/mongoose.h index e467704a0b..9dc384127e 100644 --- a/src/quick-lint-js/debug/mongoose.h +++ b/src/quick-lint-js/debug/mongoose.h @@ -41,8 +41,8 @@ class Mongoose_Mgr { template mg_event_handler_t mongoose_callback() { - using Self = typename Member_Function_Pointer_Traits::Class_Type; + using Self = typename Member_Function_Pointer_Traits< + decltype(member_function_pointer)>::Class_Type; return [](::mg_connection *c, int ev, void *ev_data, void *fn_data) -> void { (static_cast(fn_data)->*member_function_pointer)(c, ev, ev_data); }; diff --git a/src/quick-lint-js/diag/diagnostic-types-2.h b/src/quick-lint-js/diag/diagnostic-types-2.h index 60ff0ceefe..3724369792 100644 --- a/src/quick-lint-js/diag/diagnostic-types-2.h +++ b/src/quick-lint-js/diag/diagnostic-types-2.h @@ -788,10 +788,10 @@ struct Diag_Duplicated_Cases_In_Switch_Statement { struct Diag_Fallthrough_Without_Comment_In_Switch { [[qljs::diag("E0427", Diagnostic_Severity::warning)]] // - [ - [qljs::message("missing 'break;' or '// fallthrough' comment between " - "statement and 'case'", - ARG(end_of_case))]] // + [[qljs::message( + "missing 'break;' or '// fallthrough' comment between " + "statement and 'case'", + ARG(end_of_case))]] // Source_Code_Span end_of_case; }; @@ -2281,10 +2281,10 @@ struct Diag_TypeScript_Delete_Cannot_Delete_Variables { struct Diag_TypeScript_Definite_Assignment_Assertion_In_Ambient_Context { [[qljs::diag("E0445", Diagnostic_Severity::error)]] // - [ - [qljs::message("'!' (definite assignment assertion) is not allowed on " - "'declare' variables", - ARG(definite_assignment_assertion))]] // + [[qljs::message( + "'!' (definite assignment assertion) is not allowed on " + "'declare' variables", + ARG(definite_assignment_assertion))]] // [[qljs::message("'declare' here", ARG(declare_keyword))]] // Source_Code_Span definite_assignment_assertion; @@ -2309,10 +2309,10 @@ struct Diag_TypeScript_Definite_Assignment_Assertion_On_Const { struct Diag_TypeScript_Definite_Assignment_Assertion_With_Initializer { [[qljs::diag("E0442", Diagnostic_Severity::error)]] // - [ - [qljs::message("'!' (definite assignment assertion) cannot be used with " - "an initial value", - ARG(definite_assignment_assertion))]] // + [[qljs::message( + "'!' (definite assignment assertion) cannot be used with " + "an initial value", + ARG(definite_assignment_assertion))]] // [[qljs::message("initial value was given here", ARG(equal))]] // Source_Code_Span definite_assignment_assertion; @@ -2321,10 +2321,10 @@ struct Diag_TypeScript_Definite_Assignment_Assertion_With_Initializer { struct Diag_TypeScript_Definite_Assignment_Assertion_Without_Type_Annotation { [[qljs::diag("E0443", Diagnostic_Severity::error)]] // - [ - [qljs::message("type annotation is required when using '!' (definite " - "assignment assertion)", - ARG(definite_assignment_assertion))]] // + [[qljs::message( + "type annotation is required when using '!' (definite " + "assignment assertion)", + ARG(definite_assignment_assertion))]] // Source_Code_Span definite_assignment_assertion; }; @@ -2586,10 +2586,10 @@ struct Diag_TypeScript_Declare_Field_Not_Allowed_In_JavaScript { struct Diag_TypeScript_Declare_Field_Cannot_Use_Private_Identifier { [[qljs::diag("E0416", Diagnostic_Severity::error)]] // - [ - [qljs::message("private identifiers are not allowed for 'declare' " - "fields; use 'private' instead", - ARG(private_identifier_hash))]] // + [[qljs::message( + "private identifiers are not allowed for 'declare' " + "fields; use 'private' instead", + ARG(private_identifier_hash))]] // [[qljs::message("'declare' here", ARG(declare_keyword))]] // Source_Code_Span private_identifier_hash; Source_Code_Span declare_keyword; @@ -3621,10 +3621,10 @@ struct Diag_TypeScript_Namespace_Alias_Cannot_Use_Import_Type { struct Diag_Confusing_Let_Call { [[qljs::diag("E0720", Diagnostic_Severity::warning)]] // - [ - [qljs::message("function 'let' call may be confused for destructuring; " - "remove parentheses to declare a variable", - ARG(let_function_call))]] // + [[qljs::message( + "function 'let' call may be confused for destructuring; " + "remove parentheses to declare a variable", + ARG(let_function_call))]] // Source_Code_Span let_function_call; }; diff --git a/src/quick-lint-js/fe/expression.h b/src/quick-lint-js/fe/expression.h index abc05faba7..04edd2d164 100644 --- a/src/quick-lint-js/fe/expression.h +++ b/src/quick-lint-js/fe/expression.h @@ -169,7 +169,7 @@ class Expression_Arena { is_winkable_v>; template - Expression *make_expression(Args &&... args); + Expression *make_expression(Args &&...args); template Array_Ptr make_array(Vector &&); @@ -184,7 +184,7 @@ class Expression_Arena { private: template - T *allocate(Args &&... args) { + T *allocate(Args &&...args) { static_assert(is_allocatable); return this->allocator_.new_object(std::forward(args)...); } @@ -329,7 +329,7 @@ Derived expression_cast(const Expression &p) { } template -Expression *Expression_Arena::make_expression(Args &&... args) { +Expression *Expression_Arena::make_expression(Args &&...args) { Expression *result(this->allocate(std::forward(args)...)); static_assert(is_allocatable); return result; diff --git a/src/quick-lint-js/fe/keyword-list.h b/src/quick-lint-js/fe/keyword-list.h index 529d204d44..d1f2006912 100644 --- a/src/quick-lint-js/fe/keyword-list.h +++ b/src/quick-lint-js/fe/keyword-list.h @@ -70,7 +70,7 @@ QLJS_KEYWORD(public) \ QLJS_KEYWORD(readonly) \ QLJS_KEYWORD(require) \ - QLJS_KEYWORD(return ) \ + QLJS_KEYWORD(return) \ QLJS_KEYWORD(satisfies) \ QLJS_KEYWORD(set) \ QLJS_KEYWORD(static) \ diff --git a/src/quick-lint-js/fe/lex.cpp b/src/quick-lint-js/fe/lex.cpp index 14f7385652..9eb2d546bc 100644 --- a/src/quick-lint-js/fe/lex.cpp +++ b/src/quick-lint-js/fe/lex.cpp @@ -2353,7 +2353,7 @@ bool Lexer::is_identifier_byte(Char8 byte) { switch (static_cast(byte)) { QLJS_CASE_DECIMAL_DIGIT: QLJS_CASE_IDENTIFIER_START: - // clang-format off + // clang-format off /* 0xc0 */ /* 0xc1 */ case 0xc2: case 0xc3: case 0xc4: case 0xc5: case 0xc6: case 0xc7: case 0xc8: case 0xc9: case 0xca: case 0xcb: case 0xcc: case 0xcd: case 0xce: case 0xcf: case 0xd0: case 0xd1: case 0xd2: case 0xd3: case 0xd4: case 0xd5: case 0xd6: case 0xd7: diff --git a/src/quick-lint-js/fe/parse-class.cpp b/src/quick-lint-js/fe/parse-class.cpp index a309c889a4..ec60b121b4 100644 --- a/src/quick-lint-js/fe/parse-class.cpp +++ b/src/quick-lint-js/fe/parse-class.cpp @@ -127,7 +127,7 @@ std::optional Parser::parse_class_and_optional_name() { case Token_Type::identifier: case Token_Type::kw_yield: // TODO(#707): Disallow classes named 'yield' in generator function. - class_name : { + class_name: { if (this->peek().type == Token_Type::kw_let) { this->diags_.add(Diag_Cannot_Declare_Class_Named_Let{ .name = this->peek().identifier_name().span()}); diff --git a/src/quick-lint-js/fe/parse-expression.cpp b/src/quick-lint-js/fe/parse-expression.cpp index 00f2b07005..ee26686f4e 100644 --- a/src/quick-lint-js/fe/parse-expression.cpp +++ b/src/quick-lint-js/fe/parse-expression.cpp @@ -518,11 +518,10 @@ Expression* Parser::parse_primary_expression(Parse_Visitor_Base& v, Expression* ast = type == Token_Type::kw_delete ? this->make_expression(child, operator_span) - : type == Token_Type::kw_typeof - ? this->make_expression(child, - operator_span) - : this->make_expression( - child, operator_span); + : type == Token_Type::kw_typeof + ? this->make_expression(child, operator_span) + : this->make_expression(child, + operator_span); return ast; } @@ -1683,7 +1682,7 @@ Expression* Parser::parse_expression_remainder(Parse_Visitor_Base& v, // x += y // x[y] &&= z QLJS_CASE_COMPOUND_ASSIGNMENT_OPERATOR: - QLJS_CASE_CONDITIONAL_ASSIGNMENT_OPERATOR : { + QLJS_CASE_CONDITIONAL_ASSIGNMENT_OPERATOR: { if (!prec.math_or_logical_or_assignment) { break; } @@ -3016,7 +3015,7 @@ Expression* Parser::parse_object_literal(Parse_Visitor_Base& v) { break; } - QLJS_CASE_RESERVED_KEYWORD_EXCEPT_AWAIT_AND_YIELD : { + QLJS_CASE_RESERVED_KEYWORD_EXCEPT_AWAIT_AND_YIELD: { Expression* value = this->make_expression(key_token.span()); 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, .opening_tag_name = tag_namespace ? Source_Code_Span(tag_namespace->span().begin(), tag_end) - : !tag_members.empty() - ? Source_Code_Span(tag_members.front().span().begin(), - tag_end) - : tag ? tag->span() : Source_Code_Span::unit(tag_end), + : !tag_members.empty() + ? Source_Code_Span(tag_members.front().span().begin(), + tag_end) + : tag ? tag->span() + : Source_Code_Span::unit(tag_end), .closing_tag_name = closing_tag_begin <= closing_tag_end ? Source_Code_Span(closing_tag_begin, closing_tag_end) diff --git a/src/quick-lint-js/fe/parse-statement.cpp b/src/quick-lint-js/fe/parse-statement.cpp index f4acbd6a5f..5649bff48f 100644 --- a/src/quick-lint-js/fe/parse-statement.cpp +++ b/src/quick-lint-js/fe/parse-statement.cpp @@ -5012,8 +5012,7 @@ void Parser::parse_and_visit_named_exports( goto named_export; named_export: - QLJS_CASE_CONTEXTUAL_KEYWORD_EXCEPT_ASYNC_AND_GET_AND_SET_AND_STATIC_AND_TYPE - : + QLJS_CASE_CONTEXTUAL_KEYWORD_EXCEPT_ASYNC_AND_GET_AND_SET_AND_STATIC_AND_TYPE: case Token_Type::identifier: case Token_Type::kw_async: case Token_Type::kw_get: @@ -5701,7 +5700,7 @@ void Parser::parse_and_visit_let_bindings( // let switch = 3; // Invalid. // let if (x) {} // Invalid. - QLJS_CASE_RESERVED_KEYWORD_EXCEPT_AWAIT_AND_YIELD : { + QLJS_CASE_RESERVED_KEYWORD_EXCEPT_AWAIT_AND_YIELD: { Source_Code_Span keyword_span = this->peek().span(); Lexer_Transaction transaction = this->lexer_.begin_transaction(); this->skip(); diff --git a/src/quick-lint-js/fe/parse.h b/src/quick-lint-js/fe/parse.h index 27d280269f..e2409236f3 100644 --- a/src/quick-lint-js/fe/parse.h +++ b/src/quick-lint-js/fe/parse.h @@ -1011,7 +1011,7 @@ class Parser { private: template - Expression *make_expression(Args &&... args) { + Expression *make_expression(Args &&...args) { return this->expressions_.make_expression( std::forward(args)...); } diff --git a/src/quick-lint-js/fe/token.h b/src/quick-lint-js/fe/token.h index faa386a891..2796b1f2d0 100644 --- a/src/quick-lint-js/fe/token.h +++ b/src/quick-lint-js/fe/token.h @@ -121,10 +121,9 @@ case ::quick_lint_js::Token_Type::kw_of: \ case ::quick_lint_js::Token_Type::kw_satisfies -#define QLJS_CASE_CONTEXTUAL_KEYWORD_EXCEPT_ASYNC_AND_GET_AND_SET \ - QLJS_CASE_CONTEXTUAL_KEYWORD_EXCEPT_ASYNC_AND_GET_AND_SET_AND_STATIC_AND_TYPE \ - : \ - case ::quick_lint_js::Token_Type::kw_static: \ +#define QLJS_CASE_CONTEXTUAL_KEYWORD_EXCEPT_ASYNC_AND_GET_AND_SET \ + QLJS_CASE_CONTEXTUAL_KEYWORD_EXCEPT_ASYNC_AND_GET_AND_SET_AND_STATIC_AND_TYPE: \ + case ::quick_lint_js::Token_Type::kw_static: \ case ::quick_lint_js::Token_Type::kw_type // Keywords which are sometimes treated as identifiers; i.e. identifiers which diff --git a/src/quick-lint-js/fe/variable-analyzer.cpp b/src/quick-lint-js/fe/variable-analyzer.cpp index 743a0148e3..97d2582a45 100644 --- a/src/quick-lint-js/fe/variable-analyzer.cpp +++ b/src/quick-lint-js/fe/variable-analyzer.cpp @@ -656,8 +656,8 @@ void Variable_Analyzer::propagate_variable_uses_to_parent_scope( bool consume_arguments) { // Found_Variable_Type is either Declared_Variable* or // std::optional. - using Found_Variable_Type = typename std::decay_t::Found_Variable_Type; + using Found_Variable_Type = typename std::decay_t< + decltype(Parent_Scope::declared_variables)>::Found_Variable_Type; constexpr bool parent_scope_is_global_scope = std::is_same_v; diff --git a/src/quick-lint-js/io/file-canonical.cpp b/src/quick-lint-js/io/file-canonical.cpp index aa546b0172..5f7db59c0e 100644 --- a/src/quick-lint-js/io/file-canonical.cpp +++ b/src/quick-lint-js/io/file-canonical.cpp @@ -377,12 +377,12 @@ class Path_Canonicalizer_Base { // Extra components and trailing slashes are not allowed for regular // files, FIFOs, etc. if (!path_to_process_.empty()) { - return failed_result(Canonicalizing_Path_IO_Error { - .canonicalizing_path = canonical_, + return failed_result(Canonicalizing_Path_IO_Error{ + .canonicalizing_path = canonical_, #if QLJS_HAVE_UNISTD_H - .io_error = POSIX_File_IO_Error{ENOTDIR}, + .io_error = POSIX_File_IO_Error{ENOTDIR}, #elif QLJS_HAVE_WINDOWS_H - .io_error = Windows_File_IO_Error{ERROR_DIRECTORY}, + .io_error = Windows_File_IO_Error{ERROR_DIRECTORY}, #else #error "Unsupported platform" #endif diff --git a/src/quick-lint-js/io/file.cpp b/src/quick-lint-js/io/file.cpp index c990b91ebc..6128c4f3d5 100644 --- a/src/quick-lint-js/io/file.cpp +++ b/src/quick-lint-js/io/file.cpp @@ -590,10 +590,9 @@ void create_windows_junction_or_exit(const char *path, const char *target) { /*hTemplateFile=*/nullptr)); std::size_t reparse_data_data_size = - offsetof( - decltype( - std::declval<::REPARSE_DATA_BUFFER>().MountPointReparseBuffer), - PathBuffer) + + offsetof(decltype(std::declval<::REPARSE_DATA_BUFFER>() + .MountPointReparseBuffer), + PathBuffer) + // SubsituteName. +1 for null terminator. (wtarget->size() + 1) * sizeof(wchar_t) + // PrintName. Empty string with null terminator. diff --git a/src/quick-lint-js/logging/trace-types.h b/src/quick-lint-js/logging/trace-types.h index 16f7528c53..84d879d8fb 100644 --- a/src/quick-lint-js/logging/trace-types.h +++ b/src/quick-lint-js/logging/trace-types.h @@ -121,8 +121,7 @@ struct Trace_Event_VSCode_Document_Changed { Trace_Document_ID document_id; // Cannot be 0. [[qljs::trace_ctf_size_name("change_count")]] // - Span> - changes; + Span> changes; friend bool operator==(const Trace_Event_VSCode_Document_Changed& lhs, const Trace_Event_VSCode_Document_Changed& rhs) { @@ -184,8 +183,7 @@ struct Trace_Vector_Max_Size_Histogram_By_Owner_Entry { [[qljs::trace_zero_terminated]] // String8_View owner; [[qljs::trace_ctf_size_name("max_size_entry_count")]] // - Span - max_size_entries; + Span max_size_entries; friend bool operator==(const Trace_Vector_Max_Size_Histogram_By_Owner_Entry&, const Trace_Vector_Max_Size_Histogram_By_Owner_Entry&); @@ -197,8 +195,7 @@ struct Trace_Event_Vector_Max_Size_Histogram_By_Owner { static constexpr std::uint8_t id = 0x07; [[qljs::trace_ctf_size_name("entry_count")]] // - Span - entries; + Span entries; friend bool operator==(const Trace_Event_Vector_Max_Size_Histogram_By_Owner&, const Trace_Event_Vector_Max_Size_Histogram_By_Owner&); @@ -243,8 +240,7 @@ struct Trace_Event_LSP_Documents { static constexpr std::uint8_t id = 0x09; [[qljs::trace_ctf_size_name("document_count")]] // - Span - documents; + Span documents; friend bool operator==(const Trace_Event_LSP_Documents&, const Trace_Event_LSP_Documents&); diff --git a/src/quick-lint-js/port/memory-resource.cpp b/src/quick-lint-js/port/memory-resource.cpp index 726d017e95..5c1259a061 100644 --- a/src/quick-lint-js/port/memory-resource.cpp +++ b/src/quick-lint-js/port/memory-resource.cpp @@ -12,7 +12,7 @@ class New_Delete_Resource_Impl : public Memory_Resource { public: void* do_allocate(std::size_t bytes, std::size_t alignment) override { #if QLJS_HAVE_SIZED_ALIGNED_NEW - return ::operator new (bytes, std::align_val_t{alignment}); + return ::operator new(bytes, std::align_val_t{alignment}); #else QLJS_ASSERT(alignment <= __STDCPP_DEFAULT_NEW_ALIGNMENT__); return ::operator new(bytes); @@ -22,7 +22,7 @@ class New_Delete_Resource_Impl : public Memory_Resource { void do_deallocate(void* p, std::size_t bytes, std::size_t alignment) override { #if QLJS_HAVE_SIZED_ALIGNED_DELETE - ::operator delete (p, bytes, std::align_val_t{alignment}); + ::operator delete(p, bytes, std::align_val_t{alignment}); #else QLJS_ASSERT(alignment <= __STDCPP_DEFAULT_NEW_ALIGNMENT__); static_cast(bytes); diff --git a/src/quick-lint-js/reflection/cxx-parser.cpp b/src/quick-lint-js/reflection/cxx-parser.cpp index 3649cd48f7..d43e97dcf1 100644 --- a/src/quick-lint-js/reflection/cxx-parser.cpp +++ b/src/quick-lint-js/reflection/cxx-parser.cpp @@ -358,7 +358,7 @@ void CXX_Lexer::error_at_v(const Char8* location, const char* message, } QLJS_WARNING_POP - // clang-format off +// clang-format off [[noreturn]] void CXX_Lexer::fatal() { this->fatal("error: failed to lex"); } diff --git a/src/quick-lint-js/util/utf-8.cpp b/src/quick-lint-js/util/utf-8.cpp index cc6e7355b7..b7e52fe84c 100644 --- a/src/quick-lint-js/util/utf-8.cpp +++ b/src/quick-lint-js/util/utf-8.cpp @@ -40,8 +40,8 @@ namespace { QLJS_WARNING_PUSH QLJS_WARNING_IGNORE_GCC("-Wattributes") // See: https://www.unicode.org/versions/Unicode11.0.0/ch03.pdf -[[gnu::always_inline]] Decode_UTF8_Result - decode_utf_8_inline(Padded_String_View input) { +[[gnu::always_inline]] Decode_UTF8_Result decode_utf_8_inline( + Padded_String_View input) { auto is_continuation_byte = [](std::uint8_t byte) -> bool { return (byte & 0b1100'0000) == 0b1000'0000; }; @@ -106,9 +106,9 @@ QLJS_WARNING_IGNORE_GCC("-Wattributes") // 4-byte sequence (0xf0..0xf7). static_assert(Padded_String::padding_size >= 3); bool byte_0_ok = c[0] <= 0xf4; - bool byte_1_ok = (c[0] == 0xf0 ? 0x90 <= c[1] && c[1] <= 0xbf - : c[0] == 0xf4 ? 0x80 <= c[1] && c[1] <= 0x8f - : is_continuation_byte(c[1])); + bool byte_1_ok = (c[0] == 0xf0 ? 0x90 <= c[1] && c[1] <= 0xbf + : c[0] == 0xf4 ? 0x80 <= c[1] && c[1] <= 0x8f + : is_continuation_byte(c[1])); bool byte_2_ok = is_continuation_byte(c[2]); bool byte_3_ok = is_continuation_byte(c[3]); if (byte_0_ok && byte_1_ok && byte_2_ok && byte_3_ok) { diff --git a/test/quick-lint-js/diag-matcher.h b/test/quick-lint-js/diag-matcher.h index 405c6549d0..abe211de42 100644 --- a/test/quick-lint-js/diag-matcher.h +++ b/test/quick-lint-js/diag-matcher.h @@ -42,12 +42,12 @@ struct Diag_Matcher_Arg { // Create a Diag_Matcher_Arg from a Diag_ struct type and the name of a member // of that struct. -#define DIAG_MATCHER_ARG(type, member) \ - (::quick_lint_js::Diag_Matcher_Arg{ \ - #member, \ - offsetof(type, member), \ - ::quick_lint_js::get_diagnostic_message_arg_type(), \ +#define DIAG_MATCHER_ARG(type, member) \ + (::quick_lint_js::Diag_Matcher_Arg{ \ + #member, \ + offsetof(type, member), \ + ::quick_lint_js::get_diagnostic_message_arg_type< \ + decltype(type::member)>(), \ }) struct Any_Diag_Pointer { diff --git a/test/quick-lint-js/filesystem-test.cpp b/test/quick-lint-js/filesystem-test.cpp index 133d399344..4c5de043ad 100644 --- a/test/quick-lint-js/filesystem-test.cpp +++ b/test/quick-lint-js/filesystem-test.cpp @@ -72,8 +72,8 @@ void delete_directory_recursive(const std::string& path) { #endif } - void visit_directory_pre([ - [maybe_unused]] const std::string& path) override { + void visit_directory_pre( + [[maybe_unused]] const std::string& path) override { #if QLJS_HAVE_UNISTD_H // Make sure the directory is traversable before traversing. int rc = ::chmod(path.c_str(), 0700); diff --git a/test/test-event-loop.cpp b/test/test-event-loop.cpp index a61f63bc1b..875b74a9ac 100644 --- a/test/test-event-loop.cpp +++ b/test/test-event-loop.cpp @@ -1372,13 +1372,13 @@ void write_full_message(Platform_File_Ref file, String8_View message) { ::testing::internal::ParamGenerator event_loop_factories = ::testing::ValuesIn({ #if QLJS_HAVE_KQUEUE - QLJS_EVENT_LOOP_FACTORY(Event_Loop_Kqueue), + QLJS_EVENT_LOOP_FACTORY(Event_Loop_Kqueue), #endif #if QLJS_HAVE_POLL - QLJS_EVENT_LOOP_FACTORY(Event_Loop_Poll), + QLJS_EVENT_LOOP_FACTORY(Event_Loop_Poll), #endif #if defined(_WIN32) - QLJS_EVENT_LOOP_FACTORY(Event_Loop_Windows), + QLJS_EVENT_LOOP_FACTORY(Event_Loop_Windows), #endif }); INSTANTIATE_TEST_SUITE_P(, Test_Event_Loop, event_loop_factories, diff --git a/test/test-parse-expression.cpp b/test/test-parse-expression.cpp index b9573297c1..56e0c3c41c 100644 --- a/test/test-parse-expression.cpp +++ b/test/test-parse-expression.cpp @@ -935,7 +935,7 @@ TEST_F(Test_Parse_Expression, }; for (const Test_Case& test : { - // clang-format off + // clang-format off Test_Case // 'await' is either an identifier or a unary operator: @@ -1051,7 +1051,7 @@ TEST_F(Test_Parse_Expression, {u8"await++;"_sv, "rwunarysuffix(var await)", nullptr}, {u8"await--;"_sv, "rwunarysuffix(var await)", nullptr}, #endif - // clang-format on + // clang-format on }) { SCOPED_TRACE(out_string8(test.code)); diff --git a/test/test-trace-reader-writer.cpp b/test/test-trace-reader-writer.cpp index c15c939429..027dee1d37 100644 --- a/test/test-trace-reader-writer.cpp +++ b/test/test-trace-reader-writer.cpp @@ -340,7 +340,7 @@ TEST(Test_Trace_Reader_Writer, event_vector_max_size_histogram_by_owner) { 1, 0, 0, 0, 0, 0, 0, 0, // Count 3, 0, 0, 0, 0, 0, 0, 0, // Max size entry 0 max size 7, 0, 0, 0, 0, 0, 0, 0, // Max size entry 0 count - // clang-format on + // clang-format on }); } diff --git a/tools/format b/tools/format index 843e07c932..ac6b017650 100755 --- a/tools/format +++ b/tools/format @@ -13,9 +13,9 @@ source tools/files.sh clang_format_version="$(clang-format --version 2>/dev/null || :)" if [[ ${clang_format_version} = '' ]]; then - printf 'warning: clang-format is not installed. Version 9.0.x is required.\n' >&2 -elif [[ ${clang_format_version} != *"version 9"* ]]; then - printf 'warning: quick-lint-js is formatted using the clang-format tool version 9.0.x and you are using %s\n' "$clang_format_version" >&2 + printf 'warning: clang-format is not installed. Version 18.1.8 is required.\n' >&2 +elif [[ ${clang_format_version} != *"version 18.1.8"* ]]; then + printf 'warning: quick-lint-js is formatted using the clang-format tool version 18.1.8 and you are using %s\n' "$clang_format_version" >&2 fi parallelism=$(nproc 2>/dev/null || :) diff --git a/website/public/contribute/coding-standards/index.ejs.html b/website/public/contribute/coding-standards/index.ejs.html index 6e6404d452..a04af77026 100644 --- a/website/public/contribute/coding-standards/index.ejs.html +++ b/website/public/contribute/coding-standards/index.ejs.html @@ -25,12 +25,12 @@

C++ code

clang-format - tool, version 9.0.x. During development, use + tool, version 18.1.8. During development, use clang-format in one of two ways: