llvm::Optional<std::string> GetOSBuildString();
- bool GetOSKernelDescription(std::string &s);
+ llvm::Optional<std::string> GetOSKernelDescription();
// Returns the name of the platform
ConstString GetName();
return llvm::None;
}
- virtual bool GetRemoteOSKernelDescription(std::string &s) {
- s.clear();
- return false;
+ virtual llvm::Optional<std::string> GetRemoteOSKernelDescription() {
+ return llvm::None;
}
// Remote Platform subclasses need to override this function
bool GetRemoteOSVersion() override;
llvm::Optional<std::string> GetRemoteOSBuildString() override;
- bool GetRemoteOSKernelDescription(std::string &s) override;
+ llvm::Optional<std::string> GetRemoteOSKernelDescription() override;
ArchSpec GetRemoteSystemArchitecture() override;
Status RunShellCommand(llvm::StringRef command, const FileSpec &working_dir,
PlatformSP platform_sp(GetSP());
if (platform_sp) {
- std::string s;
- if (platform_sp->GetOSKernelDescription(s)) {
- if (!s.empty()) {
- // Const-ify the string so we don't need to worry about the lifetime of
- // the string
- return ConstString(s.c_str()).GetCString();
- }
+ std::string s = platform_sp->GetOSKernelDescription().getValueOr("");
+ if (!s.empty()) {
+ // Const-ify the string so we don't need to worry about the lifetime of
+ // the string
+ return ConstString(s.c_str()).GetCString();
}
}
return nullptr;
return m_gdb_client.GetOSBuildString();
}
-bool PlatformRemoteGDBServer::GetRemoteOSKernelDescription(std::string &s) {
- return m_gdb_client.GetOSKernelDescription(s);
+llvm::Optional<std::string>
+PlatformRemoteGDBServer::GetRemoteOSKernelDescription() {
+ return m_gdb_client.GetOSKernelDescription();
}
// Remote Platform subclasses need to override this function
llvm::Optional<std::string> GetRemoteOSBuildString() override;
- bool GetRemoteOSKernelDescription(std::string &s) override;
+ llvm::Optional<std::string> GetRemoteOSKernelDescription() override;
// Remote Platform subclasses need to override this function
ArchSpec GetRemoteSystemArchitecture() override;
return llvm::None;
}
-bool GDBRemoteCommunicationClient::GetOSKernelDescription(std::string &s) {
+llvm::Optional<std::string>
+GDBRemoteCommunicationClient::GetOSKernelDescription() {
if (GetHostInfo()) {
- if (!m_os_kernel.empty()) {
- s = m_os_kernel;
- return true;
- }
+ if (!m_os_kernel.empty())
+ return m_os_kernel;
}
- s.clear();
- return false;
+ return llvm::None;
}
bool GDBRemoteCommunicationClient::GetHostname(std::string &s) {
llvm::Optional<std::string> GetOSBuildString();
- bool GetOSKernelDescription(std::string &s);
+ llvm::Optional<std::string> GetOSKernelDescription();
ArchSpec GetSystemArchitecture();
if (!specific_info.empty())
strm.Printf("Platform-specific connection: %s\n", specific_info.c_str());
- std::string s;
- if (GetOSKernelDescription(s))
- strm.Printf(" Kernel: %s\n", s.c_str());
+ if (llvm::Optional<std::string> s = GetOSKernelDescription())
+ strm.Format(" Kernel: {0}\n", *s);
}
llvm::VersionTuple Platform::GetOSVersion(Process *process) {
return GetRemoteOSBuildString();
}
-bool Platform::GetOSKernelDescription(std::string &s) {
- if (IsHost()) {
- llvm::Optional<std::string> desc = HostInfo::GetOSKernelDescription();
- s = desc.getValueOr("");
- return desc.hasValue();
- }
- return GetRemoteOSKernelDescription(s);
+llvm::Optional<std::string> Platform::GetOSKernelDescription() {
+ if (IsHost())
+ return HostInfo::GetOSKernelDescription();
+ return GetRemoteOSKernelDescription();
}
void Platform::AddClangModuleCompilationOptions(
return llvm::None;
}
-bool RemoteAwarePlatform::GetRemoteOSKernelDescription(std::string &s) {
+llvm::Optional<std::string> RemoteAwarePlatform::GetRemoteOSKernelDescription() {
if (m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteOSKernelDescription(s);
- s.clear();
- return false;
+ return m_remote_platform_sp->GetRemoteOSKernelDescription();
+ return llvm::None;
}
ArchSpec RemoteAwarePlatform::GetRemoteSystemArchitecture() {