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