[PATCH] D98710: [clang-tidy] New feature --skip-headers, part 1, setTraversalScope

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 21 02:57:10 PDT 2021


sammccall added a comment.

Please before sending any more patches, let's resolve the design questions here (or via mail).

It's clear that it's possible to write a clang-tidy check whose behavior on the main file cannot be preserved without traversing the whole AST.
Silly example: the main file should have a constant like `int TotalNumberOfVarDeclsInThisTranslationUnit = 61523;`, warn if it's missing or incorrect.

Possibilities for dealing with this include:

1. traversing the whole AST
2. traversing a partial AST, and accepting some divergence in behavior
3. allowing each check to customize the strategy for subsetting the AST

So far we've been discussing #2, and hoping the divergences are small/acceptable. Are you saying that unless the divergence is zero, this feature is no use to you? And at a high level, what's your idea to address this?

Compared to the gold standard of traversing the whole AST, we can go wrong either by adding warnings we don't want (false positives), or missing warnings we want (false negatives). False positives are really bad for clang-tidy and I think we can't allow these to be common in practice. However false negatives with certain checks (e.g. the forward-declaration-namespace check) seem like an acceptable functionality vs performance tradeoff that's more than offset by the ability to run clang-tidy in more contexts.


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

https://reviews.llvm.org/D98710



More information about the cfe-commits mailing list