summaryrefslogtreecommitdiffstats
path: root/llvm/test/FileCheck
diff options
context:
space:
mode:
authorThomas Preud'homme <thomasp@graphcore.ai>2019-01-14 09:29:10 +0000
committerThomas Preud'homme <thomasp@graphcore.ai>2019-01-14 09:29:10 +0000
commit84f4ff5119e5c29ec68093e791c926f98ea60c9c (patch)
treec24e8178fe73051726e6796f1f4f0d93ca3f73bc /llvm/test/FileCheck
parentbc5e6ee87a08618c3202eb1cecddd24267e64701 (diff)
downloadbcm5719-llvm-84f4ff5119e5c29ec68093e791c926f98ea60c9c.tar.gz
bcm5719-llvm-84f4ff5119e5c29ec68093e791c926f98ea60c9c.zip
Detect incorrect FileCheck variable CLI definition
Summary: While the backend code of FileCheck relies on definition of variable from the command-line to have an equal sign '=' and a variable name before that, the frontend does not actually enforce it. This leads to FileCheck crashing when invoked with invalid syntax for the -D option. This patch adds the missing validation in the frontend. It also makes the -D option an AlwaysPrefix option to be able to detect -D=FOO as being a define without variable and -D as missing its value. Copyright: - Linaro (changes in version 2 of revision D55940) - GraphCore (changes in later versions) Reviewers: jdenny Subscribers: JonChesterfield, hiraditya, kristina, probinson, llvm-commits Differential Revision: https://reviews.llvm.org/D55940 llvm-svn: 351039
Diffstat (limited to 'llvm/test/FileCheck')
-rw-r--r--llvm/test/FileCheck/defines.txt26
1 files changed, 21 insertions, 5 deletions
diff --git a/llvm/test/FileCheck/defines.txt b/llvm/test/FileCheck/defines.txt
index c788124dcbb..05d1b7bcfe8 100644
--- a/llvm/test/FileCheck/defines.txt
+++ b/llvm/test/FileCheck/defines.txt
@@ -3,16 +3,32 @@
;
; RUN: not FileCheck -DVALUE=10 -check-prefix NOT -input-file %s %s 2>&1 | FileCheck %s -check-prefix NOT-ERRMSG
; RUN: FileCheck -DVALUE=20 -check-prefix NOT -input-file %s %s
+; RUN: not FileCheck -DVALUE10 -input-file %s %s 2>&1 | FileCheck %s -check-prefix ERRCLIEQ1
+; RUN: not FileCheck -D -input-file %s %s 2>&1 | FileCheck %s -check-prefix ERRCLIEQ2
+; RUN: not FileCheck -D=10 -input-file %s %s 2>&1 | FileCheck %s -check-prefix ERRCLIVAR1
+; RUN: not FileCheck -D= -input-file %s %s 2>&1 | FileCheck %s -check-prefix ERRCLIVAR2
+; RUN: FileCheck -DVALUE= -check-prefix EMPTY -input-file %s %s 2>&1
Value = 10
; CHECK: Value = [[VALUE]]
; NOT-NOT: Value = [[VALUE]]
-; ERRMSG: defines.txt:8:10: error: CHECK: expected string not found in input
+; ERRMSG: defines.txt:[[@LINE-3]]:10: error: CHECK: expected string not found in input
; ERRMSG: defines.txt:1:1: note: scanning from here
; ERRMSG: defines.txt:1:1: note: with variable "VALUE" equal to "20"
-; ERRMSG: defines.txt:7:1: note: possible intended match here
+; ERRMSG: defines.txt:[[@LINE-7]]:1: note: possible intended match here
-; NOT-ERRMSG: defines.txt:9:12: error: {{NOT}}-NOT: excluded string found in input
-; NOT-ERRMSG: defines.txt:7:1: note: found here
-; NOT-ERRMSG: defines.txt:7:1: note: with variable "VALUE" equal to "10" \ No newline at end of file
+; NOT-ERRMSG: defines.txt:[[@LINE-7]]:12: error: {{NOT}}-NOT: excluded string found in input
+; NOT-ERRMSG: defines.txt:[[@LINE-10]]:1: note: found here
+; NOT-ERRMSG: defines.txt:[[@LINE-11]]:1: note: with variable "VALUE" equal to "10"
+
+; ERRCLIEQ1: Missing equal sign in command-line definition '-DVALUE10'
+
+; ERRCLIEQ2: FileCheck: for the -D option: requires a value!
+
+; ERRCLIVAR1: Missing pattern variable name in command-line definition '-D=10'
+
+; ERRCLIVAR2: Missing pattern variable name in command-line definition '-D='
+
+Empty value = @@
+; EMPTY: Empty value = @[[VALUE]]@
OpenPOWER on IntegriCloud