Skip to content

Commit 6bede3a

Browse files
Merge pull request #368 from cltnschlosser/cs_optionsIntegrationTests
Update option diagnostics to match c++ driver
2 parents 344e49d + e4429fb commit 6bede3a

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,12 @@ extension Driver {
10551055
case .emitImportedModules:
10561056
return .singleCompile
10571057

1058-
case .repl, .lldbRepl:
1058+
case .repl:
1059+
if driverKind == .interactive, !parsedOptions.hasAnyInput {
1060+
diagnosticsEngine.emit(.warning_unnecessary_repl_mode(option: outputOption.option, kind: driverKind))
1061+
}
1062+
fallthrough
1063+
case .lldbRepl:
10591064
return .repl
10601065

10611066
case .deprecatedIntegratedRepl:
@@ -1120,6 +1125,10 @@ extension Driver {
11201125
}
11211126

11221127
extension Diagnostic.Message {
1128+
static func warning_unnecessary_repl_mode(option: Option, kind: DriverKind) -> Diagnostic.Message {
1129+
.warning("unnecessary option '\(option.spelling)'; this is the default for '\(kind.rawValue)' with no input files")
1130+
}
1131+
11231132
static func warn_ignoring_batch_mode(_ option: Option) -> Diagnostic.Message {
11241133
.warning("ignoring '-enable-batch-mode' because '\(option.spelling)' was also specified")
11251134
}
@@ -1252,7 +1261,7 @@ extension Driver {
12521261
compilerOutputType = nil
12531262

12541263
case .i:
1255-
diagnosticsEngine.emit(.error_i_mode(driverKind))
1264+
diagnosticsEngine.emit(.error_i_mode)
12561265

12571266
case .repl, .deprecatedIntegratedRepl, .lldbRepl:
12581267
compilerOutputType = nil
@@ -1291,11 +1300,11 @@ extension Driver {
12911300
}
12921301

12931302
extension Diagnostic.Message {
1294-
static func error_i_mode(_ driverKind: DriverKind) -> Diagnostic.Message {
1303+
static var error_i_mode: Diagnostic.Message {
12951304
.error(
12961305
"""
12971306
the flag '-i' is no longer required and has been removed; \
1298-
use '\(driverKind.usage) input-filename'
1307+
use '\(DriverKind.interactive.usage) input-filename'
12991308
"""
13001309
)
13011310
}
@@ -1424,7 +1433,8 @@ extension Driver {
14241433

14251434
if format == .codeView && (level == .lineTables || level == .dwarfTypes) {
14261435
let levelOption = parsedOptions.getLast(in: .g)!.option
1427-
diagnosticsEngine.emit(.error_argument_not_allowed_with(arg: format.rawValue, other: levelOption.spelling))
1436+
let fullNotAllowedOption = Option.debugInfoFormat.spelling + format.rawValue
1437+
diagnosticsEngine.emit(.error_argument_not_allowed_with(arg: fullNotAllowedOption, other: levelOption.spelling))
14281438
}
14291439

14301440
return DebugInfo(format: format, level: level, shouldVerify: shouldVerify)

Sources/SwiftDriver/Incremental Compilation/IncrementalCompilationState.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ extension Diagnostic.Message {
175175
static var warning_incremental_requires_build_record_entry: Diagnostic.Message {
176176
.warning(
177177
"ignoring -incremental; " +
178-
"output file map has no master dependencies entry under \(FileType.swiftDeps)"
178+
"output file map has no master dependencies entry (\"\(FileType.swiftDeps)\" under \"\")"
179179
)
180180
}
181181
fileprivate static func remark_incremental_compilation_disabled(because why: String) -> Diagnostic.Message {

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ final class SwiftDriverTests: XCTestCase {
378378
}
379379

380380
try assertDriverDiagnostics(args: "swiftc", "foo.swift", "-emit-module", "-gdwarf-types", "-debug-info-format=codeview") {
381-
$1.expect(.error("argument 'codeview' is not allowed with '-gdwarf-types'"))
381+
$1.expect(.error("argument '-debug-info-format=codeview' is not allowed with '-gdwarf-types'"))
382382
}
383383
}
384384

@@ -423,7 +423,8 @@ final class SwiftDriverTests: XCTestCase {
423423
XCTAssertEqual(driver.moduleOutputInfo.name, "main")
424424
}
425425

426-
try assertNoDriverDiagnostics(args: "swift", "-repl") { driver in
426+
try assertDriverDiagnostics(args: "swift", "-repl") { driver, verifier in
427+
verifier.expect(.warning("unnecessary option '-repl'; this is the default for 'swift' with no input files"))
427428
XCTAssertNil(driver.moduleOutputInfo.output)
428429
XCTAssertEqual(driver.moduleOutputInfo.name, "REPL")
429430
}

0 commit comments

Comments
 (0)