diff options
author | Gabor Horvath <xazax.hun@gmail.com> | 2016-08-08 13:41:04 +0000 |
---|---|---|
committer | Gabor Horvath <xazax.hun@gmail.com> | 2016-08-08 13:41:04 +0000 |
commit | c430990d0bd4b32312049adbf6a84afc990813eb (patch) | |
tree | d08d8cbd7f216ca7361682c9e5498e73f1414377 /clang/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp | |
parent | 142f4f76be8b9c65385029213a36248e34547e3f (diff) | |
download | bcm5719-llvm-c430990d0bd4b32312049adbf6a84afc990813eb.tar.gz bcm5719-llvm-c430990d0bd4b32312049adbf6a84afc990813eb.zip |
[analyzer] Command line option to show enabled checker list.
This patch adds a command line option to list the checkers that were enabled
by analyzer-checker and not disabled by -analyzer-disable-checker.
It can be very useful to debug long command lines when it is not immediately
apparent which checkers are turned on and which checkers are turned off.
Differential Revision: https://reviews.llvm.org/D23060
llvm-svn: 278006
Diffstat (limited to 'clang/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp index 75fa4c651ac..1668aebf3f9 100644 --- a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp +++ b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp @@ -101,6 +101,16 @@ void ClangCheckerRegistry::warnIncompatible(DiagnosticsEngine *diags, << pluginAPIVersion; } +static SmallVector<CheckerOptInfo, 8> +getCheckerOptList(const AnalyzerOptions &opts) { + SmallVector<CheckerOptInfo, 8> checkerOpts; + for (unsigned i = 0, e = opts.CheckersControlList.size(); i != e; ++i) { + const std::pair<std::string, bool> &opt = opts.CheckersControlList[i]; + checkerOpts.push_back(CheckerOptInfo(opt.first.c_str(), opt.second)); + } + return checkerOpts; +} + std::unique_ptr<CheckerManager> ento::createCheckerManager(AnalyzerOptions &opts, const LangOptions &langOpts, ArrayRef<std::string> plugins, @@ -108,11 +118,7 @@ ento::createCheckerManager(AnalyzerOptions &opts, const LangOptions &langOpts, std::unique_ptr<CheckerManager> checkerMgr( new CheckerManager(langOpts, &opts)); - SmallVector<CheckerOptInfo, 8> checkerOpts; - for (unsigned i = 0, e = opts.CheckersControlList.size(); i != e; ++i) { - const std::pair<std::string, bool> &opt = opts.CheckersControlList[i]; - checkerOpts.push_back(CheckerOptInfo(opt.first.c_str(), opt.second)); - } + SmallVector<CheckerOptInfo, 8> checkerOpts = getCheckerOptList(opts); ClangCheckerRegistry allCheckers(plugins, &diags); allCheckers.initializeManager(*checkerMgr, checkerOpts); @@ -137,3 +143,12 @@ void ento::printCheckerHelp(raw_ostream &out, ArrayRef<std::string> plugins) { ClangCheckerRegistry(plugins).printHelp(out); } + +void ento::printEnabledCheckerList(raw_ostream &out, + ArrayRef<std::string> plugins, + const AnalyzerOptions &opts) { + out << "OVERVIEW: Clang Static Analyzer Enabled Checkers List\n\n"; + + SmallVector<CheckerOptInfo, 8> checkerOpts = getCheckerOptList(opts); + ClangCheckerRegistry(plugins).printList(out, checkerOpts); +} |