[PATCH] D55940: Detect incorrect FileCheck variable CLI definition
Thomas Preud'homme via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 20 09:43:29 PST 2018
thopre created this revision.
thopre added a reviewer: jdenny.
While the backend code of FileCheck relies on definition of variable
from the command-line to have an equal sign '=', 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.
Repository:
rL LLVM
https://reviews.llvm.org/D55940
Files:
test/FileCheck/defines.txt
utils/FileCheck/FileCheck.cpp
Index: utils/FileCheck/FileCheck.cpp
===================================================================
--- utils/FileCheck/FileCheck.cpp
+++ utils/FileCheck/FileCheck.cpp
@@ -523,8 +523,17 @@
for (auto CheckNot : ImplicitCheckNot)
Req.ImplicitCheckNot.push_back(CheckNot);
- for (auto G : GlobalDefines)
+ bool GlobalDefineError = false;
+ for (auto G : GlobalDefines) {
+ if (G.find('=') == std::string::npos) {
+ errs() << "Command-line definition '" << G << "' missing equal sign\n";
+ GlobalDefineError = true;
+ continue;
+ }
Req.GlobalDefines.push_back(G);
+ }
+ if (GlobalDefineError)
+ return 2;
Req.AllowEmptyInput = AllowEmptyInput;
Req.EnableVarScope = EnableVarScope;
Index: test/FileCheck/defines.txt
===================================================================
--- test/FileCheck/defines.txt
+++ test/FileCheck/defines.txt
@@ -3,16 +3,19 @@
;
; 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 ERRCLI
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:9: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:8: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:10:12: error: {{NOT}}-NOT: excluded string found in input
+; NOT-ERRMSG: defines.txt:8:1: note: found here
+; NOT-ERRMSG: defines.txt:8:1: note: with variable "VALUE" equal to "10"
+
+; ERRCLI: Command-line definition 'VALUE10' missing equal sign
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55940.179093.patch
Type: text/x-patch
Size: 2179 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181220/a933cecb/attachment-0001.bin>
More information about the llvm-commits
mailing list