Coverage Report

Created: 2019-07-24 05:18

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