This is an archive of the discontinued LLVM Phabricator instance.

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

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

Details

Summary

This patch implements input annotations for diagnostics enabled by -v,
which report good matches for directives. These annotations mark
match ranges using ^~~.

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)
  - X~~    marks search range when no match is found, such as:
           - CHECK-NEXT not found (error)
  - ?      marks fuzzy match when no match is found
  - colors success, error, fuzzy match, unmatched input

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

$ FileCheck -v -dump-input=always check3 < input3 |& sed -n '/^<<<</,$p'
<<<<<<
         1: abc foobar def
check:1     ^~~
not:2           !~~~~~     error: no match expected
check:3                ^~~
>>>>>>

$ cat check3
CHECK:     abc
CHECK-NOT: foobar
CHECK:     def

$ cat input3
abc foobar def

-vv enables these annotations for FileCheck's implicit EOF patterns as
well. For an example where EOF patterns become relevant, see patch 7
in this series.

If colors are enabled, ^~~ is green to suggest success.

-v plus color enables highlighting of input text that has no final
match for any expected pattern. The highlight uses a cyan background
to suggest a cold section. This highlighting can make it easier to
spot text that was intended to be matched but that failed to be
matched in a long series of good matches.

CHECK-COUNT-<num> good matches are another case where there can be
multiple match results for the same directive.

Diff Detail

Event Timeline

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

Rebased onto updated patches earlier in series.

jdenny updated this revision to Diff 174788.Nov 20 2018, 8:51 AM
jdenny edited the summary of this revision. (Show Details)

Update for changes earlier in patch series.

jdenny updated this revision to Diff 176902.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 177351.Dec 7 2018, 4:15 PM

Fix bug in logic for highlighting unmatched text: it was broken for -allow-deprecated-dag-overlap.

jdenny updated this revision to Diff 177385.Dec 7 2018, 10:14 PM
jdenny edited the summary of this revision. (Show Details)
jdenny set the repository for this revision to rL LLVM.

Continue changes started earlier in patch series.

jdenny marked an inline comment as done.Dec 8 2018, 2:37 PM
jdenny added inline comments.
llvm/utils/FileCheck/FileCheck.cpp
434

A break statement could be here.

jdenny updated this revision to Diff 177624.Dec 10 2018, 5:01 PM
jdenny marked an inline comment as not done.
  • Add a break statement to skip useless loop iterations.
  • Convert a list to a vector.
jdenny marked an inline comment as done.Dec 10 2018, 5:03 PM
jdenny updated this revision to Diff 177942.Dec 12 2018, 3:11 PM
jdenny set the repository for this revision to rL LLVM.

Adjust comment, as suggested by probinson.

probinson accepted this revision.Dec 14 2018, 12:57 PM

The terminology around "possible" "expected" and "final" matches probably warrants a few lines of commentary somewhere, unless I missed it in an earlier patch. There are getting to be enough cases that the casual reader (ahem) can't just Zen their way through them all.
Can be done as a follow-up if you prefer.
One comment nit and LGTM.

llvm/utils/FileCheck/FileCheck.cpp
409–422

For the case...

This revision is now accepted and ready to land.Dec 14 2018, 12:57 PM

The terminology around "possible" "expected" and "final" matches probably warrants a few lines of commentary somewhere, unless I missed it in an earlier patch. There are getting to be enough cases that the casual reader (ahem) can't just Zen their way through them all.

Sure, I'll add some additional comments here.

Can be done as a follow-up if you prefer.

Yes, a follow-up would be easier. I'll just commit something. If you prefer a phab review first, that's absolutely fine for me, but let me know.

Yes, a follow-up would be easier. I'll just commit something. If you prefer a phab review first, that's absolutely fine for me, but let me know.

No, just do it.

jdenny marked an inline comment as done.Dec 15 2018, 5:56 AM

Remaining suggestions done in D55738.

This revision was automatically updated to reflect the committed changes.