clang 17.0.0git
AnalysisBasedWarnings.h
Go to the documentation of this file.
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
19namespace clang {
20
21class Decl;
22class FunctionDecl;
23class QualType;
24class Sema;
25namespace sema {
27}
28
29namespace sema {
30
32public:
33 class Policy {
35 // The warnings to run.
36 unsigned enableCheckFallThrough : 1;
37 unsigned enableCheckUnreachable : 1;
38 unsigned enableThreadSafetyAnalysis : 1;
39 unsigned enableConsumedAnalysis : 1;
40 public:
41 Policy();
42 void disableCheckFallThrough() { enableCheckFallThrough = 0; }
43 };
44
45private:
46 Sema &S;
47 Policy DefaultPolicy;
48
49 class InterProceduralData;
50 std::unique_ptr<InterProceduralData> IPData;
51
52 enum VisitFlag { NotVisited = 0, Visited = 1, Pending = 2 };
53 llvm::DenseMap<const FunctionDecl*, VisitFlag> VisitedFD;
54
55 /// \name Statistics
56 /// @{
57
58 /// Number of function CFGs built and analyzed.
59 unsigned NumFunctionsAnalyzed;
60
61 /// Number of functions for which the CFG could not be successfully
62 /// built.
63 unsigned NumFunctionsWithBadCFGs;
64
65 /// Total number of blocks across all CFGs.
66 unsigned NumCFGBlocks;
67
68 /// Largest number of CFG blocks for a single function analyzed.
69 unsigned MaxCFGBlocksPerFunction;
70
71 /// Total number of CFGs with variables analyzed for uninitialized
72 /// uses.
73 unsigned NumUninitAnalysisFunctions;
74
75 /// Total number of variables analyzed for uninitialized uses.
76 unsigned NumUninitAnalysisVariables;
77
78 /// Max number of variables analyzed for uninitialized uses in a single
79 /// function.
80 unsigned MaxUninitAnalysisVariablesPerFunction;
81
82 /// Total number of block visits during uninitialized use analysis.
83 unsigned NumUninitAnalysisBlockVisits;
84
85 /// Max number of block visits during uninitialized use analysis of
86 /// a single function.
87 unsigned MaxUninitAnalysisBlockVisitsPerFunction;
88
89 /// @}
90
91public:
94
96 const Decl *D, QualType BlockType);
97
98 Policy getDefaultPolicy() { return DefaultPolicy; }
99
100 void PrintStats() const;
101};
102
103} // namespace sema
104} // namespace clang
105
106#endif
StringRef P
__device__ __2f16 float bool s
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:83
A (possibly-)qualified type.
Definition: Type.h:736
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:358
void IssueWarnings(Policy P, FunctionScopeInfo *fscope, const Decl *D, QualType BlockType)
Retains information about a function, method, or block that is currently being parsed.
Definition: ScopeInfo.h:102
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...