This script could be used to generate a dummy Static Analyzer checker.
Example usage:
python add-new-checker.py alpha.package.Foo
It also helps to document checker-writing.
| Paths 
 |  Differential  D73521  
[analyzer] add-new-checker.py: Introduction Needs ReviewPublic Authored by Charusso on Jan 27 2020, 6:48 PM. 
Details 
 Summary This script could be used to generate a dummy Static Analyzer checker. It also helps to document checker-writing. 
Diff Detail Event TimelineHerald added subscribers: cfe-commits, dkrupp, donat.nagy and 6 others.  ·  View Herald TranscriptJan 27 2020, 6:48 PM Comment Actions This script dumps out a dummy checker which is the continuation of the Clang Tidy's https://github.com/llvm/llvm-project/blob/master/clang-tools-extra/clang-tidy/add_new_check.py However, we could stick to the main-function-redeclaration-checker in a 2020 fashion. As I see peoples starting their careers with Tidy, that is why this checker born, but please feel free to swap or modify. I think that is the easiest way to document changes in requirements of checker-writing. I also wanted to document common mistakes, like how to use a Twine, what is a dyn_cast_or_null<> vs. cast<>, make sure the SVal type is written out and it is not const or const*. Comment Actions I didn't use it yet but i like it. The code is easy to understand, so i'll be happy to maintain it as it lands. The example checker is nice and i like how you made sure it demonstrates modern API usage. I'm a bit worried that it may quickly get out of date as we update our APIs, because this happens like ~multiple times a year, much more often than in clang-tidy. Is there a way to write a test that tests that the generated checker compiles? I don't have any specific ideas but it would have been awesome. 
 Charusso marked 3 inline comments as done. Charusso retitled this revision from [analyzer][WIP] add-new-checker.py: Introduction to [analyzer] add-new-checker.py: Introduction.Comment Actions 
 Charusso added inline comments. 
 Comment Actions 
 Mm, ok, but this checker is checked in into the repo and therefore can diverge from whatever the script generates, right? Or is each test run updating the repo? Can we simply make the script do cat DummyChecker.cpp | sed s/DummyChecker/$NAME/g > $NAME.cpp and store the checker only once? 
 Charusso marked 3 inline comments as done.Comment Actions 
 Comment Actions 
 It was updating, yes. The first idea was to copy over the live checker, but I wanted to make it as portable as possible. 
 Comment Actions 
 The community owns like 50 build-bots, so it should affect all of them by default. I am hoping it will just work. 
Revision Contents 
 
Diff 253777 clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
 clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
 clang/lib/StaticAnalyzer/Checkers/ExampleChecker.cpp
 
 clang/test/Analysis/add-new-checker/add-main-package.rst
 
 clang/test/Analysis/add-new-checker/add-main-package.td
 
 clang/test/Analysis/add-new-checker/add-multiple-packages.rst
 
 clang/test/Analysis/add-new-checker/add-multiple-packages.td
 
 clang/test/Analysis/add-new-checker/check-add-new-checker.py
 
 clang/test/Analysis/add-new-checker/checker-name.rst
 
 clang/test/Analysis/add-new-checker/checker-name.td
 
 clang/test/Analysis/add-new-checker/flow-package-exist-checker.rst
 
 clang/test/Analysis/add-new-checker/flow-package-exist-checker.td
 
 clang/test/Analysis/add-new-checker/flow-package-not-exist.rst
 
 clang/test/Analysis/add-new-checker/flow-package-not-exist.td
 
 clang/test/Analysis/add-new-checker/lit.local.cfg.py
 
 clang/test/Analysis/example-checker.cpp
 
 clang/utils/analyzer/add-new-checker.py
 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The script is allergic to human issues. The followup will be to normalize the necessary files.