Skip to content

Support new diagnostic options: -no-warnings-as-errors and -print-educational-notes #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Sources/SwiftDriver/Driver/Driver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public struct Driver {
case relativeFrontendPath(String)
case subcommandPassedToDriver
case integratedReplRemoved
case conflictingOptions(Option, Option)

public var description: String {
switch self {
Expand All @@ -65,6 +66,8 @@ public struct Driver {
return "subcommand passed to driver"
case .integratedReplRemoved:
return "Compiler-internal integrated REPL has been removed; use the LLDB-enhanced REPL instead."
case .conflictingOptions(let one, let two):
return "conflicting options '\(one.spelling)' and '\(two.spelling)'"
}
}
}
Expand Down Expand Up @@ -307,6 +310,8 @@ public struct Driver {
self.numThreads = Self.determineNumThreads(&parsedOptions, compilerMode: compilerMode, diagnosticsEngine: diagnosticEngine)
self.numParallelJobs = Self.determineNumParallelJobs(&parsedOptions, diagnosticsEngine: diagnosticEngine, env: env)

try Self.validateWarningControlArgs(&parsedOptions)

// Compute debug information output.
(self.debugInfoLevel, self.debugInfoFormat, shouldVerifyDebugInfo: self.shouldVerifyDebugInfo) =
Self.computeDebugInfo(&parsedOptions, diagnosticsEngine: diagnosticEngine)
Expand Down Expand Up @@ -1457,6 +1462,16 @@ extension Diagnostic.Message {
}
}

// MARK: Miscellaneous Argument Validation
extension Driver {
static func validateWarningControlArgs(_ parsedOptions: inout ParsedOptions) throws {
if parsedOptions.hasArgument(.suppressWarnings) &&
parsedOptions.hasFlag(positive: .warningsAsErrors, negative: .noWarningsAsErrors, default: false) {
throw Error.conflictingOptions(.warningsAsErrors, .suppressWarnings)
}
}
}

extension Triple {
func toolchainType(_ diagnosticsEngine: DiagnosticsEngine) throws -> Toolchain.Type {
switch os {
Expand Down
3 changes: 2 additions & 1 deletion Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ extension Driver {
try commandLine.appendLast(.profileGenerate, from: &parsedOptions)
try commandLine.appendLast(.profileUse, from: &parsedOptions)
try commandLine.appendLast(.profileCoverageMapping, from: &parsedOptions)
try commandLine.appendLast(.warningsAsErrors, from: &parsedOptions)
try commandLine.appendLast(.warningsAsErrors, .noWarningsAsErrors, from: &parsedOptions)
try commandLine.appendLast(.sanitizeCoverageEQ, from: &parsedOptions)
try commandLine.appendLast(.static, from: &parsedOptions)
try commandLine.appendLast(.swiftVersion, from: &parsedOptions)
Expand All @@ -141,6 +141,7 @@ extension Driver {
try commandLine.appendLast(.enableFineGrainedDependencies, from: &parsedOptions)
try commandLine.appendLast(.fineGrainedDependencyIncludeIntrafile, from: &parsedOptions)
try commandLine.appendLast(.enableExperimentalConcisePoundFile, from: &parsedOptions)
try commandLine.appendLast(.printEducationalNotes, from: &parsedOptions)
try commandLine.appendAll(.D, from: &parsedOptions)
try commandLine.appendAll(.sanitizeEQ, from: &parsedOptions)
try commandLine.appendAllArguments(.debugPrefixMap, from: &parsedOptions)
Expand Down
Loading