@@ -601,13 +601,19 @@ static bool useCAS() {
601
601
}
602
602
603
603
template <typename Container>
604
- static auto toJSONStrings (llvm::json::OStream &JOS, Container &&Strings) {
605
- return [&JOS, Strings = std::forward<Container>(Strings)] {
604
+ static auto toJSONStrings (llvm::json::OStream &JOS, Container &&Strings,
605
+ bool CanonicalizePath = false ) {
606
+ return [&JOS, Strings = std::forward<Container>(Strings), CanonicalizePath] {
606
607
for (StringRef Str : Strings)
607
608
// Not reporting SDKSettings.json so that test checks can remain (mostly)
608
609
// platform-agnostic.
609
610
if (!Str.ends_with (" SDKSettings.json" ))
610
- JOS.value (Str);
611
+ if (CanonicalizePath) {
612
+ llvm::SmallString<261 > Path = Str;
613
+ llvm::sys::path::make_preferred (Path);
614
+ JOS.value (Path.str ());
615
+ } else
616
+ JOS.value (Str);
611
617
};
612
618
}
613
619
@@ -810,8 +816,11 @@ class FullDeps {
810
816
toJSONStrings (JOS, Cmd.Arguments ));
811
817
JOS.attribute (" executable" , StringRef (Cmd.Executable ));
812
818
JOS.attributeArray (" file-deps" ,
813
- toJSONStrings (JOS, I.FileDeps ));
814
- JOS.attribute (" input-file" , StringRef (I.FileName ));
819
+ toJSONStrings (JOS, I.FileDeps ,
820
+ /* CanonicalizePath*/ true ));
821
+ llvm::SmallString<261 > InputFile = StringRef (I.FileName );
822
+ llvm::sys::path::make_preferred (InputFile);
823
+ JOS.attribute (" input-file" , InputFile.str ());
815
824
if (EmitVisibleModules)
816
825
JOS.attributeArray (" visible-clang-modules" ,
817
826
toJSONSorted (JOS, I.VisibleModules ));
@@ -840,8 +849,11 @@ class FullDeps {
840
849
toJSONStrings (JOS, I.DriverCommandLine ));
841
850
JOS.attribute (" executable" , " clang" );
842
851
JOS.attributeArray (" file-deps" ,
843
- toJSONStrings (JOS, I.FileDeps ));
844
- JOS.attribute (" input-file" , StringRef (I.FileName ));
852
+ toJSONStrings (JOS, I.FileDeps ,
853
+ /* CanonicalizePath*/ true ));
854
+ llvm::SmallString<261 > InputFile = StringRef (I.FileName );
855
+ llvm::sys::path::make_preferred (InputFile);
856
+ JOS.attribute (" input-file" , InputFile.str ());
845
857
if (EmitVisibleModules)
846
858
JOS.attributeArray (" visible-clang-modules" ,
847
859
toJSONSorted (JOS, I.VisibleModules ));
0 commit comments