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.

  ANALYZER_OPTION(
      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:

  Opts.CheckerSilenceVector.clear();
  for (const Arg *A : Args.filtered(OPT_analyzer_silence_checker)) {
    A->claim();
    // 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)
      Opts.CheckerSilenceVector.emplace_back(checker);
  }

We should do this:

  assert(Opts.CheckerSilenceVector.empty());
  llvm::SmallVector<StringRef, 16> CheckerList;
  Opts.CheckersAndPackagesToSilence.split(CheckerList, ',');
  for (StringRef Checker : CheckerList)
      Opts.CheckerSilenceVector.emplace_back(checker);

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


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66042/new/

https://reviews.llvm.org/D66042



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to