Skip to content

Commit 9b83358

Browse files
allevatoartemcm
authored andcommitted
Pass the -dump-ast-format flag down to the frontend.
Companion PR to swiftlang/swift#77321.
1 parent 90ddf76 commit 9b83358

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,9 @@ extension Driver {
283283
try commandLine.appendLast(.lto, from: &parsedOptions)
284284
try commandLine.appendLast(.accessNotesPath, from: &parsedOptions)
285285
try commandLine.appendLast(.enableActorDataRaceChecks, .disableActorDataRaceChecks, from: &parsedOptions)
286+
if isFrontendArgSupported(.dumpAstFormat) {
287+
try commandLine.appendLast(.dumpAstFormat, from: &parsedOptions)
288+
}
286289
try commandLine.appendAll(.D, from: &parsedOptions)
287290
try commandLine.appendAll(.debugPrefixMap, .coveragePrefixMap, .filePrefixMap, from: &parsedOptions)
288291
try commandLine.appendAllArguments(.Xfrontend, from: &parsedOptions)

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5561,6 +5561,17 @@ final class SwiftDriverTests: XCTestCase {
55615561
}
55625562
}
55635563

5564+
func testDumpASTFormat() throws {
5565+
var driver = try Driver(args: [
5566+
"swiftc", "-dump-ast", "-dump-ast-format", "json", "foo.swift"
5567+
])
5568+
let plannedJobs = try driver.planBuild()
5569+
XCTAssertEqual(plannedJobs[0].kind, .compile)
5570+
XCTAssertTrue(plannedJobs[0].commandLine.contains("-dump-ast"))
5571+
XCTAssertTrue(plannedJobs[0].commandLine.contains("-dump-ast-format"))
5572+
XCTAssertTrue(plannedJobs[0].commandLine.contains("json"))
5573+
}
5574+
55645575
func testDeriveSwiftDocPath() throws {
55655576
var driver = try Driver(args: [
55665577
"swiftc", "-emit-module", "/tmp/main.swift", "-emit-module-path", "test-ios-macabi.swiftmodule"

0 commit comments

Comments
 (0)