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);
|
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 hasErrorOccurred() const { return ErrorOccurred; }
|
||||||
bool hasFatalErrorOccurred() const { return FatalErrorOccurred; }
|
bool hasFatalErrorOccurred() const { return FatalErrorOccurred; }
|
||||||
|
|
||||||
|
|
|
@ -220,6 +220,18 @@ void DiagnosticsEngine::setDiagnosticMapping(diag::kind Diag, diag::Mapping Map,
|
||||||
FullSourceLoc(Loc, *SourceMgr)));
|
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) {
|
void DiagnosticsEngine::Report(const StoredDiagnostic &storedDiag) {
|
||||||
assert(CurDiagID == ~0U && "Multiple diagnostics in flight at once!");
|
assert(CurDiagID == ~0U && "Multiple diagnostics in flight at once!");
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,13 @@ void clang::ProcessWarningOptions(DiagnosticsEngine &Diags,
|
||||||
Diags.setSuppressSystemWarnings(!isPositive);
|
Diags.setSuppressSystemWarnings(!isPositive);
|
||||||
continue;
|
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.
|
// -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.
|
// It also has the "specifier" form of -Werror=foo and -Werror-foo.
|
||||||
|
@ -94,15 +101,12 @@ void clang::ProcessWarningOptions(DiagnosticsEngine &Diags,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -Werror=foo maps foo to Error, -Wno-error=foo maps it to Warning.
|
// Set the warning as error flag for this specifier.
|
||||||
Mapping = isPositive ? diag::MAP_ERROR : diag::MAP_WARNING_NO_WERROR;
|
if (Diags.setDiagnosticGroupWarningAsError(Specifier, isPositive)) {
|
||||||
Opt = Specifier;
|
Diags.Report(isPositive ? diag::warn_unknown_warning_option :
|
||||||
}
|
diag::warn_unknown_negative_warning_option)
|
||||||
|
<< ("-W" + Opt.str());
|
||||||
// -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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,15 +127,19 @@ void clang::ProcessWarningOptions(DiagnosticsEngine &Diags,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -Wfatal-errors=foo maps foo to Fatal, -Wno-fatal-errors=foo
|
// Set the error as fatal flag for this specifier.
|
||||||
// maps it to Error.
|
if (Diags.setDiagnosticGroupErrorAsFatal(Specifier, isPositive)) {
|
||||||
Mapping = isPositive ? diag::MAP_FATAL : diag::MAP_ERROR_NO_WFATAL;
|
Diags.Report(isPositive ? diag::warn_unknown_warning_option :
|
||||||
Opt = Specifier;
|
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 :
|
Diags.Report(isPositive ? diag::warn_unknown_warning_option :
|
||||||
diag::warn_unknown_negative_warning_option)
|
diag::warn_unknown_negative_warning_option)
|
||||||
<< ("-W" + Opt.str());
|
<< ("-W" + Opt.str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue