[lldb][NFC] remove the ResolveSDKPathFromDebugInfo method (#145744)
This patch is part of an effort to remove the `ResolveSDKPathFromDebugInfo` method, and more specifically the variant which takes a `Module` as argument. This PR should be merged after https://github.com/llvm/llvm-project/pull/144913.
This commit is contained in:
@@ -458,22 +458,6 @@ public:
|
||||
LLVM_PRETTY_FUNCTION, GetName()));
|
||||
}
|
||||
|
||||
/// Returns the full path of the most appropriate SDK for the
|
||||
/// specified 'module'. This function gets this path by parsing
|
||||
/// debug-info (see \ref `GetSDKPathFromDebugInfo`).
|
||||
///
|
||||
/// \param[in] module Module whose debug-info to parse for
|
||||
/// which SDK it was compiled against.
|
||||
///
|
||||
/// \returns If successful, returns the full path to an
|
||||
/// Xcode SDK.
|
||||
virtual llvm::Expected<std::string>
|
||||
ResolveSDKPathFromDebugInfo(Module &module) {
|
||||
return llvm::createStringError(
|
||||
llvm::formatv("{0} not implemented for '{1}' platform.",
|
||||
LLVM_PRETTY_FUNCTION, GetName()));
|
||||
}
|
||||
|
||||
/// Search CU for the SDK path the CUs was compiled against.
|
||||
///
|
||||
/// \param[in] unit The CU
|
||||
|
||||
@@ -1130,13 +1130,33 @@ void PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(
|
||||
|
||||
if (target) {
|
||||
if (ModuleSP exe_module_sp = target->GetExecutableModule()) {
|
||||
auto path_or_err = ResolveSDKPathFromDebugInfo(*exe_module_sp);
|
||||
if (path_or_err) {
|
||||
sysroot_spec = FileSpec(*path_or_err);
|
||||
SymbolFile *sym_file = exe_module_sp->GetSymbolFile();
|
||||
if (!sym_file)
|
||||
return;
|
||||
|
||||
XcodeSDK merged_sdk;
|
||||
for (unsigned i = 0; i < sym_file->GetNumCompileUnits(); ++i) {
|
||||
if (auto cu_sp = sym_file->GetCompileUnitAtIndex(i)) {
|
||||
auto cu_sdk = sym_file->ParseXcodeSDK(*cu_sp);
|
||||
merged_sdk.Merge(cu_sdk);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: The result of this loop is almost equivalent to deriving the SDK
|
||||
// from the target triple, which would be a lot cheaper.
|
||||
|
||||
if (FileSystem::Instance().Exists(merged_sdk.GetSysroot())) {
|
||||
sysroot_spec = merged_sdk.GetSysroot();
|
||||
} else {
|
||||
LLDB_LOG_ERROR(GetLog(LLDBLog::Types | LLDBLog::Host),
|
||||
path_or_err.takeError(),
|
||||
"Failed to resolve SDK path: {0}");
|
||||
auto path_or_err =
|
||||
HostInfo::GetSDKRoot(HostInfo::SDKOptions{merged_sdk});
|
||||
if (path_or_err) {
|
||||
sysroot_spec = FileSpec(*path_or_err);
|
||||
} else {
|
||||
LLDB_LOG_ERROR(GetLog(LLDBLog::Types | LLDBLog::Host),
|
||||
path_or_err.takeError(),
|
||||
"Failed to resolve SDK path: {0}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1384,31 +1404,6 @@ PlatformDarwin::GetSDKPathFromDebugInfo(Module &module) {
|
||||
return std::pair{std::move(merged_sdk), found_mismatch};
|
||||
}
|
||||
|
||||
llvm::Expected<std::string>
|
||||
PlatformDarwin::ResolveSDKPathFromDebugInfo(Module &module) {
|
||||
auto sdk_or_err = GetSDKPathFromDebugInfo(module);
|
||||
if (!sdk_or_err)
|
||||
return llvm::createStringError(
|
||||
llvm::inconvertibleErrorCode(),
|
||||
llvm::formatv("Failed to parse SDK path from debug-info: {0}",
|
||||
llvm::toString(sdk_or_err.takeError())));
|
||||
|
||||
auto [sdk, _] = std::move(*sdk_or_err);
|
||||
|
||||
if (FileSystem::Instance().Exists(sdk.GetSysroot()))
|
||||
return sdk.GetSysroot().GetPath();
|
||||
|
||||
auto path_or_err = HostInfo::GetSDKRoot(HostInfo::SDKOptions{sdk});
|
||||
if (!path_or_err)
|
||||
return llvm::createStringError(
|
||||
llvm::inconvertibleErrorCode(),
|
||||
llvm::formatv("Error while searching for SDK (XcodeSDK '{0}'): {1}",
|
||||
sdk.GetString(),
|
||||
llvm::toString(path_or_err.takeError())));
|
||||
|
||||
return path_or_err->str();
|
||||
}
|
||||
|
||||
llvm::Expected<XcodeSDK>
|
||||
PlatformDarwin::GetSDKPathFromDebugInfo(CompileUnit &unit) {
|
||||
ModuleSP module_sp = unit.CalculateSymbolContextModule();
|
||||
|
||||
@@ -120,9 +120,6 @@ public:
|
||||
llvm::Expected<std::pair<XcodeSDK, bool>>
|
||||
GetSDKPathFromDebugInfo(Module &module) override;
|
||||
|
||||
llvm::Expected<std::string>
|
||||
ResolveSDKPathFromDebugInfo(Module &module) override;
|
||||
|
||||
llvm::Expected<XcodeSDK> GetSDKPathFromDebugInfo(CompileUnit &unit) override;
|
||||
|
||||
llvm::Expected<std::string>
|
||||
|
||||
@@ -161,9 +161,6 @@ DWARF:
|
||||
|
||||
auto platform_sp = Platform::GetHostPlatform();
|
||||
ASSERT_TRUE(platform_sp);
|
||||
auto path_or_err = platform_sp->ResolveSDKPathFromDebugInfo(*module);
|
||||
EXPECT_FALSE(static_cast<bool>(path_or_err));
|
||||
llvm::consumeError(path_or_err.takeError());
|
||||
}
|
||||
|
||||
TEST_F(XcodeSDKModuleTests, TestSDKPathFromDebugInfo_No_DW_AT_APPLE_sdk) {
|
||||
@@ -207,9 +204,6 @@ DWARF:
|
||||
|
||||
auto platform_sp = Platform::GetHostPlatform();
|
||||
ASSERT_TRUE(platform_sp);
|
||||
auto path_or_err = platform_sp->ResolveSDKPathFromDebugInfo(*module);
|
||||
EXPECT_FALSE(static_cast<bool>(path_or_err));
|
||||
llvm::consumeError(path_or_err.takeError());
|
||||
}
|
||||
|
||||
TEST_P(SDKPathParsingMultiparamTests, TestSDKPathFromDebugInfo) {
|
||||
|
||||
Reference in New Issue
Block a user