Skip to content

Commit 43094c6

Browse files
committed
[Migrator] FixitApplyDiagnosticConsumer: Ignore diags with invalid SourceLocs
Some diagnostics showing up during migration may not have valid source locations, so we obviously can't map that onto a buffer onto which we'd apply a fix-it. rdar://problem/32213595
1 parent cc389eb commit 43094c6

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/Migrator/FixitApplyDiagnosticConsumer.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ handleDiagnostic(SourceManager &SM, SourceLoc Loc,
3737
StringRef FormatString,
3838
ArrayRef<DiagnosticArgument> FormatArgs,
3939
const DiagnosticInfo &Info) {
40+
if (Loc.isInvalid()) {
41+
return;
42+
}
4043
auto ThisBufferID = SM.findBufferContainingLoc(Loc);
4144
auto ThisBufferName = SM.getIdentifierForBuffer(ThisBufferID);
4245
if (ThisBufferName != BufferName) {

test/Migrator/invalid_sourceloc.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// REQUIRES: objc_interop
2+
// RUN: rm -rf %t && mkdir -p %t && not %swift -c -update-code -primary-file %s -emit-migrated-file-path %t/api-special-cases.swift.result -emit-remap-file-path %t/api-special-cases.swift.remap -o /dev/null
3+
4+
// A failed import due to a missing -sdk frontend argument produces a
5+
// diagnostic with an invalid sourceloc.
6+
import CoreGraphics

0 commit comments

Comments
 (0)