Skip to content

Commit dfd11cf

Browse files
[DepScan] Add missing field in JSON output
SwiftSourceModule can contain "commandLine" field and add that into the JSON output format.
1 parent 0876a3e commit dfd11cf

File tree

4 files changed

+21
-15
lines changed

4 files changed

+21
-15
lines changed

lib/DependencyScan/ScanDependencies.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,20 +1016,6 @@ static void writeJSON(llvm::raw_ostream &out,
10161016
5,
10171017
/*trailingComma=*/true);
10181018
out.indent(5 * 2);
1019-
out << "\"commandLine\": [\n";
1020-
for (int i = 0, count = swiftTextualDeps->command_line->count;
1021-
i < count; ++i) {
1022-
const auto &arg =
1023-
get_C_string(swiftTextualDeps->command_line->strings[i]);
1024-
out.indent(6 * 2);
1025-
out << "\"" << quote(arg) << "\"";
1026-
if (i != count - 1)
1027-
out << ",";
1028-
out << "\n";
1029-
}
1030-
out.indent(5 * 2);
1031-
out << "],\n";
1032-
out.indent(5 * 2);
10331019
out << "\"compiledModuleCandidates\": [\n";
10341020
for (int i = 0,
10351021
count = swiftTextualDeps->compiled_module_candidates->count;
@@ -1045,6 +1031,20 @@ static void writeJSON(llvm::raw_ostream &out,
10451031
out.indent(5 * 2);
10461032
out << "],\n";
10471033
}
1034+
out.indent(5 * 2);
1035+
out << "\"commandLine\": [\n";
1036+
for (int i = 0, count = swiftTextualDeps->command_line->count; i < count;
1037+
++i) {
1038+
const auto &arg =
1039+
get_C_string(swiftTextualDeps->command_line->strings[i]);
1040+
out.indent(6 * 2);
1041+
out << "\"" << quote(arg) << "\"";
1042+
if (i != count - 1)
1043+
out << ",";
1044+
out << "\n";
1045+
}
1046+
out.indent(5 * 2);
1047+
out << "],\n";
10481048
bool hasBridgingHeaderPath =
10491049
swiftTextualDeps->bridging_header_path.data &&
10501050
get_C_string(swiftTextualDeps->bridging_header_path)[0] != '\0';

test/CAS/module_deps.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ import SubE
6666
// CHECK-DAG: "swift": "_Concurrency"
6767
// CHECK-DAG: "swift": "_cross_import_E"
6868
// CHECK: ],
69-
69+
// CHECK: "commandLine":
70+
// CHECK: "casFSRootID":
7071
// CHECK: "extraPcmArgs": [
7172
// CHECK-NEXT: "-Xcc",
7273
// CHECK-NEXT: "-target",

test/ModuleInterface/clang-session-transitive.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ import TestModule
3333
// CHECK-NEXT: "swift": {
3434
// CHECK-NEXT: "moduleInterfacePath":
3535
// CHECK-NEXT: "contextHash":
36+
// CHECK-NEXT: "compiledModuleCandidates": [
37+
// CHECK-NEXT: TestModule.swiftmodule
38+
// CHECK-NEXT: ],
3639
// CHECK-NEXT: "commandLine": [
3740
// CHECK-NEXT: "-frontend",
3841
// CHECK-NEXT: "-compile-module-from-interface",

test/ModuleInterface/extension-transitive-availability.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ func foo() {
4242
// CHECK-NEXT: "swift": {
4343
// CHECK-NEXT: "moduleInterfacePath":
4444
// CHECK-NEXT: "contextHash":
45+
// CHECK-NEXT: "compiledModuleCandidates": [
46+
// CHECK-NEXT: ],
4547
// CHECK-NEXT: "commandLine": [
4648
// CHECK-NEXT: "-frontend",
4749
// CHECK-NEXT: "-compile-module-from-interface",

0 commit comments

Comments
 (0)