This is an archive of the discontinued LLVM Phabricator instance.

[FileCheck] Move -dump-input diagnostic to first line
ClosedPublic

Authored by jdenny on Aug 3 2019, 1:00 PM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

jdenny created this revision.Aug 3 2019, 1:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2019, 1:00 PM
thopre added a comment.Aug 5 2019, 8:15 AM

Does this work for multiline annotations? If I read this correctly (I often don't so my apologies if that's the case) it will print the marker for each line in a multiline annotation except the last.

jdenny added a comment.Aug 5 2019, 8:27 AM

Does this work for multiline annotations? If I read this correctly (I often don't so my apologies if that's the case) it will print the marker for each line in a multiline annotation except the last.

It works correctly for the multi-line annotations I've tested: it prints the note (like error: no match found) only for the first line. See the test suite changes and the summary for examples. Does that help? Thanks for reviewing.

thopre accepted this revision.Aug 6 2019, 1:25 AM

Does this work for multiline annotations? If I read this correctly (I often don't so my apologies if that's the case) it will print the marker for each line in a multiline annotation except the last.

It works correctly for the multi-line annotations I've tested: it prints the note (like error: no match found) only for the first line. See the test suite changes and the summary for examples. Does that help? Thanks for reviewing.

Ah my bad I think I understand it now. The first line is dealt with outside the loop by the Annotations.push_back(A) which will print a note. The other lines, dealt in the loop, get an empty note and thus nothing besides the markers. LGTM then.

This revision is now accepted and ready to land.Aug 6 2019, 1:25 AM
This revision was automatically updated to reflect the committed changes.