diff options
| author | Thomas Preud'homme <thomasp@graphcore.ai> | 2019-05-14 11:58:30 +0000 |
|---|---|---|
| committer | Thomas Preud'homme <thomasp@graphcore.ai> | 2019-05-14 11:58:30 +0000 |
| commit | 7b4ecdd3c2c64b0656f4a45a74fd2decf7606d0c (patch) | |
| tree | e1809bf80568482321f3436be2c1174c2bc6bd1d /llvm/test/FileCheck | |
| parent | 2747ee2c83e4ba0c159f98498bdf98b3773ffa53 (diff) | |
| download | bcm5719-llvm-7b4ecdd3c2c64b0656f4a45a74fd2decf7606d0c.tar.gz bcm5719-llvm-7b4ecdd3c2c64b0656f4a45a74fd2decf7606d0c.zip | |
Reinstate "FileCheck [5/12]: Introduce regular numeric variables"
This reinstates r360578 (git e47362c1ec1ea31b626336cc05822035601c3e57),
reverted in r360653 (git 004393681c25e34e921adccc69ae6378090dee54),
with a fix for the list added in FileCheck.rst to build without error.
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/D60385
llvm-svn: 360665
Diffstat (limited to 'llvm/test/FileCheck')
| -rw-r--r-- | llvm/test/FileCheck/numeric-defines-diagnostics.txt | 33 | ||||
| -rw-r--r-- | llvm/test/FileCheck/numeric-defines.txt | 22 | ||||
| -rw-r--r-- | llvm/test/FileCheck/numeric-expression.txt | 95 | ||||
| -rw-r--r-- | llvm/test/FileCheck/pattern-defines-diagnostics.txt | 6 | ||||
| -rw-r--r-- | llvm/test/FileCheck/regex-scope.txt | 23 | ||||
| -rw-r--r-- | llvm/test/FileCheck/var-scope.txt | 35 | ||||
| -rw-r--r-- | llvm/test/FileCheck/verbose.txt | 41 |
7 files changed, 225 insertions, 30 deletions
diff --git a/llvm/test/FileCheck/numeric-defines-diagnostics.txt b/llvm/test/FileCheck/numeric-defines-diagnostics.txt new file mode 100644 index 00000000000..f0805d1c6bb --- /dev/null +++ b/llvm/test/FileCheck/numeric-defines-diagnostics.txt @@ -0,0 +1,33 @@ +; Test incorrect syntax for -D# option is correctly diagnosed. + +; Invalid variable name: starts with a digit. +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-NEXT: Global define #1: #10VALUE=10 +NUMERRCLIFMT-NEXT: {{^ \^$}} + +; Invalid definition of pseudo variable. +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-NEXT: Global define #1: #@VALUE=10 +NUMERRCLIPSEUDO-NEXT: {{^ \^$}} + +; Invalid definition of an expression. +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-NEXT: Global define #1: #VALUE+2=10 +NUMERRCLITRAIL-NEXT: {{^ \^$}} + +; Invalid value: numeric expression instead of literal. +RUN: not FileCheck -D#VALUE1=3 -D#VALUE2='VALUE1 + 2' --input-file %s %s 2>&1 \ +RUN: | FileCheck %s --strict-whitespace --check-prefix NUMERRCLIEXPR + +NUMERRCLIEXPR: Global defines:2:27: error: invalid value in numeric variable definition 'VALUE1 + 2' +NUMERRCLIEXPR-NEXT: Global define #2: #VALUE2=VALUE1 + 2 +NUMERRCLIEXPR-NEXT: {{^ \^$}} diff --git a/llvm/test/FileCheck/numeric-defines.txt b/llvm/test/FileCheck/numeric-defines.txt new file mode 100644 index 00000000000..aeaeba2db1c --- /dev/null +++ b/llvm/test/FileCheck/numeric-defines.txt @@ -0,0 +1,22 @@ +; Test functionality of -D# option: numeric variables are defined to the right +; value and CHECK directives using them match as expected given the value set. + +RUN: FileCheck -D#NUMVAL=12 --check-prefix CHECKNUM --input-file %s %s +RUN: not FileCheck -D#NUMVAL=8 --check-prefix CHECKNUM --input-file %s %s 2>&1 \ +RUN: | FileCheck %s --strict-whitespace --check-prefix NUMERRMSG +RUN: not FileCheck -D#NUMVAL=12 --check-prefix NUMNOT --input-file %s %s 2>&1 \ +RUN: | FileCheck %s --strict-whitespace --check-prefix NOT-NUMERRMSG +RUN: FileCheck -D#NUMVAL=8 --check-prefixes NUMNOT --input-file %s %s + +Numeric value = 12 +CHECKNUM: Numeric value = [[#NUMVAL]] +NUMNOT-NOT: Numeric value = [[#NUMVAL]] + +NUMERRMSG: defines.txt:[[#@LINE-3]]:11: error: CHECKNUM: expected string not found in input +NUMERRMSG: defines.txt:1:1: note: scanning from here +NUMERRMSG: defines.txt:1:1: note: with numeric expression "NUMVAL" equal to "8" +NUMERRMSG: defines.txt:[[#@LINE-7]]:1: note: possible intended match here + +NOT-NUMERRMSG: defines.txt:[[#@LINE-7]]:13: error: {{NUMNOT}}-NOT: excluded string found in input +NOT-NUMERRMSG: defines.txt:[[#@LINE-10]]:1: note: found here +NOT-NUMERRMSG: defines.txt:[[#@LINE-11]]:1: note: with numeric expression "NUMVAL" equal to "12" diff --git a/llvm/test/FileCheck/numeric-expression.txt b/llvm/test/FileCheck/numeric-expression.txt new file mode 100644 index 00000000000..3b56b8afd51 --- /dev/null +++ b/llvm/test/FileCheck/numeric-expression.txt @@ -0,0 +1,95 @@ +RUN: FileCheck -D#VAR1=11 --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 +USE NO SPC +11 +12 +10 +CHECK-LABEL: USE NO SPC +CHECK-NEXT: [[#VAR1]] +CHECK-NEXT: [[#VAR1+1]] +CHECK-NEXT: [[#VAR1-1]] + +; Numeric expressions using variables defined on the command-line in alternate +; spacing +USE ALT SPC +11 +11 +12 +12 +12 +12 +10 +10 +10 +10 +CHECK-LABEL: USE ALT SPC +CHECK-NEXT: [[# VAR1]] +CHECK-NEXT: [[# VAR1 ]] +CHECK-NEXT: [[# VAR1+1]] +CHECK-NEXT: [[# VAR1 +1]] +CHECK-NEXT: [[# VAR1 + 1]] +CHECK-NEXT: [[# VAR1 + 1 ]] +CHECK-NEXT: [[# VAR1-1]] +CHECK-NEXT: [[# VAR1 -1]] +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 +; Note: 9223372036854775819 = 0x8000000000000000 + 11 +; 9223372036854775808 = 0x8000000000000000 +USE UNSIGNED IMM +9223372036854775819 +CHECK-LABEL: USE UNSIGNED IMM +CHECK-NEXT: [[#VAR1+9223372036854775808]] + +; 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 + +UNDEF VAR USE +UNDEFVAR: 11 +UNDEF-USE-LABEL: UNDEF VAR USE +UNDEF-USE-NEXT: UNDEFVAR: [[#UNDEFVAR]] +UNDEF-USE-MSG: numeric-expression.txt:[[#@LINE-1]]:30: error: using undefined numeric variable 'UNDEFVAR' +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 \ +RUN: | FileCheck --strict-whitespace --check-prefix INVAL-OP-MSG %s + +INVALID OPERATOR +VAR1*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: {{^ \^$}} + +; Name conflict between Numeric variable definition and pattern 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 + +PATVAR NUMVAR CONFLICT +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: pattern variable with name 'PATVAR' already exists +CLI-CLI-NUM-CONFLICT-NEXT: Global define #3: #PATVAR=42 +CLI-CLI-NUM-CONFLICT-NEXT: {{^ \^$}} diff --git a/llvm/test/FileCheck/pattern-defines-diagnostics.txt b/llvm/test/FileCheck/pattern-defines-diagnostics.txt index bb6c3b648b9..c4143f297d7 100644 --- a/llvm/test/FileCheck/pattern-defines-diagnostics.txt +++ b/llvm/test/FileCheck/pattern-defines-diagnostics.txt @@ -28,7 +28,7 @@ ERRCLIVAR2: Missing pattern variable name in command-line definition '-D=' RUN: not FileCheck -D10VALUE=10 --input-file %s %s 2>&1 \ RUN: | FileCheck %s --strict-whitespace --check-prefix ERRCLIFMT -ERRCLIFMT: Global defines:1:19: error: invalid name for variable definition '10VALUE' +ERRCLIFMT: Global defines:1:19: error: invalid name in pattern variable definition '10VALUE' ERRCLIFMT-NEXT: Global define #1: 10VALUE=10 ERRCLIFMT-NEXT: {{^ \^$}} @@ -36,7 +36,7 @@ ERRCLIFMT-NEXT: {{^ \^$}} RUN: not FileCheck -D@VALUE=10 --input-file %s %s 2>&1 \ RUN: | FileCheck %s --strict-whitespace --check-prefix ERRCLIPSEUDO -ERRCLIPSEUDO: Global defines:1:19: error: invalid name for variable definition '@VALUE' +ERRCLIPSEUDO: Global defines:1:19: error: invalid name in pattern variable definition '@VALUE' ERRCLIPSEUDO-NEXT: Global define #1: @VALUE=10 ERRCLIPSEUDO-NEXT: {{^ \^$}} @@ -44,6 +44,6 @@ ERRCLIPSEUDO-NEXT: {{^ \^$}} RUN: not FileCheck -D'VALUE + 2=10' --input-file %s %s 2>&1 \ RUN: | FileCheck %s --strict-whitespace --check-prefix ERRCLITRAIL -ERRCLITRAIL: Global defines:1:19: error: invalid name for variable definition 'VALUE + 2' +ERRCLITRAIL: Global defines:1:19: error: invalid name in pattern variable definition 'VALUE + 2' ERRCLITRAIL-NEXT: Global define #1: VALUE + 2=10 ERRCLITRAIL-NEXT: {{^ \^$}} diff --git a/llvm/test/FileCheck/regex-scope.txt b/llvm/test/FileCheck/regex-scope.txt deleted file mode 100644 index 989f422c6bc..00000000000 --- a/llvm/test/FileCheck/regex-scope.txt +++ /dev/null @@ -1,23 +0,0 @@ -// RUN: FileCheck -input-file %s %s -// RUN: FileCheck -check-prefixes CHECK,GLOBAL -input-file %s %s -// RUN: FileCheck -check-prefixes CHECK,LOCAL -input-file %s %s -// RUN: FileCheck -check-prefixes CHECK,GLOBAL --enable-var-scope -input-file %s %s -// RUN: not FileCheck -check-prefixes CHECK,LOCAL --enable-var-scope -input-file %s %s - -local -global -; CHECK: [[LOCAL:loc.*]] -; CHECK: [[$GLOBAL:glo.*]] - -local2 -global2 -; CHECK: [[LOCAL]]2 -; CHECK: [[$GLOBAL]]2 - -barrier: -; CHECK-LABEL: barrier - -local3 -global3 -; LOCAL: [[LOCAL]]3 -; GLOBAL: [[$GLOBAL]]3 diff --git a/llvm/test/FileCheck/var-scope.txt b/llvm/test/FileCheck/var-scope.txt new file mode 100644 index 00000000000..b2d412dffc5 --- /dev/null +++ b/llvm/test/FileCheck/var-scope.txt @@ -0,0 +1,35 @@ +; 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 \ +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: | 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: | FileCheck --check-prefixes ERRUNDEF,ERRUNDEFLOCAL,ERRUNDEFLOCNUM %s + +local1 +global1 +CHECK: [[LOCAL:loc[^[:digit:]]*]][[#LOCNUM]] +CHECK: [[$GLOBAL:glo[^[:digit:]]*]][[#$GLOBNUM]] + +local2 +global2 +CHECK: [[LOCAL]][[#LOCNUM+1]] +CHECK: [[$GLOBAL]][[#$GLOBNUM+1]] + +barrier: +CHECK-LABEL: barrier + +local3 +global3 +LOCAL1: [[LOCAL]]3 +LOCAL2: local[[#LOCNUM+2]] +LOCAL3: [[LOCAL]][[#LOCNUM+2]] +GLOBAL: [[$GLOBAL]][[#$GLOBNUM+2]] + +ERRUNDEF: expected string not found in input +ERRUNDEFLOCAL: uses undefined variable "LOCAL" +ERRUNDEFLOCNUM: uses undefined variable "LOCNUM" diff --git a/llvm/test/FileCheck/verbose.txt b/llvm/test/FileCheck/verbose.txt index e6eec5e5462..244fff4e824 100644 --- a/llvm/test/FileCheck/verbose.txt +++ b/llvm/test/FileCheck/verbose.txt @@ -1,6 +1,6 @@ -; 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 -check-prefix V %s -; RUN: FileCheck -vv -input-file %s %s 2>&1 | FileCheck -check-prefixes V,VV %s +; 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 foo bar @@ -29,6 +29,39 @@ VV-NEXT: verbose.txt:[[@LINE-22]]:1: note: scanning from here VV-NEXT: {{^}}bar{{$}} VV-NEXT: {{^}}^{{$}} +NUMVAR:42 +NUMVAR - 1:41 +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: {{^ \^$}} +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 numeric expression "NUMVAR" equal to "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: {{C}}HECK-NEXT: {{NUMVAR - 1:[[][[]#NUMVAR - 1[]][]]$}} +V-NEXT: {{^ \^$}} +V-NEXT: verbose.txt:[[#@LINE-18]]:1: note: found here +V-NEXT: {{^}}NUMVAR - 1:41{{$}} +V-NEXT: {{^}}^~~~~~~~~~~~~{{$}} +V-NEXT: verbose.txt:[[#@LINE-21]]:1: note: with numeric expression "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: {{C}}HECK-NOT: {{[[][[]#NUMVAR [+] 1[]][]]$}} +VV-NEXT: {{^ \^$}} +VV-NEXT: verbose.txt:[[#@LINE-28]]:1: note: scanning from here +VV-NEXT: {{^}}NUMVAR - 1:41{{$}} +VV-NEXT: {{^}}^{{$}} + before empty after empty @@ -99,7 +132,7 @@ V-NEXT: {{^}}^~~{{$}} VV-NEXT: verbose.txt:[[@LINE-9]]:19: remark: implicit EOF: expected string found in input VV-NEXT: {{C}}HECK-NOT: {{[{][{]z[}][}]yx$}} -VV-NEXT: {{^ \^$}} +VV-NEXT: {{^ \^$}} VV-NEXT: verbose.txt:[[@LINE+13]]:1: note: found here VV-NOT: {{.}} VV: {{^\^$}} |

