llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: Charles Zablit (charles-zablit) <details> <summary>Changes</summary> This patch changes the return type of methods returning `std:wstring` to `std::string` in `PythonPathSetup.cpp`. This follows lldb's style of converting to `std::wstring` at the last moment. --- Full diff: https://github.com/llvm/llvm-project/pull/180786.diff 1 Files Affected: - (modified) lldb/source/Host/windows/PythonPathSetup/PythonPathSetup.cpp (+19-18) ``````````diff diff --git a/lldb/source/Host/windows/PythonPathSetup/PythonPathSetup.cpp b/lldb/source/Host/windows/PythonPathSetup/PythonPathSetup.cpp index d378e6984b056..0ca1189bec283 100644 --- a/lldb/source/Host/windows/PythonPathSetup/PythonPathSetup.cpp +++ b/lldb/source/Host/windows/PythonPathSetup/PythonPathSetup.cpp @@ -21,39 +21,40 @@ using namespace llvm; #ifdef LLDB_PYTHON_DLL_RELATIVE_PATH /// Returns the full path to the lldb.exe executable. -static std::wstring GetPathToExecutableW() { +static std::string GetPathToExecutable() { std::vector<WCHAR> buffer(MAX_PATH); while (buffer.size() <= PATHCCH_MAX_CCH) { DWORD len = GetModuleFileNameW(NULL, buffer.data(), buffer.size()); if (len == 0) - return L""; - if (len < buffer.size()) - return std::wstring(buffer.data(), len); + return ""; + if (len < buffer.size()) { + std::string buffer_utf8; + if (convertWideToUTF8(std::wstring(buffer.data(), len), buffer_utf8)) + return buffer_utf8; + return ""; + } if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) buffer.resize(buffer.size() * 2); } - return L""; + return ""; } bool AddPythonDLLToSearchPath() { - std::wstring modulePath = GetPathToExecutableW(); - if (modulePath.empty()) + std::string path_str = GetPathToExecutable(); + if (path_str.empty()) return false; - SmallVector<char, MAX_PATH> utf8Path; - if (sys::windows::UTF16ToUTF8(modulePath.c_str(), modulePath.length(), - utf8Path)) - return false; - sys::path::remove_filename(utf8Path); - sys::path::append(utf8Path, LLDB_PYTHON_DLL_RELATIVE_PATH); - sys::fs::make_absolute(utf8Path); + SmallVector<char, MAX_PATH> path(path_str.begin(), path_str.end()); + sys::path::remove_filename(path); + sys::path::append(path, LLDB_PYTHON_DLL_RELATIVE_PATH); + sys::fs::make_absolute(path); - SmallVector<wchar_t, 1> widePath; - if (sys::windows::widenPath(utf8Path.data(), widePath)) + SmallVector<wchar_t, 1> path_wide; + if (sys::windows::widenPath(path.data(), path_wide)) return false; - if (sys::fs::exists(utf8Path)) - return SetDllDirectoryW(widePath.data()); + if (sys::fs::exists(path)) + return SetDllDirectoryW(path_wide.data()); return false; } #endif `````````` </details> https://github.com/llvm/llvm-project/pull/180786 _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
