Skip to content

Commit 216db21

Browse files
committed
Canonicalize clang-scan-deps input-file/file-deps paths for Windows
1 parent d879710 commit 216db21

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

clang/tools/clang-scan-deps/ClangScanDeps.cpp

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -601,13 +601,22 @@ static bool useCAS() {
601601
}
602602

603603
template <typename Container>
604-
static auto toJSONStrings(llvm::json::OStream &JOS, Container &&Strings) {
605-
return [&JOS, Strings = std::forward<Container>(Strings)] {
606-
for (StringRef Str : Strings)
604+
static auto toJSONStrings(llvm::json::OStream &JOS, Container &&Strings,
605+
bool Paths = false) {
606+
return [&JOS, Strings = std::forward<Container>(Strings), Paths] {
607+
for (StringRef Str : Strings) {
607608
// Not reporting SDKSettings.json so that test checks can remain (mostly)
608609
// platform-agnostic.
609-
if (!Str.ends_with("SDKSettings.json"))
610+
if (Str.ends_with("SDKSettings.json"))
611+
continue;
612+
if (Paths) {
613+
llvm::SmallString<261> Path{Str};
614+
llvm::sys::path::make_preferred(Path);
615+
JOS.value(Path.str());
616+
} else {
610617
JOS.value(Str);
618+
}
619+
}
611620
};
612621
}
613622

@@ -810,8 +819,11 @@ class FullDeps {
810819
toJSONStrings(JOS, Cmd.Arguments));
811820
JOS.attribute("executable", StringRef(Cmd.Executable));
812821
JOS.attributeArray("file-deps",
813-
toJSONStrings(JOS, I.FileDeps));
814-
JOS.attribute("input-file", StringRef(I.FileName));
822+
toJSONStrings(JOS, I.FileDeps,
823+
/*Paths*/true));
824+
llvm::SmallString<261> InputFile = StringRef(I.FileName);
825+
llvm::sys::path::make_preferred(InputFile);
826+
JOS.attribute("input-file", InputFile.str());
815827
if (EmitVisibleModules)
816828
JOS.attributeArray("visible-clang-modules",
817829
toJSONSorted(JOS, I.VisibleModules));
@@ -840,8 +852,11 @@ class FullDeps {
840852
toJSONStrings(JOS, I.DriverCommandLine));
841853
JOS.attribute("executable", "clang");
842854
JOS.attributeArray("file-deps",
843-
toJSONStrings(JOS, I.FileDeps));
844-
JOS.attribute("input-file", StringRef(I.FileName));
855+
toJSONStrings(JOS, I.FileDeps,
856+
/*Paths*/true));
857+
llvm::SmallString<261> InputFile = StringRef(I.FileName);
858+
llvm::sys::path::make_preferred(InputFile);
859+
JOS.attribute("input-file", InputFile.str());
845860
if (EmitVisibleModules)
846861
JOS.attributeArray("visible-clang-modules",
847862
toJSONSorted(JOS, I.VisibleModules));

0 commit comments

Comments
 (0)