Coverage Report

Created: 2021-09-21 08:58

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/Sema/AnalysisBasedWarnings.h
Line
Count
Source
1
//=- AnalysisBasedWarnings.h - Sema warnings based on libAnalysis -*- 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
// This file defines AnalysisBasedWarnings, a worker object used by Sema
10
// that issues warnings based on dataflow-analysis.
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_CLANG_SEMA_ANALYSISBASEDWARNINGS_H
14
#define LLVM_CLANG_SEMA_ANALYSISBASEDWARNINGS_H
15
16
#include "llvm/ADT/DenseMap.h"
17
#include <memory>
18
19
namespace clang {
20
21
class BlockExpr;
22
class Decl;
23
class FunctionDecl;
24
class ObjCMethodDecl;
25
class QualType;
26
class Sema;
27
namespace sema {
28
  class FunctionScopeInfo;
29
}
30
31
namespace sema {
32
33
class AnalysisBasedWarnings {
34
public:
35
  class Policy {
36
    friend class AnalysisBasedWarnings;
37
    // The warnings to run.
38
    unsigned enableCheckFallThrough : 1;
39
    unsigned enableCheckUnreachable : 1;
40
    unsigned enableThreadSafetyAnalysis : 1;
41
    unsigned enableConsumedAnalysis : 1;
42
  public:
43
    Policy();
44
9.13k
    void disableCheckFallThrough() { enableCheckFallThrough = 0; }
45
  };
46
47
private:
48
  Sema &S;
49
  Policy DefaultPolicy;
50
51
  class InterProceduralData;
52
  std::unique_ptr<InterProceduralData> IPData;
53
54
  enum VisitFlag { NotVisited = 0, Visited = 1, Pending = 2 };
55
  llvm::DenseMap<const FunctionDecl*, VisitFlag> VisitedFD;
56
57
  /// \name Statistics
58
  /// @{
59
60
  /// Number of function CFGs built and analyzed.
61
  unsigned NumFunctionsAnalyzed;
62
63
  /// Number of functions for which the CFG could not be successfully
64
  /// built.
65
  unsigned NumFunctionsWithBadCFGs;
66
67
  /// Total number of blocks across all CFGs.
68
  unsigned NumCFGBlocks;
69
70
  /// Largest number of CFG blocks for a single function analyzed.
71
  unsigned MaxCFGBlocksPerFunction;
72
73
  /// Total number of CFGs with variables analyzed for uninitialized
74
  /// uses.
75
  unsigned NumUninitAnalysisFunctions;
76
77
  /// Total number of variables analyzed for uninitialized uses.
78
  unsigned NumUninitAnalysisVariables;
79
80
  /// Max number of variables analyzed for uninitialized uses in a single
81
  /// function.
82
  unsigned MaxUninitAnalysisVariablesPerFunction;
83
84
  /// Total number of block visits during uninitialized use analysis.
85
  unsigned NumUninitAnalysisBlockVisits;
86
87
  /// Max number of block visits during uninitialized use analysis of
88
  /// a single function.
89
  unsigned MaxUninitAnalysisBlockVisitsPerFunction;
90
91
  /// @}
92
93
public:
94
  AnalysisBasedWarnings(Sema &s);
95
  ~AnalysisBasedWarnings();
96
97
  void IssueWarnings(Policy P, FunctionScopeInfo *fscope,
98
                     const Decl *D, QualType BlockType);
99
100
3.77M
  Policy getDefaultPolicy() { return DefaultPolicy; }
101
102
  void PrintStats() const;
103
};
104
105
} // namespace sema
106
} // namespace clang
107
108
#endif