[PATCH] D49084: FileCheck: Add support for variable expressions

Thomas Preud'homme via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 20 09:51:24 PST 2018


thopre updated this revision to Diff 179094.
thopre added a comment.
Herald added a subscriber: kristina.

FileCheck: Add support for numeric variables and expressions

Summary:
Sometimes there's a need to verify output which contain several numeric
values that are related by a numeric expression. For example, one might
want to check that two numbers are consecutive but accept any value for
the smallest of the two.

This patch introduces support for numeric variables and expressions to
express this sort of constraint. A user can then define variables to
have a numeric value and write numeric expression using those variable.
A matching format specifier allows to match numbers in a variety of
format: signed and unsigned decimal numbers as well as hex number in
lower or capital case. For example, matching 2 consecutive signed
decimal integers separated by a space is done via:

[[%d,#N:]] #N+1

The syntax is modeled after that of use and definition of the already
supported variables flavour (renamed pattern variable for clarity) and
pseudo variable by adding a # just after the double opening square
bracket [[. Full details of the syntax can be found in the updated
docs/CommandGuide/FileCheck.rst.

One notable pitfall is that CHECK pattern with numeric expression using
variable defined on the same line might fail to match despite there be a
line which satisfy the conditions expressed by those numeric expression.
This is due to lack of needed support from the regular expression engine
that FileCheck relies on and is documented in the updated
docs/CommandGuide/FileCheck.rst as well as possible workaround.

Reviewers: probinson, arichardson, jhenderson, rnk, jdenny

Subscribers: llvm-commits


Repository:
  rL LLVM

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

https://reviews.llvm.org/D49084

Files:
  docs/CommandGuide/FileCheck.rst
  include/llvm/Support/FileCheck.h
  lib/Support/FileCheck.cpp
  test/FileCheck/defines.txt
  test/FileCheck/numeric-expression.txt
  test/FileCheck/regex-scope.txt
  test/FileCheck/var-scope.txt
  test/FileCheck/verbose.txt

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49084.179094.patch
Type: text/x-patch
Size: 126288 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181220/e416951d/attachment.bin>


More information about the llvm-commits mailing list