Skip to content

Commit 608f2bf

Browse files
committed
[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
1 parent dac3ea4 commit 608f2bf

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

llvm/test/FileCheck/dump-input-annotations.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
; ALIGN-NEXT:<<<<<<
2828
; ALIGN-NEXT: 1: hello world
2929
; ALIGN-NEXT:check:1 ^~~~~
30-
; ALIGN-NEXT:check:2'0 X~~~~
30+
; ALIGN-NEXT:check:2'0 X~~~~ error: no match found
3131
; ALIGN-NEXT: 2: goodbye
3232
; ALIGN-NEXT:check:2'0 ~~~~~~~
3333
; ALIGN-NEXT: 3: world
3434
; ALIGN-NEXT:check:2'0 ~~~~~
3535
; ALIGN-NEXT: 4: unicorn
36-
; ALIGN-NEXT:check:2'0 ~~~~~~~ error: no match found
36+
; ALIGN-NEXT:check:2'0 ~~~~~~~
3737
; ALIGN-NEXT:check:2'1 ? possible intended match
3838
; ALIGN-NEXT:>>>>>>
3939
; ALIGN-NOT:{{.}}
@@ -69,9 +69,9 @@
6969
; CHK-NEXT: 1: hello
7070
; CHK-V-NEXT: check:1 ^~~~~
7171
; CHK-NEXT: 2: again
72-
; CHK-NEXT: check:2'0 X~~~~
72+
; CHK-NEXT: check:2'0 X~~~~ error: no match found
7373
; CHK-NEXT: 3: whirled
74-
; CHK-NEXT: check:2'0 ~~~~~~~ error: no match found
74+
; CHK-NEXT: check:2'0 ~~~~~~~
7575
; CHK-NEXT: check:2'1 ? possible intended match
7676
; CHK-NEXT: >>>>>>
7777
; CHK-NOT: {{.}}
@@ -260,9 +260,9 @@
260260
; EMP-NEXT: 2:
261261
; EMP-V-NEXT: empty:2 ^
262262
; EMP-NEXT: 3: world
263-
; EMP-NEXT: empty:3 X~~~~
263+
; EMP-NEXT: empty:3 X~~~~ error: no match found
264264
; EMP-NEXT: 4: label
265-
; EMP-NEXT: empty:3 ~~~~~ error: no match found
265+
; EMP-NEXT: empty:3 ~~~~~
266266
; EMP-V-NEXT: label:4 ^~~~~
267267
; EMP-NEXT: >>>>>>
268268
; EMP-NOT: {{.}}
@@ -453,11 +453,11 @@
453453
; LAB-V-NEXT: label:1'0 ^~~~
454454
; LAB-V-NEXT: label:1'1 ^~~~
455455
; LAB-NEXT: 2: foo
456-
; LAB-NEXT: label:3'0 X~~
456+
; LAB-NEXT: label:3'0 X~~ error: no match found
457457
; LAB-NEXT: 3: lab1
458458
; LAB-NEXT: label:3'0 ~~~~
459459
; LAB-NEXT: label:3'1 ? possible intended match
460460
; LAB-NEXT: 4: bar
461-
; LAB-NEXT: label:3'0 ~~~ error: no match found
461+
; LAB-NEXT: label:3'0 ~~~
462462
; LAB-NEXT: >>>>>>
463463
; LAB-NOT: {{.}}

llvm/utils/FileCheck/FileCheck.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,7 @@ static void BuildInputAnnotations(const std::vector<FileCheckDiag> &Diags,
313313
Label.flush();
314314
LabelWidth = std::max((std::string::size_type)LabelWidth, A.Label.size());
315315

316-
MarkerStyle Marker = GetMarker(DiagItr->MatchTy);
317-
A.Marker = Marker;
316+
A.Marker = GetMarker(DiagItr->MatchTy);
318317
A.FoundAndExpectedMatch =
319318
DiagItr->MatchTy == FileCheckDiag::MatchFoundAndExpected;
320319

@@ -333,28 +332,25 @@ static void BuildInputAnnotations(const std::vector<FileCheckDiag> &Diags,
333332
assert(DiagItr->InputStartLine < DiagItr->InputEndLine &&
334333
"expected input range not to be inverted");
335334
A.InputEndCol = UINT_MAX;
336-
A.Marker.Note = "";
337335
Annotations.push_back(A);
338336
for (unsigned L = DiagItr->InputStartLine + 1, E = DiagItr->InputEndLine;
339337
L <= E; ++L) {
340338
// If a range ends before the first column on a line, then it has no
341339
// characters on that line, so there's nothing to render.
342-
if (DiagItr->InputEndCol == 1 && L == E) {
343-
Annotations.back().Marker.Note = Marker.Note;
340+
if (DiagItr->InputEndCol == 1 && L == E)
344341
break;
345-
}
346342
InputAnnotation B;
347343
B.CheckLine = A.CheckLine;
348344
B.CheckDiagIndex = A.CheckDiagIndex;
349345
B.Label = A.Label;
350346
B.InputLine = L;
351-
B.Marker = Marker;
347+
B.Marker = A.Marker;
352348
B.Marker.Lead = '~';
349+
B.Marker.Note = "";
353350
B.InputStartCol = 1;
354-
if (L != E) {
351+
if (L != E)
355352
B.InputEndCol = UINT_MAX;
356-
B.Marker.Note = "";
357-
} else
353+
else
358354
B.InputEndCol = DiagItr->InputEndCol;
359355
B.FoundAndExpectedMatch = A.FoundAndExpectedMatch;
360356
Annotations.push_back(B);

0 commit comments

Comments
 (0)