diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-02-14 18:13:31 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-02-14 18:13:31 +0000 |
commit | 43dee220252ef0b42c5f8a3bb1eca97f84f2565f (patch) | |
tree | 58da397a333119178a2aacb3564397dd1b01ea20 /lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp | |
parent | 5f83d6f36a7308eef21d87104fd70c421e854448 (diff) |
[analyzer] Overhauling of the checker registration mechanism.
-Checkers will be defined in the tablegen file 'Checkers.td'.
-Apart from checkers, we can define checker "packages" that will contain a collection of checkers.
-Checkers can be enabled with -analyzer-checker=<name> and disabled with -analyzer-disable-checker=<name> e.g:
Enable checkers from 'cocoa' and 'corefoundation' packages except the self-initialization checker:
-analyzer-checker=cocoa -analyzer-checker=corefoundation -analyzer-disable-checker=cocoa.SelfInit
-Introduces CheckerManager and CheckerProvider. CheckerProviders get the set of checker names to enable/disable and
register them with the CheckerManager which will be the entry point for all checker-related functionality.
Currently only the self-initialization checker takes advantage of the new mechanism.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125503 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp b/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp new file mode 100644 index 0000000000..ca25f71823 --- /dev/null +++ b/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp @@ -0,0 +1,50 @@ +//===--- CheckerRegistration.cpp - Registration for the Analyzer Checkers -===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Defines the registration function for the analyzer checkers. +// +//===----------------------------------------------------------------------===// + +#include "AnalysisConsumer.h" +#include "../Checkers/ClangSACheckerProvider.h" +#include "clang/StaticAnalyzer/Core/CheckerManager.h" +#include "clang/StaticAnalyzer/Core/CheckerProvider.h" +#include "clang/Frontend/AnalyzerOptions.h" +#include "clang/Frontend/FrontendDiagnostic.h" +#include "clang/Basic/Diagnostic.h" +#include "llvm/ADT/OwningPtr.h" +#include "llvm/ADT/SmallVector.h" + +using namespace clang; +using namespace ento; + +CheckerManager *ento::registerCheckers(const AnalyzerOptions &opts, + Diagnostic &diags) { + llvm::OwningPtr<CheckerManager> checkerMgr(new CheckerManager()); + + llvm::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)); + } + + llvm::OwningPtr<CheckerProvider> provider(createClangSACheckerProvider()); + provider->registerCheckers(*checkerMgr, + checkerOpts.data(), checkerOpts.size()); + + // FIXME: Load CheckerProviders from plugins. + + for (unsigned i = 0, e = checkerOpts.size(); i != e; ++i) { + if (checkerOpts[i].isUnclaimed()) + diags.Report(diag::warn_unkwown_analyzer_checker) + << checkerOpts[i].getName(); + } + + return checkerMgr.take(); +} |