[llvm] [llvm][Support][Windows] Fix slash in path for remove_directories (PR #121448)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 1 19:34:20 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-platform-windows
Author: Jinsong Ji (jsji)
<details>
<summary>Changes</summary>
Before 925471ed903dad871042d7ed0bab89ab6566a564 remove_directories
supports path with slash (instead of backslash).
The ILCreateFromPathW in new implementation requirs backslash path,
so the call to remove_directories will fail if the path contains slash.
This is to normalize the path to make sure remove_directories still
support path with slash as well.
---
Full diff: https://github.com/llvm/llvm-project/pull/121448.diff
1 Files Affected:
- (modified) llvm/lib/Support/Windows/Path.inc (+3-1)
``````````diff
diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc
index 17db114caeb1ec..5b311e7c475c56 100644
--- a/llvm/lib/Support/Windows/Path.inc
+++ b/llvm/lib/Support/Windows/Path.inc
@@ -1373,9 +1373,11 @@ std::error_code closeFile(file_t &F) {
}
std::error_code remove_directories(const Twine &path, bool IgnoreErrors) {
+ SmallString<128> NativePath;
+ llvm::sys::path::native(path, NativePath, path::Style::windows_backslash);
// Convert to utf-16.
SmallVector<wchar_t, 128> Path16;
- std::error_code EC = widenPath(path, Path16);
+ std::error_code EC = widenPath(NativePath, Path16);
if (EC && !IgnoreErrors)
return EC;
``````````
</details>
https://github.com/llvm/llvm-project/pull/121448
More information about the llvm-commits
mailing list