[PATCH] D97813: [FileCheck] Fix -dump-input per-pattern diagnostic indexing

Joel E. Denny via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 2 15:16:06 PST 2021


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

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 -14
  <<<<<<
              1: text
  not:imp1'0     X~~~
              2: foo
  check:1        ^~~
              3: text
  not:imp1'1     X~~~
              4: foo
  check:2        ^~~
              5: text
  not:imp1'2     X~~~
              6:
  eof:2          ^
  >>>>>>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97813

Files:
  llvm/test/FileCheck/dump-input/annotations.txt
  llvm/utils/FileCheck/FileCheck.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97813.327604.patch
Type: text/x-patch
Size: 10292 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210302/c8237968/attachment.bin>


More information about the llvm-commits mailing list