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

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 16 02:43:37 PDT 2020


jhenderson added a comment.

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

> In D81667#2092260 <https://reviews.llvm.org/D81667#2092260>, @jhenderson wrote:
>
> > I think I agree with your conclusions. More generally, I think we should be permissive, where permissiveness is not going to be surprising (i.e. no explicit format specifier seems reasonable in the general context), and should follow `scanf` style format specifiers where reasonable. If I follow it right, it would therefore be possible to specify a 16-digit hex field with `%.16x`, right? Could you clarify what the motivation of the "with empty expression" bit is for? Is that just because when there is an empty expression, your regex is incorrect, or something else?
>
>
> When only using a numeric expression, numeric substitution blocks are behaving as printf: print a value as text to be matched against the input. When defining a variable with an empty expression (the majority of definition cases), it behaves more like a scanf. Only printf support a precision in its syntax. Scanf doesn't support it. This is the main reason why I ask the question. It is also the case that we currently allow leading zeros when matching an unknown numeric value for a numeric variable definition with empty expression.
>
> I think the case of a variable defined from an expression is a special case since you are matching something specific so in itself doesn't mandate extending the precision to variable definition with empty expression. However I think allowing a precision when matching an unknown variable is both useful and makes for syntax consistency.
>
> To answer your earlier question, yes it'll be possible to match a 16-bit hex with #%.16x,VAR1: or an 8-bit hex with #%.8x, VAR2:. However #%.8, VAR1 will print all 16-bit of VAR1, same as printf. Does that seem reasonable or should we deviate from printf and give an error in such a case?


I think that seems reasonable to me overall. Thanks for explaining.


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