Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions clang/tools/clang-scan-deps/ClangScanDeps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,13 +601,22 @@ static bool useCAS() {
}

template <typename Container>
static auto toJSONStrings(llvm::json::OStream &JOS, Container &&Strings) {
return [&JOS, Strings = std::forward<Container>(Strings)] {
for (StringRef Str : Strings)
static auto toJSONStrings(llvm::json::OStream &JOS, Container &&Strings,
bool Paths = false) {
return [&JOS, Strings = std::forward<Container>(Strings), Paths] {
for (StringRef Str : Strings) {
// Not reporting SDKSettings.json so that test checks can remain (mostly)
// platform-agnostic.
if (!Str.ends_with("SDKSettings.json"))
if (Str.ends_with("SDKSettings.json"))
continue;
if (Paths) {
llvm::SmallString<261> Path{Str};
llvm::sys::path::make_preferred(Path);
JOS.value(Path.str());
} else {
JOS.value(Str);
}
}
};
}

Expand Down Expand Up @@ -810,8 +819,11 @@ class FullDeps {
toJSONStrings(JOS, Cmd.Arguments));
JOS.attribute("executable", StringRef(Cmd.Executable));
JOS.attributeArray("file-deps",
toJSONStrings(JOS, I.FileDeps));
JOS.attribute("input-file", StringRef(I.FileName));
toJSONStrings(JOS, I.FileDeps,
/*Paths*/true));
llvm::SmallString<261> InputFile = StringRef(I.FileName);
llvm::sys::path::make_preferred(InputFile);
JOS.attribute("input-file", InputFile.str());
if (EmitVisibleModules)
JOS.attributeArray("visible-clang-modules",
toJSONSorted(JOS, I.VisibleModules));
Expand Down Expand Up @@ -840,8 +852,11 @@ class FullDeps {
toJSONStrings(JOS, I.DriverCommandLine));
JOS.attribute("executable", "clang");
JOS.attributeArray("file-deps",
toJSONStrings(JOS, I.FileDeps));
JOS.attribute("input-file", StringRef(I.FileName));
toJSONStrings(JOS, I.FileDeps,
/*Paths*/true));
llvm::SmallString<261> InputFile = StringRef(I.FileName);
llvm::sys::path::make_preferred(InputFile);
JOS.attribute("input-file", InputFile.str());
if (EmitVisibleModules)
JOS.attributeArray("visible-clang-modules",
toJSONSorted(JOS, I.VisibleModules));
Expand Down