Skip to content

Commit 940eba2

Browse files
committed
[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 (cherry picked from commit a8392c2)
1 parent cd2da72 commit 940eba2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/Serialization/ModuleFile.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ ModuleFile::loadDependenciesForFileContext(const FileUnit *file,
152152
SourceLoc diagLoc,
153153
bool forTestable) {
154154
ASTContext &ctx = getContext();
155-
auto clangImporter = static_cast<ClangImporter *>(ctx.getClangModuleLoader());
156155
ModuleDecl *M = file->getParentModule();
157156

158157
bool missingDependency = false;
@@ -163,6 +162,11 @@ ModuleFile::loadDependenciesForFileContext(const FileUnit *file,
163162
assert(!dependency.isLoaded() && "already loaded?");
164163

165164
if (dependency.isHeader()) {
165+
auto clangImporter =
166+
static_cast<ClangImporter *>(ctx.getClangModuleLoader());
167+
if (!clangImporter)
168+
return Status::FailedToLoadBridgingHeader;
169+
166170
// The path may be empty if the file being loaded is a partial AST,
167171
// and the current compiler invocation is a merge-modules step.
168172
if (!dependency.Core.RawPath.empty()) {

0 commit comments

Comments
 (0)