[FileCheck] Fix numeric variable redefinition
authorThomas Preud'homme <thomasp@graphcore.ai>
Thu, 18 Jul 2019 13:39:04 +0000 (13:39 +0000)
committerThomas Preud'homme <thomasp@graphcore.ai>
Thu, 18 Jul 2019 13:39:04 +0000 (13:39 +0000)
commit70494494c1e381792638eeb350660ca7e8a442c0
tree2310c598856d2b8445713c310d1f2be5864b79e4
parent0c4948455d353e4822fb69310893f281599050e5
[FileCheck] Fix numeric variable redefinition

Summary:
Commit r365249 changed usage of FileCheckNumericVariable to have one
instance of that class per variable as opposed to one instance per
definition of a given variable as was done before. However, it retained
the safety check in setValue that it should only be called with the
variable unset, even after r365625.

However this causes assert failure when a non-pseudo variable is being
redefined. And while redefinition of @LINE at each CHECK line work in
the general case, it caused problem when a substitution failed (fixed in
r365624) and still causes problem when a CHECK line does not match since
@LINE's value is cleared after substitutions in match() happened but
printSubstitutions also attempts a substitution.

This commit solves the root of the problem by changing setValue to set a
new value regardless of whether a value was set or not, thus fixing all
the aforementioned issues.

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

llvm-svn: 366434
llvm/include/llvm/Support/FileCheck.h
llvm/lib/Support/FileCheck.cpp
llvm/test/FileCheck/line-count.txt
llvm/test/FileCheck/numeric-expression.txt
llvm/unittests/Support/FileCheckTest.cpp