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

Thomas Preud'homme via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 17 10:13:31 PDT 2020


thopre added a comment.

In D81667#2098443 <https://reviews.llvm.org/D81667#2098443>, @jdenny wrote:

> > Should the regex wildcard for a numeric variable definition with empty expression also respect the precision, i.e. #%.5u, VAR2: would be matched by (([1-9][0-9]+)? [0-9]{1,5})
>
> I believe I followed the comments about matching behavior for an empty expression (scanf-like) vs. an expression (printf-like).  So the above question is about whether, in the empty-expression case, it's worthwhile to support a precision specified by `.` even though scanf does not support that.  Right?


Correct.

> I don't understand the above regex due to the space character after the `?`.  Was that intended?

No, fixed now.

> Can you give some example inputs and explain the intended matching behavior for `#%.5u, VAR2:`?  Why is this behavior needed in FileCheck but not in scanf?

Say the directive is:

CHECK: Address #%.8x,ADDR: is aligned

and the input text is:

Address 12345678 is aligned

I'd expect the directive to match and the value in ADDR to be 0x12345678. Now if the input text was:

Address FFFFFFFF12345678

I'd expect the directive to fail. If the directive was #%x, ADDR: the first input would have led to the same outcome but the second input would have led the directive matching and the value in ADDR to be 0xFFFFFFFF12345678.

Besides whether this is a useful feature, it makes for easier parsing and consistency in the syntax (no difference between variables defined from an expression where the precision would be allowed and variables defined from an empty expression where precision would not be allowed).


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