Coverage Report

Created: 2023-09-30 09:22

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
Line
Count
Source (jump to first uncovered line)
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
0
void AnalysisManager::anchor() { }
15
16
AnalysisManager::AnalysisManager(ASTContext &ASTCtx, Preprocessor &PP,
17
                                 const PathDiagnosticConsumers &PDC,
18
                                 StoreManagerCreator storemgr,
19
                                 ConstraintManagerCreator constraintmgr,
20
                                 CheckerManager *checkerMgr,
21
                                 AnalyzerOptions &Options,
22
                                 CodeInjector *injector)
23
1.82k
    : AnaCtxMgr(
24
1.82k
          ASTCtx, Options.UnoptimizedCFG,
25
1.82k
          Options.ShouldIncludeImplicitDtorsInCFG,
26
1.82k
          /*addInitializers=*/true,
27
1.82k
          Options.ShouldIncludeTemporaryDtorsInCFG,
28
1.82k
          Options.ShouldIncludeLifetimeInCFG,
29
          // Adding LoopExit elements to the CFG is a requirement for loop
30
          // unrolling.
31
1.82k
          Options.ShouldIncludeLoopExitInCFG ||
32
1.82k
            
Options.ShouldUnrollLoops1.82k
,
33
1.82k
          Options.ShouldIncludeScopesInCFG,
34
1.82k
          Options.ShouldSynthesizeBodies,
35
1.82k
          Options.ShouldConditionalizeStaticInitializers,
36
1.82k
          /*addCXXNewAllocator=*/true,
37
1.82k
          Options.ShouldIncludeRichConstructorsInCFG,
38
1.82k
          Options.ShouldElideConstructors,
39
1.82k
          /*addVirtualBaseBranches=*/true,
40
1.82k
          injector),
41
1.82k
      Ctx(ASTCtx), PP(PP), LangOpts(ASTCtx.getLangOpts()),
42
1.82k
      PathConsumers(PDC), CreateStoreMgr(storemgr),
43
1.82k
      CreateConstraintMgr(constraintmgr), CheckerMgr(checkerMgr),
44
1.82k
      options(Options) {
45
1.82k
  AnaCtxMgr.getCFGBuildOptions().setAllAlwaysAdd();
46
1.82k
  AnaCtxMgr.getCFGBuildOptions().OmitImplicitValueInitializers = true;
47
1.82k
  AnaCtxMgr.getCFGBuildOptions().AddCXXDefaultInitExprInAggregates =
48
1.82k
      Options.ShouldIncludeDefaultInitForAggregates;
49
1.82k
}
50
51
1.82k
AnalysisManager::~AnalysisManager() {
52
1.82k
  FlushDiagnostics();
53
2.13k
  for (PathDiagnosticConsumer *Consumer : PathConsumers) {
54
2.13k
    delete Consumer;
55
2.13k
  }
56
1.82k
}
57
58
1.82k
void AnalysisManager::FlushDiagnostics() {
59
1.82k
  PathDiagnosticConsumer::FilesMade filesMade;
60
2.13k
  for (PathDiagnosticConsumer *Consumer : PathConsumers) {
61
2.13k
    Consumer->FlushDiagnostics(&filesMade);
62
2.13k
  }
63
1.82k
}