[all-commits] [llvm/llvm-project] b2de52: [clang-cl] Accept `#pragma warning(disable : N)` f...
Nico Weber via All-commits
all-commits at lists.llvm.org
Wed Sep 29 10:14:39 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: b2de52bec17b67887456ede40ac7c6959ce26d6a
https://github.com/llvm/llvm-project/commit/b2de52bec17b67887456ede40ac7c6959ce26d6a
Author: Nico Weber <thakis at chromium.org>
Date: 2021-09-29 (Wed, 29 Sep 2021)
Changed paths:
A clang/include/clang/Basic/CLWarnings.h
M clang/include/clang/Basic/Diagnostic.h
M clang/include/clang/Basic/DiagnosticCategories.h
M clang/include/clang/Basic/DiagnosticGroups.td
M clang/include/clang/Basic/DiagnosticIDs.h
M clang/include/clang/Basic/DiagnosticSemaKinds.td
M clang/include/clang/Driver/Options.td
A clang/lib/Basic/CLWarnings.cpp
M clang/lib/Basic/CMakeLists.txt
M clang/lib/Basic/Diagnostic.cpp
M clang/lib/Basic/DiagnosticIDs.cpp
M clang/lib/Driver/ToolChains/Clang.cpp
M clang/lib/Lex/Pragma.cpp
M clang/test/Driver/cl-options.c
A clang/test/Sema/pragma-warning.cpp
M clang/tools/diagtool/DiagnosticNames.cpp
M clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
M llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn
Log Message:
-----------
[clang-cl] Accept `#pragma warning(disable : N)` for some N
clang-cl maps /wdNNNN to -Wno-flags for a few warnings that map
cleanly from cl.exe concepts to clang concepts.
This patch adds support for the same numbers to
`#pragma warning(disable : NNNN)`. It also lets
`#pragma warning(push)` and `#pragma warning(pop)` have an effect,
since these are used together with `warning(disable)`.
The optional numeric argument to `warning(push)` is ignored,
as are the other non-`disable` `pragma warning()` arguments.
(Supporting `error` would be easy, but we also don't support
`/we`, and those should probably be added together.)
The motivating example is that a bunch of code (including in LLVM)
uses this idiom to locally disable warnings about calls to deprecated
functions in Windows-only code, and 4996 maps nicely to
-Wno-deprecated-declarations:
#pragma warning(push)
#pragma warning(disable: 4996)
f();
#pragma warning(pop)
Implementation-wise:
- Move `/wd` flag handling from Options.td to actual Driver-level code
- Extract the function mapping cl.exe IDs to warning groups to the
new file clang/lib/Basic/CLWarnings.cpp
- Create a diag::Group enum so that CLWarnings.cpp can refer to
existing groups by ID (and give DllexportExplicitInstantiationDecl
a named group), and add a function to map a diag::Group to the
spelling of it's associated commandline flag
- Call that new function from PragmaWarningHandler
Differential Revision: https://reviews.llvm.org/D110668
More information about the All-commits
mailing list