[PATCH] D96653: [FileCheck] Add neighboring annotations for -dump-input-filter=error

Joel E. Denny via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 13 11:39:47 PST 2021


jdenny created this revision.
jdenny added reviewers: probinson, thopre, jhenderson, mehdi_amini.
jdenny requested review of this revision.
Herald added a project: LLVM.

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:

1. Any annotation that neighbors an error annotation is likely useful in debugging that error.
2. 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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96653

Files:
  llvm/test/FileCheck/dump-input/filter-error-neighbor/check-dag.txt
  llvm/test/FileCheck/dump-input/filter-error-neighbor/check-label-follows.txt
  llvm/test/FileCheck/dump-input/filter-error-neighbor/check-next-same.txt
  llvm/test/FileCheck/dump-input/filter-error-neighbor/check-not.txt
  llvm/test/FileCheck/dump-input/filter-error-neighbor/multiline.txt
  llvm/test/FileCheck/dump-input/filter.txt
  llvm/utils/FileCheck/FileCheck.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96653.323566.patch
Type: text/x-patch
Size: 24292 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210213/bfc55d1c/attachment-0001.bin>


More information about the llvm-commits mailing list