================
@@ -33,16 +33,17 @@ FormatStringHandler::~FormatStringHandler() {}
// scanf format strings.
//===----------------------------------------------------------------------===//
-OptionalAmount
-clang::analyze_format_string::ParseAmount(const char *&Beg, const char *E) {
+OptionalAmount clang::analyze_format_string::ParseAmount(
+ const char *&Beg, const char *E,
+ const llvm::TextEncodingConverter &FormatStrConverter) {
const char *I = Beg;
UpdateOnReturn <const char*> UpdateBeg(Beg, I);
unsigned accumulator = 0;
bool hasDigits = false;
for ( ; I != E; ++I) {
- char c = *I;
+ char c = FormatStrConverter.convert(*I);
----------------
s-barannikov wrote:
> If this is the only issue, returning `std::optional` from `convert` would
> solve it. Or it should be documented that 'all zeros' input is a special
> value and should not be passed in (and asserted in the implementation).
I tried adding the assertion, but that didn't work out. Null character can
appear anywhere in the format string, and the assertion may trigger on any call
to `convert`. I guess returning 0 for non-ascii characters (as it is now) is
the simpliest solution; we only need to make sure we don't use the result of
the conversion in comparison against zero.
https://github.com/llvm/llvm-project/pull/169803
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits