[FileCheck] Add --verbose

Hi,

this patch adds a --verbose option to FileCheck. [ An alternative name could be --debug or --debug-pattern. ]

Consider a file CHECK:
...
// CHECK-LABEL:bla1
// CHECK-NEXT:bla2
// CHECK-NEXT: bla3
// CHECK-NEXT:bla4
// CHECK-NEXT: bla5
...

and a FileCheck command using --verbose:
...
$ echo | FileCheck CHECK --strict-whitespace --match-full-lines --verbose
...

For each check the actual match pattern used is shown:
...
CHECK:1:16: note: RegEx string match: '^bla1$'
// CHECK-LABEL:bla1
                ^
CHECK:2:15: note: RegEx string match: '^bla2$'
// CHECK-NEXT:bla2
               ^
CHECK:3:16: note: RegEx string match: '^bla3$'
// CHECK-NEXT: bla3
                ^
CHECK:4:15: note: RegEx string match: '^bla4$'
// CHECK-NEXT:bla4
               ^
CHECK:5:16: note: RegEx string match: '^bla5$'
// CHECK-NEXT: bla5
                ^
...

Seeing the actual match pattern allows to see the effect of command line switches that modify the original pattern (such as --match-full-lines), and help to understand why something is or is not matching.

Any comments? OK for trunk?

Thanks,
- Tom

0001-FileCheck-Add-verbose.patch (1.41 KB)

+jyknight, who added --match-full-lines

Hi,

this patch adds a --verbose option to FileCheck. [ An alternative name could be --debug or --debug-pattern. ]

Consider a file CHECK:
...
// CHECK-LABEL:bla1
// CHECK-NEXT:bla2
// CHECK-NEXT: bla3
// CHECK-NEXT:bla4
// CHECK-NEXT: bla5
...

and a FileCheck command using --verbose:
...
$ echo | FileCheck CHECK --strict-whitespace --match-full-lines --verbose
...

For each check the actual match pattern used is shown:
...
CHECK:1:16: note: RegEx string match: '^bla1$'
// CHECK-LABEL:bla1
               ^
CHECK:2:15: note: RegEx string match: '^bla2$'
// CHECK-NEXT:bla2
              ^
CHECK:3:16: note: RegEx string match: '^bla3$'
// CHECK-NEXT: bla3
               ^
CHECK:4:15: note: RegEx string match: '^bla4$'
// CHECK-NEXT:bla4
              ^
CHECK:5:16: note: RegEx string match: '^bla5$'
// CHECK-NEXT: bla5
               ^
...

Seeing the actual match pattern allows to see the effect of command line switches that modify the original pattern (such as --match-full-lines), and help to understand why something is or is not matching.

Any comments? OK for trunk?

It needs a testcase, and some docs in docs/CommandGuide/FileCheck.rst.

Jon

Seems pretty useful!
+1 to Jon's comments.
Procedural remark: patches normally go to llvm-commits not llvm-dev.
--paulr

Seems pretty useful!

Hi,

Glad to hear that :slight_smile:

+1 to Jon's comments.
Procedural remark: patches normally go to llvm-commits not llvm-dev.
--paulr

I see, thanks for pointing that out. I'll do that for a next submission.

From: llvm-dev [mailto:llvm-dev-bounces@lists.llvm.org] On Behalf Of
Jonathan Roelofs via llvm-dev
Sent: Wednesday, December 14, 2016 8:09 AM
To: Tom de Vries; llvm-dev@lists.llvm.org; James Y Knight
Subject: Re: [llvm-dev] [FileCheck] Add --verbose

+jyknight, who added --match-full-lines

Hi,

this patch adds a --verbose option to FileCheck. [ An alternative name
could be --debug or --debug-pattern. ]

Consider a file CHECK:
...
// CHECK-LABEL:bla1
// CHECK-NEXT:bla2
// CHECK-NEXT: bla3
// CHECK-NEXT:bla4
// CHECK-NEXT: bla5
...

and a FileCheck command using --verbose:
...
$ echo | FileCheck CHECK --strict-whitespace --match-full-lines --

verbose

...

For each check the actual match pattern used is shown:
...
CHECK:1:16: note: RegEx string match: '^bla1$'
// CHECK-LABEL:bla1
               ^
CHECK:2:15: note: RegEx string match: '^bla2$'
// CHECK-NEXT:bla2
              ^
CHECK:3:16: note: RegEx string match: '^bla3$'
// CHECK-NEXT: bla3
               ^
CHECK:4:15: note: RegEx string match: '^bla4$'
// CHECK-NEXT:bla4
              ^
CHECK:5:16: note: RegEx string match: '^bla5$'
// CHECK-NEXT: bla5
               ^
...

Seeing the actual match pattern allows to see the effect of command
line switches that modify the original pattern (such as
--match-full-lines), and help to understand why something is or is not
matching.

Any comments? OK for trunk?

It needs a testcase,

Done.

and some docs in docs/CommandGuide/FileCheck.rst.

Done.

Any further comments? OK for trunk?

Thanks,
- Tom

0001-FileCheck-Add-verbose.patch (2.51 KB)