clang 8.0.0

AnalysisBasedWarnings.h
Go to the documentation of this file.
1 //=- AnalysisBasedWarnings.h - Sema warnings based on libAnalysis -*- C++ -*-=//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines AnalysisBasedWarnings, a worker object used by Sema
11 // that issues warnings based on dataflow-analysis.
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_CLANG_SEMA_ANALYSISBASEDWARNINGS_H
15 #define LLVM_CLANG_SEMA_ANALYSISBASEDWARNINGS_H
16
17 #include "llvm/ADT/DenseMap.h"
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 void disableCheckFallThrough() { enableCheckFallThrough = 0; }
45 };
46
47 private:
48 Sema &S;
49 Policy DefaultPolicy;
50
51 enum VisitFlag { NotVisited = 0, Visited = 1, Pending = 2 };
52 llvm::DenseMap<const FunctionDecl*, VisitFlag> VisitedFD;
53
54 /// \name Statistics
55 /// @{
56
57 /// Number of function CFGs built and analyzed.
58 unsigned NumFunctionsAnalyzed;
59
60 /// Number of functions for which the CFG could not be successfully
61 /// built.
62 unsigned NumFunctionsWithBadCFGs;
63
64 /// Total number of blocks across all CFGs.
65 unsigned NumCFGBlocks;
66
67 /// Largest number of CFG blocks for a single function analyzed.
68 unsigned MaxCFGBlocksPerFunction;
69
70 /// Total number of CFGs with variables analyzed for uninitialized
71 /// uses.
72 unsigned NumUninitAnalysisFunctions;
73
74 /// Total number of variables analyzed for uninitialized uses.
75 unsigned NumUninitAnalysisVariables;
76
77 /// Max number of variables analyzed for uninitialized uses in a single
78 /// function.
79 unsigned MaxUninitAnalysisVariablesPerFunction;
80
81 /// Total number of block visits during uninitialized use analysis.
82 unsigned NumUninitAnalysisBlockVisits;
83
84 /// Max number of block visits during uninitialized use analysis of
85 /// a single function.
86 unsigned MaxUninitAnalysisBlockVisitsPerFunction;
87
88 /// @}
89
90 public:
91 AnalysisBasedWarnings(Sema &s);
92
93 void IssueWarnings(Policy P, FunctionScopeInfo *fscope,
94 const Decl *D, const BlockExpr *blkExpr);
95
96 Policy getDefaultPolicy() { return DefaultPolicy; }
97
98 void PrintStats() const;
99 };
100
101 }} // end namespace clang::sema
102
103 #endif
clang::sema::AnalysisBasedWarnings
Definition: AnalysisBasedWarnings.h:33
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:87
P
StringRef P
Definition: ASTMatchersInternal.cpp:439
clang::CodeGen::AlignmentSource::Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
clang::sema::FunctionScopeInfo
Retains information about a function, method, or block that is currently being parsed.
Definition: ScopeInfo.h:97
clang::Sema
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:278
clang::BlockExpr
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:5177
clang::sema::AnalysisBasedWarnings::Policy::disableCheckFallThrough
void disableCheckFallThrough()
Definition: AnalysisBasedWarnings.h:44
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:22
clang::sema::AnalysisBasedWarnings::getDefaultPolicy
Policy getDefaultPolicy()
Definition: AnalysisBasedWarnings.h:96
clang::sema::AnalysisBasedWarnings::Policy
Definition: AnalysisBasedWarnings.h:35