<div dir="ltr">My previous message is also bogus, I was looking at the updated code instead of the original code. I think it's time to call it a day before I say more nonsense. I'll take a fresh look tomorrow :-) </div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 28, 2020 at 8:01 PM Jonas Devlieghere <<a href="mailto:jonas@devlieghere.com">jonas@devlieghere.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div>Actually the statement in the commit message is incorrect, it looks like StringMap does guarantee both key and value to be stable. The patch is still correct though, because GetXcodeSDK does return a std::string, so we were returning a reference to a temporary. </div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 28, 2020 at 7:22 PM Jonas Devlieghere via lldb-commits <<a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><br>
Author: Jonas Devlieghere<br>
Date: 2020-04-28T19:21:58-07:00<br>
New Revision: b14c37a29a5455853419f5fe0605f6023c51de89<br>
<br>
URL: <a href="https://github.com/llvm/llvm-project/commit/b14c37a29a5455853419f5fe0605f6023c51de89" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/b14c37a29a5455853419f5fe0605f6023c51de89</a><br>
DIFF: <a href="https://github.com/llvm/llvm-project/commit/b14c37a29a5455853419f5fe0605f6023c51de89.diff" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/b14c37a29a5455853419f5fe0605f6023c51de89.diff</a><br>
<br>
LOG: [lldb/Platform] Return a std::string from GetSDKPath<br>
<br>
Nothing guarantees that the objects in the StringMap remains at the same<br>
address when the StringMap grows. Therefore we shouldn't return a<br>
reference into the StringMap but return a copy of the string instead.<br>
<br>
Added: <br>
<br>
<br>
Modified: <br>
    lldb/include/lldb/Target/Platform.h<br>
    lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp<br>
    lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h<br>
<br>
Removed: <br>
<br>
<br>
<br>
################################################################################<br>
diff  --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h<br>
index 872e5301d984..640261033c4b 100644<br>
--- a/lldb/include/lldb/Target/Platform.h<br>
+++ b/lldb/include/lldb/Target/Platform.h<br>
@@ -435,7 +435,7 @@ class Platform : public PluginInterface {<br>
     return lldb_private::ConstString();<br>
   }<br>
<br>
-  virtual llvm::StringRef GetSDKPath(lldb_private::XcodeSDK sdk) {<br>
+  virtual std::string GetSDKPath(lldb_private::XcodeSDK sdk) {<br>
     return {};<br>
   }<br>
<br>
<br>
diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp<br>
index 0777c78aa22d..5252d37a01c5 100644<br>
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp<br>
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp<br>
@@ -1761,11 +1761,11 @@ PlatformDarwin::FindXcodeContentsDirectoryInPath(llvm::StringRef path) {<br>
   return {};<br>
 }<br>
<br>
-llvm::StringRef PlatformDarwin::GetSDKPath(XcodeSDK sdk) {<br>
+std::string PlatformDarwin::GetSDKPath(XcodeSDK sdk) {<br>
   std::string &path = m_sdk_path[sdk.GetString()];<br>
-  if (path.empty())<br>
-    path = HostInfo::GetXcodeSDK(sdk);<br>
-  return path;<br>
+  if (!path.empty())<br>
+    return path;<br>
+  return HostInfo::GetXcodeSDK(sdk);<br>
 }<br>
<br>
 FileSpec PlatformDarwin::GetXcodeContentsDirectory() {<br>
<br>
diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h<br>
index 7d205be59689..d3b4181aafa0 100644<br>
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h<br>
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h<br>
@@ -89,7 +89,7 @@ class PlatformDarwin : public PlatformPOSIX {<br>
   llvm::Expected<lldb_private::StructuredData::DictionarySP><br>
   FetchExtendedCrashInformation(lldb_private::Process &process) override;<br>
<br>
-  llvm::StringRef GetSDKPath(lldb_private::XcodeSDK sdk) override;<br>
+  std::string GetSDKPath(lldb_private::XcodeSDK sdk) override;<br>
<br>
   static lldb_private::FileSpec GetXcodeContentsDirectory();<br>
   static lldb_private::FileSpec GetXcodeDeveloperDirectory();<br>
<br>
<br>
<br>
_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits</a><br>
</blockquote></div></div></div>
</blockquote></div>