Skip to content

Commit 0a239d5

Browse files
committed
Update diag_deprecated_string_interpolation to use column offsets in -verify mode instead of FileCheck
1 parent 3a2547c commit 0a239d5

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

lib/Frontend/DiagnosticVerifier.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,12 +565,14 @@ bool DiagnosticVerifier::verifyFile(unsigned BufferID,
565565

566566
llvm::SMFixIt fixIt(llvm::SMRange{StartLoc, EndLoc}, I->getMessage());
567567
addError(expected.MessageRange.begin(), "incorrect message found", fixIt);
568-
} else {
568+
} else if (I->getColumnNo() + 1 != (int)*expected.ColumnNo) {
569569
// The difference must be only in the column
570570
addError(expected.MessageRange.begin(),
571571
llvm::formatv("message found at column {0} but was expected to "
572572
"appear at column {1}",
573573
I->getColumnNo() + 1, *expected.ColumnNo));
574+
} else {
575+
llvm_unreachable("unhandled difference from expected diagnostic");
574576
}
575577
CapturedDiagnostics.erase(I);
576578
ExpectedDiagnostics.erase(ExpectedDiagnostics.begin()+i);
Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
1-
// RUN: %target-swift-frontend -swift-version 5 -typecheck %s 2>&1 | %FileCheck %s
1+
// RUN: %target-typecheck-verify-swift -swift-version 5
22

33
extension DefaultStringInterpolation {
44
@available(*, deprecated) func appendInterpolation(deprecated: Int) {}
55
}
66

77
// Make sure diagnostics emitted via string interpolations have a reasonable source location
88

9-
_ = "\(deprecated: 42)"
10-
// CHECK: [[@LINE-1]]:7: warning: 'appendInterpolation(deprecated:)' is deprecated
9+
_ = "\(deprecated: 42)" // expected-warning@:7 {{'appendInterpolation(deprecated:)' is deprecated}}
1110

12-
_ = "hello, world\(deprecated: 42)!!!"
13-
// CHECK: [[@LINE-1]]:19: warning: 'appendInterpolation(deprecated:)' is deprecated
11+
_ = "hello, world\(deprecated: 42)!!!" // expected-warning@:19 {{'appendInterpolation(deprecated:)' is deprecated}}
1412

1513
_ = "\(42)\(deprecated: 42)test\(deprecated: 42)"
16-
// CHECK: [[@LINE-1]]:12: warning: 'appendInterpolation(deprecated:)' is deprecated
17-
// CHECK: [[@LINE-2]]:33: warning: 'appendInterpolation(deprecated:)' is deprecated
18-
14+
// expected-warning@-1:12 {{'appendInterpolation(deprecated:)' is deprecated}}
15+
// expected-warning@-2:33 {{'appendInterpolation(deprecated:)' is deprecated}}
1916
_ = """
2017
This is a multiline literal with a deprecated interpolation:
2118
2219
\(deprecated: 42)
2320
"""
24-
// CHECK: [[@LINE-2]]:2: warning: 'appendInterpolation(deprecated:)' is deprecated
21+
// expected-warning@-2:2 {{'appendInterpolation(deprecated:)' is deprecated}}

0 commit comments

Comments
 (0)