[FileCheck] Move -dump-input diagnostic to first line
authorJoel E. Denny <jdenny.ornl@gmail.com>
Wed, 14 Aug 2019 02:56:09 +0000 (02:56 +0000)
committerJoel E. Denny <jdenny.ornl@gmail.com>
Wed, 14 Aug 2019 02:56:09 +0000 (02:56 +0000)
commit608f2bfd65ec14debe22bce8179ffe2b514b4e91
treeec643018c6c883a5a18e3f8b879344cfa70fcb20
parentdac3ea4eb3f6fc75be4305b9b7ed1a861ea5993e
[FileCheck] Move -dump-input diagnostic to first line

Without this patch, `-dump-input` prints a diagnostic at the end of
its marker range.  For example:

```
         1: Start.
check:1     ^~~~~~
         2: Bad.
next:2      X~~~
         3: Many lines
next:2      ~~~~~~~~~~
         4: of input.
next:2      ~~~~~~~~~
         5: End.
next:2      ~~~~ error: no match found
```

This patch moves it to the beginning like this:

```
         1: Start.
check:1     ^~~~~~
         2: Bad.
next:2      X~~~ error: no match found
         3: Many lines
next:2      ~~~~~~~~~~
         4: of input.
next:2      ~~~~~~~~~
         5: End.
next:2      ~~~~
```

The former somehow looks nicer because the diagnostic doesn't appear
to be somewhere within the marker range.  However, the latter is more
practical, especially when the marker range includes the remainder of
a very long dump.  First, in the case of an error, this patch enables
me to search the dump for `error:` and usually immediately land where
the detected error began.  Second, when trying to follow FileCheck's
logic, it's best to read top down, so this patch enables me to see
each diagnostic as soon as I encounter its marker.

Reviewed By: thopre

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

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