[PATCH] D26418: [clang-tidy] Add '-suppress-checks-filter' option to suppress diagnostics from certain files

Nikita Kakuev via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 8 23:17:02 PST 2016


nkakuev added a comment.

In https://reviews.llvm.org/D26418#590170, @alexfh wrote:

> I also don't understand the use case for turning off only some checks for third-party headers. Either you care about third-party stuff or not, why only switch off certain checks?


The use case is ignoring false positives that originate from third-party headers. Because even if you don't care about third-party stuff, you can't suppress all diagnostics from it. Here's an example:

  // header.h
  void TriggerWarning(const int& In, int& Out) {
    if (In > 123)
      Out = 123;
  }



  // source.cpp
  #include "header.h"
  void MaybeInitialize(int &Out) {
    int In;
    TriggerWarning(In, Out);
  }

The warning is caused by a third-party code, but header filter won't help you to suppress it since it now relates to your sources.

But let's say this warning is a false-positive. What can you do to suppress it? You can turn off a faulty check, but you need to turn it off for //your// code.

With '-suppress-checks-filter' you can turn it off for third-party headers only, without sabotaging your own sources.


https://reviews.llvm.org/D26418





More information about the cfe-commits mailing list