diff options
author | Joel E. Denny <jdenny.ornl@gmail.com> | 2018-12-18 00:02:47 +0000 |
---|---|---|
committer | Joel E. Denny <jdenny.ornl@gmail.com> | 2018-12-18 00:02:47 +0000 |
commit | 0e7e3fa0e9a5dac6bf42f4771768968460ab48a8 (patch) | |
tree | cc2243aa8bd79eaac4c4bee3aafbf77351049b38 /llvm/utils/FileCheck | |
parent | cadfcef493d4b31421558a03b895262e3d7769da (diff) | |
download | bcm5719-llvm-0e7e3fa0e9a5dac6bf42f4771768968460ab48a8.tar.gz bcm5719-llvm-0e7e3fa0e9a5dac6bf42f4771768968460ab48a8.zip |
[FileCheck] Annotate input dump (4/7)
This patch implements input annotations for diagnostics that report
unexpected matches for CHECK-NOT. Like wrong-line matches for
CHECK-NEXT, CHECK-SAME, and CHECK-EMPTY, these annotations mark match
ranges using red `!~~` to indicate bad matches that are errors.
For example:
```
$ FileCheck -dump-input=help
The following description was requested by -dump-input=help to
explain the input annotations printed by -dump-input=always and
-dump-input=fail:
- L: labels line number L of the input file
- T:L labels the only match result for a pattern of type T from line L of
the check file
- T:L'N labels the Nth match result for a pattern of type T from line L of
the check file
- !~~ marks bad match, such as:
- CHECK-NEXT on same line as previous match (error)
- CHECK-NOT found (error)
- X~~ marks search range when no match is found, such as:
- CHECK-NEXT not found (error)
- ? marks fuzzy match when no match is found
- colors error, fuzzy match
If you are not seeing color above or in input dumps, try: -color
$ FileCheck -v -dump-input=always check3 < input3 |& sed -n '/^<<<</,$p'
<<<<<<
1: abc foobar def
not:2 !~~~~~ error: no match expected
>>>>>>
$ cat check3
CHECK: abc
CHECK-NOT: foobar
CHECK: def
$ cat input3
abc foobar def
```
Reviewed By: george.karpenkov, probinson
Differential Revision: https://reviews.llvm.org/D53896
llvm-svn: 349421
Diffstat (limited to 'llvm/utils/FileCheck')
-rw-r--r-- | llvm/utils/FileCheck/FileCheck.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/utils/FileCheck/FileCheck.cpp b/llvm/utils/FileCheck/FileCheck.cpp index d027f3e6676..1f6caeee2e1 100644 --- a/llvm/utils/FileCheck/FileCheck.cpp +++ b/llvm/utils/FileCheck/FileCheck.cpp @@ -143,6 +143,8 @@ struct MarkerStyle { static MarkerStyle GetMarker(FileCheckDiag::MatchType MatchTy) { switch (MatchTy) { + case FileCheckDiag::MatchFinalButExcluded: + return MarkerStyle('!', raw_ostream::RED, "error: no match expected"); case FileCheckDiag::MatchFinalButWrongLine: return MarkerStyle('!', raw_ostream::RED, "error: match on wrong line"); case FileCheckDiag::MatchNoneButExpected: @@ -182,6 +184,7 @@ static void DumpInputAnnotationHelp(raw_ostream &OS) { WithColor(OS, raw_ostream::SAVEDCOLOR, true) << "!~~"; OS << " marks bad match, such as:\n" << " - CHECK-NEXT on same line as previous match (error)\n" + << " - CHECK-NOT found (error)\n" << " - "; WithColor(OS, raw_ostream::SAVEDCOLOR, true) << "X~~"; OS << " marks search range when no match is found, such as:\n" |