Skip to content

[ClangImporter] Update umbrella header diagnostic handling #34108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions lib/ClangImporter/ClangSourceBufferImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,17 @@ SourceLoc ClangSourceBufferImporter::resolveSourceLocation(

StringRef presumedFile = presumedLoc.getFilename();
SourceLoc startOfLine = loc.getAdvancedLoc(-presumedLoc.getColumn() + 1);
bool isNewVirtualFile = swiftSourceManager.openVirtualFile(
startOfLine, presumedFile, presumedLoc.getLine() - bufferLineNumber);
if (isNewVirtualFile) {
SourceLoc endOfLine = findEndOfLine(swiftSourceManager, loc, mirrorID);
swiftSourceManager.closeVirtualFile(endOfLine);

// FIXME: Virtual files can't actually model the EOF position correctly, so
// if this virtual file would start at EOF, just hope the physical location
// will do.
if (startOfLine != swiftSourceManager.getRangeForBuffer(mirrorID).getEnd()) {
bool isNewVirtualFile = swiftSourceManager.openVirtualFile(
startOfLine, presumedFile, presumedLoc.getLine() - bufferLineNumber);
if (isNewVirtualFile) {
SourceLoc endOfLine = findEndOfLine(swiftSourceManager, loc, mirrorID);
swiftSourceManager.closeVirtualFile(endOfLine);
}
}

using SourceManagerRef = llvm::IntrusiveRefCntPtr<const clang::SourceManager>;
Expand Down
2 changes: 1 addition & 1 deletion test/ClangImporter/diags_from_module.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import Module
// CHECK-PRIMARY: diags_from_module.swift:[[@LINE-4]]:8: error: could not build Objective-C module 'Module'

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

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