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);
56 DynamicLibrary lib = DynamicLibrary::getPermanentLibrary(i->c_str(), &err);
58 diags->
Report(diag::err_fe_unable_to_load_plugin) << *i << err;
63 const char *pluginAPIVersion =
64 (
const char *) lib.getAddressOfSymbol(
"clang_analyzerAPIVersionString");
65 if (!isCompatibleAPIVersion(pluginAPIVersion)) {
66 warnIncompatible(diags, *i, pluginAPIVersion);
71 RegisterCheckersFn registerPluginCheckers =
72 (RegisterCheckersFn) (
intptr_t) lib.getAddressOfSymbol(
73 "clang_registerCheckers");
74 if (registerPluginCheckers)
75 registerPluginCheckers(*
this);
79 bool ClangCheckerRegistry::isCompatibleAPIVersion(
const char *versionString) {
91 const char *pluginAPIVersion) {
94 if (!pluginAPIVersion)
97 diags->
Report(diag::warn_incompatible_analyzer_plugin_api)
98 << llvm::sys::path::filename(pluginPath);
99 diags->
Report(diag::note_incompatible_analyzer_plugin_api)
119 std::unique_ptr<CheckerManager> checkerMgr(
124 ClangCheckerRegistry allCheckers(plugins, &diags);
126 for (
const auto &Fn : checkerRegistrationFns)
129 allCheckers.initializeManager(*checkerMgr, checkerOpts);
130 allCheckers.validateCheckerOptions(opts, diags);
131 checkerMgr->finishedCheckerRegistration();
133 for (
unsigned i = 0, e = checkerOpts.size(); i != e; ++i) {
134 if (checkerOpts[i].isUnclaimed()) {
135 diags.
Report(diag::err_unknown_analyzer_checker)
136 << checkerOpts[i].getName();
137 diags.
Report(diag::note_suggest_disabling_all_checkers);
146 out <<
"OVERVIEW: Clang Static Analyzer Checkers List\n\n";
147 out <<
"USAGE: -analyzer-checker <CHECKER or PACKAGE,...>\n\n";
149 ClangCheckerRegistry(plugins).printHelp(out);
155 out <<
"OVERVIEW: Clang Static Analyzer Enabled Checkers List\n\n";
158 ClangCheckerRegistry(plugins).printList(out, checkerOpts);
Manages a set of available checkers for running a static analysis.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
void printEnabledCheckerList(raw_ostream &OS, ArrayRef< std::string > plugins, const AnalyzerOptions &opts)
#define CLANG_ANALYZER_API_VERSION_STRING
Represents a request to include or exclude a checker or package from a specific analysis run...
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.
Defines the Diagnostic-related interfaces.
std::vector< std::pair< std::string, bool > > CheckersControlList
Pair of checker name and enable/disable.
__INTPTR_TYPE__ intptr_t
A signed integer type with the property that any valid pointer to void can be converted to this type...
std::unique_ptr< CheckerManager > createCheckerManager(AnalyzerOptions &opts, const LangOptions &langOpts, ArrayRef< std::string > plugins, ArrayRef< std::function< void(CheckerRegistry &)>> checkerRegistrationFns, DiagnosticsEngine &diags)
static SmallVector< CheckerOptInfo, 8 > getCheckerOptList(const AnalyzerOptions &opts)
void printCheckerHelp(raw_ostream &OS, ArrayRef< std::string > plugins)
Dataflow Directional Tag Classes.
void registerBuiltinCheckers(CheckerRegistry ®istry)