Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,20 @@ SwiftASTContext::SwiftASTContext(std::string description,
GetClangModulesCacheProperty());
}

static std::string DerivePlatformPluginPath(StringRef sdk_path) {
llvm::StringRef path = sdk_path;
path = llvm::sys::path::parent_path(path);
if (llvm::sys::path::filename(path) != "SDKs")
return {};
path = llvm::sys::path::parent_path(path);
if (llvm::sys::path::filename(path) != "Developer")
return {};
path = llvm::sys::path::parent_path(path);
if (!path.ends_with(".platform"))
return {};
return std::string(path) + "/usr/local/lib/swift/host/plugins";
}

void SwiftASTContext::SetCompilerInvocationLLDBOverrides() {
swift::IRGenOptions &ir_gen_opts =
m_compiler_invocation_ap->getIRGenOptions();
Expand All @@ -1018,6 +1032,20 @@ void SwiftASTContext::SetCompilerInvocationLLDBOverrides() {
// Bypass deserialization safety to allow deserializing internal details from
// swiftmodule files.
lang_opts.EnableDeserializationSafety = false;

// Platform plugin path (macOS hosts only).
swift::PluginSearchOption::ExternalPluginPath platform_plugins;
platform_plugins.SearchPath =
DerivePlatformPluginPath(m_compiler_invocation_ap->getSDKPath());
if (!platform_plugins.SearchPath.empty()) {
platform_plugins.ServerPath = GetPluginServer(platform_plugins.SearchPath);
if (!platform_plugins.ServerPath.empty()) {
if (FileSystem::Instance().Exists(platform_plugins.SearchPath) &&
FileSystem::Instance().Exists(platform_plugins.ServerPath))
m_compiler_invocation_ap->getSearchPathOptions()
.PluginSearchOpts.push_back(platform_plugins);
}
}
}

SwiftASTContext::~SwiftASTContext() {
Expand Down Expand Up @@ -1272,7 +1300,6 @@ static bool DeserializeAllCompilerFlags(swift::CompilerInvocation &invocation,
for (; !buf.empty(); buf = buf.substr(info.bytes)) {
llvm::SmallVector<swift::serialization::SearchPath> searchPaths;
swift::serialization::ExtendedValidationInfo extended_validation_info;
auto &langOpts = invocation.getLangOptions();
info = swift::serialization::validateSerializedAST(
buf, invocation.getSILOptions().EnableOSSAModules,
/*requiredSDK*/ StringRef(), &extended_validation_info,
Expand Down
1 change: 1 addition & 0 deletions lldb/test/API/lang/swift/macro/TestSwiftMacro.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ def testInteractive(self):
# CHECK: CacheUserImports(){{.*}}: Macro.
# CHECK: SwiftASTContextForExpressions{{.*}}::LoadOneModule(){{.*}}Imported module Macro from {kind = Serialized Swift AST, filename = "{{.*}}Macro.swiftmodule";}
# CHECK: CacheUserImports(){{.*}}Scanning for search paths in{{.*}}Macro.swiftmodule
# CHECK: SwiftASTContextForExpressions{{.*}}::LogConfiguration(){{.*}} -external-plugin-path {{.*}}/Developer/Platforms/{{.*}}.platform/Developer/usr/local/lib/swift/host/plugins{{.*}}#{{.*}}/swift-plugin-server
# CHECK: SwiftASTContextForExpressions{{.*}}::LogConfiguration(){{.*}} -external-plugin-path {{.*}}/lang/swift/macro/{{.*}}#{{.*}}/swift-plugin-server