Skip to content

Commit f9d5ffb

Browse files
committed
[Serialization] Return a nullptr instead of crashing
We got LLDB crash logs where `importer` is dereferenced. In the same crash log the parent frame correctly checks for nullptr, so this would fix the immediate crash. In LLDB it is not guaranteed that a ClangImporter is installed at all times. Ideally this function should be converted to return `llvm::Expected<ModuleDecl &>`. rdar://166224928 (cherry picked from commit bacb121)
1 parent 18861a3 commit f9d5ffb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/Serialization/Deserialization.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3113,7 +3113,8 @@ ModuleDecl *ModuleFile::getModule(ImportPath::Module name,
31133113
name.front().Item == getContext().getRealModuleName(parentName)) {
31143114
if (!UnderlyingModule && allowLoading) {
31153115
auto importer = getContext().getClangModuleLoader();
3116-
assert(importer && "no way to import shadowed module");
3116+
if (!importer)
3117+
return nullptr;
31173118
UnderlyingModule =
31183119
importer->loadModule(SourceLoc(), name.getTopLevelPath());
31193120
}

0 commit comments

Comments
 (0)