[clang] [clang-tools-extra] [llvm] [clang] Introduce diagnostics suppression mappings (PR #112517)

Boaz Brickner via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 28 06:57:10 PDT 2024


================
@@ -946,6 +953,24 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
     return (Level)Diags->getDiagnosticLevel(DiagID, Loc, *this);
   }
 
+  /// Diagnostic suppression mappings can be used to ignore diagnostics based on
+  /// the file they occur in. Mapping file is expected to be a special case list
+  /// with sections denoting diagnostic groups and `src` entries for globs to
+  /// suppress. `emit` category can be used to disable suppression. Longest glob
+  /// that matches a filepath takes precendence. For example:
+  ///   [unused]
+  ///   src:*clang/*
+  ///   src:*clang/foo/*=emit
+  ///   src:*clang/foo/bar/*
+  ///
+  /// Such a mappings file suppress all diagnostics produced by -Wunused in all
+  /// sources under `clang/` directory apart from `clang/foo/`. Diagnostics
----------------
bricknerb wrote:

Would "*clang" catch "xclang" or does it assume "clang" must be a full path part?
Also, it would catch all clang directories, and not necessarily "the" clang/ directory.
It might be better to make this more explicit and not try to write it in a way that tries to catch everything.

https://github.com/llvm/llvm-project/pull/112517


More information about the cfe-commits mailing list