[FileCheck] Forbid using var defined on same line
authorThomas Preud'homme <thomasp@graphcore.ai>
Mon, 2 Sep 2019 14:04:00 +0000 (14:04 +0000)
committerThomas Preud'homme <thomasp@graphcore.ai>
Mon, 2 Sep 2019 14:04:00 +0000 (14:04 +0000)
commita291b950dbd9887e3b9162951b81fcdd71927756
treee00030b720af1a560ecfef2db815a7b2339057c2
parentb567ce76804fda5d14c09da77fb2889215fd710e
[FileCheck] Forbid using var defined on same line

Summary:
Commit r366897 introduced the possibility to set a variable from an
expression, such as [[#VAR2:VAR1+3]]. While introducing this feature, it
introduced extra logic to allow using such a variable on the same line
later on. Unfortunately that extra logic is flawed as it relies on a
mapping from variable to expression defining it when the mapping is from
variable definition to expression. This flaw causes among other issues
PR42896.

This commit avoids the problem by forbidding all use of a variable
defined on the same line, and removes the now useless logic. Redesign
will be done in a later commit because it will require some amount of
refactoring first for the solution to be clean. One example is the need
for some sort of transaction mechanism to set a variable temporarily and
from an expression and rollback if the CHECK pattern does not match so
that diagnostics show the right variable values.

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

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

Tags: #llvm

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

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