FileCheck [2/12]: Stricter parsing of -D option
authorThomas Preud'homme <thomasp@graphcore.ai>
Mon, 29 Apr 2019 13:32:36 +0000 (13:32 +0000)
committerThomas Preud'homme <thomasp@graphcore.ai>
Mon, 29 Apr 2019 13:32:36 +0000 (13:32 +0000)
commit5a33047022ca4b7863be05b4be75678d5c0a44ee
treef64cb08dcc1f1637f4abbe30c2582fa61f39bb9f
parent0822bfc6de4b65dab5161a20429b6bc11c2c47bd
FileCheck [2/12]: Stricter parsing of -D option

Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the -D option.

Prior to this change, parsing of -D option was very loose: it assumed
that there is an equal sign (which to be fair is now checked by the
FileCheck executable) and that the part on the left of the equal sign
was a valid variable name. This commit adds logic to ensure that this
is the case and gives diagnostic when it is not, making it clear that
the issue came from a command-line option error. This is achieved by
sharing the variable parsing code into a new function ParseVariable.

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/D60382

llvm-svn: 359447
llvm/include/llvm/Support/FileCheck.h
llvm/lib/Support/FileCheck.cpp
llvm/test/FileCheck/defines.txt
llvm/unittests/Support/FileCheckTest.cpp