29#include "llvm/ADT/StringRef.h"
30#include "llvm/Support/VirtualFileSystem.h"
40 Diags.
Report(diag::warn_unknown_diag_option)
41 << (Flavor == diag::Flavor::WarningOrError ? 0 : 1)
42 << (Prefix.str() += std::string(Opt)) << !Suggestion.empty()
43 << (Prefix.str() += std::string(Suggestion));
48 llvm::vfs::FileSystem &VFS,
61 if (Opts.TemplateBacktraceLimit)
63 if (Opts.ConstexprBacktraceLimit)
69 if (Opts.PedanticErrors)
71 else if (Opts.Pedantic)
77 if (
auto FileContents =
80 }
else if (ReportDiags) {
81 Diags.
Report(diag::err_drv_no_such_file)
94 bool SetDiagnostic = (
Report == 0);
98 if (!SetDiagnostic && !ReportDiags)
101 for (
unsigned i = 0, e = Opts.
Warnings.size(); i != e; ++i) {
102 const auto Flavor = diag::Flavor::WarningOrError;
104 StringRef OrigOpt = Opts.
Warnings[i];
107 if (Opt ==
"format=0")
112 bool isPositive = !Opt.consume_front(
"no-");
117 isPositive ? diag::Severity::Warning : diag::Severity::Ignored;
121 if (Opt ==
"system-headers") {
129 if (Opt ==
"everything") {
145 if (Opt.starts_with(
"error")) {
147 if (Opt.size() > 5) {
149 Opt.substr(5) !=
"-implicit-function-declaration") {
151 Diags.
Report(diag::warn_unknown_warning_specifier)
152 <<
"-Werror" << (
"-W" + OrigOpt.str());
167 }
else if (DiagIDs->getDiagnosticsInGroup(Flavor,
Specifier, _Diags)) {
174 if (Opt.starts_with(
"fatal-errors")) {
176 if (Opt.size() != 12) {
177 if ((Opt[12] !=
'=' && Opt[12] !=
'-') || Opt.size() == 13) {
179 Diags.
Report(diag::warn_unknown_warning_specifier)
180 <<
"-Wfatal-errors" << (
"-W" + OrigOpt.str());
195 }
else if (DiagIDs->getDiagnosticsInGroup(Flavor,
Specifier, _Diags)) {
202 if (DiagIDs->getDiagnosticsInGroup(Flavor, Opt, _Diags))
210 for (StringRef Opt : Opts.
Remarks) {
211 const auto Flavor = diag::Flavor::Remark;
215 bool IsPositive = !Opt.consume_front(
"no-");
217 auto Severity = IsPositive ? diag::Severity::Remark
218 : diag::Severity::Ignored;
223 if (Opt ==
"everything") {
230 if (DiagIDs->getDiagnosticsInGroup(Flavor, Opt, _Diags))
235 IsPositive ? diag::Severity::Remark
236 : diag::Severity::Ignored);
Includes all the separate Diagnostic headers & some related helpers.
Defines the Diagnostic-related interfaces.
Defines the Diagnostic IDs-related interfaces.
const NestedNameSpecifier * Specifier
static void EmitUnknownDiagWarning(DiagnosticsEngine &Diags, diag::Flavor Flavor, StringRef Prefix, StringRef Opt)
static StringRef getNearestOption(diag::Flavor Flavor, StringRef Group)
Get the diagnostic option with the closest edit distance to the given group name.
Options for controlling the compiler diagnostics engine.
std::string DiagnosticSuppressionMappingsFile
Path for the file that defines diagnostic suppression mappings.
std::vector< std::string > Remarks
The list of -R... options used to alter the diagnostic mappings, with the prefixes removed.
std::vector< std::string > Warnings
The list of -W... options used to alter the diagnostic mappings, with the prefixes removed.
Concrete class used by the front-end to report problems and issues.
void setErrorsAsFatal(bool Val)
When set to true, any error reported is made a fatal error.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
void setDiagSuppressionMapping(llvm::MemoryBuffer &Input)
Diagnostic suppression mappings can be used to suppress specific diagnostics in specific files.
void setPrintTemplateTree(bool Val)
Set tree printing, to outputting the template difference in a tree format.
void setSuppressSystemWarnings(bool Val)
When set to true mask warnings that come from system headers.
void setSeverityForAll(diag::Flavor Flavor, diag::Severity Map, SourceLocation Loc=SourceLocation())
Add the specified mapping to all diagnostics of the specified flavor.
void setIgnoreAllWarnings(bool Val)
When set to true, any unmapped warnings are ignored.
void setExtensionHandlingBehavior(diag::Severity H)
Controls whether otherwise-unmapped extension diagnostics are mapped onto ignore/warning/error.
void setTemplateBacktraceLimit(unsigned Limit)
Specify the maximum number of template instantiation notes to emit along with a given diagnostic.
void setErrorLimit(unsigned Limit)
Specify a limit for the number of errors we should emit before giving up.
void setWarningsAsErrors(bool Val)
When set to true, any warnings reported are issued as errors.
void setShowOverloads(OverloadsShown Val)
Specify which overload candidates to show when overload resolution fails.
void setEnableAllWarnings(bool Val)
When set to true, any unmapped ignored warnings are no longer ignored.
void setConstexprBacktraceLimit(unsigned Limit)
Specify the maximum number of constexpr evaluation notes to emit along with a given diagnostic.
bool setDiagnosticGroupErrorAsFatal(StringRef Group, bool Enabled)
Set the error-as-fatal flag for the given diagnostic group.
void setShowColors(bool Val)
Set color printing, so the type diffing will inject color markers into the output.
bool setDiagnosticGroupWarningAsError(StringRef Group, bool Enabled)
Set the warning-as-error flag for the given diagnostic group.
bool setSeverityForGroup(diag::Flavor Flavor, StringRef Group, diag::Severity Map, SourceLocation Loc=SourceLocation())
Change an entire diagnostic group (e.g.
void setElideType(bool Val)
Set type eliding, to skip outputting same types occurring in template types.
const IntrusiveRefCntPtr< DiagnosticIDs > & getDiagnosticIDs() const
Severity
Enum values that allow the client to map NOTEs, WARNINGs, and EXTENSIONs to either Ignore (nothing),...
Flavor
Flavors of diagnostics we can emit.
The JSON file list parser is used to communicate input to InstallAPI.
void ProcessWarningOptions(DiagnosticsEngine &Diags, const DiagnosticOptions &Opts, llvm::vfs::FileSystem &VFS, bool ReportDiags=true)
ProcessWarningOptions - Initialize the diagnostic client and process the warning options specified on...