Revert "[lldb/Platform] Return a std::string from GetSDKPath"
authorJonas Devlieghere <jonas@devlieghere.com>
Wed, 29 Apr 2020 08:23:49 +0000 (01:23 -0700)
committerJonas Devlieghere <jonas@devlieghere.com>
Wed, 29 Apr 2020 08:26:24 +0000 (01:26 -0700)
This reverts commit b14c37a29a5455853419f5fe0605f6023c51de89.

lldb/include/lldb/Target/Platform.h
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h

index 6402610..1b130cd 100644 (file)
@@ -435,9 +435,7 @@ public:
     return lldb_private::ConstString();
   }
 
-  virtual std::string GetSDKPath(lldb_private::XcodeSDK sdk) {
-    return {};
-  }
+  virtual llvm::StringRef GetSDKPath(lldb_private::XcodeSDK sdk) { return {}; }
 
   const std::string &GetRemoteURL() const { return m_remote_url; }
 
index 6a00afb..436f93d 100644 (file)
@@ -1761,12 +1761,12 @@ PlatformDarwin::FindXcodeContentsDirectoryInPath(llvm::StringRef path) {
   return {};
 }
 
-std::string PlatformDarwin::GetSDKPath(XcodeSDK sdk) {
+llvm::StringRef PlatformDarwin::GetSDKPath(XcodeSDK sdk) {
   std::lock_guard<std::mutex> guard(m_sdk_path_mutex);
   std::string &path = m_sdk_path[sdk.GetString()];
-  if (!path.empty())
-    return path;
-  return HostInfo::GetXcodeSDK(sdk);
+  if (path.empty())
+    path = HostInfo::GetXcodeSDK(sdk);
+  return path;
 }
 
 FileSpec PlatformDarwin::GetXcodeContentsDirectory() {
index e4f7173..0252b09 100644 (file)
@@ -89,7 +89,7 @@ public:
   llvm::Expected<lldb_private::StructuredData::DictionarySP>
   FetchExtendedCrashInformation(lldb_private::Process &process) override;
 
-  std::string GetSDKPath(lldb_private::XcodeSDK sdk) override;
+  llvm::StringRef GetSDKPath(lldb_private::XcodeSDK sdk) override;
 
   static lldb_private::FileSpec GetXcodeContentsDirectory();
   static lldb_private::FileSpec GetXcodeDeveloperDirectory();