30#include "llvm/ADT/StringRef.h"
31#include "llvm/Support/Process.h"
32#include "llvm/Support/VirtualFileSystem.h"
33#include "llvm/Support/raw_ostream.h"
44 Diags.
Report(diag::warn_unknown_diag_option)
46 << (Prefix.str() += std::string(Opt)) << !Suggestion.empty()
47 << (Prefix.str() += std::string(Suggestion));
52 llvm::vfs::FileSystem &VFS,
61 Opts.
showColors(llvm::sys::Process::StandardErrHasColors()));
66 if (Opts.TemplateBacktraceLimit)
68 if (Opts.ConstexprBacktraceLimit)
74 if (Opts.PedanticErrors)
76 else if (Opts.Pedantic)
89 bool SetDiagnostic = (
Report == 0);
93 if (!SetDiagnostic && !ReportDiags)
96 for (
unsigned i = 0, e = Opts.
Warnings.size(); i != e; ++i) {
99 StringRef OrigOpt = Opts.
Warnings[i];
102 if (Opt ==
"format=0")
107 bool isPositive = !Opt.consume_front(
"no-");
116 if (Opt ==
"system-headers") {
124 if (Opt ==
"everything") {
140 if (Opt.starts_with(
"error")) {
142 if (Opt.size() > 5) {
144 Opt.substr(5) !=
"-implicit-function-declaration") {
146 Diags.
Report(diag::warn_unknown_warning_specifier)
147 <<
"-Werror" << (
"-W" + OrigOpt.str());
150 Specifier = Opt.substr(6);
153 if (Specifier.empty()) {
162 }
else if (DiagIDs->getDiagnosticsInGroup(Flavor, Specifier, _Diags)) {
169 if (Opt.starts_with(
"fatal-errors")) {
171 if (Opt.size() != 12) {
172 if ((Opt[12] !=
'=' && Opt[12] !=
'-') || Opt.size() == 13) {
174 Diags.
Report(diag::warn_unknown_warning_specifier)
175 <<
"-Wfatal-errors" << (
"-W" + OrigOpt.str());
178 Specifier = Opt.substr(13);
181 if (Specifier.empty()) {
190 }
else if (DiagIDs->getDiagnosticsInGroup(Flavor, Specifier, _Diags)) {
197 if (DiagIDs->getDiagnosticsInGroup(Flavor, Opt, _Diags))
205 for (StringRef Opt : Opts.
Remarks) {
210 bool IsPositive = !Opt.consume_front(
"no-");
218 if (Opt ==
"everything") {
225 if (DiagIDs->getDiagnosticsInGroup(Flavor, Opt, _Diags))
240 if (
auto FileContents =
243 }
else if (ReportDiags) {
244 Diags.
Report(diag::err_drv_no_such_file)
Includes all the separate Diagnostic headers & some related helpers.
Defines the Diagnostic-related interfaces.
Defines the Diagnostic IDs-related interfaces.
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.
bool showColors(bool StreamHasColors) const
Resolve the color mode against a stream's capability.
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
Flavor
Flavors of diagnostics we can emit.
@ WarningOrError
A diagnostic that indicates a problem or potential problem.
@ Remark
A diagnostic that indicates normal progress through compilation.
Severity
Enum values that allow the client to map NOTEs, WARNINGs, and EXTENSIONs to either Ignore (nothing),...
@ Warning
Present this diagnostic as a warning.
@ Error
Present this diagnostic as an error.
@ Remark
Present this diagnostic as a remark.
@ Ignored
Do not present this diagnostic, ignore it.
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...