1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00
llvm-mirror/include/llvm
Joel E. Denny 12285ee434 [FileCheck] Annotate input dump (1/7)
Extend FileCheck to dump its input annotated with FileCheck's
diagnostics: errors, good matches if -v, and additional information if
-vv.  The goal is to make it easier to visualize FileCheck's matching
behavior when debugging.

Each patch in this series implements input annotations for a
particular category of FileCheck diagnostics.  While the first few
patches alone are somewhat useful, the annotations become much more
useful as later patches implement annotations for -v and -vv
diagnostics, which show the matching behavior leading up to the error.

This first patch implements boilerplate plus input annotations for
error diagnostics reporting that no matches were found for a
directive.  These annotations mark the search ranges of the failed
directives.  Instead of using the usual `^~~`, which is used by later
patches for good matches, these annotations use `X~~` so that this
category of errors is visually distinct.

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 match result for a pattern of type T from line L of
           the check file
  - X~~    marks search range when no match is found
  - colors error

If you are not seeing color above or in input dumps, try: -color

$ FileCheck -v -dump-input=always check1 < input1 |& sed -n '/^Input file/,$p'
Input file: <stdin>
Check file: check1

-dump-input=help describes the format of the following dump.

Full input was:
<<<<<<
        1: ; abc def
        2: ; ghI jkl
next:3     X~~~~~~~~ error: no match found
>>>>>>

$ cat check1
CHECK: abc
CHECK-SAME: def
CHECK-NEXT: ghi
CHECK-SAME: jkl

$ cat input1
; abc def
; ghI jkl
```

Some additional details related to the boilerplate:

* Enabling: The annotated input dump is enabled by `-dump-input`,
  which can also be set via the `FILECHECK_OPTS` environment variable.
  Accepted values are `help`, `always`, `fail`, or `never`.  As shown
  above, `help` describes the format of the dump.  `always` is helpful
  when you want to investigate a successful FileCheck run, perhaps for
  an unexpected pass. `-dump-input-on-failure` and
  `FILECHECK_DUMP_INPUT_ON_FAILURE` remain as a deprecated alias for
  `-dump-input=fail`.

* Diagnostics: The usual diagnostics are not suppressed in this mode
  and are printed first.  For brevity in the example above, I've
  omitted them using a sed command.  Sometimes they're perfectly
  sufficient, and then they make debugging quicker than if you were
  forced to hunt through a dump of long input looking for the error.
  If you think they'll get in the way sometimes, keep in mind that
  it's pretty easy to grep for the start of the input dump, which is
  `<<<`.

* Colored Annotations: The annotated input is colored if colors are
  enabled (enabling colors can be forced using -color).  For example,
  errors are red.  However, as in the above example, colors are not
  vital to reading the annotations.

I don't know how to test color in the output, so any hints here would
be appreciated.

Reviewed By: george.karpenkov, zturner, probinson

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

llvm-svn: 349418
2018-12-18 00:01:39 +00:00
..
ADT [ADT] Fix bugs in SmallBitVector. 2018-12-14 18:21:20 +00:00
Analysis [NewPM] fixing asserts on deleted loop in -print-after-all 2018-12-11 19:05:35 +00:00
AsmParser
BinaryFormat [WebAssembly] Check if the section order is correct 2018-12-15 00:58:12 +00:00
Bitcode [IR] Add a dedicated FNeg IR Instruction 2018-11-13 18:15:47 +00:00
CodeGen [TargetLowering] Add DemandedElts mask to SimplifyDemandedBits (PR40000) 2018-12-17 18:43:43 +00:00
Config [Support/FileSystem] Add sub-second precision for atime/mtime of sys::fs::file_status on unix platforms 2018-11-26 00:03:39 +00:00
DebugInfo [PDB] Add some helper functions for working with scopes. 2018-12-17 16:15:36 +00:00
Demangle [MS Demangler] Add a helper function to print a Node as a string. 2018-12-17 16:14:50 +00:00
ExecutionEngine [ExecutionEngine] Change NotifyObjectEmitted/NotifyObjectFreed API. 2018-12-04 00:55:15 +00:00
FuzzMutate
IR [macho] save the SDK version stored in module metadata into the version min and 2018-12-14 01:14:10 +00:00
IRReader
LineEditor
Linker
LTO [ThinLTO] Compute synthetic function entry count 2018-12-13 19:54:27 +00:00
MC [codeview] Flush labels before S_DEFRANGE* fragments 2018-12-17 21:49:35 +00:00
MCA [MCA] Add support for BeginGroup/EndGroup. 2018-12-17 14:27:33 +00:00
Object [WebAssembly] Check if the section order is correct 2018-12-15 00:58:12 +00:00
ObjectYAML [WebAssembly] Update dylink section parsing 2018-12-12 23:40:58 +00:00
Option [opt] Change the parameter of OptTable::PrintHelp from Name to Usage and don't append "[options] <inputs>" 2018-10-10 00:15:31 +00:00
Passes Add an OptimizerLast EP 2018-11-12 11:17:07 +00:00
ProfileData [SampleFDO][NFC] Remove debugging log left over in the code. 2018-10-11 22:14:27 +00:00
Support [FileCheck] Annotate input dump (1/7) 2018-12-18 00:01:39 +00:00
TableGen Fix and modernize StringMatcher comment; NFC 2018-09-28 13:31:55 +00:00
Target Implement -frecord-command-line (-frecord-gcc-switches) 2018-12-14 15:38:15 +00:00
Testing/Support
TextAPI/ELF [TextAPI][elfabi] Make SoName optional 2018-12-11 01:00:16 +00:00
ToolDrivers
Transforms [ThinLTO] Compute synthetic function entry count 2018-12-13 19:54:27 +00:00
WindowsManifest
WindowsResource
XRay [XRay] Improve FDR trace handling and error messaging 2018-11-09 06:26:48 +00:00
CMakeLists.txt
InitializePasses.h [Unroll/UnrollAndJam/Vectorizer/Distribute] Add followup loop attributes. 2018-12-12 17:32:52 +00:00
LinkAllIR.h
LinkAllPasses.h [Unroll/UnrollAndJam/Vectorizer/Distribute] Add followup loop attributes. 2018-12-12 17:32:52 +00:00
module.extern.modulemap [LLVM] Allow modulemap installation 2018-11-21 20:46:50 +00:00
module.install.modulemap [LLVM] Allow modulemap installation 2018-11-21 20:46:50 +00:00
module.modulemap [LLVM] Allow modulemap installation 2018-11-21 20:46:50 +00:00
module.modulemap.build
Pass.h [New PM][PassInstrumentation] IR printing support for New Pass Manager 2018-09-24 16:08:15 +00:00
PassAnalysisSupport.h
PassInfo.h
PassRegistry.h
PassSupport.h