CreateCheckerManager.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //===- CheckerManager.h - Static Analyzer Checker Manager -------*- 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 Static Analyzer Checker Manager.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #include "clang/StaticAnalyzer/Core/CheckerManager.h"
  13. #include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
  14. #include <memory>
  15. namespace clang {
  16. namespace ento {
  17. CheckerManager::CheckerManager(
  18. ASTContext &Context, AnalyzerOptions &AOptions, const Preprocessor &PP,
  19. ArrayRef<std::string> plugins,
  20. ArrayRef<std::function<void(CheckerRegistry &)>> checkerRegistrationFns)
  21. : Context(&Context), LangOpts(Context.getLangOpts()), AOptions(AOptions),
  22. PP(&PP), Diags(Context.getDiagnostics()),
  23. RegistryData(std::make_unique<CheckerRegistryData>()) {
  24. CheckerRegistry Registry(*RegistryData, plugins, Context.getDiagnostics(),
  25. AOptions, checkerRegistrationFns);
  26. Registry.initializeRegistry(*this);
  27. Registry.initializeManager(*this);
  28. finishedCheckerRegistration();
  29. }
  30. CheckerManager::CheckerManager(AnalyzerOptions &AOptions,
  31. const LangOptions &LangOpts,
  32. DiagnosticsEngine &Diags,
  33. ArrayRef<std::string> plugins)
  34. : LangOpts(LangOpts), AOptions(AOptions), Diags(Diags),
  35. RegistryData(std::make_unique<CheckerRegistryData>()) {
  36. CheckerRegistry Registry(*RegistryData, plugins, Diags, AOptions, {});
  37. Registry.initializeRegistry(*this);
  38. }
  39. CheckerManager::~CheckerManager() {
  40. for (const auto &CheckerDtor : CheckerDtors)
  41. CheckerDtor();
  42. }
  43. } // namespace ento
  44. } // namespace clang