return Diags->setDiagnosticGroupMapping(Group, Map, Loc, *this);
}
+ /// \brief Set the warning-as-error flag for the given diagnostic group.
+ ///
+ /// \returns True if the given group is unknown, false otherwise.
+ bool setDiagnosticGroupWarningAsError(StringRef Group, bool Enabled);
+
+ /// \brief Set the error-as-fatal flag for the given diagnostic group.
+ ///
+ /// \returns True if the given group is unknown, false otherwise.
+ bool setDiagnosticGroupErrorAsFatal(StringRef Group, bool Enabled);
+
bool hasErrorOccurred() const { return ErrorOccurred; }
bool hasFatalErrorOccurred() const { return FatalErrorOccurred; }
FullSourceLoc(Loc, *SourceMgr)));
}
+bool DiagnosticsEngine::setDiagnosticGroupWarningAsError(StringRef Group,
+ bool Enabled) {
+ diag::Mapping Map = Enabled ? diag::MAP_ERROR : diag::MAP_WARNING_NO_WERROR;
+ return setDiagnosticGroupMapping(Group, Map);
+}
+
+bool DiagnosticsEngine::setDiagnosticGroupErrorAsFatal(StringRef Group,
+ bool Enabled) {
+ diag::Mapping Map = Enabled ? diag::MAP_FATAL : diag::MAP_ERROR_NO_WFATAL;
+ return setDiagnosticGroupMapping(Group, Map);
+}
+
void DiagnosticsEngine::Report(const StoredDiagnostic &storedDiag) {
assert(CurDiagID == ~0U && "Multiple diagnostics in flight at once!");
Diags.setSuppressSystemWarnings(!isPositive);
continue;
}
+
+ // -Weverything is a special case as well. It implicitly enables all
+ // warnings, including ones not explicitly in a warning group.
+ if (Opt == "everything") {
+ Diags.setEnableAllWarnings(true);
+ continue;
+ }
// -Werror/-Wno-error is a special case, not controlled by the option table.
// It also has the "specifier" form of -Werror=foo and -Werror-foo.
continue;
}
- // -Werror=foo maps foo to Error, -Wno-error=foo maps it to Warning.
- Mapping = isPositive ? diag::MAP_ERROR : diag::MAP_WARNING_NO_WERROR;
- Opt = Specifier;
- }
-
- // -Weverything is a special case as well. It implicitly enables all
- // warnings, including ones not explicitly in a warning group.
- if (Opt == "everything") {
- Diags.setEnableAllWarnings(true);
+ // Set the warning as error flag for this specifier.
+ if (Diags.setDiagnosticGroupWarningAsError(Specifier, isPositive)) {
+ Diags.Report(isPositive ? diag::warn_unknown_warning_option :
+ diag::warn_unknown_negative_warning_option)
+ << ("-W" + Opt.str());
+ }
continue;
}
continue;
}
- // -Wfatal-errors=foo maps foo to Fatal, -Wno-fatal-errors=foo
- // maps it to Error.
- Mapping = isPositive ? diag::MAP_FATAL : diag::MAP_ERROR_NO_WFATAL;
- Opt = Specifier;
+ // Set the error as fatal flag for this specifier.
+ if (Diags.setDiagnosticGroupErrorAsFatal(Specifier, isPositive)) {
+ Diags.Report(isPositive ? diag::warn_unknown_warning_option :
+ diag::warn_unknown_negative_warning_option)
+ << ("-W" + Opt.str());
+ }
+ continue;
}
- if (Diags.setDiagnosticGroupMapping(Opt, Mapping))
+ if (Diags.setDiagnosticGroupMapping(Opt, Mapping)) {
Diags.Report(isPositive ? diag::warn_unknown_warning_option :
diag::warn_unknown_negative_warning_option)
<< ("-W" + Opt.str());
+ }
}
}