23 #include "llvm/ADT/SmallVector.h"
24 #include "llvm/Support/DynamicLibrary.h"
25 #include "llvm/Support/Path.h"
26 #include "llvm/Support/raw_ostream.h"
29 using namespace clang;
31 using llvm::sys::DynamicLibrary;
37 static bool isCompatibleAPIVersion(
const char *versionString);
39 const char *pluginAPIVersion);
55 DynamicLibrary lib = DynamicLibrary::getPermanentLibrary(i->c_str());
58 const char *pluginAPIVersion =
59 (
const char *) lib.getAddressOfSymbol(
"clang_analyzerAPIVersionString");
60 if (!isCompatibleAPIVersion(pluginAPIVersion)) {
61 warnIncompatible(diags, *i, pluginAPIVersion);
66 RegisterCheckersFn registerPluginCheckers =
67 (RegisterCheckersFn) (intptr_t) lib.getAddressOfSymbol(
68 "clang_registerCheckers");
69 if (registerPluginCheckers)
70 registerPluginCheckers(*
this);
74 bool ClangCheckerRegistry::isCompatibleAPIVersion(
const char *versionString) {
89 const char *pluginAPIVersion) {
92 if (!pluginAPIVersion)
95 diags->
Report(diag::warn_incompatible_analyzer_plugin_api)
96 << llvm::sys::path::filename(pluginPath);
97 diags->
Report(diag::note_incompatible_analyzer_plugin_api)
102 std::unique_ptr<CheckerManager>
106 std::unique_ptr<CheckerManager> checkerMgr(
112 checkerOpts.push_back(
CheckerOptInfo(opt.first.c_str(), opt.second));
115 ClangCheckerRegistry allCheckers(plugins, &diags);
116 allCheckers.initializeManager(*checkerMgr, checkerOpts);
117 allCheckers.validateCheckerOptions(opts, diags);
118 checkerMgr->finishedCheckerRegistration();
120 for (
unsigned i = 0, e = checkerOpts.size(); i != e; ++i) {
121 if (checkerOpts[i].isUnclaimed()) {
122 diags.
Report(diag::err_unknown_analyzer_checker)
123 << checkerOpts[i].getName();
124 diags.
Report(diag::note_suggest_disabling_all_checkers);
133 out <<
"OVERVIEW: Clang Static Analyzer Checkers List\n\n";
134 out <<
"USAGE: -analyzer-checker <CHECKER or PACKAGE,...>\n\n";
136 ClangCheckerRegistry(plugins).printHelp(out);
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
#define CLANG_ANALYZER_API_VERSION_STRING
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Concrete class used by the front-end to report problems and issues.
std::vector< std::pair< std::string, bool > > CheckersControlList
Pair of checker name and enable/disable.
void printCheckerHelp(raw_ostream &OS, ArrayRef< std::string > plugins)
void registerBuiltinCheckers(CheckerRegistry ®istry)
Defines the Diagnostic-related interfaces.
std::unique_ptr< CheckerManager > createCheckerManager(AnalyzerOptions &opts, const LangOptions &langOpts, ArrayRef< std::string > plugins, DiagnosticsEngine &diags)