forked from OSchip/llvm-project
Basic/Diagnostic: Factor out
DiagnosticsEngine::setDiagnosticGroup{ErrorAsFatal,WarningAsError} methods which more accurately model the correct API -- no internal change to the diagnostics engine yet though. - Also, stop honoring -Werror=everything (etc.) as a valid (but oddly behaved) option. llvm-svn: 140747
This commit is contained in:
parent
44e688d46a
commit
c2e5ca6e50
|
@ -452,6 +452,16 @@ public:
|
|||
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; }
|
||||
|
||||
|
|
|
@ -220,6 +220,18 @@ void DiagnosticsEngine::setDiagnosticMapping(diag::kind Diag, diag::Mapping Map,
|
|||
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!");
|
||||
|
||||
|
|
|
@ -75,6 +75,13 @@ void clang::ProcessWarningOptions(DiagnosticsEngine &Diags,
|
|||
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.
|
||||
|
@ -94,15 +101,12 @@ void clang::ProcessWarningOptions(DiagnosticsEngine &Diags,
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -123,15 +127,19 @@ void clang::ProcessWarningOptions(DiagnosticsEngine &Diags,
|
|||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue