Skip to content
Open
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
14 changes: 14 additions & 0 deletions include/swift/AST/DiagnosticEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,9 @@ namespace swift {

/// Don't emit any warnings
bool suppressWarnings = false;

/// Don't emit any notes
bool suppressNotes = false;

/// Don't emit any remarks
bool suppressRemarks = false;
Expand Down Expand Up @@ -663,6 +666,10 @@ namespace swift {
void setSuppressWarnings(bool val) { suppressWarnings = val; }
bool getSuppressWarnings() const { return suppressWarnings; }

/// Whether to skip emitting notes
void setSuppressNotes(bool val) { suppressNotes = val; }
bool getSuppressNotes() const { return suppressNotes; }

/// Whether to skip emitting remarks
void setSuppressRemarks(bool val) { suppressRemarks = val; }
bool getSuppressRemarks() const { return suppressRemarks; }
Expand Down Expand Up @@ -708,6 +715,7 @@ namespace swift {
void swap(DiagnosticState &other) {
std::swap(showDiagnosticsAfterFatalError, other.showDiagnosticsAfterFatalError);
std::swap(suppressWarnings, other.suppressWarnings);
std::swap(suppressNotes, other.suppressNotes);
std::swap(suppressRemarks, other.suppressRemarks);
std::swap(warningsAsErrors, other.warningsAsErrors);
std::swap(fatalErrorOccurred, other.fatalErrorOccurred);
Expand Down Expand Up @@ -904,6 +912,12 @@ namespace swift {
return state.getSuppressWarnings();
}

/// Whether to skip emitting notes
void setSuppressNotes(bool val) { state.setSuppressNotes(val); }
bool getSuppressNotes() const {
return state.getSuppressNotes();
}

/// Whether to skip emitting remarks
void setSuppressRemarks(bool val) { state.setSuppressRemarks(val); }
bool getSuppressRemarks() const {
Expand Down
3 changes: 3 additions & 0 deletions include/swift/Basic/DiagnosticOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class DiagnosticOptions {
/// Suppress all warnings
bool SuppressWarnings = false;

/// Suppress all notes
bool SuppressNotes = false;

/// Suppress all remarks
bool SuppressRemarks = false;

Expand Down
2 changes: 1 addition & 1 deletion include/swift/Frontend/ModuleInterfaceLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ struct InterfaceSubContextDelegateImpl : InterfaceSubContextDelegate {
const LangOptions &LangOpts,
const ClangImporterOptions &clangImporterOpts,
const CASOptions &casOpts,
bool suppressRemarks);
bool suppressNotes, bool suppressRemarks);
bool extractSwiftInterfaceVersionAndArgs(CompilerInvocation &subInvocation,
DiagnosticEngine &subInstanceDiags,
SwiftInterfaceInfo &interfaceInfo,
Expand Down
4 changes: 4 additions & 0 deletions include/swift/Option/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,10 @@ def Wwarning : Separate<["-"], "Wwarning">,
MetaVarName<"<diagnostic_group>">,
HelpText<"Treat this warning group as warning">;

def suppress_notes : Flag<["-"], "suppress-notes">,
Flags<[FrontendOption]>,
HelpText<"Suppress all notes">;

def suppress_remarks : Flag<["-"], "suppress-remarks">,
Flags<[FrontendOption]>,
HelpText<"Suppress all remarks">;
Expand Down
5 changes: 5 additions & 0 deletions lib/AST/DiagnosticEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,11 @@ DiagnosticState::determineBehavior(const Diagnostic &diag) const {
if (suppressWarnings)
lvl = DiagnosticBehavior::Ignore;
}

if (lvl == DiagnosticBehavior::Note) {
if (suppressNotes)
lvl = DiagnosticBehavior::Ignore;
}

if (lvl == DiagnosticBehavior::Remark) {
if (suppressRemarks)
Expand Down
4 changes: 4 additions & 0 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2652,6 +2652,7 @@ static bool ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
}

Opts.SuppressWarnings |= Args.hasArg(OPT_suppress_warnings);
Opts.SuppressNotes |= Args.hasArg(OPT_suppress_notes);
Opts.SuppressRemarks |= Args.hasArg(OPT_suppress_remarks);
for (const Arg *arg : Args.filtered(OPT_warning_treating_Group)) {
Opts.WarningsAsErrorsRules.push_back([&] {
Expand Down Expand Up @@ -2732,6 +2733,9 @@ static void configureDiagnosticEngine(
if (Options.SuppressWarnings) {
Diagnostics.setSuppressWarnings(true);
}
if (Options.SuppressNotes) {
Diagnostics.setSuppressNotes(true);
}
if (Options.SuppressRemarks) {
Diagnostics.setSuppressRemarks(true);
}
Expand Down
9 changes: 8 additions & 1 deletion lib/Frontend/ModuleInterfaceLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1663,7 +1663,7 @@ void InterfaceSubContextDelegateImpl::inheritOptionsForBuildingInterface(
FrontendOptions::ActionType requestedAction,
const SearchPathOptions &SearchPathOpts, const LangOptions &LangOpts,
const ClangImporterOptions &clangImporterOpts, const CASOptions &casOpts,
bool suppressRemarks) {
bool suppressNotes, bool suppressRemarks) {
GenericArgs.push_back("-frontend");
// Start with a genericSubInvocation that copies various state from our
// invoking ASTContext.
Expand Down Expand Up @@ -1752,6 +1752,12 @@ void InterfaceSubContextDelegateImpl::inheritOptionsForBuildingInterface(
genericSubInvocation.getDiagnosticOptions().SuppressWarnings = true;
GenericArgs.push_back("-suppress-warnings");

// Inherit the parent invocation's setting on whether to suppress remarks
if (suppressNotes) {
genericSubInvocation.getDiagnosticOptions().SuppressNotes = true;
GenericArgs.push_back("-suppress-notes");
}

// Inherit the parent invocation's setting on whether to suppress remarks
if (suppressRemarks) {
genericSubInvocation.getDiagnosticOptions().SuppressRemarks = true;
Expand Down Expand Up @@ -1863,6 +1869,7 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
genericSubInvocation.setMainExecutablePath(LoaderOpts.mainExecutablePath);
inheritOptionsForBuildingInterface(LoaderOpts.requestedAction, searchPathOpts,
langOpts, clangImporterOpts, casOpts,
Diags->getSuppressNotes(),
Diags->getSuppressRemarks());
// Configure front-end input.
auto &SubFEOpts = genericSubInvocation.getFrontendOptions();
Expand Down