From f9d5ffb5f00423d078c625c3c914d7e6f3cf0274 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Fri, 19 Dec 2025 15:17:15 -0800 Subject: [PATCH] [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`. rdar://166224928 (cherry picked from commit bacb12131fa28185c9217ea1fcd1bd5893e879a3) --- lib/Serialization/Deserialization.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Serialization/Deserialization.cpp b/lib/Serialization/Deserialization.cpp index e5796a69ca66d..a7d3ca5fe2b1d 100644 --- a/lib/Serialization/Deserialization.cpp +++ b/lib/Serialization/Deserialization.cpp @@ -3113,7 +3113,8 @@ ModuleDecl *ModuleFile::getModule(ImportPath::Module name, name.front().Item == getContext().getRealModuleName(parentName)) { if (!UnderlyingModule && allowLoading) { auto importer = getContext().getClangModuleLoader(); - assert(importer && "no way to import shadowed module"); + if (!importer) + return nullptr; UnderlyingModule = importer->loadModule(SourceLoc(), name.getTopLevelPath()); }