[clang] Introduce support for disabling warnings in system macros
authorCarlos Galvez <carlosgalvezp@gmail.com>
Fri, 7 Jan 2022 18:45:20 +0000 (18:45 +0000)
committerCarlos Galvez <carlosgalvezp@gmail.com>
Wed, 12 Jan 2022 08:18:19 +0000 (08:18 +0000)
commitc4db521cea32fcfb714d1a622e0efce69a564a28
tree446d18a43c9fa56c38737c16058506bd313ca7dc
parent22225cc5e6654eea3f9f1599e6dfc07fc979db62
[clang] Introduce support for disabling warnings in system macros

Often we run into situations where we want to ignore
warnings from system headers, but Clang will still
give warnings about the contents of a macro defined
in a system header used in user-code.

Introduce a ShowInSystemMacro option to be able to
specify which warnings we do want to keep raising
warnings for. The current behavior is kept in this patch
(i.e. warnings from system macros are enabled by default).
The decision as to whether this should be an opt-in or opt-out
feature can be made in a separate patch.

To put the feature to test, replace duplicated code for
Wshadow and Wold-style-cast with the SuppressInSystemMacro tag.
Also disable the warning for C++20 designators, fixing #52944.

Differential Revision: https://reviews.llvm.org/D116833
23 files changed:
clang-tools-extra/clangd/Diagnostics.cpp
clang/include/clang/Basic/Diagnostic.td
clang/include/clang/Basic/DiagnosticAST.h
clang/include/clang/Basic/DiagnosticAnalysis.h
clang/include/clang/Basic/DiagnosticComment.h
clang/include/clang/Basic/DiagnosticCrossTU.h
clang/include/clang/Basic/DiagnosticDriver.h
clang/include/clang/Basic/DiagnosticFrontend.h
clang/include/clang/Basic/DiagnosticIDs.h
clang/include/clang/Basic/DiagnosticLex.h
clang/include/clang/Basic/DiagnosticParse.h
clang/include/clang/Basic/DiagnosticRefactoring.h
clang/include/clang/Basic/DiagnosticSema.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/DiagnosticSerialization.h
clang/lib/Basic/DiagnosticIDs.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCXX/warn-sysheader-macro.cpp
clang/test/TableGen/DiagnosticBase.inc
clang/test/TableGen/deferred-diag.td
clang/tools/diagtool/DiagnosticNames.cpp
clang/utils/TableGen/ClangDiagnosticsEmitter.cpp