aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support/FileCheckTest.cpp
diff options
context:
space:
mode:
authorThomas Preud'homme <thomasp@graphcore.ai>2019-07-10 12:49:17 +0000
committerThomas Preud'homme <thomasp@graphcore.ai>2019-07-10 12:49:17 +0000
commitf6ea43b8b302acfae974065f0aa16e7432db099e (patch)
treec23cd8c3b286b008ac6428d0315c86051543c475 /llvm/unittests/Support/FileCheckTest.cpp
parent775b2f598a99883a5dc1218ba4c7e77af2e3c26a (diff)
downloadllvm-f6ea43b8b302acfae974065f0aa16e7432db099e.zip
llvm-f6ea43b8b302acfae974065f0aa16e7432db099e.tar.gz
llvm-f6ea43b8b302acfae974065f0aa16e7432db099e.tar.bz2
[FileCheck] Fix @LINE value after match failure
Summary: The value of the FileCheckNumericVariable class instance representing the @LINE numeric variable is set and cleared respectively before and after substitutions are made, if any. However, when a substitution fails, the value is not cleared. This causes the next substitution of @LINE later on to give the wrong value since setValue is a nop if the value is already set. This is what caused failures after commit r365249. 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/D64449 llvm-svn: 365624
Diffstat (limited to 'llvm/unittests/Support/FileCheckTest.cpp')
-rw-r--r--llvm/unittests/Support/FileCheckTest.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/unittests/Support/FileCheckTest.cpp b/llvm/unittests/Support/FileCheckTest.cpp
index 7fcd5bb..58550c7 100644
--- a/llvm/unittests/Support/FileCheckTest.cpp
+++ b/llvm/unittests/Support/FileCheckTest.cpp
@@ -334,6 +334,21 @@ TEST_F(FileCheckTest, Match) {
EXPECT_TRUE(Tester.matchExpect("19 21"));
EXPECT_TRUE(Tester.matchExpect("18 21"));
EXPECT_FALSE(Tester.matchExpect("18 20"));
+
+ // Check matching a numeric expression using @LINE after match failure uses
+ // the correct value for @LINE.
+ Tester.initNextPattern();
+ EXPECT_FALSE(Tester.parsePatternExpect("[[#@LINE]]"));
+ // Ok, @LINE is 4 now.
+ EXPECT_FALSE(Tester.matchExpect("4"));
+ Tester.initNextPattern();
+ // @LINE is now 5, match with substitution failure.
+ EXPECT_FALSE(Tester.parsePatternExpect("[[#UNKNOWN]]"));
+ EXPECT_TRUE(Tester.matchExpect("FOO"));
+ Tester.initNextPattern();
+ // Check that @LINE is 6 as expected.
+ EXPECT_FALSE(Tester.parsePatternExpect("[[#@LINE]]"));
+ EXPECT_FALSE(Tester.matchExpect("6"));
}
TEST_F(FileCheckTest, Substitution) {