summaryrefslogtreecommitdiffstats
path: root/llvm/test/FileCheck
diff options
context:
space:
mode:
authorThomas Preud'homme <thomasp@graphcore.ai>2019-06-06 13:21:06 +0000
committerThomas Preud'homme <thomasp@graphcore.ai>2019-06-06 13:21:06 +0000
commit71d3f227a790d6cf39d8c6267940e0dc0c237e11 (patch)
tree581cedcd98bb3f08cf845dd37fc36a5f2cde0e61 /llvm/test/FileCheck
parentbf5bca5bea5b75faa1e66db458382929fbe4e475 (diff)
downloadbcm5719-llvm-71d3f227a790d6cf39d8c6267940e0dc0c237e11.tar.gz
bcm5719-llvm-71d3f227a790d6cf39d8c6267940e0dc0c237e11.zip
FileCheck [6/12]: Introduce numeric variable definition
Summary: This patch is part of a patch series to add support for FileCheck numeric expressions. This specific patch introduces support for defining numeric variable in a CHECK directive. This commit introduces support for defining numeric variable from a litteral value in the input text. Numeric expressions can then use the variable provided it is on a later line. 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/D60386 llvm-svn: 362705
Diffstat (limited to 'llvm/test/FileCheck')
-rw-r--r--llvm/test/FileCheck/numeric-defines-diagnostics.txt6
-rw-r--r--llvm/test/FileCheck/numeric-expression.txt107
-rw-r--r--llvm/test/FileCheck/var-scope.txt17
-rw-r--r--llvm/test/FileCheck/verbose.txt29
4 files changed, 97 insertions, 62 deletions
diff --git a/llvm/test/FileCheck/numeric-defines-diagnostics.txt b/llvm/test/FileCheck/numeric-defines-diagnostics.txt
index f0805d1c6bb..a5b3e2bc843 100644
--- a/llvm/test/FileCheck/numeric-defines-diagnostics.txt
+++ b/llvm/test/FileCheck/numeric-defines-diagnostics.txt
@@ -4,7 +4,7 @@
RUN: not FileCheck -D#10VALUE=10 --input-file %s %s 2>&1 \
RUN: | FileCheck %s --strict-whitespace --check-prefix NUMERRCLIFMT
-NUMERRCLIFMT: Global defines:1:20: error: invalid name in numeric variable definition '10VALUE'
+NUMERRCLIFMT: Global defines:1:20: error: invalid variable name
NUMERRCLIFMT-NEXT: Global define #1: #10VALUE=10
NUMERRCLIFMT-NEXT: {{^ \^$}}
@@ -12,7 +12,7 @@ NUMERRCLIFMT-NEXT: {{^ \^$}}
RUN: not FileCheck -D#@VALUE=10 --input-file %s %s 2>&1 \
RUN: | FileCheck %s --strict-whitespace --check-prefix NUMERRCLIPSEUDO
-NUMERRCLIPSEUDO: Global defines:1:20: error: invalid name in numeric variable definition '@VALUE'
+NUMERRCLIPSEUDO: Global defines:1:20: error: definition of pseudo numeric variable unsupported
NUMERRCLIPSEUDO-NEXT: Global define #1: #@VALUE=10
NUMERRCLIPSEUDO-NEXT: {{^ \^$}}
@@ -20,7 +20,7 @@ NUMERRCLIPSEUDO-NEXT: {{^ \^$}}
RUN: not FileCheck -D#VALUE+2=10 --input-file %s %s 2>&1 \
RUN: | FileCheck %s --strict-whitespace --check-prefix NUMERRCLITRAIL
-NUMERRCLITRAIL: Global defines:1:20: error: invalid name in numeric variable definition 'VALUE+2'
+NUMERRCLITRAIL: Global defines:1:20: error: invalid variable name
NUMERRCLITRAIL-NEXT: Global define #1: #VALUE+2=10
NUMERRCLITRAIL-NEXT: {{^ \^$}}
diff --git a/llvm/test/FileCheck/numeric-expression.txt b/llvm/test/FileCheck/numeric-expression.txt
index 422f71e304e..42ca7be692a 100644
--- a/llvm/test/FileCheck/numeric-expression.txt
+++ b/llvm/test/FileCheck/numeric-expression.txt
@@ -1,21 +1,42 @@
-RUN: FileCheck -D#VAR1=11 --input-file %s %s
+RUN: FileCheck --input-file %s %s
; We use CHECK-NEXT directives to force a match on all lines with digits.
-; Numeric expressions using variables defined on the command-line without
-; spaces
+; Numeric variable definition without spaces.
+DEF NO SPC
+11
+CHECK-LABEL: DEF NO SPC
+CHECK-NEXT: [[#VAR1:]]
+
+; Numeric variable definition with different spacing.
+DEF SPC
+11
+11
+11
+CHECK-LABEL: DEF SPC
+CHECK-NEXT: [[# VAR1a:]]
+CHECK-NEXT: [[# VAR1b :]]
+CHECK-NEXT: [[# VAR1c : ]]
+
+; Numeric expressions using variables defined on other lines without spaces.
USE NO SPC
11
12
10
-CHECK-LABEL: USE NO SPC
+11
+11
+11
+CHECK-LABEL: USE
CHECK-NEXT: [[#VAR1]]
CHECK-NEXT: [[#VAR1+1]]
CHECK-NEXT: [[#VAR1-1]]
+CHECK-NEXT: [[#VAR1a]]
+CHECK-NEXT: [[#VAR1b]]
+CHECK-NEXT: [[#VAR1c]]
-; Numeric expressions using variables defined on the command-line in alternate
-; spacing
-USE ALT SPC
+; Numeric expressions using variables defined on other lines with different
+; spacing.
+USE SPC
11
11
12
@@ -26,7 +47,7 @@ USE ALT SPC
10
10
10
-CHECK-LABEL: USE ALT SPC
+CHECK-LABEL: USE SPC
CHECK-NEXT: [[# VAR1]]
CHECK-NEXT: [[# VAR1 ]]
CHECK-NEXT: [[# VAR1+1]]
@@ -39,7 +60,7 @@ CHECK-NEXT: [[# VAR1 - 1]]
CHECK-NEXT: [[# VAR1 - 1 ]]
; Numeric expressions using variables defined on the command-line and an
-; immediate interpreted as an unsigned value
+; immediate interpreted as an unsigned value.
; Note: 9223372036854775819 = 0x8000000000000000 + 11
; 9223372036854775808 = 0x8000000000000000
USE UNSIGNED IMM
@@ -47,7 +68,7 @@ USE UNSIGNED IMM
CHECK-LABEL: USE UNSIGNED IMM
CHECK-NEXT: [[#VAR1+9223372036854775808]]
-; Numeric expression using undefined variable
+; Numeric expression using undefined variable.
RUN: not FileCheck --check-prefix UNDEF-USE --input-file %s %s 2>&1 \
RUN: | FileCheck --strict-whitespace --check-prefix UNDEF-USE-MSG %s
@@ -59,37 +80,51 @@ UNDEF-USE-MSG: numeric-expression.txt:[[#@LINE-1]]:30: error: using undefined nu
UNDEF-USE-MSG-NEXT: {{U}}NDEF-USE-NEXT: UNDEFVAR: {{\[\[#UNDEFVAR\]\]}}
UNDEF-USE-MSG-NEXT: {{^ \^$}}
-; Numeric expression with unsupported operator
-RUN: not FileCheck -D#VAR1=11 --check-prefixes CHECK,INVAL-OP --input-file %s %s 2>&1 \
+; Numeric expression with unsupported operator.
+RUN: not FileCheck -D#NUMVAR=10 --check-prefix INVAL-OP --input-file %s %s 2>&1 \
RUN: | FileCheck --strict-whitespace --check-prefix INVAL-OP-MSG %s
INVALID OPERATOR
-VAR1*2: 22
+NUMVAR*2: 22
INVAL-OP-LABEL: INVALID OPERATOR
-INVAL-OP-NEXT: VAR1*2: [[#VAR1*2]]
-INVAL-OP-MSG: numeric-expression.txt:[[#@LINE-1]]:31: error: unsupported numeric operation '*'
-INVAL-OP-MSG-NEXT: {{I}}NVAL-OP-NEXT: VAR1*2: {{\[\[#VAR1\*2\]\]}}
-INVAL-OP-MSG-NEXT: {{^ \^$}}
+INVAL-OP-NEXT: NUMVAR*2: [[#NUMVAR*2]]
+INVAL-OP-MSG: numeric-expression.txt:[[#@LINE-1]]:35: error: unsupported numeric operation '*'
+INVAL-OP-MSG-NEXT: {{I}}NVAL-OP-NEXT: NUMVAR*2: {{\[\[#NUMVAR\*2\]\]}}
+INVAL-OP-MSG-NEXT: {{^ \^$}}
; Name conflict between Numeric variable definition and string variable
-; definition
-RUN: not FileCheck -D#VAR1=11 -D#NUMVAR=42 --check-prefixes CONFLICT,CONFLICT1 --input-file %s %s 2>&1 \
-RUN: | FileCheck --strict-whitespace --check-prefix CLI-INPUT-PAT-CONFLICT %s
-RUN: not FileCheck -D#VAR1=11 -D#NUMVAR=42 -DNUMVAR=foobar --check-prefix CONFLICT --input-file %s %s 2>&1 \
-RUN: | FileCheck --strict-whitespace --check-prefix CLI-CLI-PAT-CONFLICT %s
-RUN: not FileCheck -D#VAR1=11 -DPATVAR=foobar -D#PATVAR=42 --check-prefix CONFLICT --input-file %s %s 2>&1 \
-RUN: | FileCheck --strict-whitespace --check-prefix CLI-CLI-NUM-CONFLICT %s
+; definition whether from the command-line or input text.
+RUN: not FileCheck --check-prefixes CONFLICT,CONFLICT1,CONFLICT2 --input-file %s %s 2>&1 \
+RUN: | FileCheck --strict-whitespace --check-prefix INPUT-STR-CONFLICT %s
+RUN: not FileCheck -D#NUMVAR=42 --check-prefixes CONFLICT,CONFLICT2 --input-file %s %s 2>&1 \
+RUN: | FileCheck --strict-whitespace --check-prefix INPUT-STR-CONFLICT %s
+RUN: not FileCheck -D#NUMVAR=42 -DNUMVAR=foobar --check-prefix CONFLICT --input-file %s %s 2>&1 \
+RUN: | FileCheck --strict-whitespace --check-prefix CLI-STR-CONFLICT %s
+RUN: not FileCheck --check-prefixes CONFLICT,CONFLICT3,CONFLICT4 --input-file %s %s 2>&1 \
+RUN: | FileCheck --strict-whitespace --check-prefix INPUT-NUM-CONFLICT %s
+RUN: not FileCheck -DSTRVAR=foobar --check-prefixes CONFLICT,CONFLICT4 --input-file %s %s 2>&1 \
+RUN: | FileCheck --strict-whitespace --check-prefix INPUT-NUM-CONFLICT %s
+RUN: not FileCheck -DSTRVAR=foobar -D#STRVAR=42 --check-prefix CONFLICT --input-file %s %s 2>&1 \
+RUN: | FileCheck --strict-whitespace --check-prefix CLI-NUM-CONFLICT %s
-PATVAR NUMVAR CONFLICT
+STRVAR NUMVAR CONFLICT
+redef1 42
foobar
-CONFLICT-LABEL: PATVAR NUMVAR CONFLICT
-CONFLICT1-NEXT: [[NUMVAR:foo.*]]
-CLI-INPUT-PAT-CONFLICT: numeric-expression.txt:[[#@LINE-1]]:19: error: numeric variable with name 'NUMVAR' already exists
-CLI-INPUT-PAT-CONFLICT-NEXT: {{C}}ONFLICT1-NEXT: {{\[\[NUMVAR:foo\.\*\]\]}}
-CLI-INPUT-PAT-CONFLICT-NEXT: {{^ \^$}}
-CLI-CLI-PAT-CONFLICT: Global defines:3:19: error: numeric variable with name 'NUMVAR' already exists
-CLI-CLI-PAT-CONFLICT-NEXT: Global define #3: NUMVAR=foobar
-CLI-CLI-PAT-CONFLICT-NEXT: {{^ \^$}}
-CLI-CLI-NUM-CONFLICT: Global defines:3:20: error: string variable with name 'PATVAR' already exists
-CLI-CLI-NUM-CONFLICT-NEXT: Global define #3: #PATVAR=42
-CLI-CLI-NUM-CONFLICT-NEXT: {{^ \^$}}
+redef2 42
+CONFLICT-LABEL: STRVAR NUMVAR CONFLICT
+CONFLICT1-NEXT: redef1 [[#NUMVAR:]]
+CONFLICT2: [[NUMVAR:foo.*]]
+CONFLICT3: [[STRVAR:foo.*]]
+CONFLICT4: redef2 [[#STRVAR:]]
+INPUT-STR-CONFLICT: numeric-expression.txt:[[#@LINE-3]]:14: error: numeric variable with name 'NUMVAR' already exists
+INPUT-STR-CONFLICT-NEXT: {{C}}ONFLICT2: {{\[\[NUMVAR:foo\.\*\]\]}}
+INPUT-STR-CONFLICT-NEXT: {{^ \^$}}
+CLI-STR-CONFLICT: Global defines:2:19: error: numeric variable with name 'NUMVAR' already exists
+CLI-STR-CONFLICT-NEXT: Global define #2: NUMVAR=foobar
+CLI-STR-CONFLICT-NEXT: {{^ \^$}}
+INPUT-NUM-CONFLICT: numeric-expression.txt:[[#@LINE-7]]:22: error: string variable with name 'STRVAR' already exists
+INPUT-NUM-CONFLICT-NEXT: CONFLICT4: redef2 {{\[\[#STRVAR:\]\]}}
+INPUT-NUM-CONFLICT-NEXT: {{^ \^$}}
+CLI-NUM-CONFLICT: Global defines:2:20: error: string variable with name 'STRVAR' already exists
+CLI-NUM-CONFLICT-NEXT: Global define #2: #STRVAR=42
+CLI-NUM-CONFLICT-NEXT: {{^ \^$}}
diff --git a/llvm/test/FileCheck/var-scope.txt b/llvm/test/FileCheck/var-scope.txt
index b2d412dffc5..c45a3848126 100644
--- a/llvm/test/FileCheck/var-scope.txt
+++ b/llvm/test/FileCheck/var-scope.txt
@@ -1,19 +1,22 @@
; Test that variables not starting with dollar sign get undefined after a
; CHECK-LABEL directive iff --enable-var-scope is used.
-RUN: FileCheck -D#LOCNUM=1 -D'#$GLOBNUM=1' --check-prefixes CHECK,LOCAL3,GLOBAL --input-file %s %s
-RUN: FileCheck -D#LOCNUM=1 -D'#$GLOBNUM=1' --check-prefixes CHECK,GLOBAL --enable-var-scope --input-file %s %s
-RUN: not FileCheck -D#LOCNUM=1 -D#'$GLOBNUM=1' --check-prefixes CHECK,LOCAL1 --enable-var-scope --input-file %s %s 2>&1 \
+; Reference run: variables remain defined at all time when not using
+; --enable-var-scope option.
+RUN: FileCheck --check-prefixes CHECK,LOCAL3,GLOBAL --input-file %s %s
+
+RUN: FileCheck --check-prefixes CHECK,GLOBAL --enable-var-scope --input-file %s %s
+RUN: not FileCheck --check-prefixes CHECK,LOCAL1 --enable-var-scope --input-file %s %s 2>&1 \
RUN: | FileCheck --check-prefixes ERRUNDEF,ERRUNDEFLOCAL %s
-RUN: not FileCheck -D#LOCNUM=1 -D#'$GLOBNUM=1' --check-prefixes CHECK,LOCAL2 --enable-var-scope --input-file %s %s 2>&1 \
+RUN: not FileCheck --check-prefixes CHECK,LOCAL2 --enable-var-scope --input-file %s %s 2>&1 \
RUN: | FileCheck --check-prefixes ERRUNDEF,ERRUNDEFLOCNUM %s
-RUN: not FileCheck -D#LOCNUM=1 -D#'$GLOBNUM=1' --check-prefixes CHECK,LOCAL3 --enable-var-scope --input-file %s %s 2>&1 \
+RUN: not FileCheck --check-prefixes CHECK,LOCAL3 --enable-var-scope --input-file %s %s 2>&1 \
RUN: | FileCheck --check-prefixes ERRUNDEF,ERRUNDEFLOCAL,ERRUNDEFLOCNUM %s
local1
global1
-CHECK: [[LOCAL:loc[^[:digit:]]*]][[#LOCNUM]]
-CHECK: [[$GLOBAL:glo[^[:digit:]]*]][[#$GLOBNUM]]
+CHECK: [[LOCAL:loc[^[:digit:]]*]][[#LOCNUM:]]
+CHECK: [[$GLOBAL:glo[^[:digit:]]*]][[#$GLOBNUM:]]
local2
global2
diff --git a/llvm/test/FileCheck/verbose.txt b/llvm/test/FileCheck/verbose.txt
index 4d44c775159..cc10aa5b316 100644
--- a/llvm/test/FileCheck/verbose.txt
+++ b/llvm/test/FileCheck/verbose.txt
@@ -1,6 +1,6 @@
-; RUN: FileCheck -D#NUMVAR=42 -input-file %s %s 2>&1 | FileCheck -check-prefix QUIET --allow-empty %s
-; RUN: FileCheck -v -D#NUMVAR=42 -input-file %s %s 2>&1 | FileCheck --strict-whitespace -check-prefix V %s
-; RUN: FileCheck -vv -D#NUMVAR=42 -input-file %s %s 2>&1 | FileCheck --strict-whitespace -check-prefixes V,VV %s
+; RUN: FileCheck -input-file %s %s 2>&1 | FileCheck -check-prefix QUIET --allow-empty %s
+; RUN: FileCheck -v -input-file %s %s 2>&1 | FileCheck --strict-whitespace -check-prefix V %s
+; RUN: FileCheck -vv -input-file %s %s 2>&1 | FileCheck --strict-whitespace -check-prefixes V,VV %s
foo
bar
@@ -29,36 +29,33 @@ VV-NEXT: verbose.txt:[[@LINE-22]]:1: note: scanning from here
VV-NEXT: {{^}}bar{{$}}
VV-NEXT: {{^}}^{{$}}
-NUMVAR:42
+NUMVAR=42
NUMVAR - 1:41
-CHECK: NUMVAR:[[#NUMVAR]]
+CHECK: NUMVAR=[[#NUMVAR:]]
CHECK-NOT: [[#NUMVAR + 1]]
CHECK-NEXT: NUMVAR - 1:[[#NUMVAR - 1]]
V: verbose.txt:[[#@LINE-4]]:8: remark: {{C}}HECK: expected string found in input
-V-NEXT: {{C}}HECK: {{NUMVAR:[[][[]#NUMVAR[]][]]$}}
+V-NEXT: {{C}}HECK: {{NUMVAR=[[][[]#NUMVAR:[]][]]$}}
V-NEXT: {{^ \^$}}
V-NEXT: verbose.txt:[[#@LINE-9]]:1: note: found here
-V-NEXT: {{^}}NUMVAR:42{{$}}
-V-NEXT: {{^}}^~~~~~~~~{{$}}
-V-NEXT: verbose.txt:[[#@LINE-12]]:1: note: with "NUMVAR" equal to "42"
-V-NEXT: {{^}}NUMVAR:42{{$}}
+V-NEXT: {{^}}NUMVAR=42{{$}}
V-NEXT: {{^}}^~~~~~~~~{{$}}
-V-NEXT: verbose.txt:[[#@LINE-12]]:13: remark: {{C}}HECK-NEXT: expected string found in input
+V-NEXT: verbose.txt:[[#@LINE-9]]:13: remark: {{C}}HECK-NEXT: expected string found in input
V-NEXT: {{C}}HECK-NEXT: {{NUMVAR - 1:[[][[]#NUMVAR - 1[]][]]$}}
V-NEXT: {{^ \^$}}
-V-NEXT: verbose.txt:[[#@LINE-18]]:1: note: found here
+V-NEXT: verbose.txt:[[#@LINE-15]]:1: note: found here
V-NEXT: {{^}}NUMVAR - 1:41{{$}}
V-NEXT: {{^}}^~~~~~~~~~~~~{{$}}
-V-NEXT: verbose.txt:[[#@LINE-21]]:1: note: with "NUMVAR - 1" equal to "41"
+V-NEXT: verbose.txt:[[#@LINE-18]]:1: note: with "NUMVAR - 1" equal to "41"
V-NEXT: {{^}}NUMVAR - 1:41{{$}}
V-NEXT: {{^}}^~~~~~~~~~~~~{{$}}
-VV-NEXT: verbose.txt:[[#@LINE-23]]:12: remark: {{C}}HECK-NOT: excluded string not found in input
+VV-NEXT: verbose.txt:[[#@LINE-20]]:12: remark: {{C}}HECK-NOT: excluded string not found in input
VV-NEXT: {{C}}HECK-NOT: {{[[][[]#NUMVAR [+] 1[]][]]$}}
-VV-NEXT: {{^ \^$}}
-VV-NEXT: verbose.txt:[[#@LINE-28]]:1: note: scanning from here
+VV-NEXT: {{^ \^$}}
+VV-NEXT: verbose.txt:[[#@LINE-25]]:1: note: scanning from here
VV-NEXT: {{^}}NUMVAR - 1:41{{$}}
VV-NEXT: {{^}}^{{$}}
OpenPOWER on IntegriCloud