llvm-project/llvm/test/FileCheck
Joel E. Denny c7c542e8f3 [FileCheck] Fix -dump-input per-pattern diagnostic indexing
In input dump annotations, `check:2'1` indicates diagnostic 1 for the
`CHECK` directive on check file line 2.  Without this patch,
`-dump-input` computes the diagnostic index with the assumption that
FileCheck *consecutively* produces all diagnostics for the same
pattern.  Already, that can be a false assumption, as in the examples
below.  Moreover, it seems like a brittle assumption as FileCheck
evolves.  Finally, it actually complicates the implementation even if
it makes it slightly more efficient.

This patch avoids that assumption.  Examples below show results after
applying this patch.  Before applying this patch, `'N` is omitted
throughout these examples because the implementation doesn't notice
there's more than one diagnostic per pattern.

First, `CHECK-LABEL` violates the assumption because `CHECK-LABEL`
tries to match twice, and other directives can match in between:

```
$ cat check
CHECK: foobar
CHECK-LABEL: foobar

$ FileCheck -vv check < input |& tail -8
<<<<<<
           1: text
           2: foobar
label:2'0     ^~~~~~
check:1       ^~~~~~
label:2'1           X error: no match found
           3: text
>>>>>>
```

Second, `--implicit-check-not` is obviously processed many times among
other directives:

```
$ cat check
CHECK: foo
CHECK: foo

$ FileCheck -vv -dump-input=always -implicit-check-not=foo \
            check < input |& tail -16
<<<<<<
            1: text
not:imp1'0     X~~~~
            2: foo
check:1        ^~~
not:imp1'1        X
            3: text
not:imp1'1     ~~~~~
            4: foo
check:2        ^~~
not:imp1'2        X
            5: text
not:imp1'2     ~~~~~
            6:
eof:2          ^
>>>>>>
```

Reviewed By: thopre, jhenderson

Differential Revision: https://reviews.llvm.org/D97813
2021-03-27 10:36:21 -04:00
..
Inputs Add missing EOL. NFCI. 2020-10-31 17:32:04 +00:00
comment
dump-input [FileCheck] Fix -dump-input per-pattern diagnostic indexing 2021-03-27 10:36:21 -04:00
match-time-error-propagation [FileCheck] Fix redundant diagnostics due to numeric errors 2021-03-17 19:25:41 -04:00
allow-unused-prefixes.txt [FileCheck] Default --allow-unused-prefixes to false 2021-02-08 13:37:04 -08:00
bad-char.txt
check-a-b-has-b.txt [FileCheck] Address unused prefixes in tests 2020-10-30 14:14:02 -07:00
check-b-a-has-b.txt [FileCheck] Address unused prefixes in tests 2020-10-30 14:14:02 -07:00
check-count.txt
check-dag-multi-prefix-2.txt
check-dag-multi-prefix.txt
check-dag-not-dag.txt
check-dag-overlap-torture.txt
check-dag-overlap.txt
check-dag-substring-prefix.txt
check-dag-xfails.txt
check-dag.txt
check-empty-tag.txt
check-empty.txt
check-empty2.txt
check-ignore-case.txt
check-label-dag-capture.txt
check-label-dag.txt
check-label.txt
check-literal.txt [FileCheck] Add a literal check directive modifier 2020-12-18 17:26:15 -08:00
check-multi-prefix-label.txt
check-multiple-prefixes-mixed.txt
check-multiple-prefixes-nomatch-2.txt
check-multiple-prefixes-nomatch.txt
check-multiple-prefixes-substr.txt [FileCheck] Address unused prefixes in tests 2020-10-30 14:14:02 -07:00
check-not-diaginfo.txt
check-prefixes.txt
check-substring-multi-prefix-2.txt [FileCheck] Address unused prefixes in tests 2020-10-30 14:14:02 -07:00
check-substring-multi-prefix.txt
dos-style-eol.txt
empty-regex-match-at-start.txt
envvar-opts.txt
first-character-match.txt
implicit-check-not.txt
line-count-2.txt
line-count.txt
lit.local.cfg [FileCheck] Default --allow-unused-prefixes to false 2021-02-08 13:37:04 -08:00
match-full-lines.txt
multiple-check-not-failures.txt
multiple-missing-prefixes.txt [FileCheck] Address unused prefixes in tests 2020-10-30 14:14:02 -07:00
next-no-match.txt
no-check-file.txt
no-multi-suffixes.txt
numeric-defines-diagnostics.txt
numeric-defines.txt
numeric-expression.txt [FileCheck] Add support for hex alternate form in FileCheck 2021-03-12 18:14:17 +00:00
opt-color.txt
regex-brackets.txt
regex-no-match.txt
same.txt
separate-multi-prefix.txt
simple-var-capture.txt [FileCheck] Fix PR49531: invalid use of string var 2021-03-24 18:49:58 +00:00
string-defines-diagnostics.txt
string-defines.txt
two-checks-for-same-match.txt
validate-check-prefix.txt
var-ref-same-line.txt
var-scope.txt
verbose.txt [FileCheck] Do not skip end of line in diagnostics 2021-03-03 08:20:39 +00:00