-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[analyzer] Prettify checker registration and unittest code #147797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
fc638a1
1e29385
43a3430
4c5c619
0709492
5ea4670
073f056
211794e
7023b59
514b336
0523e08
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -38,29 +38,29 @@ | |||||||
| // function clang_registerCheckers. For example: | ||||||||
| // | ||||||||
| // extern "C" | ||||||||
| // void clang_registerCheckers (CheckerRegistry ®istry) { | ||||||||
| // registry.addChecker<MainCallChecker>("example.MainCallChecker", | ||||||||
| // "Disallows calls to functions called main"); | ||||||||
| // void clang_registerCheckers(CheckerRegistry &Registry) { | ||||||||
| // Registry.addChecker<MainCallChecker>( | ||||||||
| // "example.MainCallChecker", | ||||||||
| // "Disallows calls to functions called main"); | ||||||||
| // } | ||||||||
| // | ||||||||
| // The first method argument is the full name of the checker, including its | ||||||||
| // enclosing package. By convention, the registered name of a checker is the | ||||||||
| // name of the associated class (the template argument). | ||||||||
| // The second method argument is a short human-readable description of the | ||||||||
| // checker. | ||||||||
| // The first argument of this templated method is the full name of the checker | ||||||||
| // (including its package), while the second argument is a short description | ||||||||
| // that is printed by `-analyzer-checker-help`. | ||||||||
| // | ||||||||
| // The clang_registerCheckers function may add any number of checkers to the | ||||||||
| // registry. If any checkers require additional initialization, use the three- | ||||||||
| // argument form of CheckerRegistry::addChecker. | ||||||||
| // A plugin may register several separate checkers by calling `addChecker()` | ||||||||
| // multiple times. If a checker requires custom registration functions (e.g. | ||||||||
| // checker option handling) use the non-templated variant of `addChecker` that | ||||||||
| // takes two callback functions as the first two parameters. | ||||||||
| // | ||||||||
| // To load a checker plugin, specify the full path to the dynamic library as | ||||||||
| // the argument to the -load option in the cc1 frontend. You can then enable | ||||||||
| // your custom checker using the -analyzer-checker: | ||||||||
| // | ||||||||
| // clang -cc1 -load </path/to/plugin.dylib> -analyze | ||||||||
| // -analyzer-checker=<example.MainCallChecker> | ||||||||
| // clang -cc1 -load /path/to/plugin.dylib -analyze | ||||||||
| // -analyzer-checker=example.MainCallChecker | ||||||||
| // | ||||||||
| // For a complete working example, see examples/analyzer-plugin. | ||||||||
| // For complete examples, see clang/lib/Analysis/plugins/SampleAnalyzer | ||||||||
|
|
||||||||
| #ifndef CLANG_ANALYZER_API_VERSION_STRING | ||||||||
| // FIXME: The Clang version string is not particularly granular; | ||||||||
|
|
@@ -112,26 +112,35 @@ class CheckerRegistry { | |||||||
| return true; | ||||||||
| } | ||||||||
|
|
||||||||
| public: | ||||||||
| /// Adds a checker to the registry. Use this non-templated overload when your | ||||||||
| /// checker requires custom initialization. | ||||||||
| void addChecker(RegisterCheckerFn Fn, ShouldRegisterFunction sfn, | ||||||||
| /// Adds a checker to the registry. This private, most general variant is | ||||||||
|
||||||||
| /// Adds a checker to the registry. This private, most general variant is | |
| /// Adds a checker to the registry. | |
| /// This private, most general overload is... |
Could you make the Adds a checker to the registry. the first and dedicated line of all of the overloads?
That would make these stand out thus easier to read.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a random comment: I never understood why does returnTrue depend on type T if it just returns true xD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I, too, have no idea 🙃 and I asked @Szelethus who added the template parameter in 2020, but he doesn't remember why was it added.
The projects can be compiled and linked without the template parameter, so I decided to remove it in 4c5c619
Uh oh!
There was an error while loading. Please reload this page.