Skip to content

Commit e4429fb

Browse files
committed
Update option diagnostics to match c++ driver
Adds -repl warning Rewords warning_incremental_requires_build_record_entry Fix error_i_mode using potentially wrong driver kind Fix error_argument_not_allowed_with not using '-debug-info-format=' Fixes Driver/options.swift (except for swift-driver doesn't allow integrated repl)
1 parent 8f65c26 commit e4429fb

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
@@ -1051,7 +1051,12 @@ extension Driver {
10511051
case .emitImportedModules:
10521052
return .singleCompile
10531053

1054-
case .repl, .lldbRepl:
1054+
case .repl:
1055+
if driverKind == .interactive, !parsedOptions.hasAnyInput {
1056+
diagnosticsEngine.emit(.warning_unnecessary_repl_mode(option: outputOption.option, kind: driverKind))
1057+
}
1058+
fallthrough
1059+
case .lldbRepl:
10551060
return .repl
10561061

10571062
case .deprecatedIntegratedRepl:
@@ -1116,6 +1121,10 @@ extension Driver {
11161121
}
11171122

11181123
extension Diagnostic.Message {
1124+
static func warning_unnecessary_repl_mode(option: Option, kind: DriverKind) -> Diagnostic.Message {
1125+
.warning("unnecessary option '\(option.spelling)'; this is the default for '\(kind.rawValue)' with no input files")
1126+
}
1127+
11191128
static func warn_ignoring_batch_mode(_ option: Option) -> Diagnostic.Message {
11201129
.warning("ignoring '-enable-batch-mode' because '\(option.spelling)' was also specified")
11211130
}
@@ -1248,7 +1257,7 @@ extension Driver {
12481257
compilerOutputType = nil
12491258

12501259
case .i:
1251-
diagnosticsEngine.emit(.error_i_mode(driverKind))
1260+
diagnosticsEngine.emit(.error_i_mode)
12521261

12531262
case .repl, .deprecatedIntegratedRepl, .lldbRepl:
12541263
compilerOutputType = nil
@@ -1287,11 +1296,11 @@ extension Driver {
12871296
}
12881297

12891298
extension Diagnostic.Message {
1290-
static func error_i_mode(_ driverKind: DriverKind) -> Diagnostic.Message {
1299+
static var error_i_mode: Diagnostic.Message {
12911300
.error(
12921301
"""
12931302
the flag '-i' is no longer required and has been removed; \
1294-
use '\(driverKind.usage) input-filename'
1303+
use '\(DriverKind.interactive.usage) input-filename'
12951304
"""
12961305
)
12971306
}
@@ -1420,7 +1429,8 @@ extension Driver {
14201429

14211430
if format == .codeView && (level == .lineTables || level == .dwarfTypes) {
14221431
let levelOption = parsedOptions.getLast(in: .g)!.option
1423-
diagnosticsEngine.emit(.error_argument_not_allowed_with(arg: format.rawValue, other: levelOption.spelling))
1432+
let fullNotAllowedOption = Option.debugInfoFormat.spelling + format.rawValue
1433+
diagnosticsEngine.emit(.error_argument_not_allowed_with(arg: fullNotAllowedOption, other: levelOption.spelling))
14241434
}
14251435

14261436
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)