[FileCheck] Improve -dump-input documentation

Document the default of `fail` in `-help`.  Extend `-dump-input=help`
to help users find related command-line options, but let `-help`
provide their full documentation.

Reviewed By: probinson

Differential Revision: https://reviews.llvm.org/D83091
This commit is contained in:
Joel E. Denny 2020-07-09 17:31:31 -04:00
parent f40b11325e
commit 839f8e4fe2
2 changed files with 15 additions and 12 deletions

View File

@ -224,7 +224,7 @@ BADVAL: {{F|f}}ile{{C|c}}heck{{.*}}: for the --dump-input option: Cannot find op
; HELP-NOT: {{.}} ; HELP-NOT: {{.}}
; HELP: The following description was requested by -dump-input=help ; HELP: The following description was requested by -dump-input=help
; HELP: try{{.*}}-color ; HELP: - colors {{.*}}
; HELP-NOT: {{.}} ; HELP-NOT: {{.}}
; Trace is sometimes suppressed. ; Trace is sometimes suppressed.

View File

@ -121,10 +121,9 @@ static cl::list<DumpInputValue> DumpInputs(
cl::desc("Dump input to stderr, adding annotations representing\n" cl::desc("Dump input to stderr, adding annotations representing\n"
"currently enabled diagnostics. When there are multiple\n" "currently enabled diagnostics. When there are multiple\n"
"occurrences of this option, the <value> that appears earliest\n" "occurrences of this option, the <value> that appears earliest\n"
"in the list below has precedence.\n"), "in the list below has precedence. The default is 'fail'.\n"),
cl::value_desc("mode"), cl::value_desc("mode"),
cl::values(clEnumValN(DumpInputHelp, "help", cl::values(clEnumValN(DumpInputHelp, "help", "Explain input dump and quit"),
"Explain dump format and quit"),
clEnumValN(DumpInputAlways, "always", "Always dump input"), clEnumValN(DumpInputAlways, "always", "Always dump input"),
clEnumValN(DumpInputFail, "fail", "Dump input on failure"), clEnumValN(DumpInputFail, "fail", "Dump input on failure"),
clEnumValN(DumpInputNever, "never", "Never dump input"))); clEnumValN(DumpInputNever, "never", "Never dump input")));
@ -180,8 +179,15 @@ static MarkerStyle GetMarker(FileCheckDiag::MatchType MatchTy) {
static void DumpInputAnnotationHelp(raw_ostream &OS) { static void DumpInputAnnotationHelp(raw_ostream &OS) {
OS << "The following description was requested by -dump-input=help to\n" OS << "The following description was requested by -dump-input=help to\n"
<< "explain the input annotations printed by -dump-input=always and\n" << "explain the input dump printed by FileCheck.\n"
<< "-dump-input=fail:\n\n"; << "\n"
<< "Related command-line options:\n"
<< " - -dump-input=<value> enables or disables the input dump\n"
<< " - -v and -vv add more annotations\n"
<< " - -color forces colors to be enabled both in the dump and below\n"
<< " - -help documents the above options in more detail\n"
<< "\n"
<< "Input dump annotation format:\n";
// Labels for input lines. // Labels for input lines.
OS << " - "; OS << " - ";
@ -233,8 +239,7 @@ static void DumpInputAnnotationHelp(raw_ostream &OS) {
WithColor(OS, raw_ostream::CYAN, true, false) << "discarded match"; WithColor(OS, raw_ostream::CYAN, true, false) << "discarded match";
OS << ", "; OS << ", ";
WithColor(OS, raw_ostream::CYAN, true, true) << "unmatched input"; WithColor(OS, raw_ostream::CYAN, true, true) << "unmatched input";
OS << "\n\n" OS << "\n";
<< "If you are not seeing color above or in input dumps, try: -color\n";
} }
/// An annotation for a single input line. /// An annotation for a single input line.
@ -675,12 +680,10 @@ int main(int argc, char **argv) {
if (DumpInput == DumpInputAlways || if (DumpInput == DumpInputAlways ||
(ExitCode == 1 && DumpInput == DumpInputFail)) { (ExitCode == 1 && DumpInput == DumpInputFail)) {
errs() << "\n" errs() << "\n"
<< "Input file: " << "Input file: " << InputFilename << "\n"
<< InputFilename
<< "\n"
<< "Check file: " << CheckFilename << "\n" << "Check file: " << CheckFilename << "\n"
<< "\n" << "\n"
<< "-dump-input=help describes the format of the following dump.\n" << "-dump-input=help explains the following input dump.\n"
<< "\n"; << "\n";
std::vector<InputAnnotation> Annotations; std::vector<InputAnnotation> Annotations;
unsigned LabelWidth; unsigned LabelWidth;