| 1 | //===-- AnalysisManager.cpp -------------------------------------*- 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 | #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h" |
| 10 | |
| 11 | using namespace clang; |
| 12 | using namespace ento; |
| 13 | |
| 14 | void AnalysisManager::anchor() { } |
| 15 | |
| 16 | AnalysisManager::AnalysisManager(ASTContext &ASTCtx, Preprocessor &PP, |
| 17 | PathDiagnosticConsumers PDC, |
| 18 | StoreManagerCreator storemgr, |
| 19 | ConstraintManagerCreator constraintmgr, |
| 20 | CheckerManager *checkerMgr, |
| 21 | AnalyzerOptions &Options, |
| 22 | std::unique_ptr<CodeInjector> injector) |
| 23 | : AnaCtxMgr( |
| 24 | ASTCtx, Options.UnoptimizedCFG, |
| 25 | Options.ShouldIncludeImplicitDtorsInCFG, |
| 26 | /*addInitializers=*/true, Options.ShouldIncludeTemporaryDtorsInCFG, |
| 27 | Options.ShouldIncludeLifetimeInCFG, |
| 28 | // Adding LoopExit elements to the CFG is a requirement for loop |
| 29 | // unrolling. |
| 30 | Options.ShouldIncludeLoopExitInCFG || Options.ShouldUnrollLoops, |
| 31 | Options.ShouldIncludeScopesInCFG, Options.ShouldSynthesizeBodies, |
| 32 | Options.ShouldConditionalizeStaticInitializers, |
| 33 | /*addCXXNewAllocator=*/true, |
| 34 | Options.ShouldIncludeRichConstructorsInCFG, |
| 35 | Options.ShouldElideConstructors, |
| 36 | /*addVirtualBaseBranches=*/true, std::move(injector)), |
| 37 | Ctx(ASTCtx), PP(PP), LangOpts(ASTCtx.getLangOpts()), |
| 38 | PathConsumers(std::move(PDC)), CreateStoreMgr(storemgr), |
| 39 | CreateConstraintMgr(constraintmgr), CheckerMgr(checkerMgr), |
| 40 | options(Options) { |
| 41 | AnaCtxMgr.getCFGBuildOptions().setAllAlwaysAdd(); |
| 42 | AnaCtxMgr.getCFGBuildOptions().OmitImplicitValueInitializers = true; |
| 43 | AnaCtxMgr.getCFGBuildOptions().AddCXXDefaultInitExprInAggregates = |
| 44 | Options.ShouldIncludeDefaultInitForAggregates; |
| 45 | } |
| 46 | |
| 47 | AnalysisManager::~AnalysisManager() { |
| 48 | FlushDiagnostics(); |
| 49 | } |
| 50 | |
| 51 | void AnalysisManager::FlushDiagnostics() { |
| 52 | PathDiagnosticConsumer::FilesMade filesMade; |
| 53 | for (const auto &Consumer : PathConsumers) { |
| 54 | Consumer->FlushDiagnostics(FilesMade: &filesMade); |
| 55 | } |
| 56 | } |
| 57 | |