mirror of
https://github.com/apple/swift.git
synced 2026-02-27 18:26:24 +01:00
[LLDB] Add a missing nullptr check for ClangImporter
This is not a possible code path in the Swift compiler, but LLDB has error paths where ClangImporter could be null, and it has (for testing mostly) a setting to disable ClangImporter entirely. When importing a Module with a header dependency this crashes LLDB. rdar://170007373
This commit is contained in:
@@ -152,7 +152,6 @@ ModuleFile::loadDependenciesForFileContext(const FileUnit *file,
|
||||
SourceLoc diagLoc,
|
||||
bool forTestable) {
|
||||
ASTContext &ctx = getContext();
|
||||
auto clangImporter = static_cast<ClangImporter *>(ctx.getClangModuleLoader());
|
||||
ModuleDecl *M = file->getParentModule();
|
||||
|
||||
bool missingDependency = false;
|
||||
@@ -163,6 +162,11 @@ ModuleFile::loadDependenciesForFileContext(const FileUnit *file,
|
||||
assert(!dependency.isLoaded() && "already loaded?");
|
||||
|
||||
if (dependency.isHeader()) {
|
||||
auto clangImporter =
|
||||
static_cast<ClangImporter *>(ctx.getClangModuleLoader());
|
||||
if (!clangImporter)
|
||||
return Status::FailedToLoadBridgingHeader;
|
||||
|
||||
// The path may be empty if the file being loaded is a partial AST,
|
||||
// and the current compiler invocation is a merge-modules step.
|
||||
if (!dependency.Core.RawPath.empty()) {
|
||||
|
||||
Reference in New Issue
Block a user