1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
|
//===--- AnalyzerOptions.h - Analysis Engine Options ------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This header defines various options for the static analyzer that are set
// by the frontend and are consulted throughout the analyzer.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_ANALYZEROPTIONS_H
#define LLVM_CLANG_ANALYZEROPTIONS_H
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringMap.h"
#include <string>
#include <vector>
namespace clang {
class ASTConsumer;
class DiagnosticsEngine;
class Preprocessor;
class LangOptions;
/// Analysis - Set of available source code analyses.
enum Analyses {
#define ANALYSIS(NAME, CMDFLAG, DESC, SCOPE) NAME,
#include "clang/StaticAnalyzer/Core/Analyses.def"
NumAnalyses
};
/// AnalysisStores - Set of available analysis store models.
enum AnalysisStores {
#define ANALYSIS_STORE(NAME, CMDFLAG, DESC, CREATFN) NAME##Model,
#include "clang/StaticAnalyzer/Core/Analyses.def"
NumStores
};
/// AnalysisConstraints - Set of available constraint models.
enum AnalysisConstraints {
#define ANALYSIS_CONSTRAINTS(NAME, CMDFLAG, DESC, CREATFN) NAME##Model,
#include "clang/StaticAnalyzer/Core/Analyses.def"
NumConstraints
};
/// AnalysisDiagClients - Set of available diagnostic clients for rendering
/// analysis results.
enum AnalysisDiagClients {
#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATFN, AUTOCREAT) PD_##NAME,
#include "clang/StaticAnalyzer/Core/Analyses.def"
NUM_ANALYSIS_DIAG_CLIENTS
};
/// AnalysisPurgeModes - Set of available strategies for dead symbol removal.
enum AnalysisPurgeMode {
#define ANALYSIS_PURGE(NAME, CMDFLAG, DESC) NAME,
#include "clang/StaticAnalyzer/Core/Analyses.def"
NumPurgeModes
};
/// AnalysisIPAMode - Set of inter-procedural modes.
enum AnalysisIPAMode {
#define ANALYSIS_IPA(NAME, CMDFLAG, DESC) NAME,
#include "clang/StaticAnalyzer/Core/Analyses.def"
NumIPAModes
};
/// AnalysisInlineFunctionSelection - Set of inlining function selection heuristics.
enum AnalysisInliningMode {
#define ANALYSIS_INLINING_MODE(NAME, CMDFLAG, DESC) NAME,
#include "clang/StaticAnalyzer/Core/Analyses.def"
NumInliningModes
};
/// \brief Describes the different kinds of C++ member functions which can be
/// considered for inlining by the analyzer.
///
/// These options are cumulative; enabling one kind of member function will
/// enable all kinds with lower enum values.
enum CXXInlineableMemberKind {
// Uninitialized = 0,
/// A dummy mode in which no C++ inlining is enabled.
CIMK_None = 1,
/// Refers to regular member function and operator calls.
CIMK_MemberFunctions,
/// Refers to constructors (implicit or explicit).
///
/// Note that a constructor will not be inlined if the corresponding
/// destructor is non-trivial.
CIMK_Constructors,
/// Refers to destructors (implicit or explicit).
CIMK_Destructors
};
class AnalyzerOptions : public llvm::RefCountedBase<AnalyzerOptions> {
public:
typedef llvm::StringMap<std::string> ConfigTable;
/// \brief Pair of checker name and enable/disable.
std::vector<std::pair<std::string, bool> > CheckersControlList;
/// \brief A key-value table of use-specified configuration values.
ConfigTable Config;
AnalysisStores AnalysisStoreOpt;
AnalysisConstraints AnalysisConstraintsOpt;
AnalysisDiagClients AnalysisDiagOpt;
AnalysisPurgeMode AnalysisPurgeOpt;
// \brief The interprocedural analysis mode.
AnalysisIPAMode IPAMode;
std::string AnalyzeSpecificFunction;
/// \brief The maximum number of exploded nodes the analyzer will generate.
unsigned MaxNodes;
/// \brief The maximum number of times the analyzer visits a block.
unsigned maxBlockVisitOnPath;
unsigned ShowCheckerHelp : 1;
unsigned AnalyzeAll : 1;
unsigned AnalyzerDisplayProgress : 1;
unsigned AnalyzeNestedBlocks : 1;
/// \brief The flag regulates if we should eagerly assume evaluations of
/// conditionals, thus, bifurcating the path.
///
/// This flag indicates how the engine should handle expressions such as: 'x =
/// (y != 0)'. When this flag is true then the subexpression 'y != 0' will be
/// eagerly assumed to be true or false, thus evaluating it to the integers 0
/// or 1 respectively. The upside is that this can increase analysis
/// precision until we have a better way to lazily evaluate such logic. The
/// downside is that it eagerly bifurcates paths.
unsigned eagerlyAssumeBinOpBifurcation : 1;
unsigned TrimGraph : 1;
unsigned visualizeExplodedGraphWithGraphViz : 1;
unsigned visualizeExplodedGraphWithUbiGraph : 1;
unsigned UnoptimizedCFG : 1;
unsigned PrintStats : 1;
/// \brief Do not re-analyze paths leading to exhausted nodes with a different
/// strategy. We get better code coverage when retry is enabled.
unsigned NoRetryExhausted : 1;
/// \brief The inlining stack depth limit.
unsigned InlineMaxStackDepth;
/// \brief The mode of function selection used during inlining.
unsigned InlineMaxFunctionSize;
/// \brief The mode of function selection used during inlining.
AnalysisInliningMode InliningMode;
private:
/// Controls which C++ member functions will be considered for inlining.
CXXInlineableMemberKind CXXMemberInliningMode;
/// \sa includeTemporaryDtorsInCFG
llvm::Optional<bool> IncludeTemporaryDtorsInCFG;
/// \sa mayInlineCXXStandardLibrary
llvm::Optional<bool> InlineCXXStandardLibrary;
/// \sa mayInlineTemplateFunctions
llvm::Optional<bool> InlineTemplateFunctions;
/// \sa mayInlineObjCMethod
llvm::Optional<bool> ObjCInliningMode;
// Cache of the "ipa-always-inline-size" setting.
// \sa getAlwaysInlineSize
llvm::Optional<unsigned> AlwaysInlineSize;
/// \sa shouldPruneNullReturnPaths
llvm::Optional<bool> PruneNullReturnPaths;
/// \sa shouldAvoidSuppressingNullArgumentPaths
llvm::Optional<bool> AvoidSuppressingNullArgumentPaths;
/// \sa getGraphTrimInterval
llvm::Optional<unsigned> GraphTrimInterval;
/// \sa getMaxTimesInlineLarge
llvm::Optional<unsigned> MaxTimesInlineLarge;
/// Interprets an option's string value as a boolean.
///
/// Accepts the strings "true" and "false".
/// If an option value is not provided, returns the given \p DefaultVal.
bool getBooleanOption(StringRef Name, bool DefaultVal);
/// Variant that accepts a Optional value to cache the result.
bool getBooleanOption(llvm::Optional<bool> &V, StringRef Name,
bool DefaultVal);
/// Interprets an option's string value as an integer value.
int getOptionAsInteger(llvm::StringRef Name, int DefaultVal);
public:
/// Returns the option controlling which C++ member functions will be
/// considered for inlining.
///
/// This is controlled by the 'c++-inlining' config option.
///
/// \sa CXXMemberInliningMode
bool mayInlineCXXMemberFunction(CXXInlineableMemberKind K);
/// Returns true if ObjectiveC inlining is enabled, false otherwise.
bool mayInlineObjCMethod();
/// Returns whether or not the destructors for C++ temporary objects should
/// be included in the CFG.
///
/// This is controlled by the 'cfg-temporary-dtors' config option, which
/// accepts the values "true" and "false".
bool includeTemporaryDtorsInCFG();
/// Returns whether or not C++ standard library functions may be considered
/// for inlining.
///
/// This is controlled by the 'c++-stdlib-inlining' config option, which
/// accepts the values "true" and "false".
bool mayInlineCXXStandardLibrary();
/// Returns whether or not templated functions may be considered for inlining.
///
/// This is controlled by the 'c++-template-inlining' config option, which
/// accepts the values "true" and "false".
bool mayInlineTemplateFunctions();
/// Returns whether or not paths that go through null returns should be
/// suppressed.
///
/// This is a heuristic for avoiding bug reports with paths that go through
/// inlined functions that are more defensive than their callers.
///
/// This is controlled by the 'suppress-null-return-paths' config option,
/// which accepts the values "true" and "false".
bool shouldPruneNullReturnPaths();
/// Returns whether a bug report should \em not be suppressed if its path
/// includes a call with a null argument, even if that call has a null return.
///
/// This option has no effect when #shouldPruneNullReturnPaths() is false.
///
/// This is a counter-heuristic to avoid false negatives.
///
/// This is controlled by the 'avoid-suppressing-null-argument-paths' config
/// option, which accepts the values "true" and "false".
bool shouldAvoidSuppressingNullArgumentPaths();
// Returns the size of the functions (in basic blocks), which should be
// considered to be small enough to always inline.
//
// This is controlled by "ipa-always-inline-size" analyzer-config option.
unsigned getAlwaysInlineSize();
/// Returns true if the analyzer engine should synthesize fake bodies
/// for well-known functions.
bool shouldSynthesizeBodies();
/// Returns how often nodes in the ExplodedGraph should be recycled to save
/// memory.
///
/// This is controlled by the 'graph-trim-interval' config option. To disable
/// node reclamation, set the option to "0".
unsigned getGraphTrimInterval();
/// Returns the maximum times a large function could be inlined.
///
/// This is controlled by the 'max-times-inline-large' config option.
unsigned getMaxTimesInlineLarge();
public:
AnalyzerOptions() : CXXMemberInliningMode() {
AnalysisStoreOpt = RegionStoreModel;
AnalysisConstraintsOpt = RangeConstraintsModel;
AnalysisDiagOpt = PD_HTML;
AnalysisPurgeOpt = PurgeStmt;
IPAMode = DynamicDispatchBifurcate;
ShowCheckerHelp = 0;
AnalyzeAll = 0;
AnalyzerDisplayProgress = 0;
AnalyzeNestedBlocks = 0;
eagerlyAssumeBinOpBifurcation = 0;
TrimGraph = 0;
visualizeExplodedGraphWithGraphViz = 0;
visualizeExplodedGraphWithUbiGraph = 0;
UnoptimizedCFG = 0;
PrintStats = 0;
NoRetryExhausted = 0;
// Cap the stack depth at 4 calls (5 stack frames, base + 4 calls).
InlineMaxStackDepth = 5;
InlineMaxFunctionSize = 50;
InliningMode = NoRedundancy;
}
};
typedef llvm::IntrusiveRefCntPtr<AnalyzerOptions> AnalyzerOptionsRef;
}
#endif
|