[lldb/Platform] Return a std::string from GetSDKPath

Nothing guarantees that the objects in the StringMap remains at the same
address when the StringMap grows. Therefore we shouldn't return a
reference into the StringMap but return a copy of the string instead.
This commit is contained in:
Jonas Devlieghere 2020-04-28 19:05:51 -07:00
parent 329ebb85a9
commit b14c37a29a
3 changed files with 6 additions and 6 deletions

View File

@ -435,7 +435,7 @@ public:
return lldb_private::ConstString();
}
virtual llvm::StringRef GetSDKPath(lldb_private::XcodeSDK sdk) {
virtual std::string GetSDKPath(lldb_private::XcodeSDK sdk) {
return {};
}

View File

@ -1761,11 +1761,11 @@ PlatformDarwin::FindXcodeContentsDirectoryInPath(llvm::StringRef path) {
return {};
}
llvm::StringRef PlatformDarwin::GetSDKPath(XcodeSDK sdk) {
std::string PlatformDarwin::GetSDKPath(XcodeSDK sdk) {
std::string &path = m_sdk_path[sdk.GetString()];
if (path.empty())
path = HostInfo::GetXcodeSDK(sdk);
return path;
if (!path.empty())
return path;
return HostInfo::GetXcodeSDK(sdk);
}
FileSpec PlatformDarwin::GetXcodeContentsDirectory() {

View File

@ -89,7 +89,7 @@ public:
llvm::Expected<lldb_private::StructuredData::DictionarySP>
FetchExtendedCrashInformation(lldb_private::Process &process) override;
llvm::StringRef GetSDKPath(lldb_private::XcodeSDK sdk) override;
std::string GetSDKPath(lldb_private::XcodeSDK sdk) override;
static lldb_private::FileSpec GetXcodeContentsDirectory();
static lldb_private::FileSpec GetXcodeDeveloperDirectory();