This is an archive of the discontinued LLVM Phabricator instance.

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

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

Details

Summary

This patch implements input annotations for diagnostics that suggest
fuzzy matches for directives for which no matches were found. Instead
of using the usual ^~~, which is used by later patches for good
matches, these annotations use ? so that fuzzy matches are visually
distinct. No tildes are included as these diagnostics (independently
of this patch) currently identify only the start of the match.

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
  - X~~    marks search range when no match is found
  - ?      marks fuzzy match when no match is found
  - colors error, fuzzy match

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

$ FileCheck -v -dump-input=always check1 < input1 |& sed -n '/^<<<</,$p'
<<<<<<
          1: ; abc def
          2: ; ghI jkl
next:3'0     X~~~~~~~~ error: no match found
next:3'1       ?       possible intended match
>>>>>>

$ cat check1
CHECK: abc
CHECK-SAME: def
CHECK-NEXT: ghi
CHECK-SAME: jkl

$ cat input1
; abc def
; ghI jkl

This patch introduces the concept of multiple "match results" per
directive. In the above example, the first match result for the
CHECK-NEXT directive is the failed match, for which the annotation
shows the search range. The second match result is the fuzzy match.
Later patches will introduce other cases of multiple match results per
directive.

When colors are enabled, ? is colored magenta. That is, it doesn't
indicate the actual error, which a red X~~ marker indicates, but its
color suggests it's closely related.

Diff Detail

Event Timeline

jdenny created this revision.Oct 30 2018, 2:05 PM
jdenny updated this revision to Diff 173043.Nov 7 2018, 3:12 PM

Rebased onto updated patches earlier in series.

jdenny updated this revision to Diff 174785.Nov 20 2018, 8:50 AM

Update for changes earlier in patch series.

jdenny updated this revision to Diff 176896.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 177381.Dec 7 2018, 10:14 PM
jdenny edited the summary of this revision. (Show Details)

Continue changes started earlier in patch series.

probinson accepted this revision.Dec 12 2018, 10:41 AM

One small comment fix needed, otherwise LGTM.

llvm/include/llvm/Support/FileCheck.h
168

Comments should be proper sentences.

This revision is now accepted and ready to land.Dec 12 2018, 10:41 AM
jdenny updated this revision to Diff 177935.Dec 12 2018, 3:11 PM
jdenny set the repository for this revision to rL LLVM.

Adjust comment, as suggested by probinson.

jdenny marked an inline comment as done.Dec 12 2018, 3:19 PM
This revision was automatically updated to reflect the committed changes.