xref: /freebsd/contrib/llvm-project/clang/lib/StaticAnalyzer/Frontend/CreateCheckerManager.cpp (revision e25152834cdf3b353892835a4f3b157e066a8ed4)
1*5ffd83dbSDimitry Andric //===- CheckerManager.h - Static Analyzer Checker Manager -------*- C++ -*-===//
2*5ffd83dbSDimitry Andric //
3*5ffd83dbSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*5ffd83dbSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*5ffd83dbSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*5ffd83dbSDimitry Andric //
7*5ffd83dbSDimitry Andric //===----------------------------------------------------------------------===//
8*5ffd83dbSDimitry Andric //
9*5ffd83dbSDimitry Andric // Defines the Static Analyzer Checker Manager.
10*5ffd83dbSDimitry Andric //
11*5ffd83dbSDimitry Andric //===----------------------------------------------------------------------===//
12*5ffd83dbSDimitry Andric 
13*5ffd83dbSDimitry Andric #include "clang/StaticAnalyzer/Core/CheckerManager.h"
14*5ffd83dbSDimitry Andric #include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
15*5ffd83dbSDimitry Andric #include <memory>
16*5ffd83dbSDimitry Andric 
17*5ffd83dbSDimitry Andric namespace clang {
18*5ffd83dbSDimitry Andric namespace ento {
19*5ffd83dbSDimitry Andric 
CheckerManager(ASTContext & Context,AnalyzerOptions & AOptions,const Preprocessor & PP,ArrayRef<std::string> plugins,ArrayRef<std::function<void (CheckerRegistry &)>> checkerRegistrationFns)20*5ffd83dbSDimitry Andric CheckerManager::CheckerManager(
21*5ffd83dbSDimitry Andric     ASTContext &Context, AnalyzerOptions &AOptions, const Preprocessor &PP,
22*5ffd83dbSDimitry Andric     ArrayRef<std::string> plugins,
23*5ffd83dbSDimitry Andric     ArrayRef<std::function<void(CheckerRegistry &)>> checkerRegistrationFns)
24*5ffd83dbSDimitry Andric     : Context(&Context), LangOpts(Context.getLangOpts()), AOptions(AOptions),
25*5ffd83dbSDimitry Andric       PP(&PP), Diags(Context.getDiagnostics()),
26*5ffd83dbSDimitry Andric       RegistryData(std::make_unique<CheckerRegistryData>()) {
27*5ffd83dbSDimitry Andric   CheckerRegistry Registry(*RegistryData, plugins, Context.getDiagnostics(),
28*5ffd83dbSDimitry Andric                            AOptions, checkerRegistrationFns);
29*5ffd83dbSDimitry Andric   Registry.initializeRegistry(*this);
30*5ffd83dbSDimitry Andric   Registry.initializeManager(*this);
31*5ffd83dbSDimitry Andric   finishedCheckerRegistration();
32*5ffd83dbSDimitry Andric }
33*5ffd83dbSDimitry Andric 
CheckerManager(AnalyzerOptions & AOptions,const LangOptions & LangOpts,DiagnosticsEngine & Diags,ArrayRef<std::string> plugins)34*5ffd83dbSDimitry Andric CheckerManager::CheckerManager(AnalyzerOptions &AOptions,
35*5ffd83dbSDimitry Andric                                const LangOptions &LangOpts,
36*5ffd83dbSDimitry Andric                                DiagnosticsEngine &Diags,
37*5ffd83dbSDimitry Andric                                ArrayRef<std::string> plugins)
38*5ffd83dbSDimitry Andric     : LangOpts(LangOpts), AOptions(AOptions), Diags(Diags),
39*5ffd83dbSDimitry Andric       RegistryData(std::make_unique<CheckerRegistryData>()) {
40*5ffd83dbSDimitry Andric   CheckerRegistry Registry(*RegistryData, plugins, Diags, AOptions, {});
41*5ffd83dbSDimitry Andric   Registry.initializeRegistry(*this);
42*5ffd83dbSDimitry Andric }
43*5ffd83dbSDimitry Andric 
~CheckerManager()44*5ffd83dbSDimitry Andric CheckerManager::~CheckerManager() {
45*5ffd83dbSDimitry Andric   for (const auto &CheckerDtor : CheckerDtors)
46*5ffd83dbSDimitry Andric     CheckerDtor();
47*5ffd83dbSDimitry Andric }
48*5ffd83dbSDimitry Andric 
49*5ffd83dbSDimitry Andric } // namespace ento
50*5ffd83dbSDimitry Andric } // namespace clang
51