Skip to content

Commit 5f140ba

Browse files
committed
Revert "[clang] Introduce diagnostics suppression mappings (#112517)"
This reverts commit 12e3ed8. This reverts commit 41e3919. There are some buildbot breakages in https://lab.llvm.org/buildbot/#/builders/18/builds/6832.
1 parent 39351f8 commit 5f140ba

28 files changed

+33
-641
lines changed

clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ ExpandModularHeadersPPCallbacks::ExpandModularHeadersPPCallbacks(
8181
Diags.setSourceManager(&Sources);
8282
// FIXME: Investigate whatever is there better way to initialize DiagEngine
8383
// or whatever DiagEngine can be shared by multiple preprocessors
84-
ProcessWarningOptions(Diags, Compiler.getDiagnosticOpts(),
85-
Compiler.getVirtualFileSystem());
84+
ProcessWarningOptions(Diags, Compiler.getDiagnosticOpts());
8685

8786
LangOpts.Modules = false;
8887

clang/docs/ReleaseNotes.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -870,9 +870,6 @@ New features
870870
attribute, the compiler can generate warnings about the use of any language features, or calls to
871871
other functions, which may block.
872872

873-
- Introduced ``-warning-suppression-mappings`` flag to control diagnostic
874-
suppressions per file. See `documentation <https://clang.llvm.org/docs/WarningSuppressionMappings.html>_` for details.
875-
876873
Crash and bug fixes
877874
^^^^^^^^^^^^^^^^^^^
878875

clang/docs/UsersManual.rst

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,6 @@ Options to Control Error and Warning Messages
151151
instantiation backtrace for a single warning or error. The default is 10, and
152152
the limit can be disabled with `-ftemplate-backtrace-limit=0`.
153153

154-
.. option:: --warning-suppression-mappings=foo.txt
155-
156-
:ref:`Suppress certain diagnostics for certain files. <warning_suppression_mappings>`
157-
158154
.. _cl_diag_formatting:
159155

160156
Formatting of Diagnostics
@@ -1319,34 +1315,6 @@ with its corresponding `Wno-` option.
13191315
Note that when combined with :option:`-w` (which disables all warnings),
13201316
disabling all warnings wins.
13211317

1322-
.. _warning_suppression_mappings:
1323-
1324-
Controlling Diagnostics via Suppression Mappings
1325-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1326-
1327-
Warning suppression mappings enable users to suppress Clang's diagnostics in a
1328-
per-file granular manner. Enabling enforcement of diagnostics in specific parts
1329-
of the project, even if there are violations in some headers.
1330-
1331-
.. code-block:: console
1332-
1333-
$ cat mappings.txt
1334-
[unused]
1335-
src:foo/*
1336-
1337-
$ clang --warning-suppression-mappings=mapping.txt -Wunused foo/bar.cc
1338-
# This compilation won't emit any unused findings for sources under foo/
1339-
# directory. But it'll still complain for all the other sources, e.g:
1340-
$ cat foo/bar.cc
1341-
#include "dir/include.h" // Clang flags unused declarations here.
1342-
#include "foo/include.h" // but unused warnings under this source is omitted.
1343-
#include "next_to_bar_cc.h" // as are unused warnings from this header file.
1344-
// Further, unused warnings in the remainder of bar.cc are also omitted.
1345-
1346-
1347-
See :doc:`WarningSuppressionMappings` for details about the file format and
1348-
functionality.
1349-
13501318
Controlling Static Analyzer Diagnostics
13511319
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13521320

clang/docs/WarningSuppressionMappings.rst

Lines changed: 0 additions & 97 deletions
This file was deleted.

clang/docs/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Using Clang as a Compiler
2222
ClangCommandLineReference
2323
AttributeReference
2424
DiagnosticsReference
25-
WarningSuppressionMappings
2625
CrossCompilation
2726
ClangStaticAnalyzer
2827
ThreadSafetyAnalysis

clang/include/clang/Basic/Diagnostic.h

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "clang/Basic/Specifiers.h"
2121
#include "llvm/ADT/ArrayRef.h"
2222
#include "llvm/ADT/DenseMap.h"
23-
#include "llvm/ADT/FunctionExtras.h"
2423
#include "llvm/ADT/IntrusiveRefCntPtr.h"
2524
#include "llvm/ADT/SmallVector.h"
2625
#include "llvm/ADT/StringRef.h"
@@ -41,10 +40,6 @@
4140
namespace llvm {
4241
class Error;
4342
class raw_ostream;
44-
class MemoryBuffer;
45-
namespace vfs {
46-
class FileSystem;
47-
} // namespace vfs
4843
} // namespace llvm
4944

5045
namespace clang {
@@ -560,10 +555,6 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
560555
void *ArgToStringCookie = nullptr;
561556
ArgToStringFnTy ArgToStringFn;
562557

563-
/// Whether the diagnostic should be suppressed in FilePath.
564-
llvm::unique_function<bool(diag::kind, llvm::StringRef /*FilePath*/) const>
565-
DiagSuppressionMapping;
566-
567558
public:
568559
explicit DiagnosticsEngine(IntrusiveRefCntPtr<DiagnosticIDs> Diags,
569560
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts,
@@ -955,27 +946,6 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
955946
return (Level)Diags->getDiagnosticLevel(DiagID, Loc, *this);
956947
}
957948

958-
/// Diagnostic suppression mappings can be used to suppress specific
959-
/// diagnostics in specific files.
960-
/// Mapping file is expected to be a special case list with sections denoting
961-
/// diagnostic groups and `src` entries for globs to suppress. `emit` category
962-
/// can be used to disable suppression. Longest glob that matches a filepath
963-
/// takes precedence. For example:
964-
/// [unused]
965-
/// src:clang/*
966-
/// src:clang/foo/*=emit
967-
/// src:clang/foo/bar/*
968-
///
969-
/// Such a mappings file suppress all diagnostics produced by -Wunused in all
970-
/// sources under `clang/` directory apart from `clang/foo/`. Diagnostics
971-
/// under `clang/foo/bar/` will also be suppressed. Note that the FilePath is
972-
/// matched against the globs as-is.
973-
/// These take presumed locations into account, and can still be overriden by
974-
/// clang-diagnostics pragmas.
975-
void setDiagSuppressionMapping(llvm::MemoryBuffer &Input);
976-
bool isSuppressedViaMapping(diag::kind DiagId,
977-
llvm::StringRef FilePath) const;
978-
979949
/// Issue the message to the client.
980950
///
981951
/// This actually returns an instance of DiagnosticBuilder which emits the
@@ -1789,7 +1759,7 @@ const char ToggleHighlight = 127;
17891759
/// warning options specified on the command line.
17901760
void ProcessWarningOptions(DiagnosticsEngine &Diags,
17911761
const DiagnosticOptions &Opts,
1792-
llvm::vfs::FileSystem &VFS, bool ReportDiags = true);
1762+
bool ReportDiags = true);
17931763
void EscapeStringForDiagnostic(StringRef Str, SmallVectorImpl<char> &OutStr);
17941764
} // namespace clang
17951765

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,4 @@ def err_drv_triple_version_invalid : Error<
834834

835835
def warn_missing_include_dirs : Warning<
836836
"no such include directory: '%0'">, InGroup<MissingIncludeDirs>, DefaultIgnore;
837-
838-
def err_drv_malformed_warning_suppression_mapping : Error<
839-
"failed to process suppression mapping file '%0': %1">;
840837
}

clang/include/clang/Basic/DiagnosticOptions.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,6 @@ class DiagnosticOptions : public RefCountedBase<DiagnosticOptions>{
108108
/// The file to serialize diagnostics to (non-appending).
109109
std::string DiagnosticSerializationFile;
110110

111-
/// Path for the file that defines diagnostic suppression mappings.
112-
std::string DiagnosticSuppressionMappingsFile;
113-
114111
/// The list of -W... options used to alter the diagnostic mappings, with the
115112
/// prefixes removed.
116113
std::vector<std::string> Warnings;

clang/include/clang/Driver/Options.td

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9019,8 +9019,3 @@ def wasm_opt : Flag<["--"], "wasm-opt">,
90199019
Group<m_Group>,
90209020
HelpText<"Enable the wasm-opt optimizer (default)">,
90219021
MarshallingInfoNegativeFlag<LangOpts<"NoWasmOpt">>;
9022-
9023-
def warning_suppression_mappings_EQ : Joined<["--"],
9024-
"warning-suppression-mappings=">, Group<Diag_Group>,
9025-
HelpText<"File containing diagnostic suppresion mappings. See user manual "
9026-
"for file format.">, Visibility<[ClangOption, CC1Option]>;

clang/include/clang/Frontend/CompilerInstance.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "llvm/ADT/StringRef.h"
2525
#include "llvm/Support/BuryPointer.h"
2626
#include "llvm/Support/FileSystem.h"
27-
#include "llvm/Support/VirtualFileSystem.h"
2827
#include <cassert>
2928
#include <list>
3029
#include <memory>
@@ -702,10 +701,11 @@ class CompilerInstance : public ModuleLoader {
702701
/// used by some diagnostics printers (for logging purposes only).
703702
///
704703
/// \return The new object on success, or null on failure.
705-
static IntrusiveRefCntPtr<DiagnosticsEngine> createDiagnostics(
706-
DiagnosticOptions *Opts, DiagnosticConsumer *Client = nullptr,
707-
bool ShouldOwnClient = true, const CodeGenOptions *CodeGenOpts = nullptr,
708-
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr);
704+
static IntrusiveRefCntPtr<DiagnosticsEngine>
705+
createDiagnostics(DiagnosticOptions *Opts,
706+
DiagnosticConsumer *Client = nullptr,
707+
bool ShouldOwnClient = true,
708+
const CodeGenOptions *CodeGenOpts = nullptr);
709709

710710
/// Create the file manager and replace any existing one with it.
711711
///

0 commit comments

Comments
 (0)