[all-commits] [llvm/llvm-project] 402eb2: [libc++][format] Improves diagnostics.
Mark de Wever via All-commits
all-commits at lists.llvm.org
Tue Jul 18 12:11:32 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 402eb2ef099f6b5ea71420399f5236eb7faf9c5f
https://github.com/llvm/llvm-project/commit/402eb2ef099f6b5ea71420399f5236eb7faf9c5f
Author: Mark de Wever <koraq at xs4all.nl>
Date: 2023-07-18 (Tue, 18 Jul 2023)
Changed paths:
M libcxx/include/__chrono/formatter.h
M libcxx/include/__chrono/parser_std_format_spec.h
M libcxx/include/__format/format_functions.h
M libcxx/include/__format/format_string.h
M libcxx/include/__format/formatter_tuple.h
M libcxx/include/__format/parser_std_format_spec.h
M libcxx/include/__format/range_formatter.h
M libcxx/test/std/containers/container.adaptors/container.adaptors.format/format.functions.tests.h
M libcxx/test/std/containers/sequences/vector.bool/vector.bool.fmt/format.functions.tests.h
M libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.tests.h
M libcxx/test/std/time/time.syn/formatter.day.pass.cpp
M libcxx/test/std/time/time.syn/formatter.duration.pass.cpp
M libcxx/test/std/time/time.syn/formatter.file_time.pass.cpp
M libcxx/test/std/time/time.syn/formatter.hh_mm_ss.pass.cpp
M libcxx/test/std/time/time.syn/formatter.local_time.pass.cpp
M libcxx/test/std/time/time.syn/formatter.month.pass.cpp
M libcxx/test/std/time/time.syn/formatter.month_day.pass.cpp
M libcxx/test/std/time/time.syn/formatter.month_day_last.pass.cpp
M libcxx/test/std/time/time.syn/formatter.month_weekday.pass.cpp
M libcxx/test/std/time/time.syn/formatter.sys_time.pass.cpp
M libcxx/test/std/time/time.syn/formatter.weekday.pass.cpp
M libcxx/test/std/time/time.syn/formatter.weekday_index.pass.cpp
M libcxx/test/std/time/time.syn/formatter.weekday_last.pass.cpp
M libcxx/test/std/time/time.syn/formatter.year.pass.cpp
M libcxx/test/std/time/time.syn/formatter.year_month.pass.cpp
M libcxx/test/std/time/time.syn/formatter.year_month_day.pass.cpp
M libcxx/test/std/time/time.syn/formatter.year_month_day_last.pass.cpp
M libcxx/test/std/time/time.syn/formatter.year_month_weekday.pass.cpp
M libcxx/test/std/time/time.syn/formatter.year_month_weekday_last.pass.cpp
M libcxx/test/std/utilities/format/format.functions/fill.unicode.pass.cpp
M libcxx/test/std/utilities/format/format.functions/format_tests.h
M libcxx/test/std/utilities/format/format.range/format.range.fmtmap/format.functions.tests.h
M libcxx/test/std/utilities/format/format.range/format.range.fmtset/format.functions.tests.h
M libcxx/test/std/utilities/format/format.range/format.range.fmtstr/format.functions.tests.h
M libcxx/test/std/utilities/format/format.range/format.range.formatter/format.functions.tests.h
M libcxx/test/std/utilities/format/format.tuple/format.functions.tests.h
M libcxx/test/support/format.functions.common.h
Log Message:
-----------
[libc++][format] Improves diagnostics.
Improves both the compile-time and run-time errors.
At compile-time it does a bit more work to get more specific errors.
This could be done at run-time too, but that has a performance penalty.
Since it's expected most use-cases use format* instead of vformat* the
compile-time errors are more common.
For example when using
std::format_to("{:-c}", 42);
Before compile output would contain
std::__throw_format_error("The format-spec should consume the input or end with a '}'");
Now it contains
std::__throw_format_error("The format specifier does not allow the sign option");
Given a better indication the sign option is not allowed. Note the
output is still not user-friendly; C++ doesn't have good facilities to
generate nice messages from the library.
In general all messages have been reviewed and improved, using a more
consistent style and using less terms used in the standard. For example
format-spec -> format specifier
arg-id -> argument index
Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D152624
More information about the All-commits
mailing list