[PATCH] D67336: [analyzer][NFC] Introduce SuperChecker<>, a convenient alternative to Checker<> for storing subcheckers
Kristóf Umann via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 8 15:09:08 PDT 2019
Szelethus created this revision.
Szelethus added reviewers: NoQ, xazax.hun, rnkovacs, dcoughlin, Charusso, baloghadamsoftware, dkrupp.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, gamesh411, donat.nagy, mikhail.ramalho, a.sidorin, szepet, whisperity.
Please don't take a shot for each time I write checker, it'd end bad.
The term "super checker" or "modeling checker", and the term "subchecker" always existed conceptually, but they weren't ever formalized. In the last half a year or so, we referred to them as
- Super/modeling checker: A checker that models some C++ code, but doesn't (or, as of now, just //shouldn't//) emit any diagnostics, at least not under its own name.
- Subcheckers: Checkers that are a part of super/modeling checkers, enabling/disabling them (ideally) only toggles whether a diagnostic is emitted from the checker it is a part of. They don't possess a checker object on their own, and are basically glorified checker options.
While checker dependencies were in similar shoes (existed conceptually but not formalized), this change isn't //as// critical, it just removes boilerplate code. When you look at `IteratorChecker`, `SecuritySyntaxChecker` or `RetainCountBase` they all use a similar, some cases faulty implementation to keep track of which subcheckers are enabled and what their name is, so its about time we combined them.
I envision this interface to be used to enforce our currently non-existent specification on the checker system.
In detail:
- Introduce `SuperChecker`:
- It is essentially the same as `Checker`, but requires an enum template argument to keep track of which subcheckers are enabled.
- While previously we defined subcheckers as checkers that don't have a checker object on their own, `SuperChecker` does create a `CheckerBase` object for them, but they still can't have checker callbacks.
- Add `CheckerManager::registerSubChecker` adds a new checker to a `SuperChecker`. It is ensured runtime that the `SuperChecker` was previously registered, and that a subchecker isn't registered multiple times.
- Add thorough test cases for the new interface.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D67336
Files:
clang/include/clang/StaticAnalyzer/Core/Checker.h
clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67336.219280.patch
Type: text/x-patch
Size: 10652 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190908/ba424872/attachment-0001.bin>
More information about the cfe-commits
mailing list