1515#include " lldb/Utility/Log.h"
1616#include " lldb/Utility/Timer.h"
1717
18- #include " clang/Basic/DarwinSDKInfo.h"
1918#include " llvm/ADT/ScopeExit.h"
2019#include " llvm/ADT/SmallString.h"
2120#include " llvm/ADT/StringMap.h"
22- #include " llvm/Support/Error.h"
2321#include " llvm/Support/FileSystem.h"
2422#include " llvm/Support/Path.h"
25- #include " llvm/Support/VersionTuple.h"
2623#include " llvm/Support/raw_ostream.h"
2724
2825// C++ Includes
@@ -572,52 +569,10 @@ static bool ResolveAndVerifyCandidateSupportDir(FileSpec &path) {
572569 cache.insert ({key, {error, true }});
573570 return llvm::createStringError (llvm::inconvertibleErrorCode (), error);
574571 }
575-
576- if (path_or_err->empty ())
577- return llvm::createStringError (" Empty path determined for '%s'" ,
578- key.data ());
579-
580572 auto it_new = cache.insert ({key, {*path_or_err, false }});
581573 return it_new.first ->second .str ;
582574}
583575
584- static llvm::Expected<std::string>
585- GetCommandLineToolsSDKRoot (llvm::VersionTuple version) {
586- std::string clt_root_dir;
587- FileSystem::Instance ().EnumerateDirectory (
588- " /Library/Developer/CommandLineTools/SDKs/" , /* find_directories=*/ true ,
589- /* find_files=*/ false , /* find_other=*/ false ,
590- [&](void *baton, llvm::sys::fs::file_type file_type,
591- llvm::StringRef name) {
592- assert (file_type == llvm::sys::fs::file_type::directory_file);
593-
594- if (!name.ends_with (" .sdk" ))
595- return FileSystem::eEnumerateDirectoryResultNext;
596-
597- llvm::Expected<std::optional<clang::DarwinSDKInfo>> sdk_info =
598- clang::parseDarwinSDKInfo (
599- *FileSystem::Instance ().GetVirtualFileSystem (), name);
600- if (!sdk_info) {
601- LLDB_LOG_ERROR (GetLog (LLDBLog::Expressions), sdk_info.takeError (),
602- " Error while parsing {1}: {0}" , name);
603- return FileSystem::eEnumerateDirectoryResultNext;
604- }
605-
606- if (!*sdk_info)
607- return FileSystem::eEnumerateDirectoryResultNext;
608-
609- if (version == (*sdk_info)->getVersion ()) {
610- clt_root_dir = name;
611- return FileSystem::eEnumerateDirectoryResultQuit;
612- }
613-
614- return FileSystem::eEnumerateDirectoryResultNext;
615- },
616- /* baton=*/ nullptr );
617-
618- return clt_root_dir;
619- }
620-
621576llvm::Expected<llvm::StringRef> HostInfoMacOSX::GetSDKRoot (SDKOptions options) {
622577 static llvm::StringMap<ErrorOrPath> g_sdk_path;
623578 static std::mutex g_sdk_path_mutex;
@@ -626,21 +581,6 @@ static bool ResolveAndVerifyCandidateSupportDir(FileSpec &path) {
626581 " XcodeSDK not specified" );
627582 XcodeSDK sdk = *options.XcodeSDKSelection ;
628583 auto key = sdk.GetString ();
629-
630- // xcrun doesn't search SDKs in the CommandLineTools (CLT) directory. So if
631- // a program was compiled against a CLT SDK, but that SDK wasn't present in
632- // any of the Xcode installations, then xcrun would fail to find the SDK
633- // (which is expensive). To avoid this we first try to find the specified SDK
634- // in the CLT directory.
635- auto clt_root_dir = find_cached_path (g_sdk_path, g_sdk_path_mutex, key, [&] {
636- return GetCommandLineToolsSDKRoot (sdk.GetVersion ());
637- });
638-
639- if (clt_root_dir)
640- return clt_root_dir;
641- else
642- llvm::consumeError (clt_root_dir.takeError ());
643-
644584 return find_cached_path (g_sdk_path, g_sdk_path_mutex, key, [&](){
645585 return GetXcodeSDK (sdk);
646586 });
0 commit comments