Skip to content

Commit dec5c46

Browse files
committed
Adapt new variant of GetXcodeSDKPath()
(cherry picked from commit 57ea924)
1 parent d3f4680 commit dec5c46

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,6 +1354,22 @@ static llvm::Optional<StringRef> GetDSYMBundle(Module &module) {
13541354
return dsym;
13551355
}
13561356

1357+
static std::string GetSDKPath(std::string m_description, XcodeSDK sdk) {
1358+
auto sdk_path_or_err = HostInfo::GetXcodeSDKPath(sdk);
1359+
if (!sdk_path_or_err) {
1360+
Debugger::ReportError("Error while searching for Xcode SDK: " +
1361+
toString(sdk_path_or_err.takeError()));
1362+
HEALTH_LOG_PRINTF("Error while searching for Xcode SDK %s.",
1363+
sdk.GetString().str().c_str());
1364+
return {};
1365+
}
1366+
1367+
std::string sdk_path = sdk_path_or_err->str();
1368+
LOG_PRINTF(GetLog(LLDBLog::Types), "Host SDK path for sdk %s is %s.",
1369+
sdk.GetString().str().c_str(), sdk_path.c_str());
1370+
return sdk_path;
1371+
}
1372+
13571373
/// Force parsing of the CUs to extract the SDK info.
13581374
static std::string GetSDKPathFromDebugInfo(std::string m_description,
13591375
Module &module) {
@@ -1376,11 +1392,7 @@ static std::string GetSDKPathFromDebugInfo(std::string m_description,
13761392
"'%s'. Mixed use of SDKs indicates use of different "
13771393
"toolchains, which is not supported.",
13781394
module.GetFileSpec().GetFilename().GetCString());
1379-
1380-
std::string sdk_path = HostInfo::GetXcodeSDKPath(sdk).str();
1381-
LOG_PRINTF(GetLog(LLDBLog::Types), "Host SDK path for sdk %s is %s.",
1382-
sdk.GetString().str().c_str(), sdk_path.c_str());
1383-
return sdk_path;
1395+
return GetSDKPath(m_description, sdk);
13841396
}
13851397

13861398
/// Detect whether a Swift module was "imported" by DWARFImporter.
@@ -2464,15 +2476,15 @@ void SwiftASTContext::InitializeSearchPathOptions(
24642476
XcodeSDK::Info info;
24652477
info.type = XcodeSDK::GetSDKTypeForTriple(triple);
24662478
XcodeSDK sdk(info);
2467-
sdk_path = HostInfo::GetXcodeSDKPath(sdk).str();
2479+
sdk_path = GetSDKPath(m_description, sdk);
24682480
}
24692481
if (sdk_path.empty()) {
24702482
// This fallback is questionable. Perhaps it should be removed.
24712483
XcodeSDK::Info info;
24722484
info.type = XcodeSDK::GetSDKTypeForTriple(
24732485
HostInfo::GetArchitecture().GetTriple());
24742486
XcodeSDK sdk(info);
2475-
sdk_path = std::string(HostInfo::GetXcodeSDKPath(sdk));
2487+
sdk_path = GetSDKPath(m_description, sdk);
24762488
}
24772489
if (!sdk_path.empty()) {
24782490
// Note that calling setSDKPath() also recomputes all paths that

0 commit comments

Comments
 (0)