Skip to content

Commit 59e3450

Browse files
Merge pull request #17345 from adrian-prantl/40950542
Restrict RemoteASTTypeBuilder::findModule() to the list of loaded modules
2 parents c93a5a5 + 30ea6ec commit 59e3450

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/RemoteAST/RemoteAST.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,13 @@ RemoteASTTypeBuilder::createNominalTypeDecl(const Demangle::NodePointer &node) {
570570
ModuleDecl *RemoteASTTypeBuilder::findModule(const Demangle::NodePointer &node){
571571
assert(node->getKind() == Demangle::Node::Kind::Module);
572572
const auto &moduleName = node->getText();
573-
return Ctx.getModuleByName(moduleName);
573+
// Intentionally using getLoadedModule() instead of getModuleByName() here.
574+
// LLDB uses RemoteAST for its per-module SwiftASTContext. Importing external
575+
// modules here could permanently damage this context, for example when a
576+
// Clang import fails because of missing header search options. To avoid this
577+
// situation, restrict RemoteAST's access to only the module's transitive
578+
// closure of imports.
579+
return Ctx.getLoadedModule(Ctx.getIdentifier(moduleName));
574580
}
575581

576582
Demangle::NodePointer

0 commit comments

Comments
 (0)