[llvm] r351881 - [FileCheck] Suppress old -v/-vv diags if dumping input

Joel E. Denny via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 22 13:41:43 PST 2019


Author: jdenny
Date: Tue Jan 22 13:41:42 2019
New Revision: 351881

URL: http://llvm.org/viewvc/llvm-project?rev=351881&view=rev
Log:
[FileCheck] Suppress old -v/-vv diags if dumping input

The old diagnostic form of the trace produced by -v and -vv looks
like:

```
check1:1:8: remark: CHECK: expected string found in input
CHECK: abc
       ^
<stdin>:1:3: note: found here
; abc def
  ^~~
```

When dumping annotated input is requested (via -dump-input), I find
that this old trace is not useful and is sometimes harmful:

1. The old trace is mostly redundant because the same basic
   information also appears in the input dump's annotations.

2. The old trace buries any error diagnostic between it and the input
   dump, but I find it useful to see any error diagnostic up front.

3. FILECHECK_OPTS=-dump-input=fail requests annotated input dumps only
   for failed FileCheck calls.  However, I have to also add -v or -vv
   to get a full set of annotations, and that can produce massive
   output from all FileCheck calls in all tests.  That's a real
   problem when I run this in the IDE I use, which grinds to a halt as
   it tries to capture all that output.

When -dump-input=fail|always, this patch suppresses the old trace from
-v or -vv.  Error diagnostics still print as usual.  If you want the
old trace, perhaps to see variable expansions, you can set
-dump-input=none (the default).

Reviewed By: probinson

Differential Revision: https://reviews.llvm.org/D55825

Modified:
    llvm/trunk/docs/CommandGuide/FileCheck.rst
    llvm/trunk/lib/Support/FileCheck.cpp
    llvm/trunk/test/FileCheck/dump-input-annotations.txt
    llvm/trunk/test/FileCheck/dump-input-enable.txt
    llvm/trunk/utils/FileCheck/FileCheck.cpp

Modified: llvm/trunk/docs/CommandGuide/FileCheck.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/FileCheck.rst?rev=351881&r1=351880&r2=351881&view=diff
==============================================================================
--- llvm/trunk/docs/CommandGuide/FileCheck.rst (original)
+++ llvm/trunk/docs/CommandGuide/FileCheck.rst Tue Jan 22 13:41:42 2019
@@ -111,13 +111,16 @@ and from the command line.
 
 .. option:: -v
 
-  Print directive pattern matches.
+  Print good directive pattern matches.  However, if ``-input-dump=fail`` or
+  ``-input-dump=always``, add those matches as input annotations instead.
 
 .. option:: -vv
 
   Print information helpful in diagnosing internal FileCheck issues, such as
   discarded overlapping ``CHECK-DAG:`` matches, implicit EOF pattern matches,
   and ``CHECK-NOT:`` patterns that do not have matches.  Implies ``-v``.
+  However, if ``-input-dump=fail`` or ``-input-dump=always``, just add that
+  information as input annotations instead.
 
 .. option:: --allow-deprecated-dag-overlap
 

Modified: llvm/trunk/lib/Support/FileCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/FileCheck.cpp?rev=351881&r1=351880&r2=351881&view=diff
==============================================================================
--- llvm/trunk/lib/Support/FileCheck.cpp (original)
+++ llvm/trunk/lib/Support/FileCheck.cpp Tue Jan 22 13:41:42 2019
@@ -900,16 +900,24 @@ static void PrintMatch(bool ExpectedMatc
                        StringMap<StringRef> &VariableTable, size_t MatchPos,
                        size_t MatchLen, const FileCheckRequest &Req,
                        std::vector<FileCheckDiag> *Diags) {
+  bool PrintDiag = true;
   if (ExpectedMatch) {
     if (!Req.Verbose)
       return;
     if (!Req.VerboseVerbose && Pat.getCheckTy() == Check::CheckEOF)
       return;
+    // Due to their verbosity, we don't print verbose diagnostics here if we're
+    // gathering them for a different rendering, but we always print other
+    // diagnostics.
+    PrintDiag = !Diags;
   }
   SMRange MatchRange = ProcessMatchResult(
       ExpectedMatch ? FileCheckDiag::MatchFoundAndExpected
                     : FileCheckDiag::MatchFoundButExcluded,
       SM, Loc, Pat.getCheckTy(), Buffer, MatchPos, MatchLen, Diags);
+  if (!PrintDiag)
+    return;
+
   std::string Message = formatv("{0}: {1} string found in input",
                                 Pat.getCheckTy().getDescription(Prefix),
                                 (ExpectedMatch ? "expected" : "excluded"))
@@ -940,27 +948,37 @@ static void PrintNoMatch(bool ExpectedMa
                          StringRef Buffer, StringMap<StringRef> &VariableTable,
                          bool VerboseVerbose,
                          std::vector<FileCheckDiag> *Diags) {
-  if (!ExpectedMatch && !VerboseVerbose)
+  bool PrintDiag = true;
+  if (!ExpectedMatch) {
+    if (!VerboseVerbose)
+      return;
+    // Due to their verbosity, we don't print verbose diagnostics here if we're
+    // gathering them for a different rendering, but we always print other
+    // diagnostics.
+    PrintDiag = !Diags;
+  }
+
+  // If the current position is at the end of a line, advance to the start of
+  // the next line.
+  Buffer = Buffer.substr(Buffer.find_first_not_of(" \t\n\r"));
+  SMRange SearchRange = ProcessMatchResult(
+      ExpectedMatch ? FileCheckDiag::MatchNoneButExpected
+                    : FileCheckDiag::MatchNoneAndExcluded,
+      SM, Loc, Pat.getCheckTy(), Buffer, 0, Buffer.size(), Diags);
+  if (!PrintDiag)
     return;
 
-  // Otherwise, we have an error, emit an error message.
+  // Print "not found" diagnostic.
   std::string Message = formatv("{0}: {1} string not found in input",
                                 Pat.getCheckTy().getDescription(Prefix),
                                 (ExpectedMatch ? "expected" : "excluded"))
                             .str();
   if (Pat.getCount() > 1)
     Message += formatv(" ({0} out of {1})", MatchedCount, Pat.getCount()).str();
-
   SM.PrintMessage(
       Loc, ExpectedMatch ? SourceMgr::DK_Error : SourceMgr::DK_Remark, Message);
 
-  // Print the "scanning from here" line.  If the current position is at the
-  // end of a line, advance to the start of the next line.
-  Buffer = Buffer.substr(Buffer.find_first_not_of(" \t\n\r"));
-  SMRange SearchRange = ProcessMatchResult(
-      ExpectedMatch ? FileCheckDiag::MatchNoneButExpected
-                    : FileCheckDiag::MatchNoneAndExcluded,
-      SM, Loc, Pat.getCheckTy(), Buffer, 0, Buffer.size(), Diags);
+  // Print the "scanning from here" line.
   SM.PrintMessage(SearchRange.Start, SourceMgr::DK_Note, "scanning from here");
 
   // Allow the pattern to print additional information if desired.
@@ -1275,13 +1293,17 @@ FileCheckString::CheckDag(const SourceMg
         break;
       }
       if (Req.VerboseVerbose) {
-        SMLoc OldStart = SMLoc::getFromPointer(Buffer.data() + MI->Pos);
-        SMLoc OldEnd = SMLoc::getFromPointer(Buffer.data() + MI->End);
-        SMRange OldRange(OldStart, OldEnd);
-        SM.PrintMessage(OldStart, SourceMgr::DK_Note,
-                        "match discarded, overlaps earlier DAG match here",
-                        {OldRange});
-        if (Diags)
+        // Due to their verbosity, we don't print verbose diagnostics here if
+        // we're gathering them for a different rendering, but we always print
+        // other diagnostics.
+        if (!Diags) {
+          SMLoc OldStart = SMLoc::getFromPointer(Buffer.data() + MI->Pos);
+          SMLoc OldEnd = SMLoc::getFromPointer(Buffer.data() + MI->End);
+          SMRange OldRange(OldStart, OldEnd);
+          SM.PrintMessage(OldStart, SourceMgr::DK_Note,
+                          "match discarded, overlaps earlier DAG match here",
+                          {OldRange});
+        } else
           Diags->rbegin()->MatchTy = FileCheckDiag::MatchFoundButDiscarded;
       }
       MatchPos = MI->End;

Modified: llvm/trunk/test/FileCheck/dump-input-annotations.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FileCheck/dump-input-annotations.txt?rev=351881&r1=351880&r2=351881&view=diff
==============================================================================
--- llvm/trunk/test/FileCheck/dump-input-annotations.txt (original)
+++ llvm/trunk/test/FileCheck/dump-input-annotations.txt Tue Jan 22 13:41:42 2019
@@ -16,7 +16,12 @@
 ; RUN: echo 'CHECK: universe' >> %t.chk
 
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \
-; RUN: | FileCheck -strict-whitespace -match-full-lines -check-prefix=ALIGN %s
+; RUN: | FileCheck -strict-whitespace -match-full-lines -check-prefix=ALIGN \
+; RUN:             -implicit-check-not='remark:' %s
+
+; Verbose diagnostics are suppressed but not errors.
+; ALIGN:{{.*}}error:{{.*}}
+; ALIGN:{{.*}}possible intended match here{{.*}}
 
 ; ALIGN:Full input was:
 ; ALIGN-NEXT:<<<<<<
@@ -47,11 +52,18 @@
 ; RUN: echo 'CHECK: world' >> %t.chk
 
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefix=CHK
+; RUN: | FileCheck -match-full-lines %s -check-prefix=CHK \
+; RUN:             -implicit-check-not='remark:'
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefixes=CHK,CHK-V
+; RUN: | FileCheck -match-full-lines %s -check-prefixes=CHK,CHK-V \
+; RUN:             -implicit-check-not='remark:'
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefixes=CHK,CHK-V
+; RUN: | FileCheck -match-full-lines %s -check-prefixes=CHK,CHK-V \
+; RUN:             -implicit-check-not='remark:'
+
+; Verbose diagnostics are suppressed but not errors.
+; CHK: {{.*}}error:{{.*}}
+; CHK: {{.*}}possible intended match here{{.*}}
 
 ; CHK:        <<<<<<
 ; CHK-NEXT:              1: hello
@@ -77,11 +89,17 @@
 ; RUN: echo 'CHECK-COUNT-3: pete' > %t.chk
 
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefixes=CNT,CNT-Q
+; RUN: | FileCheck -match-full-lines %s -check-prefixes=CNT,CNT-Q \
+; RUN:             -implicit-check-not='remark:'
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefixes=CNT,CNT-V
+; RUN: | FileCheck -match-full-lines %s -check-prefixes=CNT,CNT-V \
+; RUN:             -implicit-check-not='remark:'
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefixes=CNT,CNT-V
+; RUN: | FileCheck -match-full-lines %s -check-prefixes=CNT,CNT-V \
+; RUN:             -implicit-check-not='remark:'
+
+; Verbose diagnostics are suppressed but not errors.
+; CNT: {{.*}}error:{{.*}}
 
 ; CNT:          <<<<<<
 ; CNT-NEXT:                1: pete
@@ -108,11 +126,17 @@
 ; RUN: echo 'CHECK-NEXT: world' >> %t.chk
 
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefix=NXT
+; RUN: | FileCheck -match-full-lines %s -check-prefix=NXT \
+; RUN:             -implicit-check-not='remark:'
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefixes=NXT,NXT-V
+; RUN: | FileCheck -match-full-lines %s -check-prefixes=NXT,NXT-V \
+; RUN:             -implicit-check-not='remark:'
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefixes=NXT,NXT-V,NXT-VV
+; RUN: | FileCheck -match-full-lines %s -check-prefixes=NXT,NXT-V,NXT-VV \
+; RUN:             -implicit-check-not='remark:'
+
+; Verbose diagnostics are suppressed but not errors.
+; NXT: {{.*}}error:{{.*}}
 
 ; NXT:        <<<<<<
 ; NXT-NEXT:            1: hello
@@ -155,11 +179,17 @@
 ; RUN: echo 'CHECK-SAME: again' >> %t.chk
 
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefix=SAM
+; RUN: | FileCheck -match-full-lines %s -check-prefix=SAM \
+; RUN:             -implicit-check-not='remark:'
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefixes=SAM,SAM-V
+; RUN: | FileCheck -match-full-lines %s -check-prefixes=SAM,SAM-V \
+; RUN:             -implicit-check-not='remark:'
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefixes=SAM,SAM-V,SAM-VV
+; RUN: | FileCheck -match-full-lines %s -check-prefixes=SAM,SAM-V,SAM-VV \
+; RUN:             -implicit-check-not='remark:'
+
+; Verbose diagnostics are suppressed but not errors.
+; SAM: {{.*}}error:{{.*}}
 
 ; SAM:        <<<<<<
 ; SAM-NEXT:            1: hello world!
@@ -174,7 +204,11 @@
 ; RUN: echo 'again' >> %t.in
 
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefixes=SAM2
+; RUN: | FileCheck -match-full-lines %s -check-prefixes=SAM2 \
+; RUN:             -implicit-check-not='remark:'
+
+; Verbose diagnostics are suppressed but not errors.
+; SAM2: {{.*}}error:{{.*}}
 
 ; SAM2:      <<<<<<
 ; SAM2-NEXT:          1: hello world!
@@ -208,11 +242,17 @@
 ; RUN: echo 'CHECK-LABEL: label' >> %t.chk
 
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefix=EMP
+; RUN: | FileCheck -match-full-lines %s -check-prefix=EMP \
+; RUN:             -implicit-check-not='remark:'
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefixes=EMP,EMP-V
+; RUN: | FileCheck -match-full-lines %s -check-prefixes=EMP,EMP-V \
+; RUN:             -implicit-check-not='remark:'
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefixes=EMP,EMP-V,EMP-VV
+; RUN: | FileCheck -match-full-lines %s -check-prefixes=EMP,EMP-V,EMP-VV \
+; RUN:             -implicit-check-not='remark:'
+
+; Verbose diagnostics are suppressed but not errors.
+; EMP: {{.*}}error:{{.*}}
 
 ; EMP:        <<<<<<
 ; EMP-NEXT:            1: hello
@@ -236,11 +276,17 @@
 ; RUN: echo 'CHECK-EMPTY:' >> %t.chk
 
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefix=EMP2
+; RUN: | FileCheck -match-full-lines %s -check-prefix=EMP2 \
+; RUN:             -implicit-check-not='remark:'
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefixes=EMP2,EMP2-V
+; RUN: | FileCheck -match-full-lines %s -check-prefixes=EMP2,EMP2-V \
+; RUN:             -implicit-check-not='remark:'
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefixes=EMP2,EMP2-V,EMP2-VV
+; RUN: | FileCheck -match-full-lines %s -check-prefixes=EMP2,EMP2-V,EMP2-VV \
+; RUN:             -implicit-check-not='remark:'
+
+; Verbose diagnostics are suppressed but not errors.
+; EMP2: {{.*}}error:{{.*}}
 
 ; EMP2:        <<<<<<
 ; EMP2-NEXT:            1: hello
@@ -265,11 +311,17 @@
 ; RUN: echo 'CHECK-NOT: world' >> %t.chk
 
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefix=NOT
+; RUN: | FileCheck -match-full-lines %s -check-prefix=NOT \
+; RUN:             -implicit-check-not='remark:'
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefixes=NOT,NOT-V
+; RUN: | FileCheck -match-full-lines %s -check-prefixes=NOT,NOT-V \
+; RUN:             -implicit-check-not='remark:'
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefixes=NOT,NOT-V,NOT-VV
+; RUN: | FileCheck -match-full-lines %s -check-prefixes=NOT,NOT-V,NOT-VV \
+; RUN:             -implicit-check-not='remark:'
+
+; Verbose diagnostics are suppressed but not errors.
+; NOT: {{.*}}error:{{.*}}
 
 ; NOT:         <<<<<<
 ; NOT-NEXT:           1: hello
@@ -289,11 +341,17 @@
 ; RUN: echo 'CHECK: ain' >> %t.chk
 
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefix=NOT2
+; RUN: | FileCheck -match-full-lines %s -check-prefix=NOT2 \
+; RUN:             -implicit-check-not='remark:'
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefixes=NOT2,NOT2-V
+; RUN: | FileCheck -match-full-lines %s -check-prefixes=NOT2,NOT2-V \
+; RUN:             -implicit-check-not='remark:'
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefixes=NOT2,NOT2-V,NOT2-VV
+; RUN: | FileCheck -match-full-lines %s -check-prefixes=NOT2,NOT2-V,NOT2-VV \
+; RUN:             -implicit-check-not='remark:'
+
+; Verbose diagnostics are suppressed but not errors.
+; NOT2: {{.*}}error:{{.*}}
 
 ; NOT2:         <<<<<<
 ; NOT2-NEXT:             1: hello
@@ -330,11 +388,17 @@
 ; DAG-VV = -vv
 
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefixes=DAG,DAG-Q
+; RUN: | FileCheck -match-full-lines %s -check-prefixes=DAG,DAG-Q \
+; RUN:             -implicit-check-not='remark:'
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefixes=DAG,DAG-V,DAG-VQ
+; RUN: | FileCheck -match-full-lines %s -check-prefixes=DAG,DAG-V,DAG-VQ \
+; RUN:             -implicit-check-not='remark:'
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefixes=DAG,DAG-V,DAG-VV
+; RUN: | FileCheck -match-full-lines %s -check-prefixes=DAG,DAG-V,DAG-VV \
+; RUN:             -implicit-check-not='remark:'
+
+; Verbose diagnostics are suppressed but not errors.
+; DAG: {{.*}}error:{{.*}}
 
 ; DAG:         <<<<<<
 ; DAG-NEXT:             1: abc
@@ -371,11 +435,18 @@
 ; RUN: echo 'CHECK-LABEL: lab2' >> %t.chk
 
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefixes=LAB
+; RUN: | FileCheck -match-full-lines %s -check-prefixes=LAB \
+; RUN:             -implicit-check-not='remark:'
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefixes=LAB,LAB-V
+; RUN: | FileCheck -match-full-lines %s -check-prefixes=LAB,LAB-V \
+; RUN:             -implicit-check-not='remark:'
 ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \
-; RUN: | FileCheck -match-full-lines %s -check-prefixes=LAB,LAB-V,LAB-VV
+; RUN: | FileCheck -match-full-lines %s -check-prefixes=LAB,LAB-V,LAB-VV \
+; RUN:             -implicit-check-not='remark:'
+
+; Verbose diagnostics are suppressed but not errors.
+; LAB: {{.*}}error:{{.*}}
+; LAB: {{.*}}possible intended match{{.*}}
 
 ; LAB:         <<<<<<
 ; LAB-NEXT:               1: lab0
@@ -390,5 +461,3 @@
 ; LAB-NEXT:    label:3'0     ~~~ error: no match found
 ; LAB-NEXT:    >>>>>>
 ; LAB-NOT:     {{.}}
-
-

Modified: llvm/trunk/test/FileCheck/dump-input-enable.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FileCheck/dump-input-enable.txt?rev=351881&r1=351880&r2=351881&view=diff
==============================================================================
--- llvm/trunk/test/FileCheck/dump-input-enable.txt (original)
+++ llvm/trunk/test/FileCheck/dump-input-enable.txt Tue Jan 22 13:41:42 2019
@@ -1,14 +1,21 @@
-; RUN: echo ciao > %t.good
+;--------------------------------------------------
+; Create the check file, good input, and bad input.
+;
+; For both good and bad input, make sure the -v trace has at least one remark
+; so we can check how trace suppression is affected by -dump-input.
+;--------------------------------------------------
+
+; RUN: echo hello > %t.good
 ; RUN: echo world >> %t.good
 
 ; RUN: echo hello > %t.err
-; RUN: echo world >> %t.err
+; RUN: echo whirled >> %t.err
 
-; RUN: echo 'CHECK: ciao' > %t.check
+; RUN: echo 'CHECK: hello' > %t.check
 ; RUN: echo 'CHECK-NEXT: world' >> %t.check
 
 ;--------------------------------------------------
-; unknown value
+; Check -dump-input=<bad value>.
 ;--------------------------------------------------
 
 ; RUN: not FileCheck -input-file %t.good %t.check -check-prefix=CHECK \
@@ -22,7 +29,7 @@
 BADVAL: FileCheck{{.*}}: for the -dump-input option: Cannot find option named 'foobar'!
 
 ;--------------------------------------------------
-; help
+; Check -dump-input=help.
 ;--------------------------------------------------
 
 ; Appended to normal command line.
@@ -38,91 +45,131 @@ HELP: try{{.*}}-color
 HELP-NOT: {{.}}
 
 ;--------------------------------------------------
-; never
+; Check -dump-input=never.
+;
+; Include the case without -v, which isn't covered elsewhere.
 ;--------------------------------------------------
 
 ; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \
 ; RUN:           -match-full-lines -dump-input=never 2>&1 \
-; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-NODUMP -allow-empty
+; RUN: | FileCheck %s -match-full-lines -allow-empty \
+; RUN:             -check-prefixes=NOTRACE,NODUMP
 
 ; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \
 ; RUN:               -match-full-lines -dump-input=never 2>&1 \
-; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-NODUMP
+; RUN: | FileCheck %s -match-full-lines -check-prefixes=NOTRACE,ERR,NODUMP
+
+; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \
+; RUN:           -match-full-lines -dump-input=never -v 2>&1 \
+; RUN: | FileCheck %s -match-full-lines -check-prefixes=TRACE,NODUMP
+
+; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \
+; RUN:               -match-full-lines -dump-input=never -v 2>&1 \
+; RUN: | FileCheck %s -match-full-lines -check-prefixes=TRACE,ERR,NODUMP
 
 ;--------------------------------------------------
-; default: never
+; Check no -dump-input, which defaults to never.
 ;--------------------------------------------------
 
 ; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \
-; RUN:           -match-full-lines 2>&1 \
-; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-NODUMP -allow-empty
+; RUN:           -match-full-lines -v 2>&1 \
+; RUN: | FileCheck %s -match-full-lines -check-prefixes=TRACE,NODUMP
 
 ; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \
-; RUN:               -match-full-lines 2>&1 \
-; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-NODUMP
+; RUN:               -match-full-lines -v 2>&1 \
+; RUN: | FileCheck %s -match-full-lines -check-prefixes=TRACE,ERR,NODUMP
 
 ;--------------------------------------------------
-; fail
+; Check -dump-input=fail.
+;
+; Include the case without -v, which isn't covered elsewhere.
 ;--------------------------------------------------
 
 ; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \
 ; RUN:           -match-full-lines -dump-input=fail 2>&1 \
-; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-NODUMP -allow-empty
+; RUN: | FileCheck %s -match-full-lines -allow-empty \
+; RUN:             -check-prefixes=NOTRACE,NODUMP
 
 ; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \
 ; RUN:               -match-full-lines -dump-input=fail 2>&1 \
-; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-ERR
+; RUN: | FileCheck %s -match-full-lines -check-prefixes=NOTRACE,ERR,DUMP-ERR
+
+; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \
+; RUN:           -match-full-lines -dump-input=fail -v 2>&1 \
+; RUN: | FileCheck %s -match-full-lines -allow-empty \
+; RUN:             -check-prefixes=NOTRACE,NODUMP
+
+; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \
+; RUN:               -match-full-lines -dump-input=fail -v 2>&1 \
+; RUN: | FileCheck %s -match-full-lines \
+; RUN:                -check-prefixes=NOTRACE,ERR,DUMP-ERR,DUMP-ERR-V
 
 ;--------------------------------------------------
-; -dump-input-on-failure
+; Check -dump-input-on-failure.
 ;--------------------------------------------------
 
 ; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \
-; RUN:           -match-full-lines -dump-input-on-failure 2>&1 \
-; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-NODUMP -allow-empty
+; RUN:           -match-full-lines -dump-input-on-failure -v 2>&1 \
+; RUN: | FileCheck %s -match-full-lines -allow-empty \
+; RUN:             -check-prefixes=NOTRACE,NODUMP
 
 ; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \
-; RUN:               -match-full-lines -dump-input-on-failure 2>&1 \
-; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-ERR
+; RUN:               -match-full-lines -dump-input-on-failure -v 2>&1 \
+; RUN: | FileCheck %s -match-full-lines \
+; RUN:                -check-prefixes=NOTRACE,ERR,DUMP-ERR,DUMP-ERR-V
 
 ; RUN: env FILECHECK_DUMP_INPUT_ON_FAILURE=1 \
 ; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \
-; RUN:           -match-full-lines 2>&1 \
-; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-NODUMP -allow-empty
+; RUN:           -match-full-lines -v 2>&1 \
+; RUN: | FileCheck %s -match-full-lines -allow-empty \
+; RUN:             -check-prefixes=NOTRACE,NODUMP
 
 ; RUN: env FILECHECK_DUMP_INPUT_ON_FAILURE=1 \
 ; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \
-; RUN:               -match-full-lines 2>&1 \
-; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-ERR
+; RUN:               -match-full-lines -v 2>&1 \
+; RUN: | FileCheck %s -match-full-lines \
+; RUN:                -check-prefixes=NOTRACE,ERR,DUMP-ERR,DUMP-ERR-V
 
 ;--------------------------------------------------
-; always
+; Check -dump-input=always.
 ;--------------------------------------------------
 
 ; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \
 ; RUN:           -match-full-lines -dump-input=always -v 2>&1 \
-; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-GOOD
+; RUN: | FileCheck %s -match-full-lines -check-prefixes=NOTRACE,DUMP-OK
 
 ; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \
-; RUN:               -match-full-lines -dump-input=always 2>&1 \
-; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-ERR
+; RUN:               -match-full-lines -dump-input=always -v 2>&1 \
+; RUN: | FileCheck %s -match-full-lines \
+; RUN:                -check-prefixes=NOTRACE,ERR,DUMP-ERR,DUMP-ERR-V
 
 ; END.
 
-; CHECK-GOOD: Full input was:
-; CHECK-GOOD-NEXT: <<<<<<
-; CHECK-GOOD-NEXT:          1: ciao
-; CHECK-GOOD-NEXT: check:1     ^~~~
-; CHECK-GOOD-NEXT:          2: world
-; CHECK-GOOD-NEXT: next:2      ^~~~~
-; CHECK-GOOD-NEXT: >>>>>>
-
-; CHECK-ERR: Full input was:
-; CHECK-ERR-NEXT: <<<<<<
-; CHECK-ERR-NEXT:          1: hello
-; CHECK-ERR-NEXT: check:1     X~~~~
-; CHECK-ERR-NEXT:          2: world
-; CHECK-ERR-NEXT: check:1     ~~~~~ error: no match found
-; CHECK-ERR-NEXT: >>>>>>
+;--------------------------------------------------
+; Check the output for all cases that actually process directives.
+;--------------------------------------------------
 
-; CHECK-NODUMP-NOT: <<<<<<
+; Trace is sometimes suppressed.
+; TRACE:       {{.*}}remark:{{.*}}
+; NOTRACE-NOT: remark:
+
+; Error diagnostics are never suppressed.
+; ERR: {{.*}}error:{{.*}}
+
+; NODUMP-NOT: <<<<<<
+
+; DUMP-OK:      Full input was:
+; DUMP-OK-NEXT: <<<<<<
+; DUMP-OK-NEXT:          1: hello
+; DUMP-OK-NEXT: check:1     ^~~~~
+; DUMP-OK-NEXT:          2: world
+; DUMP-OK-NEXT: next:2      ^~~~~
+; DUMP-OK-NEXT: >>>>>>
+
+; DUMP-ERR:        Full input was:
+; DUMP-ERR-NEXT:   <<<<<<
+; DUMP-ERR-NEXT:            1: hello
+; DUMP-ERR-V-NEXT: check:1     ^~~~~
+; DUMP-ERR-NEXT:            2: whirled
+; DUMP-ERR-NEXT:   next:2      X~~~~~~ error: no match found
+; DUMP-ERR-NEXT:   >>>>>>

Modified: llvm/trunk/utils/FileCheck/FileCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/FileCheck/FileCheck.cpp?rev=351881&r1=351880&r2=351881&view=diff
==============================================================================
--- llvm/trunk/utils/FileCheck/FileCheck.cpp (original)
+++ llvm/trunk/utils/FileCheck/FileCheck.cpp Tue Jan 22 13:41:42 2019
@@ -79,13 +79,16 @@ static cl::opt<bool> AllowDeprecatedDagO
              "provided for convenience as old tests are migrated to the new\n"
              "non-overlapping CHECK-DAG implementation.\n"));
 
-static cl::opt<bool> Verbose("v", cl::init(false),
-                             cl::desc("Print directive pattern matches.\n"));
+static cl::opt<bool> Verbose(
+    "v", cl::init(false),
+    cl::desc("Print directive pattern matches, or add them to the input dump\n"
+             "if enabled.\n"));
 
 static cl::opt<bool> VerboseVerbose(
     "vv", cl::init(false),
     cl::desc("Print information helpful in diagnosing internal FileCheck\n"
-             "issues.  Implies -v.\n"));
+             "issues, or add it to the input dump if enabled.  Implies\n"
+             "-v.\n"));
 static const char * DumpInputEnv = "FILECHECK_DUMP_INPUT_ON_FAILURE";
 
 static cl::opt<bool> DumpInputOnFailure(




More information about the llvm-commits mailing list