This is an archive of the discontinued LLVM Phabricator instance.

[FileCheck] Annotate input dump (7/7)
ClosedPublic

Authored by jdenny on Oct 30 2018, 2:21 PM.

Details

Summary
This patch implements annotations for diagnostics reporting CHECK-NOT
failed matches.  These diagnostics are enabled by -vv.  As for
diagnostics reporting failed matches for other directives, these
annotations mark the search ranges using `X~~`.  The difference here
is that failed matches for CHECK-NOT are successes not errors, so they
are green not red when colors are enabled.

For example:

```
$ FileCheck -dump-input=help
The following description was requested by -dump-input=help to
explain the input annotations printed by -dump-input=always and
-dump-input=fail:

  - L:     labels line number L of the input file
  - T:L    labels the only match result for a pattern of type T from line L of
           the check file
  - T:L'N  labels the Nth match result for a pattern of type T from line L of
           the check file
  - ^~~    marks good match (reported if -v)
  - !~~    marks bad match, such as:
           - CHECK-NEXT on same line as previous match (error)
           - CHECK-NOT found (error)
           - CHECK-DAG overlapping match (discarded, reported if -vv)
  - X~~    marks search range when no match is found, such as:
           - CHECK-NEXT not found (error)
           - CHECK-NOT not found (success, reported if -vv)
           - CHECK-DAG not found after discarded matches (error)
  - ?      marks fuzzy match when no match is found
  - colors success, error, fuzzy match, discarded match, unmatched input

If you are not seeing color above or in input dumps, try: -color

$ FileCheck -vv -dump-input=always check5 < input5 |& sed -n '/^<<<</,$p'
<<<<<<
         1: abcdef
check:1     ^~~
not:2          X~~
         2: ghijkl
not:2       ~~~
check:3        ^~~
         3: mnopqr
not:4       X~~~~~
         4: stuvwx
not:4       ~~~~~~
         5:
eof:4       ^
>>>>>>

$ cat check5
CHECK: abc
CHECK-NOT: foobar
CHECK: jkl
CHECK-NOT: foobar

$ cat input5
abcdef
ghijkl
mnopqr
stuvwx
```

Diff Detail

Event Timeline

jdenny created this revision.Oct 30 2018, 2:21 PM
jdenny updated this revision to Diff 173051.Nov 7 2018, 3:14 PM

Rebased onto updated patches earlier in series.

jdenny updated this revision to Diff 174790.Nov 20 2018, 8:51 AM

Update for changes earlier in patch series.

jdenny updated this revision to Diff 176904.Dec 5 2018, 4:43 PM
jdenny edited the summary of this revision. (Show Details)
jdenny set the repository for this revision to rL LLVM.

Propagate changes started earlier in patch series.

jdenny updated this revision to Diff 177387.Dec 7 2018, 10:14 PM
jdenny edited the summary of this revision. (Show Details)

Continue changes started earlier in patch series.

jdenny updated this revision to Diff 177948.Dec 12 2018, 3:11 PM
jdenny set the repository for this revision to rL LLVM.

Adjust comment, as suggested by probinson.

Remove MatchTypeCount, which is unused as of this patch.

Remove MatchTypeCount, which is unused as of this patch.

What do we see if a Counted match doesn't have enough matches? I'm not seeing a test that covers that case.

jdenny added inline comments.Dec 14 2018, 1:31 PM
llvm/test/FileCheck/dump-input-annotations.txt
88–89

Remove MatchTypeCount, which is unused as of this patch.

To be clear, I originally meant MatchTypeCount to be a count of the MatchType members, so it's not actually related to your question below. In this version of the patch series, that wasn't even it's role anymore. I should have named it something more like MatchTypeUndefined. Sorry about that. Anyway, this final patch removes it.

What do we see if a Counted match doesn't have enough matches? I'm not seeing a test that covers that case.

I'm responding as an inline comment in the test that covers it. (Don't be misled: the error isn't reported twice as CNT-Q and CNT-V are not active at the same time.)

Do you feel we need a separate MatchType and a more specific note for this case?

probinson added inline comments.Dec 14 2018, 2:06 PM
llvm/test/FileCheck/dump-input-annotations.txt
88–89

Thanks for pointing it out, and no I think what you have is fine.

jdenny marked 2 inline comments as done.Dec 15 2018, 5:59 AM
This revision is now accepted and ready to land.Dec 17 2018, 8:16 AM
This revision was automatically updated to reflect the committed changes.