Skip to content

Commit 99b16d0

Browse files
authored
Merge pull request #34108 from brentdax/merged-into-an-umbrella-corporation
[ClangImporter] Update umbrella header diagnostic handling
2 parents 0bc74db + aaa4e45 commit 99b16d0

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

lib/ClangImporter/ClangSourceBufferImporter.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,17 @@ SourceLoc ClangSourceBufferImporter::resolveSourceLocation(
6767

6868
StringRef presumedFile = presumedLoc.getFilename();
6969
SourceLoc startOfLine = loc.getAdvancedLoc(-presumedLoc.getColumn() + 1);
70-
bool isNewVirtualFile = swiftSourceManager.openVirtualFile(
71-
startOfLine, presumedFile, presumedLoc.getLine() - bufferLineNumber);
72-
if (isNewVirtualFile) {
73-
SourceLoc endOfLine = findEndOfLine(swiftSourceManager, loc, mirrorID);
74-
swiftSourceManager.closeVirtualFile(endOfLine);
70+
71+
// FIXME: Virtual files can't actually model the EOF position correctly, so
72+
// if this virtual file would start at EOF, just hope the physical location
73+
// will do.
74+
if (startOfLine != swiftSourceManager.getRangeForBuffer(mirrorID).getEnd()) {
75+
bool isNewVirtualFile = swiftSourceManager.openVirtualFile(
76+
startOfLine, presumedFile, presumedLoc.getLine() - bufferLineNumber);
77+
if (isNewVirtualFile) {
78+
SourceLoc endOfLine = findEndOfLine(swiftSourceManager, loc, mirrorID);
79+
swiftSourceManager.closeVirtualFile(endOfLine);
80+
}
7581
}
7682

7783
using SourceManagerRef = llvm::IntrusiveRefCntPtr<const clang::SourceManager>;

test/ClangImporter/diags_from_module.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import Module
3737
// CHECK-PRIMARY: diags_from_module.swift:[[@LINE-4]]:8: error: could not build Objective-C module 'Module'
3838

3939
// CHECK-WARN: Sub2.h:7:2: warning: here is some warning about something
40-
// CHECK-WARN: <module-includes>:1:1: warning: umbrella header for module 'Module' does not include header 'NotInModule.h'
40+
// CHECK-WARN: Module.h:20:1: warning: umbrella header for module 'Module' does not include header 'NotInModule.h'
4141
// FIXME: show [-Wincomplete-umbrella]
4242

4343
// CHECK-NO-WARN-NOT: warning about something

0 commit comments

Comments
 (0)