Skip to content

Commit ae21bd1

Browse files
authored
Merge pull request #91 from owenv/update-diag-opts
Support new diagnostic options: -no-warnings-as-errors and -print-educational-notes
2 parents 5d2c560 + 7b94c00 commit ae21bd1

File tree

5 files changed

+116
-7
lines changed

5 files changed

+116
-7
lines changed

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public struct Driver {
4949
case relativeFrontendPath(String)
5050
case subcommandPassedToDriver
5151
case integratedReplRemoved
52+
case conflictingOptions(Option, Option)
5253

5354
public var description: String {
5455
switch self {
@@ -65,6 +66,8 @@ public struct Driver {
6566
return "subcommand passed to driver"
6667
case .integratedReplRemoved:
6768
return "Compiler-internal integrated REPL has been removed; use the LLDB-enhanced REPL instead."
69+
case .conflictingOptions(let one, let two):
70+
return "conflicting options '\(one.spelling)' and '\(two.spelling)'"
6871
}
6972
}
7073
}
@@ -307,6 +310,8 @@ public struct Driver {
307310
self.numThreads = Self.determineNumThreads(&parsedOptions, compilerMode: compilerMode, diagnosticsEngine: diagnosticEngine)
308311
self.numParallelJobs = Self.determineNumParallelJobs(&parsedOptions, diagnosticsEngine: diagnosticEngine, env: env)
309312

313+
try Self.validateWarningControlArgs(&parsedOptions)
314+
310315
// Compute debug information output.
311316
(self.debugInfoLevel, self.debugInfoFormat, shouldVerifyDebugInfo: self.shouldVerifyDebugInfo) =
312317
Self.computeDebugInfo(&parsedOptions, diagnosticsEngine: diagnosticEngine)
@@ -1457,6 +1462,16 @@ extension Diagnostic.Message {
14571462
}
14581463
}
14591464

1465+
// MARK: Miscellaneous Argument Validation
1466+
extension Driver {
1467+
static func validateWarningControlArgs(_ parsedOptions: inout ParsedOptions) throws {
1468+
if parsedOptions.hasArgument(.suppressWarnings) &&
1469+
parsedOptions.hasFlag(positive: .warningsAsErrors, negative: .noWarningsAsErrors, default: false) {
1470+
throw Error.conflictingOptions(.warningsAsErrors, .suppressWarnings)
1471+
}
1472+
}
1473+
}
1474+
14601475
extension Triple {
14611476
func toolchainType(_ diagnosticsEngine: DiagnosticsEngine) throws -> Toolchain.Type {
14621477
switch os {

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ extension Driver {
118118
try commandLine.appendLast(.profileGenerate, from: &parsedOptions)
119119
try commandLine.appendLast(.profileUse, from: &parsedOptions)
120120
try commandLine.appendLast(.profileCoverageMapping, from: &parsedOptions)
121-
try commandLine.appendLast(.warningsAsErrors, from: &parsedOptions)
121+
try commandLine.appendLast(.warningsAsErrors, .noWarningsAsErrors, from: &parsedOptions)
122122
try commandLine.appendLast(.sanitizeCoverageEQ, from: &parsedOptions)
123123
try commandLine.appendLast(.static, from: &parsedOptions)
124124
try commandLine.appendLast(.swiftVersion, from: &parsedOptions)
@@ -141,6 +141,7 @@ extension Driver {
141141
try commandLine.appendLast(.enableFineGrainedDependencies, from: &parsedOptions)
142142
try commandLine.appendLast(.fineGrainedDependencyIncludeIntrafile, from: &parsedOptions)
143143
try commandLine.appendLast(.enableExperimentalConcisePoundFile, from: &parsedOptions)
144+
try commandLine.appendLast(.printEducationalNotes, from: &parsedOptions)
144145
try commandLine.appendAll(.D, from: &parsedOptions)
145146
try commandLine.appendAll(.sanitizeEQ, from: &parsedOptions)
146147
try commandLine.appendAllArguments(.debugPrefixMap, from: &parsedOptions)

0 commit comments

Comments
 (0)