llvm/test/FileCheck/line-count.txt
Thomas Preud'homme 1f688f6d4c [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366434 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-18 13:39:04 +00:00

73 lines
2.8 KiB
Plaintext

; RUN: FileCheck -input-file %s %s
; RUN: not FileCheck -check-prefix BAD1 -input-file %s %s 2>&1 | FileCheck -check-prefix ERR1 %s
; RUN: not FileCheck -check-prefix BAD2 -input-file %s %s 2>&1 | FileCheck -check-prefix ERR2 %s
; RUN: not FileCheck -check-prefix BAD3 -input-file %s %s 2>&1 | FileCheck -check-prefix ERR3 %s
; RUN: not FileCheck -check-prefix BAD4 -input-file %s %s 2>&1 | FileCheck -check-prefix ERR4 %s
; RUN: not FileCheck -check-prefix BAD5 -input-file %s %s 2>&1 | FileCheck -check-prefix ERR5 %s
; RUN: not FileCheck -check-prefix BAD6 -input-file %s %s 2>&1 | FileCheck -check-prefix ERR6 %s
; RUN: not FileCheck -check-prefix BAD7 -input-file %s %s 2>&1 | FileCheck -check-prefix ERR7 %s
; RUN: not FileCheck -check-prefix BAD8 -input-file %s %s 2>&1 | FileCheck -check-prefix ERR8 %s
; RUN: not FileCheck -check-prefix BAD9 -input-file %s %s 2>&1 | FileCheck -check-prefix ERR9 %s
; RUN: not FileCheck -check-prefix BAD10 -input-file %s %s 2>&1 | FileCheck -check-prefix ERR10 %s
; RUN: not FileCheck -check-prefix BAD11 -input-file %s %s 2>&1 | FileCheck -check-prefix ERR11 %s
13
14 aaa
15 bbb
16 ccc
17 CHECK: [[@LINE-3]] {{a}}aa
18 CHECK: [[@LINE-3]] {{b}}bb
19 CHECK: [[@LINE-3]] {{c}}cc
20 foobar
21 CHECK: [[@LINE-1]] {{foo}}bar
22
23 arst CHECK: [[@LINE]] {{a}}rst
24
25 BAD1: [[@LINE:cant-have-regex]]
26 ERR1: line-count.txt:[[#@LINE-1]]:12: error: invalid name in string variable definition
27
28 BAD2: [[ @LINE]]
29 ERR2: line-count.txt:[[#@LINE-1]]:12: error: unexpected whitespace
30
31 BAD3: [[@LINE ]]
32 ERR3: line-count.txt:[[#@LINE-1]]:17: error: unexpected whitespace
33
34 BAD4: [[ @LINE-1]]
35 ERR4: line-count.txt:[[#@LINE-1]]:12: error: unexpected whitespace
36
37 BAD5: [[@LINE -1]]
38 ERR5: line-count.txt:[[#@LINE-1]]:17: error: unexpected whitespace
39
40 BAD6: [[@LINE- 1]]
41 ERR6: line-count.txt:[[#@LINE-1]]:18: error: unexpected whitespace
42
43 BAD7: [[@LINE-1 ]]
44 ERR7: line-count.txt:[[#@LINE-1]]:19: error: unexpected whitespace
45
46 BAD8: [[@LIN]]
47 ERR8: line-count.txt:[[#@LINE-1]]:12: error: invalid pseudo numeric variable '@LIN'
48
49 BAD9: [[@LINE*2]]
50 ERR9: line-count.txt:[[#@LINE-1]]:17: error: unsupported operation '*'
51
52 BAD10: [[@LINE-x]]
53 ERR10: line-count.txt:[[#@LINE-1]]:19: error: invalid operand format 'x'
54
55 BAD11: [[@LINE-1x]]
56 ERR11: line-count.txt:[[#@LINE-1]]:20: error: unexpected characters at end of expression 'x'
57
; RUN: not FileCheck -check-prefix BAD12 -input-file %s %s 2>&1 \
; RUN: | FileCheck -check-prefix ERR12 %s
60
61 BAD12: [[#@LINE-1]] NOT HERE
62 ERR12: note: with "@LINE-1" equal to "60"
63
64 CHECK: [[#@LINE]] CHECK
65 CHECK: [[# @LINE]] CHECK
66 CHECK: [[# @LINE ]] CHECK
67
68 CHECK: [[#@LINE-1]]
69 CHECK: [[# @LINE-1]] CHECK
70 CHECK: [[# @LINE -1]] CHECK
71 CHECK: [[# @LINE - 1]] CHECK
72 CHECK: [[# @LINE - 1 ]] CHECK