1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 06:48:12 +00:00

AK+Userland: Extend the compiletime format string check to other functions

Thanks to @trflynn89 for the neat implicit consteval ctor trick!
This allows us to basically slap `CheckedFormatString` on any
formatting function, and have its format argument checked at compiletime.

Note that there is a validator bug where it doesn't parse inner replaced
fields like `{:~>{}}` correctly (what should be 'left align with next
argument as size' is parsed as `{:~>{` following a literal closing
brace), so the compiletime checks are disabled on these temporarily by
forcing them to be StringViews.

This commit also removes the now unused `AK::StringLiteral` type (which
was introduced for use with NTTP strings).
This commit is contained in:
AnotherTest 2021-02-22 02:37:24 +03:30 committed by Andreas Kling
parent 29c8d34be7
commit 347d741afb
6 changed files with 277 additions and 229 deletions

View file

@ -1894,16 +1894,16 @@ void Shell::possibly_print_error() const
warn("\x1b[31m");
size_t length_written_so_far = 0;
if (line == (i64)source_position.position->start_line.line_number) {
warn("{:~>{}}", "", 5 + source_position.position->start_line.line_column);
warn(StringView { "{:~>{}}" }, "", 5 + source_position.position->start_line.line_column);
length_written_so_far += source_position.position->start_line.line_column;
} else {
warn("{:~>{}}", "", 5);
warn(StringView { "{:~>{}}" }, "", 5);
}
if (line == (i64)source_position.position->end_line.line_number) {
warn("{:^>{}}", "", source_position.position->end_line.line_column - length_written_so_far);
warn(StringView { "{:^>{}}" }, "", source_position.position->end_line.line_column - length_written_so_far);
length_written_so_far += source_position.position->start_line.line_column;
} else {
warn("{:^>{}}", "", current_line.length() - length_written_so_far);
warn(StringView { "{:^>{}}" }, "", current_line.length() - length_written_so_far);
}
warnln("\x1b[0m");
}