diff options
author | Joel E. Denny <jdenny.ornl@gmail.com> | 2019-08-14 02:56:09 +0000 |
---|---|---|
committer | Joel E. Denny <jdenny.ornl@gmail.com> | 2019-08-14 02:56:09 +0000 |
commit | 608f2bfd65ec14debe22bce8179ffe2b514b4e91 (patch) | |
tree | ec643018c6c883a5a18e3f8b879344cfa70fcb20 /llvm/utils/FileCheck/FileCheck.cpp | |
parent | dac3ea4eb3f6fc75be4305b9b7ed1a861ea5993e (diff) | |
download | llvm-608f2bfd65ec14debe22bce8179ffe2b514b4e91.zip llvm-608f2bfd65ec14debe22bce8179ffe2b514b4e91.tar.gz llvm-608f2bfd65ec14debe22bce8179ffe2b514b4e91.tar.bz2 |
[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
Diffstat (limited to 'llvm/utils/FileCheck/FileCheck.cpp')
-rw-r--r-- | llvm/utils/FileCheck/FileCheck.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/llvm/utils/FileCheck/FileCheck.cpp b/llvm/utils/FileCheck/FileCheck.cpp index d9cad13..879a383 100644 --- a/llvm/utils/FileCheck/FileCheck.cpp +++ b/llvm/utils/FileCheck/FileCheck.cpp @@ -313,8 +313,7 @@ static void BuildInputAnnotations(const std::vector<FileCheckDiag> &Diags, Label.flush(); LabelWidth = std::max((std::string::size_type)LabelWidth, A.Label.size()); - MarkerStyle Marker = GetMarker(DiagItr->MatchTy); - A.Marker = Marker; + A.Marker = GetMarker(DiagItr->MatchTy); A.FoundAndExpectedMatch = DiagItr->MatchTy == FileCheckDiag::MatchFoundAndExpected; @@ -333,28 +332,25 @@ static void BuildInputAnnotations(const std::vector<FileCheckDiag> &Diags, assert(DiagItr->InputStartLine < DiagItr->InputEndLine && "expected input range not to be inverted"); A.InputEndCol = UINT_MAX; - A.Marker.Note = ""; Annotations.push_back(A); for (unsigned L = DiagItr->InputStartLine + 1, E = DiagItr->InputEndLine; L <= E; ++L) { // If a range ends before the first column on a line, then it has no // characters on that line, so there's nothing to render. - if (DiagItr->InputEndCol == 1 && L == E) { - Annotations.back().Marker.Note = Marker.Note; + if (DiagItr->InputEndCol == 1 && L == E) break; - } InputAnnotation B; B.CheckLine = A.CheckLine; B.CheckDiagIndex = A.CheckDiagIndex; B.Label = A.Label; B.InputLine = L; - B.Marker = Marker; + B.Marker = A.Marker; B.Marker.Lead = '~'; + B.Marker.Note = ""; B.InputStartCol = 1; - if (L != E) { + if (L != E) B.InputEndCol = UINT_MAX; - B.Marker.Note = ""; - } else + else B.InputEndCol = DiagItr->InputEndCol; B.FoundAndExpectedMatch = A.FoundAndExpectedMatch; Annotations.push_back(B); |