Skip to content

Commit 435f1d4

Browse files
committed
[Dependency Scanning] Escape quoted strings in dependency command-line output
Resolves rdar://120872469
1 parent 6c75168 commit 435f1d4

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

lib/DependencyScan/ScanDependencies.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,8 @@ std::string quote(StringRef unquoted) {
413413
for (const auto ch : unquoted) {
414414
if (ch == '\\')
415415
os << '\\';
416+
if (ch == '"')
417+
os << '\\';
416418
os << ch;
417419
}
418420
return buffer.str().str();

test/ScanDependencies/placholder_overlay_deps.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -placeholder-dependency-module-map-file %t/inputs/map.json -o %t/deps.json
1515

1616
// Check the contents of the JSON output
17-
// RUN: %validate-json %t/deps.json &>/dev/null
18-
// RUN: %FileCheck %s < %t/deps.json
17+
// RUN: %validate-json %t/deps.json > %t/validated_deps.json
18+
// RUN: %FileCheck %s < %t/validated_deps.json
1919

2020
// REQUIRES: executable_test
2121
// REQUIRES: objc_interop
@@ -25,8 +25,7 @@ import Metal
2525
// Ensure the dependency on Darwin is captured even though it is a placeholder
2626

2727
// CHECK: "modulePath": "{{.*}}{{/|\\}}Metal-{{.*}}.swiftmodule",
28-
// CHECK-NEXT: "sourceFiles": [
29-
// CHECK-NEXT: ],
28+
// CHECK: "directDependencies": [
3029
// CHECK: {
3130
// CHECK: "swiftPlaceholder": "Darwin"
3231
// CHECK: },
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %empty-directory(%t/module-cache)
3+
// RUN: %empty-directory(%t/inputs)
4+
// RUN: split-file %s %t
5+
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/module-cache %t/test.swift -o %t/deps.json -I %t/inputs -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import
6+
// RUN: %validate-json %t/deps.json > %t/validated_deps.json
7+
// RUN: %FileCheck %s < %t/validated_deps.json
8+
9+
//--- inputs/Foo.swiftinterface
10+
// swift-interface-format-version: 1.0
11+
// swift-module-flags: -module-name Foo
12+
// swift-module-flags-ignorable-private: -package-name "\"ManyFoos\""
13+
public func foo() {}
14+
15+
//--- test.swift
16+
import Foo
17+
18+
// CHECK: "-package-name"
19+
// CHECK-NEXT: "\"ManyFoos\""

0 commit comments

Comments
 (0)