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

Ilya Biryukov via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 17 08:48:47 PDT 2024


================
@@ -70,6 +169,14 @@ void clang::ProcessWarningOptions(DiagnosticsEngine &Diags,
   else
     Diags.setExtensionHandlingBehavior(diag::Severity::Ignored);
 
+  if (!Opts.SuppressionMappingsFile.empty()) {
+    if (auto Buf = VFS.getBufferForFile(Opts.SuppressionMappingsFile)) {
+      parseSuppressionMappings(**Buf, Diags);
----------------
ilya-biryukov wrote:

NIT: maybe make this return suppression mappings rather then setting them?
It would make the function interface more explicit (memory buffer as input, mapping as output) and would allow to move error handling to the client (no need to pass `Diags` as parameter).

NIT2: we could name the type for the lambda that we return (via typedef or through a real struct) to make these changes easier. I feel that right now the fact that the type is anonymous stops us from writing things like `Expected<ParsedMapping>`.



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


More information about the cfe-commits mailing list