For example:
$ cat check CHECK: start CHECK-NEXT: end $ FileCheck -v check < input |& tail -27 <<<<<< 1: start check:1 ^~~~~ 2: foo0 3: foo1 4: foo2 5: foo3 6: foo4 . . . 18: foo16 19: foo17 20: foo18 21: foo19 22: foo20 23: end next:2 !~~ error: match on wrong line 24: bar0 25: bar1 26: bar2 27: bar3 28: bar4 . . . >>>>>>
Without this patch, input lines 1-6 are not shown. This patch reveals
those lines because that's where the actual problem is because that's
where the CHECK-NEXT directive was expected to match but didn't.
Seeing the line where CHECK-NEXT actually matched, line 23, is
typically less useful information in my experience.
In general, this patch depends on the following heuristics:
- Any annotation that neighbors an error annotation is likely useful in debugging that error.
- Revealing these annotations usually does not increase verbosity significantly.
To point 1, this patch facilitates debugging of several kinds of
errors, examples of which this patch adds to the test suite:
- A CHECK-NEXT or CHECK-SAME match on the wrong line.
- A CHECK-NOT unexpected match because a neighboring directive matched at an unexpected point, affecting the search range.
- An unmatched CHECK because a subsequent CHECK-LABEL matched at an unexpected point, affecting the search range.
To point 2:
- This patch is intended to reveal at most two neighboring annotations per error.
- This patch has no effect when neither -v or -vv is specified because annotations for successful directives are then not generated. Generally, I keep -vv in my environment's FILECHECK_OPTS, but I'm not sure other LLVM developers will want it enabled by default.
- This patch usually doesn't affect the most common kind of failure: a positive directive that doesn't match anything and that isn't followed by a CHECK-LABEL. First, its error annotation already starts at the preceding match, so context typically already reveals the preceding match's annotation. Second, no more directives are processed after the failure, so there are no subsequent annotations to reveal.
- This patch has no effect when -dump-input-filter is set to something other than error (the default). Other values usually produce more verbose input dumps already.