aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/FileCheck/FileCheck.cpp
diff options
context:
space:
mode:
authorJoel E. Denny <jdenny.ornl@gmail.com>2019-12-03 10:13:00 -0500
committerJoel E. Denny <jdenny.ornl@gmail.com>2019-12-03 14:21:13 -0500
commitfdde18a7c3e5ae62f458fb83230ec340bf658668 (patch)
tree590932fed309f765c49509725d01379f826f5a6a /llvm/utils/FileCheck/FileCheck.cpp
parent6da7dbb806dce9fbc05416482a5b895efdea96b0 (diff)
downloadllvm-fdde18a7c3e5ae62f458fb83230ec340bf658668.zip
llvm-fdde18a7c3e5ae62f458fb83230ec340bf658668.tar.gz
llvm-fdde18a7c3e5ae62f458fb83230ec340bf658668.tar.bz2
[FileCheck] Given multiple -dump-input, prefer most verbose
Problem: `FILECHECK_OPTS` was implemented so that a test runner, such as a bot, can specify FileCheck debugging options, such as `-dump-input=fail`. However, some existing test suites have FileCheck calls that already specify `-dump-input=fail` or `-dump-input=always`. Without this patch, such tests fail under such a test runner because FileCheck doesn't accept multiple occurrences of `-dump-input`. Solution: This patch permits multiple occurrences of `-dump-input` by assigning precedence to its values in the following descending order: `help`, `always`, `fail`, and `never`. That is, any occurrence of `help` always obtains help, and otherwise the behavior is similar to `-v` vs. `-vv` in that the option specifying the greatest verbosity has precedence. Rationale: My justification for the new behavior is as follows. I have not experienced use cases where, either as a test runner or as a test author, I want to **limit** the permitted debugging verbosity (except as a test author in FileCheck's or lit's test suites where the FileCheck debugging output itself is under test, but the solution there is `env FILECHECK_OPTS=`, and I imagine we should use the same solution anywhere else this need might occur). Of course, as either a test runner or test author, it is useful to **increase** debugging verbosity. Reviewed By: probinson Differential Revision: https://reviews.llvm.org/D70784
Diffstat (limited to 'llvm/utils/FileCheck/FileCheck.cpp')
-rw-r--r--llvm/utils/FileCheck/FileCheck.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/llvm/utils/FileCheck/FileCheck.cpp b/llvm/utils/FileCheck/FileCheck.cpp
index 44d5be1..6f579135 100644
--- a/llvm/utils/FileCheck/FileCheck.cpp
+++ b/llvm/utils/FileCheck/FileCheck.cpp
@@ -108,24 +108,28 @@ static cl::opt<bool> DumpInputOnFailure(
"FILECHECK_DUMP_INPUT_ON_FAILURE environment variable.\n"
"This option is deprecated in favor of -dump-input=fail.\n"));
+// The order of DumpInputValue members affects their precedence, as documented
+// for -dump-input below.
enum DumpInputValue {
DumpInputDefault,
- DumpInputHelp,
DumpInputNever,
DumpInputFail,
- DumpInputAlways
+ DumpInputAlways,
+ DumpInputHelp
};
-static cl::opt<DumpInputValue> DumpInput(
- "dump-input", cl::init(DumpInputDefault),
+static cl::list<DumpInputValue> DumpInputs(
+ "dump-input",
cl::desc("Dump input to stderr, adding annotations representing\n"
- " currently enabled diagnostics\n"),
+ "currently enabled diagnostics. When there are multiple\n"
+ "occurrences of this option, the <value> that appears earliest\n"
+ "in the list below has precedence.\n"),
cl::value_desc("mode"),
cl::values(clEnumValN(DumpInputHelp, "help",
"Explain dump format and quit"),
- clEnumValN(DumpInputNever, "never", "Never dump input"),
+ clEnumValN(DumpInputAlways, "always", "Always dump input"),
clEnumValN(DumpInputFail, "fail", "Dump input on failure"),
- clEnumValN(DumpInputAlways, "always", "Always dump input")));
+ clEnumValN(DumpInputNever, "never", "Never dump input")));
typedef cl::list<std::string>::const_iterator prefix_iterator;
@@ -516,6 +520,10 @@ int main(int argc, char **argv) {
InitLLVM X(argc, argv);
cl::ParseCommandLineOptions(argc, argv, /*Overview*/ "", /*Errs*/ nullptr,
"FILECHECK_OPTS");
+ DumpInputValue DumpInput =
+ DumpInputs.empty()
+ ? DumpInputDefault
+ : *std::max_element(DumpInputs.begin(), DumpInputs.end());
if (DumpInput == DumpInputHelp) {
DumpInputAnnotationHelp(outs());
return 0;