@@ -1354,6 +1354,22 @@ static llvm::Optional<StringRef> GetDSYMBundle(Module &module) {
1354
1354
return dsym;
1355
1355
}
1356
1356
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
+
1357
1373
// / Force parsing of the CUs to extract the SDK info.
1358
1374
static std::string GetSDKPathFromDebugInfo (std::string m_description,
1359
1375
Module &module ) {
@@ -1376,11 +1392,7 @@ static std::string GetSDKPathFromDebugInfo(std::string m_description,
1376
1392
" '%s'. Mixed use of SDKs indicates use of different "
1377
1393
" toolchains, which is not supported." ,
1378
1394
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);
1384
1396
}
1385
1397
1386
1398
// / Detect whether a Swift module was "imported" by DWARFImporter.
@@ -2464,15 +2476,15 @@ void SwiftASTContext::InitializeSearchPathOptions(
2464
2476
XcodeSDK::Info info;
2465
2477
info.type = XcodeSDK::GetSDKTypeForTriple (triple);
2466
2478
XcodeSDK sdk (info);
2467
- sdk_path = HostInfo::GetXcodeSDKPath ( sdk). str ( );
2479
+ sdk_path = GetSDKPath (m_description, sdk);
2468
2480
}
2469
2481
if (sdk_path.empty ()) {
2470
2482
// This fallback is questionable. Perhaps it should be removed.
2471
2483
XcodeSDK::Info info;
2472
2484
info.type = XcodeSDK::GetSDKTypeForTriple (
2473
2485
HostInfo::GetArchitecture ().GetTriple ());
2474
2486
XcodeSDK sdk (info);
2475
- sdk_path = std::string ( HostInfo::GetXcodeSDKPath ( sdk) );
2487
+ sdk_path = GetSDKPath (m_description, sdk);
2476
2488
}
2477
2489
if (!sdk_path.empty ()) {
2478
2490
// Note that calling setSDKPath() also recomputes all paths that
0 commit comments