Skip to content

Commit e1cb1a2

Browse files
authored
Merge pull request #30501 from omochi/fix-verify-range
[Diagnostics] Fix range of fix-its in verify mode
2 parents 80cca7d + 3ccec26 commit e1cb1a2

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

lib/Frontend/DiagnosticVerifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ DiagnosticVerifier::verifyFile(unsigned BufferID, bool shouldAutoApplyFixes) {
530530
// fixit to add them in.
531531
auto actual = renderFixits(FoundDiagnostic.getFixIts(), InputFile);
532532
auto replStartLoc = SMLoc::getFromPointer(expected.ExpectedEnd - 8); // {{none}} length
533-
auto replEndLoc = SMLoc::getFromPointer(expected.ExpectedEnd - 1);
533+
auto replEndLoc = SMLoc::getFromPointer(expected.ExpectedEnd);
534534

535535
llvm::SMFixIt fix(llvm::SMRange(replStartLoc, replEndLoc), actual);
536536
addError(replStartLoc.getPointer(), "expected no fix-its; actual fix-it seen: " + actual, fix);

test/FixCode/verify-fixits.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: cp %s %t
2+
// RUN: not %swift -typecheck -target %target-triple -verify-apply-fixes %t
3+
// RUN: diff %t %s.result
4+
5+
func f1() {
6+
guard true { return } // expected-error {{...}}
7+
8+
guard true { return } // expected-error {{expected 'else' after 'guard' condition}} {{none}}
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: cp %s %t
2+
// RUN: not %swift -typecheck -target %target-triple -verify-apply-fixes %t
3+
// RUN: diff %t %s.result
4+
5+
func f1() {
6+
guard true { return } // expected-error {{expected 'else' after 'guard' condition}}
7+
8+
guard true { return } // expected-error {{expected 'else' after 'guard' condition}} {{14-14=else }}
9+
}

0 commit comments

Comments
 (0)