[PATCH] D81667: [RFC, FileCheck] Add precision to format specifier

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 18 01:35:58 PDT 2020


jhenderson added a comment.

In D81667#2100079 <https://reviews.llvm.org/D81667#2100079>, @thopre wrote:

> In D81667#2100049 <https://reviews.llvm.org/D81667#2100049>, @jhenderson wrote:
>
> > In D81667#2098944 <https://reviews.llvm.org/D81667#2098944>, @jdenny wrote:
> >
> > > > I'd expect 0x[[#%.8x, ADDR:]] to match 00001234 or FFFFFFFF12345678 but not 1234 due to there not being enough digits.
> > >
> > > OK, it would expect a value that could have been printed by printf with `%.8x`.
> >
> >
> > FWIW, this is what I'm imagining the overall behaviour to be. If printf could have produced the output for a given format specifier, we should accept it, and conversely if it can't produce the output for a given format specifier, we shouldn't accept it.
> >
> > I'm not sure whether we should consume all digits before applying the precision check or not though. I can see benefits for either side.
>
>
> We currently accept numbers with leading zeroes but printf would not produce those without a precision. Should we start by fixing this then?


I think we need leading zeros to be accepted until we have an alternative in place. Otherwise, there may be existing tests that rely on the current behaviour which we can't migrate. I think that means a rough order of: 1) Add precision support; 2) Migrate existing tests to use it where needed; 3) Stop accepting leading zeros except via precision. 2) and 3) can probably be done at the same time. We should only do them as part of 1) if it's harder to keep them separate, in my opinion.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81667/new/

https://reviews.llvm.org/D81667





More information about the llvm-commits mailing list