[PATCH] D60388: FileCheck [8/12]: Define numeric var from expr

Thomas Preud'homme via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 7 16:22:46 PDT 2019


thopre created this revision.
thopre added reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
thopre added a parent revision: D60387: FileCheck [7/12]: Arbitrary long numeric expressions.

This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch lift the restriction for a
numeric expression to either be a variable definition or a numeric
expression to try to match.

This commit allows a numeric variable to be set to the result of the
evaluation of a numeric expression after it has been matched
successfully. When it happens, the variable is allowed to be used on
the same line since its value is known at match time.

It also makes use of this possibility to reuse the parsing code to
parse a command-line definition by crafting a mirror string of the
-D option with the equal sign replaced by a colon sign, e.g. for option
'-D#NUMVAL=10' it creates the string
'-D#NUMVAL=10 (parsed as #NUMVAL:10)' where the numeric expression
is parsed to define NUMVAL. This result in a few tests needing updating
for the location diagnostics on top of the tests for the new feature.

It also enables empty numeric expression which match any number without
defining a variable. This is done here rather than in commit #5 of the
patch series because it requires to dissociate automatic regex insertion
in RegExStr from variable definition which would make commit #5 even
bigger than it already is.

Copyright:

- Linaro (changes up to diff 183612 of revision D55940 <https://reviews.llvm.org/D55940>)
- GraphCore (changes in later versions of revision D55940 <https://reviews.llvm.org/D55940> and in new revision created off D55940 <https://reviews.llvm.org/D55940>)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60388

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60388.194083.patch
Type: text/x-patch
Size: 24750 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190407/dbc99430/attachment.bin>


More information about the llvm-commits mailing list