Argyrios Kyrtzidis | 43dee22 | 2011-02-14 18:13:31 +0000 | [diff] [blame^] | 1 | //===--- CheckerRegistration.cpp - Registration for the Analyzer Checkers -===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // Defines the registration function for the analyzer checkers. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "AnalysisConsumer.h" |
| 15 | #include "../Checkers/ClangSACheckerProvider.h" |
| 16 | #include "clang/StaticAnalyzer/Core/CheckerManager.h" |
| 17 | #include "clang/StaticAnalyzer/Core/CheckerProvider.h" |
| 18 | #include "clang/Frontend/AnalyzerOptions.h" |
| 19 | #include "clang/Frontend/FrontendDiagnostic.h" |
| 20 | #include "clang/Basic/Diagnostic.h" |
| 21 | #include "llvm/ADT/OwningPtr.h" |
| 22 | #include "llvm/ADT/SmallVector.h" |
| 23 | |
| 24 | using namespace clang; |
| 25 | using namespace ento; |
| 26 | |
| 27 | CheckerManager *ento::registerCheckers(const AnalyzerOptions &opts, |
| 28 | Diagnostic &diags) { |
| 29 | llvm::OwningPtr<CheckerManager> checkerMgr(new CheckerManager()); |
| 30 | |
| 31 | llvm::SmallVector<CheckerOptInfo, 8> checkerOpts; |
| 32 | for (unsigned i = 0, e = opts.CheckersControlList.size(); i != e; ++i) { |
| 33 | const std::pair<std::string, bool> &opt = opts.CheckersControlList[i]; |
| 34 | checkerOpts.push_back(CheckerOptInfo(opt.first.c_str(), opt.second)); |
| 35 | } |
| 36 | |
| 37 | llvm::OwningPtr<CheckerProvider> provider(createClangSACheckerProvider()); |
| 38 | provider->registerCheckers(*checkerMgr, |
| 39 | checkerOpts.data(), checkerOpts.size()); |
| 40 | |
| 41 | // FIXME: Load CheckerProviders from plugins. |
| 42 | |
| 43 | for (unsigned i = 0, e = checkerOpts.size(); i != e; ++i) { |
| 44 | if (checkerOpts[i].isUnclaimed()) |
| 45 | diags.Report(diag::warn_unkwown_analyzer_checker) |
| 46 | << checkerOpts[i].getName(); |
| 47 | } |
| 48 | |
| 49 | return checkerMgr.take(); |
| 50 | } |