Skip to content

Commit

Permalink
[FileCheck] Implement -v and -vv for tracing matches
Browse files Browse the repository at this point in the history
-v prints all directive pattern matches.

-vv additionally prints info that might be noise to users but that can
be helpful to FileCheck developers.

To maximize code reuse and to make diagnostics more consistent, this
patch also adjusts and extends some of the existing diagnostics.
CHECK-NOT failures now report variables uses.  Many more diagnostics
now report the check prefix and kind of directive.

Reviewed By: probinson

Differential Revision: https://reviews.llvm.org/D47114

llvm-svn: 336967
  • Loading branch information
jdenny-ornl committed Jul 13, 2018
1 parent 01c762b commit dc5ba31
Show file tree
Hide file tree
Showing 11 changed files with 300 additions and 59 deletions.
10 changes: 10 additions & 0 deletions llvm/docs/CommandGuide/FileCheck.rst
Expand Up @@ -95,6 +95,16 @@ OPTIONS

Show the version number of this program.

.. option:: -v

Print directive pattern matches.

.. option:: -vv

Print information helpful in diagnosing internal FileCheck issues, such as
discarded overlapping ``CHECK-DAG:`` matches, implicit EOF pattern matches,
and ``CHECK-NOT:`` patterns that do not have matches. Implies ``-v``.

.. option:: --allow-deprecated-dag-overlap

Enable overlapping among matches in a group of consecutive ``CHECK-DAG:``
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/FileCheck/check-empty.txt
Expand Up @@ -9,4 +9,4 @@
; EMPTY-ERR: FileCheck error: '-' is empty.
; EMPTY-ERR-NEXT: FileCheck command line: {{.*}}FileCheck{{.*}}-check-prefix={{.*}}FOO {{.*}}check-empty.txt
; NO-EMPTY-ERR-NOT: FileCheck error: '-' is empty.
; NOT-FOUND: error: expected string not found in input
; NOT-FOUND: error: FOO: expected string not found in input
2 changes: 1 addition & 1 deletion llvm/test/FileCheck/check-label-dag.txt
Expand Up @@ -7,5 +7,5 @@ CHECK-LABEL: {{^}}bar
CHECK-DAG: {{^}}foo
CHECK-LABEL: {{^}}zed

ERROR: error: expected string not found in input
ERROR: error: CHECK-DAG: expected string not found in input
ERROR-NEXT: CHECK-DAG: {{.....}}foo
2 changes: 1 addition & 1 deletion llvm/test/FileCheck/check-multiple-prefixes-nomatch-2.txt
Expand Up @@ -8,5 +8,5 @@ bar
; FOO: fo{{o}}
; BAR: ba{{r}}

; CHECK: {{error: expected string not found in input}}
; CHECK: {{error: FOO: expected string not found in input}}
; CHECK-NEXT: {{F}}OO: fo{{[{][{]o[}][}]}}
2 changes: 1 addition & 1 deletion llvm/test/FileCheck/check-multiple-prefixes-nomatch.txt
Expand Up @@ -8,5 +8,5 @@ foo
; BAR: ba{{z}}
; FOO: fo{{o}}

; CHECK: {{error: expected string not found in input}}
; CHECK: {{error: BAR: expected string not found in input}}
; CHECK-NEXT: {{B}}AR: ba{{[{][{]z[}][}]}}
5 changes: 4 additions & 1 deletion llvm/test/FileCheck/check-not-diaginfo.txt
Expand Up @@ -2,6 +2,9 @@

CHECK-NOT: test

DIAG: CHECK-NOT: pattern specified here
DIAG: error: CHECK-NOT: excluded string found in input
DIAG-NEXT: CHECK-NOT: test
DIAG-NEXT: {{^ \^}}
DIAG-NEXT: note: found here
DIAG-NEXT: CHECK-NOT: test
DIAG-NEXT: {{^ \^}}
13 changes: 11 additions & 2 deletions llvm/test/FileCheck/defines.txt
@@ -1,9 +1,18 @@
; RUN: FileCheck -DVALUE=10 -input-file %s %s
; RUN: not FileCheck -DVALUE=20 -input-file %s %s 2>&1 | FileCheck %s -check-prefix ERRMSG
;
; RUN: not FileCheck -DVALUE=10 -check-prefix NOT -input-file %s %s 2>&1 | FileCheck %s -check-prefix NOT-ERRMSG
; RUN: FileCheck -DVALUE=20 -check-prefix NOT -input-file %s %s

Value = 10
; CHECK: Value = [[VALUE]]
; NOT-NOT: Value = [[VALUE]]

; ERRMSG: defines.txt:5:10: error: expected string not found in input
; ERRMSG: defines.txt:8:10: error: CHECK: expected string not found in input
; ERRMSG: defines.txt:1:1: note: scanning from here
; ERRMSG: defines.txt:1:1: note: with variable "VALUE" equal to "20"
; ERRMSG: defines.txt:4:1: note: possible intended match here
; ERRMSG: defines.txt:7:1: note: possible intended match here

; NOT-ERRMSG: defines.txt:9:12: error: {{NOT}}-NOT: excluded string found in input
; NOT-ERRMSG: defines.txt:7:1: note: found here
; NOT-ERRMSG: defines.txt:7:1: note: with variable "VALUE" equal to "10"
28 changes: 14 additions & 14 deletions llvm/test/FileCheck/implicit-check-not.txt
Expand Up @@ -9,36 +9,36 @@

warning: aaa
; CHECK-PASS: warning: aaa
; CHECK-ERROR1: error: CHECK-FAIL1-NOT: string occurred!
; CHECK-ERROR1: command line:1:22: note: CHECK-FAIL1-NOT: pattern specified here
; CHECK-ERROR1: command line:1:22: error: CHECK-FAIL1-NOT: excluded string found in input
; CHECK-ERROR1-NEXT: -implicit-check-not='warning:'
; CHECK-ERROR1: note: found here
; CHECK-FAIL2: warning: aaa
; CHECK-FAIL3: warning: aaa
; CHECK-ERROR4: error: CHECK-FAIL1-NOT: string occurred!
; CHECK-ERROR4: command line:1:22: note: CHECK-FAIL1-NOT: pattern specified here
; CHECK-ERROR4: command line:1:22: error: CHECK-FAIL1-NOT: excluded string found in input
; CHECK-ERROR4-NEXT: {{-implicit-check-not='\{\{aaa\|bbb\|ccc\}\}'}}
; CHECK-ERROR5: error: CHECK-FAIL1-NOT: string occurred!
; CHECK-ERROR5: command line:1:22: note: CHECK-FAIL1-NOT: pattern specified here
; CHECK-ERROR4: note: found here
; CHECK-ERROR5: command line:1:22: error: CHECK-FAIL1-NOT: excluded string found in input
; CHECK-ERROR5-NEXT: -implicit-check-not='aaa'
; CHECK-ERROR5: note: found here

warning: bbb
; CHECK-PASS: warning: bbb
; CHECK-FAIL1: warning: bbb
; CHECK-ERROR2: error: CHECK-FAIL2-NOT: string occurred!
; CHECK-ERROR2: command line:1:22: note: CHECK-FAIL2-NOT: pattern specified here
; CHECK-ERROR2: command line:1:22: error: CHECK-FAIL2-NOT: excluded string found in input
; CHECK-ERROR2-NEXT: -implicit-check-not='warning:'
; CHECK-ERROR2: note: found here
; CHECK-FAIL3: warning: bbb
; CHECK-ERROR6: error: CHECK-FAIL2-NOT: string occurred!
; CHECK-ERROR6: command line:1:22: note: CHECK-FAIL2-NOT: pattern specified here
; CHECK-ERROR6: command line:1:22: error: CHECK-FAIL2-NOT: excluded string found in input
; CHECK-ERROR6-NEXT: -implicit-check-not='bbb'
; CHECK-ERROR6: note: found here

warning: ccc
; CHECK-PASS: warning: ccc
; CHECK-FAIL1: warning: ccc
; CHECK-FAIL2: warning: ccc
; CHECK-ERROR3: error: CHECK-FAIL3-NOT: string occurred!
; CHECK-ERROR3: command line:1:22: note: CHECK-FAIL3-NOT: pattern specified here
; CHECK-ERROR3: command line:1:22: error: CHECK-FAIL3-NOT: excluded string found in input
; CHECK-ERROR3-NEXT: -implicit-check-not='warning:'
; CHECK-ERROR7: error: CHECK-FAIL3-NOT: string occurred!
; CHECK-ERROR7: command line:1:22: note: CHECK-FAIL3-NOT: pattern specified here
; CHECK-ERROR3: note: found here
; CHECK-ERROR7: command line:1:22: error: CHECK-FAIL3-NOT: excluded string found in input
; CHECK-ERROR7-NEXT: -implicit-check-not='ccc'
; CHECK-ERROR7: note: found here
10 changes: 5 additions & 5 deletions llvm/test/FileCheck/match-full-lines.txt
Expand Up @@ -26,28 +26,28 @@ Label 66
// CHECK:a line
// CHECK:trailing whitespace
// CHECK:trailing more whitespace
// ERROR-STRICT:error: expected string not found in input
// ERROR-STRICT:error: {{C}}HECK: expected string not found in input
// ERROR-STRICT:// {{C}}HECK:trailing whitespace

// CHECK-LABEL:Label 2
// CHECK:a line
// CHECK-NEXT:leading whitespace
// CHECK-NEXT: leading more whitespace
// ERROR-STRICT:error: expected string not found in input
// ERROR-STRICT:error: {{C}}HECK-NEXT: expected string not found in input
// ERROR-STRICT:// {{C}}HECK-NEXT:leading whitespace

// CHECK-LABEL:Label 3
// CHECK:line
// ERROR:error: expected string not found in input
// ERROR:error: {{C}}HECK: expected string not found in input
// ERROR:// {{C}}HECK:line

// CHECK-LABEL:Label 4
// CHECK:a line
// CHECK-NOT:random
// ERROR:error: {{C}}HECK-NOT: string occurred!
// ERROR:error: {{C}}HECK-NOT: excluded string found in input
// ERROR:a random thing

// CHECK-LABEL:Label 5
// CHECK-LABEL:Label 6
// ERROR:error: expected string not found in input
// ERROR:error: {{C}}HECK-LABEL: expected string not found in input
// ERROR:{{C}}HECK-LABEL:Label 6
115 changes: 115 additions & 0 deletions llvm/test/FileCheck/verbose.txt
@@ -0,0 +1,115 @@
; RUN: FileCheck -input-file %s %s 2>&1 | FileCheck -check-prefix QUIET --allow-empty %s
; RUN: FileCheck -v -input-file %s %s 2>&1 | FileCheck -check-prefix V %s
; RUN: FileCheck -vv -input-file %s %s 2>&1 | FileCheck -check-prefixes V,VV %s

foo
bar
CHECK: foo
CHECK-NOT: raboof
CHECK-NEXT: bar

V: verbose.txt:[[@LINE-4]]:8: remark: {{C}}HECK: expected string found in input
V-NEXT: {{C}}HECK: foo{{$}}
V-NEXT: {{^ \^$}}
V-NEXT: verbose.txt:[[@LINE-9]]:1: note: found here
V-NEXT: {{^}}foo{{$}}
V-NEXT: {{^}}^~~{{$}}

V-NEXT: verbose.txt:[[@LINE-9]]:13: remark: {{C}}HECK-NEXT: expected string found in input
V-NEXT: {{C}}HECK-NEXT: bar{{$}}
V-NEXT: {{^ \^$}}
V-NEXT: verbose.txt:[[@LINE-15]]:1: note: found here
V-NEXT: {{^}}bar{{$}}
V-NEXT: {{^}}^~~{{$}}

VV-NEXT: verbose.txt:[[@LINE-17]]:12: remark: {{C}}HECK-NOT: excluded string not found in input
VV-NEXT: {{C}}HECK-NOT: raboof{{$}}
VV-NEXT: {{^ \^$}}
VV-NEXT: verbose.txt:[[@LINE-22]]:1: note: scanning from here
VV-NEXT: {{^}}bar{{$}}
VV-NEXT: {{^}}^{{$}}

before empty

after empty
CHECK: before empty
CHECK-EMPTY:
CHECK-NEXT: after empty

V: verbose.txt:[[@LINE-4]]:8: remark: {{C}}HECK: expected string found in input
V-NEXT: {{C}}HECK: before empty{{$}}
V-NEXT: {{^ \^$}}
V-NEXT: verbose.txt:[[@LINE-10]]:1: note: found here
V-NEXT: {{^}}before empty{{$}}
V-NEXT: {{^}}^~~~~~~~~~~~{{$}}

V-NEXT: verbose.txt:[[@LINE-10]]:13: remark: {{C}}HECK-EMPTY: expected string found in input
V-NEXT: {{C}}HECK-EMPTY:{{$}}
V-NEXT: {{^ \^$}}
V-NEXT: verbose.txt:[[@LINE-16]]:1: note: found here
V-EMPTY:
V-NEXT: {{^}}^{{$}}

V-NEXT: verbose.txt:[[@LINE-16]]:13: remark: {{C}}HECK-NEXT: expected string found in input
V-NEXT: {{C}}HECK-NEXT: after empty{{$}}
V-NEXT: {{^ \^$}}
V-NEXT: verbose.txt:[[@LINE-22]]:1: note: found here
V-NEXT: {{^}}after empty{{$}}
V-NEXT: {{^}}^~~~~~~~~~~{{$}}

abcdef
abcdef
CHECK-DAG: abcdef
CHECK-DAG: def

V-NEXT: verbose.txt:[[@LINE-3]]:12: remark: {{C}}HECK-DAG: expected string found in input
V-NEXT: {{C}}HECK-DAG: abcdef
V-NEXT: {{^ \^$}}
V-NEXT: verbose.txt:[[@LINE-8]]:1: note: found here
V-NEXT: {{^}}abcdef{{$}}
V-NEXT: {{^}}^~~~~~{{$}}

VV-NEXT: verbose.txt:[[@LINE-9]]:12: remark: {{C}}HECK-DAG: expected string found in input
VV-NEXT: {{C}}HECK-DAG: def
VV-NEXT: {{^ \^$}}
VV-NEXT: verbose.txt:[[@LINE-15]]:4: note: found here
VV-NEXT: {{^abcdef$}}
VV-NEXT: {{^ \^~~$}}
VV-NEXT: verbose.txt:[[@LINE-18]]:1: note: match discarded, overlaps earlier DAG match here
VV-NEXT: {{^}}abcdef{{$}}
VV-NEXT: {{^}}^~~~~~{{$}}

V-NEXT: verbose.txt:[[@LINE-19]]:12: remark: {{C}}HECK-DAG: expected string found in input
V-NEXT: {{C}}HECK-DAG: def
V-NEXT: {{^ \^$}}
V-NEXT: verbose.txt:[[@LINE-24]]:4: note: found here
V-NEXT: {{^abcdef$}}
V-NEXT: {{^ \^~~$}}

xyz
CHECK: xyz
CHECK-NOT: {{z}}yx

V: verbose.txt:[[@LINE-3]]:8: remark: {{C}}HECK: expected string found in input
V-NEXT: {{C}}HECK: xyz{{$}}
V-NEXT: {{^ \^$}}
V-NEXT: verbose.txt:[[@LINE-7]]:1: note: found here
V-NEXT: {{^}}xyz{{$}}
V-NEXT: {{^}}^~~{{$}}

VV-NEXT: verbose.txt:[[@LINE-9]]:19: remark: implicit EOF: expected string found in input
VV-NEXT: {{C}}HECK-NOT: {{[{][{]z[}][}]yx$}}
VV-NEXT: {{^ \^$}}
VV-NEXT: verbose.txt:[[@LINE+13]]:1: note: found here
VV-NOT: {{.}}
VV: {{^\^$}}

VV-NEXT: verbose.txt:[[@LINE-16]]:12: remark: {{C}}HECK-NOT: excluded string not found in input
VV-NEXT: {{C}}HECK-NOT: {{[{][{]z[}][}]yx$}}
VV-NEXT: {{^ \^$}}
VV-NEXT: verbose.txt:[[@LINE-20]]:1: note: scanning from here
VV-NEXT: {{^C}}HECK: xyz{{$}}
VV-NEXT: {{^\^$}}

QUIET-NOT: {{.}}
V-NOT: {{.}}

0 comments on commit dc5ba31

Please sign in to comment.