https://github.com/Jwata updated 
https://github.com/llvm/llvm-project/pull/179410

>From cfc863031c9607bb2f2334ba1f14d9c9d674173d Mon Sep 17 00:00:00 2001
From: Junji Watanabe <[email protected]>
Date: Tue, 3 Feb 2026 17:01:13 +0900
Subject: [PATCH] [Windows] Fix path separator mismatches in LLVM tests

---
 clang-tools-extra/clangd/unittests/TestFS.cpp |  8 +++++---
 clang-tools-extra/clangd/unittests/TestFS.h   |  2 +-
 .../clangd/unittests/URITests.cpp             | 19 ++++++++++++-------
 lld/test/COFF/linkreprofullpathrsp.test       |  2 +-
 lld/test/ELF/dependency-file.s                | 12 ++++++------
 llvm/utils/lit/lit/llvm/subst.py              |  4 ++++
 6 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/clang-tools-extra/clangd/unittests/TestFS.cpp 
b/clang-tools-extra/clangd/unittests/TestFS.cpp
index bb309609eda20..bbc60753b10e0 100644
--- a/clang-tools-extra/clangd/unittests/TestFS.cpp
+++ b/clang-tools-extra/clangd/unittests/TestFS.cpp
@@ -82,12 +82,14 @@ MockCompilationDatabase::getCompileCommand(PathRef File) 
const {
                                   FileName, std::move(CommandLine), "")};
 }
 
-const char *testRoot() {
+std::string testRoot() {
+  llvm::SmallString<32> Path;
 #ifdef _WIN32
-  return "C:\\clangd-test";
+  llvm::sys::path::native("C:/clangd-test", Path);
 #else
-  return "/clangd-test";
+  llvm::sys::path::native("/clangd-test", Path);
 #endif
+  return std::string(Path.str());
 }
 
 std::string testPath(PathRef File, llvm::sys::path::Style Style) {
diff --git a/clang-tools-extra/clangd/unittests/TestFS.h 
b/clang-tools-extra/clangd/unittests/TestFS.h
index 568533f3b3b91..804d94fb524ee 100644
--- a/clang-tools-extra/clangd/unittests/TestFS.h
+++ b/clang-tools-extra/clangd/unittests/TestFS.h
@@ -73,7 +73,7 @@ class MockCompilationDatabase : public 
GlobalCompilationDatabase {
 };
 
 // Returns an absolute (fake) test directory for this OS.
-const char *testRoot();
+std::string testRoot();
 
 // Returns a suitable absolute path for this OS.
 std::string testPath(PathRef File,
diff --git a/clang-tools-extra/clangd/unittests/URITests.cpp 
b/clang-tools-extra/clangd/unittests/URITests.cpp
index c0ccfc539c452..a8dcb928e61d3 100644
--- a/clang-tools-extra/clangd/unittests/URITests.cpp
+++ b/clang-tools-extra/clangd/unittests/URITests.cpp
@@ -133,8 +133,10 @@ TEST(URITest, ParseFailed) {
 
 TEST(URITest, Resolve) {
 #ifdef _WIN32
-  EXPECT_THAT(resolveOrDie(parseOrDie("file:///c%3a/x/y/z")), "c:\\x\\y\\z");
-  EXPECT_THAT(resolveOrDie(parseOrDie("file:///c:/x/y/z")), "c:\\x\\y\\z");
+  llvm::SmallString<32> Expected;
+  llvm::sys::path::native("c:/x/y/z", Expected);
+  EXPECT_THAT(resolveOrDie(parseOrDie("file:///c%3a/x/y/z")), Expected);
+  EXPECT_THAT(resolveOrDie(parseOrDie("file:///c:/x/y/z")), Expected);
 #else
   EXPECT_EQ(resolveOrDie(parseOrDie("file:/a/b/c")), "/a/b/c");
   EXPECT_EQ(resolveOrDie(parseOrDie("file://auth/a/b/c")), "//auth/a/b/c");
@@ -148,13 +150,16 @@ TEST(URITest, Resolve) {
 
 TEST(URITest, ResolveUNC) {
 #ifdef _WIN32
-  EXPECT_THAT(resolveOrDie(parseOrDie("file://example.com/x/y/z")),
-              "\\\\example.com\\x\\y\\z");
-  EXPECT_THAT(resolveOrDie(parseOrDie("file://127.0.0.1/x/y/z")),
-              "\\\\127.0.0.1\\x\\y\\z");
+  llvm::SmallString<32> Expected;
+  llvm::sys::path::native("//example.com/x/y/z", Expected);
+  EXPECT_THAT(resolveOrDie(parseOrDie("file://example.com/x/y/z")), Expected);
+
+  llvm::SmallString<32> ExpectedIP;
+  llvm::sys::path::native("//127.0.0.1/x/y/z", ExpectedIP);
+  EXPECT_THAT(resolveOrDie(parseOrDie("file://127.0.0.1/x/y/z")), ExpectedIP);
   // Ensure non-traditional file URI still resolves to correct UNC path.
   EXPECT_THAT(resolveOrDie(parseOrDie("file:////127.0.0.1/x/y/z")),
-              "\\\\127.0.0.1\\x\\y\\z");
+              ExpectedIP);
 #else
   EXPECT_THAT(resolveOrDie(parseOrDie("file://example.com/x/y/z")),
               "//example.com/x/y/z");
diff --git a/lld/test/COFF/linkreprofullpathrsp.test 
b/lld/test/COFF/linkreprofullpathrsp.test
index 66f2e2ba2f859..3f319e9493432 100644
--- a/lld/test/COFF/linkreprofullpathrsp.test
+++ b/lld/test/COFF/linkreprofullpathrsp.test
@@ -14,7 +14,7 @@ Test link.exe-style /linkreprofullpathrsp: flag.
 # RUN: lld-link /subsystem:console %t.obj %p/Inputs/std32.lib 
/defaultlib:%p/Inputs/library.lib \
 # RUN:  /libpath:%p/Inputs /defaultlib:std64.lib ret42.lib /entry:main@0 
/linkreprofullpathrsp:%t.rsp \
 # RUN:   %t.pdb /wholearchive:%t.archive.lib /out:%t.exe /timestamp:0
-# # RUN: FileCheck %s --check-prefix=RSP -DT=%t -DP=%p < %t.rsp
+# RUN: FileCheck %s --check-prefix=RSP -DT=%/t -DP=%/p < %t.rsp
 
 # RUN: lld-link /subsystem:console @%t.rsp /out:%t2.exe /entry:main@0 
/timestamp:0
 # RUN: diff %t.exe %t2.exe
diff --git a/lld/test/ELF/dependency-file.s b/lld/test/ELF/dependency-file.s
index e7dbf9c7695f7..537c4cb5251bc 100644
--- a/lld/test/ELF/dependency-file.s
+++ b/lld/test/ELF/dependency-file.s
@@ -1,10 +1,10 @@
 # REQUIRES: x86
-# RUN: mkdir -p %t
-# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t/foo.o
-# RUN: llvm-mc -filetype=obj -triple=x86_64 /dev/null -o "%t/bar baz.o"
-# RUN: llvm-mc -filetype=obj -triple=x86_64 /dev/null -o "%t/#quux$.o"
-# RUN: ld.lld -o %t/foo.exe %t/foo.o %t/"bar baz.o" "%t/#quux$.o" 
--dependency-file=%t/foo.d
-# RUN: FileCheck --match-full-lines -DFILE=%t %s < %t/foo.d
+# RUN: mkdir -p %/t
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %/t/foo.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64 /dev/null -o "%/t/bar baz.o"
+# RUN: llvm-mc -filetype=obj -triple=x86_64 /dev/null -o "%/t/#quux$.o"
+# RUN: ld.lld -o %/t/foo.exe %/t/foo.o %/t/"bar baz.o" "%/t/#quux$.o" 
--dependency-file=%/t/foo.d
+# RUN: FileCheck --match-full-lines -DFILE=%/t %s < %/t/foo.d
 
 # CHECK:      [[FILE]]{{/|(\\)+}}foo.exe: \
 # CHECK-NEXT:   [[FILE]]{{/|(\\)+}}foo.o \
diff --git a/llvm/utils/lit/lit/llvm/subst.py b/llvm/utils/lit/lit/llvm/subst.py
index 09ab3555a6b44..4e8ef584dd0df 100644
--- a/llvm/utils/lit/lit/llvm/subst.py
+++ b/llvm/utils/lit/lit/llvm/subst.py
@@ -1,5 +1,6 @@
 import os
 import re
+import sys
 
 import lit.util
 
@@ -117,6 +118,9 @@ def resolve(self, config, search_dirs):
         else:
             command_str = str(self.command)
 
+        if sys.platform == 'win32' and command_str:
+            command_str = command_str.replace('\\', '/')
+
         if command_str:
             if self.extra_args:
                 command_str = " ".join([command_str] + self.extra_args)

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to