-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ClangImporter] don't add swift_attr files to a module's auxiliary files #65867
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
Conversation
rdar://107624995
@swift-ci Please test |
lib/AST/Module.cpp
Outdated
for (auto *sourceFile : AuxiliaryFiles) | ||
sourceFileLocationMap->allSourceFiles.push_back(sourceFile); | ||
for (auto *sourceFile : AuxiliaryFiles) { | ||
if (sourceFile->getBufferID()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only use of AuxiliaryFiles
and in general it doesn't really make sense to me to have an auxiliary file without a backing buffer. IMO we should just not add the auxiliary file in getClangSwiftAttrSourceFile
.
@swift-ci Please test |
@swift-ci Please clean test macOS |
@swift-ci Please smoke test |
@swift-ci Please smoke test Linux |
…les (#65867) rdar://107624995
…les (swiftlang#65867) rdar://107624995
…les (swiftlang#65867) rdar://107624995
Resolves rdar://107624995
The source-file location map used to determine which source files correspond to which locations assumes that all the source files used in the comparison have backing buffers. This holds for regular library files and macro expansions, but when Objective-C code with
__attribute__((swift_attr))
attributes is imported, the attributes get a fake source file with no backing buffer added to the module's auxiliary files.When SourceEntityWalker tries to determine whether a source location corresponds to a macro expansion, it uses this file map to look up a corresponding source file. When a module contains imported Objective-C code with
swift_attr
attributes as well as a Swift extension of that type, an empty optional containing the file's buffer ID is unwrapped, causing a crash. This is consistently triggered by SymbolGraphGen, as it is one of the major users of SourceEntityWalker.This PR updates the source-file location map to skip auxiliary files that don't have a backing buffer, the same as the module's regular files.