[PATCH] D66042: [analyzer] Analysis: "Disable" core checkers

Kristóf Umann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 13 14:41:29 PDT 2019

Szelethus added a comment.

In D66042#1627842 <https://reviews.llvm.org/D66042#1627842>, @Charusso wrote:

> Any analyzer config flag is equally accessible to anyone as the driver flags as they are both flags. The only difference is the config flags are more code to implement, and a lot more difficult to use. @NoQ, why the hell would we pick another type of flag which makes zero improvement? The goal is to introduce the best possible solution, which is already here.

Well, `-analyzer-checker` and `-analyzer-silence-checker` would be on the same level, while there isn't a consensus on that silencing checkers is desired. Config flags are exactly one layer lower, that much more harder is it to discover. They are *just* a tad bit more uncomfortable to use, but that shouldn't matter inside `scan-build`s implementation, should it?

By the way, are they longer to implement? We gain 5 LOC by deleting the existing flags. Depending on how long you're like to make your description, the config flag, with a newline, would add 3-4 more.

      StringRef, CheckersAndPackagesToSilence, "analyzer-silence-checkers",
      "A comma-separated list of checkers and packages to silence.", "")

The changes you made in `clang/lib/Frontend/CompilerInvocation.cpp` should be moved after the call to `parseAnalyzerConfigs`, and instead of this:

  for (const Arg *A : Args.filtered(OPT_analyzer_silence_checker)) {
    // We can have a list of comma separated checker names, e.g:
    // '-analyzer-checker=cocoa,unix'
    StringRef checkerList = A->getValue();
    SmallVector<StringRef, 16> checkers;
    checkerList.split(checkers, ",");
    for (auto checker : checkers)

We should do this:

  llvm::SmallVector<StringRef, 16> CheckerList;
  Opts.CheckersAndPackagesToSilence.split(CheckerList, ',');
  for (StringRef Checker : CheckerList)

Thats another 5 LOC minus, we actually lost 7! I suspect not even the additional scan-build would make it worse.



More information about the cfe-commits mailing list