[PATCH] D121175: [clang] Add -Wstart-no-unknown-warning-option/-Wend-no-unknown-warning-option.
Daniel Thornburgh via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 7 16:53:44 PST 2022
mysterymath created this revision.
mysterymath added reviewers: phosek, MaskRay.
Herald added a subscriber: dexonsmith.
Herald added a project: All.
mysterymath requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
These options allow guarding a region of warning options to allow
specify unknown options, akin to https://reviews.llvm.org/D116503. This
allows supressing new warnings in a way that allows compilation with
older versions of clang, without globally setting
-Wno-unknown-warning-option.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D121175
Files:
clang/docs/ClangCommandLineReference.rst
clang/lib/Basic/Warnings.cpp
clang/test/Frontend/warning-options.cpp
Index: clang/test/Frontend/warning-options.cpp
===================================================================
--- clang/test/Frontend/warning-options.cpp
+++ clang/test/Frontend/warning-options.cpp
@@ -1,8 +1,11 @@
// RUN: %clang_cc1 -Wmonkey -Wno-monkey -Wno-unused-command-line-arguments \
-// RUN: -Wno-unused-command-line-argument -Wmodule-build -Werror-vla -Rmodule-built %s 2>&1 | FileCheck %s
+// RUN: -Wno-unused-command-line-argument -Wmodule-build -Werror-vla -Rmodule-built \
+// RUN: -Wstart-no-unknown-warning-option -Wfoobarbaz -Wend-no-unknown-warning-option -Wplughxyzzy \
+// RUN: %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'; did you mean '-Wno-unused-command-line-argument'?
// CHECK: unknown warning option '-Wmodule-build'; did you mean '-Wmodule-conflict'?
// CHECK-NEXT: unknown -Werror warning specifier: '-Werror-vla'
+// CHECK: unknown warning option '-Wplughxyzzy'
// CHECK: unknown remark option '-Rmodule-built'; did you mean '-Rmodule-build'?
Index: clang/lib/Basic/Warnings.cpp
===================================================================
--- clang/lib/Basic/Warnings.cpp
+++ clang/lib/Basic/Warnings.cpp
@@ -189,6 +189,20 @@
continue;
}
+ if (Opt == "start-no-unknown-warning-option" ||
+ Opt == "end-no-unknown-warning-option") {
+ // These flags should explicitly take effect during the report phase,
+ // not the set-diagnostic phase, since they guard the processing of
+ // specific arguments.
+ if (Report) {
+ Diags.setSeverityForGroup(Flavor, "unknown-warning-option",
+ Opt == "start-no-unknown-warning-option"
+ ? diag::Severity::Ignored
+ : diag::Severity::Warning);
+ }
+ continue;
+ }
+
if (Report) {
if (DiagIDs->getDiagnosticsInGroup(Flavor, Opt, _Diags))
EmitUnknownDiagWarning(Diags, Flavor, isPositive ? "-W" : "-Wno-",
Index: clang/docs/ClangCommandLineReference.rst
===================================================================
--- clang/docs/ClangCommandLineReference.rst
+++ clang/docs/ClangCommandLineReference.rst
@@ -1367,6 +1367,10 @@
.. option:: -Wdeprecated, -Wno-deprecated
+Within the given flag region, prevent warning about unknown warning enable/disable flags.
+
+.. option:: -Wstart-no-unknown-warning-option, -Wend-no-unknown-warning-option
+
Enable warnings for deprecated constructs and define \_\_DEPRECATED
.. option:: -Wframe-larger-than=<arg>, -Wframe-larger-than
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121175.413659.patch
Type: text/x-patch
Size: 2761 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220308/a9360d7b/attachment-0001.bin>
More information about the cfe-commits
mailing list