FileCheck [8/12]: Define numeric var from expr
authorThomas Preud'homme <thomasp@graphcore.ai>
Wed, 24 Jul 2019 12:38:22 +0000 (12:38 +0000)
committerThomas Preud'homme <thomasp@graphcore.ai>
Wed, 24 Jul 2019 12:38:22 +0000 (12:38 +0000)
commit4cd9b853b5ae3f569683cdba955cd70c39a7bbe7
treee9076e6c90b01ffa446fda580570b8419f181f1f
parent7d79b552e36dc94f81231849443dcb7b63aa8457
FileCheck [8/12]: Define numeric var from expr

Summary:
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)
    - GraphCore (changes in later versions of revision D55940 and
                 in new revision created off D55940)

Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk

Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D60388

> llvm-svn: 366860

llvm-svn: 366897
llvm/docs/CommandGuide/FileCheck.rst
llvm/include/llvm/Support/FileCheck.h
llvm/lib/Support/FileCheck.cpp
llvm/test/FileCheck/numeric-defines-diagnostics.txt
llvm/test/FileCheck/numeric-defines.txt
llvm/test/FileCheck/numeric-expression.txt
llvm/unittests/Support/FileCheckTest.cpp