[libcxx-commits] [flang] [compiler-rt] [libunwind] [libcxx] [clang] [lld] [clang-tools-extra] [lldb] [libc] [llvm] Fix clang to recognize new C23 modifiers %w and %wf when printing (PR #71771)
Aaron Ballman via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Dec 1 04:54:06 PST 2023
================
@@ -286,7 +286,33 @@ clang::analyze_format_string::ParseLengthModifier(FormatSpecifier &FS,
lmKind = LengthModifier::AsInt3264;
break;
case 'w':
- lmKind = LengthModifier::AsWide; ++I; break;
+ ++I;
+ if (I == E) return false;
+ if (*I == 'f') {
+ lmKind = LengthModifier::AsWideFast;
+ ++I;
+ } else {
+ lmKind = LengthModifier::AsWide;
+ }
+
+ if (I == E) return false;
+ int s = 0;
+ while (unsigned(*I - '0') <= 9) {
+ s = 10 * s + unsigned(*I - '0');
+ ++I;
+ }
+
+ // s == 0 is MSVCRT case, like l but only for c, C, s, S, or Z on windows
+ // s != 0 for b, d, i, o, u, x, or X when a size followed(like 8, 16, 32 or 64)
+ if (s != 0) {
----------------
AaronBallman wrote:
Should we return false in the case `s == 0`?
It would be good to add test coverage for parsing failures.
https://github.com/llvm/llvm-project/pull/71771
More information about the libcxx-commits
mailing list