[PATCH] D49114: [clang-tidy] Add a check for "magic numbers"
Florin Iucha via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 10 03:54:11 PDT 2018
0x8000-0000 added a comment.
In https://reviews.llvm.org/D49114#1156987, @JonasToth wrote:
> I think some of the logic you have in your check code could be done via matchers. That is usually better for performance, because you analyze less code.
I have considered that approach, but had to abandon it because the logic in this check is substractive, not additive: I would not use matchers to find more loci to diagnose, but to exculpate loci found by more general rules.
In other words: I want to report as diagnostic _all_ integer literals, except some, based on the larger construct they are part of.
In my understanding matchers are effective if you need to search for "X followed by Y", "X followed by Z", "X followed by Y". The union of the results is the set I want.
In my case, I am searching for "all of X", "X unless preceded by A", "X unless preceded by B". The "unless preceded by" rules don't compose well, as their union tends to be the whole set "all of X".
rCTE Clang Tools Extra
More information about the cfe-commits