[cfe-commits] r156937 - in /cfe/trunk: include/clang/Basic/DiagnosticFrontendKinds.td lib/Frontend/Warnings.cpp test/Driver/warning-options.cpp
Chad Rosier
mcrosier at apple.com
Wed May 16 12:28:02 PDT 2012
Author: mcrosier
Date: Wed May 16 14:28:02 2012
New Revision: 156937
URL: http://llvm.org/viewvc/llvm-project?rev=156937&view=rev
Log:
Warn about -Wno-foo where foo is an unknown warning option. This is helpful
for subtle misspellings such as -Wno-unused-command-line-arguments instead of
-Wno-unused-command-line-argument.
Also fix the diagnostic messages to properly handle -Wno- options. Previously,
the positive version was always emitted (i.e., -Wfoo was emitted for -Wno-foo).
rdar://11461500
Modified:
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/lib/Frontend/Warnings.cpp
cfe/trunk/test/Driver/warning-options.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=156937&r1=156936&r2=156937&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Wed May 16 14:28:02 2012
@@ -94,13 +94,13 @@
InGroup<DiagGroup<"unknown-warning-option"> >;
def warn_unknown_negative_warning_option : Warning<
"unknown warning option '%0'?">,
- InGroup<DiagGroup<"unknown-warning-option"> >, DefaultIgnore;
+ InGroup<DiagGroup<"unknown-warning-option"> >;
def warn_unknown_warning_option_suggest : Warning<
"unknown warning option '%0'; did you mean '%1'?">,
InGroup<DiagGroup<"unknown-warning-option"> >;
def warn_unknown_negative_warning_option_suggest : Warning<
"unknown warning option '%0'; did you mean '%1'?">,
- InGroup<DiagGroup<"unknown-warning-option"> >, DefaultIgnore;
+ InGroup<DiagGroup<"unknown-warning-option"> >;
def warn_unknown_warning_specifier : Warning<
"unknown %0 warning specifier: '%1'">,
InGroup<DiagGroup<"unknown-warning-option"> >;
Modified: cfe/trunk/lib/Frontend/Warnings.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Warnings.cpp?rev=156937&r1=156936&r2=156937&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/Warnings.cpp (original)
+++ cfe/trunk/lib/Frontend/Warnings.cpp Wed May 16 14:28:02 2012
@@ -83,6 +83,7 @@
bool SetDiagnostic = (Report == 0);
for (unsigned i = 0, e = Opts.Warnings.size(); i != e; ++i) {
StringRef Opt = Opts.Warnings[i];
+ StringRef OrigOpt = Opts.Warnings[i];
// Treat -Wformat=0 as an alias for -Wno-format.
if (Opt == "format=0")
@@ -130,7 +131,7 @@
if ((Opt[5] != '=' && Opt[5] != '-') || Opt.size() == 6) {
if (Report)
Diags.Report(diag::warn_unknown_warning_specifier)
- << "-Werror" << ("-W" + Opt.str());
+ << "-Werror" << ("-W" + OrigOpt.str());
continue;
}
Specifier = Opt.substr(6);
@@ -158,7 +159,7 @@
if ((Opt[12] != '=' && Opt[12] != '-') || Opt.size() == 13) {
if (Report)
Diags.Report(diag::warn_unknown_warning_specifier)
- << "-Wfatal-errors" << ("-W" + Opt.str());
+ << "-Wfatal-errors" << ("-W" + OrigOpt.str());
continue;
}
Specifier = Opt.substr(13);
@@ -182,7 +183,7 @@
if (Report) {
if (DiagIDs->getDiagnosticsInGroup(Opt, _Diags))
- EmitUnknownDiagWarning(Diags, "-W", Opt, isPositive);
+ EmitUnknownDiagWarning(Diags, "-W", OrigOpt, isPositive);
} else {
Diags.setDiagnosticGroupMapping(Opt, Mapping);
}
Modified: cfe/trunk/test/Driver/warning-options.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/warning-options.cpp?rev=156937&r1=156936&r2=156937&view=diff
==============================================================================
--- cfe/trunk/test/Driver/warning-options.cpp (original)
+++ cfe/trunk/test/Driver/warning-options.cpp Wed May 16 14:28:02 2012
@@ -2,3 +2,9 @@
// LARGE_VALUE_COPY_DEFAULT: -Wlarge-by-value-copy=64
// RUN: %clang -### -Wlarge-by-value-copy=128 %s 2>&1 | FileCheck -check-prefix=LARGE_VALUE_COPY_JOINED %s
// LARGE_VALUE_COPY_JOINED: -Wlarge-by-value-copy=128
+
+// RUN: %clang -c -Wmonkey -Wno-monkey -Wno-unused-command-line-arguments \
+// RUN: -Wno-unused-command-line-argument %s 2>&1 | FileCheck %s
+// CHECK: unknown warning option '-Wmonkey'
+// CHECK: unknown warning option '-Wno-monkey'
+// CHECK: unknown warning option '-Wno-unused-command-line-arguments'
More information about the cfe-commits
mailing list