1//===-- AnalyzerOptions.def - Metadata about Static Analyses ----*- 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 the analyzer options avaible with -analyzer-config.
11//
12// This file is in part intended for method generation. If it's not included
13// for that purpose, the following function-like macros should be predefined,
14// through which all registered options are accessible:
15//
16// * ANALYZER_OPTION: Register a new option.
17// * ANALYZER_OPTION_DEPENDS_ON_USER_MODE: Register a new option, default
18// value depends on the "user-mode" option.
19//
20// Options where a simple getter method is sufficient are registered with the
21// following macros:
22//
23// * ANALYZER_OPTION_GEN_FN: Register a new option, and generate a getter
24// method for it in AnalyzerOptions.
25//
26// * ANALYZER_OPTION_GEN_FN_DEPENDS_ON_USER_MODE: Same as above, but
27// generates a getter function that depends on the "user-mode" option.
28//
29// You can only include this file when both or none of the above two macros
30// are defined!
31// When they are defined, entries that do not generate functions won't appear,
32// and when they aren't, all entries are converted to ANALYZER_OPTION or to
33// ANALYZER_OPTION_DEPENDS_ON_USER_MODE.
34//
35//===----------------------------------------------------------------------===//
36
37#ifndef LLVM_ADT_STRINGREF_H
38#error This .def file is expected to be included in translation units where \
39"llvm/ADT/StringRef.h" is already included!
40#endif
41
42#ifdef ANALYZER_OPTION
43#ifndef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
44#error If you didnt include this file with the intent of generating methods, \
45define both 'ANALYZER_OPTION' and 'ANALYZER_OPTION_DEPENDS_ON_USER_MODE' macros!
46#endif
47#endif
48
49#ifndef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
50#ifdef ANALYZER_OPTION
51#error If you didnt include this file with the intent of generating methods, \
52define both 'ANALYZER_OPTION' and 'ANALYZER_OPTION_DEPENDS_ON_USER_MODE' macros!
53#endif
54#endif
55
56#ifdef ANALYZER_OPTION_GEN_FN
57#ifndef ANALYZER_OPTION_GEN_FN_DEPENDS_ON_USER_MODE
58#error If you include this file with the intent of generating functions, \
59define both 'ANALYZER_OPTION_GEN_FN' and \
60'ANALYZER_OPTION_GEN_FN_DEPENDS_ON_USER_MODE' macros!
61#endif
62#endif
63
64#ifdef ANALYZER_OPTION_GEN_FN_DEPENDS_ON_USER_MODE
65#ifndef ANALYZER_OPTION_GEN_FN
66#error If you include this file with the intent of generating functions, \
67define both 'ANALYZER_OPTION_GEN_FN' and \
68'ANALYZER_OPTION_GEN_FN_DEPENDS_ON_USER_MODE' macros!
69#endif
70#endif
71
72#ifndef ANALYZER_OPTION
73/// Create a new analyzer option, but dont generate a method for it in
74/// AnalyzerOptions.
75///
76/// TYPE - The type of the option object that will be stored in
77/// AnalyzerOptions. This file is expected to be icluded in translation
78/// units where AnalyzerOptions.h is included, so types from that
79/// header should be used.
80/// NAME - The name of the option object.
81/// CMDFLAG - The command line flag for the option.
82/// (-analyzer-config CMDFLAG=VALUE)
83/// DESC - Description of the flag.
84/// DEFAULT_VAL - The default value for CMDFLAG.
85#define ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC, DEFAULT_VAL)
86#endif
87
88#ifndef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
89/// Create a new analyzer option, but dont generate a method for it in
90/// AnalyzerOptions. It's value depends on the option "user-mode".
91///
92/// TYPE - The type of the option object that will be stored in
93/// AnalyzerOptions. This file is expected to be icluded in translation
94/// units where AnalyzerOptions.h is included, so types from that
95/// header should be used.
96/// NAME - The name of the option object.
97/// CMDFLAG - The command line flag for the option.
98/// (-analyzer-config CMDFLAG=VALUE)
99/// DESC - Description of the flag.
100/// SHALLOW_VAL - The default value for CMDFLAG, when "user-mode" was set to
101/// "shallow".
102/// DEEP_VAL - The default value for CMDFLAG, when "user-mode" was set to
103/// "deep".
104#define ANALYZER_OPTION_DEPENDS_ON_USER_MODE(TYPE, NAME, CMDFLAG, DESC, \
105 SHALLOW_VAL, DEEP_VAL)
106#endif
107
108#ifndef ANALYZER_OPTION_GEN_FN
109/// Create a new analyzer option, and generate a getter method for it in
110/// AnalyzerOptions.
111///
112/// TYPE - The type of the option object that will be stored in
113/// AnalyzerOptions. This file is expected to be icluded in translation
114/// units where AnalyzerOptions.h is included, so types from that
115/// header should be used.
116/// NAME - The name of the option object.
117/// CMDFLAG - The command line flag for the option.
118/// (-analyzer-config CMDFLAG=VALUE)
119/// DESC - Description of the flag.
120/// DEFAULT_VAL - The default value for CMDFLAG.
121/// CREATE_FN - Name of the getter function.
122//
123// If this def file wasn't included with the intent of generating functions,
124// regard all entries as ANALYZER_OPTION.
125#define ANALYZER_OPTION_GEN_FN(TYPE, NAME, CMDFLAG, DESC, DEFAULT_VAL, \
126 CREATE_FN) \
127 ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC, DEFAULT_VAL)
128#endif
129
130#ifndef ANALYZER_OPTION_GEN_FN_DEPENDS_ON_USER_MODE
131/// Create a new analyzer option, and generate a getter method for it in
132/// AnalyzerOptions, and make it's default value depend on the "user-mode"
133/// option.
134///
135/// TYPE - The type of the option object that will be stored in
136/// AnalyzerOptions. This file is expected to be icluded in translation
137/// units where AnalyzerOptions.h is included, so types from that
138/// header should be used.
139/// NAME - The name of the option object.
140/// CMDFLAG - The command line flag for the option.
141/// (-analyzer-config CMDFLAG=VALUE)
142/// DESC - Description of the flago.
143/// SHALLOW_VAL - The default value for CMDFLAG, when "user-mode" was set to
144/// "shallow".
145/// DEEP_VAL - The default value for CMDFLAG, when "user-mode" was set to
146/// "deep".
147/// CREATE_FN - Name of the getter function.
148//
149// If this def file wasn't included with the intent of generating functions,
150// regard all entries as ANALYZER_OPTION_DEPENDS_ON_USER_MODE.
151#define ANALYZER_OPTION_GEN_FN_DEPENDS_ON_USER_MODE( \
152 TYPE, NAME, CMDFLAG, DESC, SHALLOW_VAL, DEEP_VAL, CREATE_FN) \
153 ANALYZER_OPTION_DEPENDS_ON_USER_MODE(TYPE, NAME, CMDFLAG, DESC, SHALLOW_VAL, \
154 DEEP_VAL)
155#endif
156
157//===----------------------------------------------------------------------===//
158// Boolean analyzer options.
159//===----------------------------------------------------------------------===//
160
161ANALYZER_OPTION_GEN_FN(bool, IncludeImplicitDtorsInCFG, "cfg-implicit-dtors",
162 "Whether or not implicit destructors for C++ objects "
163 "should be included in the CFG.",
164 true, includeImplicitDtorsInCFG)
165
166ANALYZER_OPTION_GEN_FN(bool, IncludeTemporaryDtorsInCFG, "cfg-temporary-dtors",
167 "Whether or not the destructors for C++ temporary "
168 "objects should be included in the CFG.",
169 true, includeTemporaryDtorsInCFG)
170
171ANALYZER_OPTION_GEN_FN(
172 bool, IncludeLifetimeInCFG, "cfg-lifetime",
173 "Whether or not end-of-lifetime information should be included in the CFG.",
174 false, includeLifetimeInCFG)
175
176ANALYZER_OPTION_GEN_FN(bool, IncludeLoopExitInCFG, "cfg-loopexit",
177 "Whether or not the end of the loop information should "
178 "be included in the CFG.",
179 false, includeLoopExitInCFG)
180
181ANALYZER_OPTION_GEN_FN(bool, IncludeRichConstructorsInCFG,
182 "cfg-rich-constructors",
183 "Whether or not construction site information should be "
184 "included in the CFG C++ constructor elements.",
185 true, includeRichConstructorsInCFG)
186
187ANALYZER_OPTION_GEN_FN(
188 bool, IncludeScopesInCFG, "cfg-scopes",
189 "Whether or not scope information should be included in the CFG.", false,
190 includeScopesInCFG)
191
192ANALYZER_OPTION_GEN_FN(
193 bool, InlineTemplateFunctions, "c++-template-inlining",
194 "Whether or not templated functions may be considered for inlining.", true,
195 mayInlineTemplateFunctions)
196
197ANALYZER_OPTION_GEN_FN(bool, InlineCXXStandardLibrary, "c++-stdlib-inlining",
198 "Whether or not C++ standard library functions may be "
199 "considered for inlining.",
200 true, mayInlineCXXStandardLibrary)
201
202ANALYZER_OPTION_GEN_FN(
203 bool, InlineCXXAllocator, "c++-allocator-inlining",
204 "Whether or not allocator call may be considered for inlining.", true,
205 mayInlineCXXAllocator)
206
207ANALYZER_OPTION_GEN_FN(
208 bool, InlineCXXSharedPtrDtor, "c++-shared_ptr-inlining",
209 "Whether or not the destructor of C++ 'shared_ptr' may be considered for "
210 "inlining. This covers std::shared_ptr, std::tr1::shared_ptr, and "
211 "boost::shared_ptr, and indeed any destructor named '~shared_ptr'.",
212 false, mayInlineCXXSharedPtrDtor)
213
214ANALYZER_OPTION_GEN_FN(bool, InlineCXXTemporaryDtors, "c++-temp-dtor-inlining",
215 "Whether C++ temporary destructors should be inlined "
216 "during analysis. If temporary destructors are disabled "
217 "in the CFG via the 'cfg-temporary-dtors' option, "
218 "temporary destructors would not be inlined anyway.",
219 true, mayInlineCXXTemporaryDtors)
220
221ANALYZER_OPTION_GEN_FN(
222 bool, SuppressNullReturnPaths, "suppress-null-return-paths",
223 "Whether or not paths that go through null returns should be suppressed. "
224 "This is a heuristic for avoiding bug reports with paths that go through "
225 "inlined functions that are more defensive than their callers.",
226 true, shouldSuppressNullReturnPaths)
227
228ANALYZER_OPTION_GEN_FN(
229 bool, AvoidSuppressingNullArgumentPaths,
230 "avoid-suppressing-null-argument-paths",
231 "Whether a bug report should not be suppressed if its path includes a call "
232 "with a null argument, even if that call has a null return. This option "
233 "has no effect when #shouldSuppressNullReturnPaths() is false. This is a "
234 "counter-heuristic to avoid false negatives.",
235 false, shouldAvoidSuppressingNullArgumentPaths)
236
237ANALYZER_OPTION_GEN_FN(bool, SuppressInlinedDefensiveChecks,
238 "suppress-inlined-defensive-checks",
239 "Whether or not diagnostics containing inlined "
240 "defensive NULL checks should be suppressed.",
241 true, shouldSuppressInlinedDefensiveChecks)
242
243ANALYZER_OPTION_GEN_FN(bool, InlineCXXContainerMethods,
244 "c++-container-inlining",
245 "Whether or not methods of C++ container objects may be "
246 "considered for inlining.",
247 false, mayInlineCXXContainerMethods)
248
249ANALYZER_OPTION_GEN_FN(bool, SuppressFromCXXStandardLibrary,
250 "suppress-c++-stdlib",
251 "Whether or not diagnostics reported within the C++ "
252 "standard library should be suppressed.",
253 true, shouldSuppressFromCXXStandardLibrary)
254
255ANALYZER_OPTION_GEN_FN(bool, CrosscheckWithZ3, "crosscheck-with-z3",
256 "Whether bug reports should be crosschecked with the Z3 "
257 "constraint manager backend.",
258 false, shouldCrosscheckWithZ3)
259
260ANALYZER_OPTION_GEN_FN(bool, ReportIssuesInMainSourceFile,
261 "report-in-main-source-file",
262 "Whether or not the diagnostic report should be always "
263 "reported in the main source file and not the headers.",
264 false, shouldReportIssuesInMainSourceFile)
265
266ANALYZER_OPTION_GEN_FN(
267 bool, WriteStableReportFilename, "stable-report-filename",
268 "Whether or not the report filename should be random or not.", false,
269 shouldWriteStableReportFilename)
270
271ANALYZER_OPTION_GEN_FN(
272 bool, SerializeStats, "serialize-stats",
273 "Whether the analyzer should serialize statistics to plist output. "
274 "Statistics would be serialized in JSON format inside the main dictionary "
275 "under the statistics key. Available only if compiled in assert mode or "
276 "with LLVM statistics explicitly enabled.",
277 false, shouldSerializeStats)
278
279ANALYZER_OPTION_GEN_FN(
280 bool, InlineObjCMethod, "objc-inlining",
281 "Whether ObjectiveC inlining is enabled, false otherwise.", true,
282 mayInlineObjCMethod)
283
284ANALYZER_OPTION_GEN_FN(bool, PrunePaths, "prune-paths",
285 "Whether irrelevant parts of a bug report path should "
286 "be pruned out of the final output.",
287 true, shouldPrunePaths)
288
289ANALYZER_OPTION_GEN_FN(
290 bool, ConditionalizeStaticInitializers,
291 "cfg-conditional-static-initializers",
292 "Whether 'static' initializers should be in conditional logic in the CFG.",
293 true, shouldConditionalizeStaticInitializers)
294
295ANALYZER_OPTION_GEN_FN(bool, SynthesizeBodies, "faux-bodies",
296 "Whether the analyzer engine should synthesize fake "
297 "bodies for well-known functions.",
298 true, shouldSynthesizeBodies)
299
300ANALYZER_OPTION_GEN_FN(
301 bool, ElideConstructors, "elide-constructors",
302 "Whether elidable C++ copy-constructors and move-constructors should be "
303 "actually elided during analysis. Both behaviors are allowed by the C++ "
304 "standard, and the analyzer, like CodeGen, defaults to eliding. Starting "
305 "with C++17 some elisions become mandatory, and in these cases the option "
306 "will be ignored.",
307 true, shouldElideConstructors)
308
309ANALYZER_OPTION_GEN_FN(
310 bool, InlineLambdas, "inline-lambdas",
311 "Whether lambdas should be inlined. Otherwise a sink node will be "
312 "generated each time a LambdaExpr is visited.",
313 true, shouldInlineLambdas)
314
315ANALYZER_OPTION_GEN_FN(bool, WidenLoops, "widen-loops",
316 "Whether the analysis should try to widen loops.", false,
317 shouldWidenLoops)
318
319ANALYZER_OPTION_GEN_FN(
320 bool, UnrollLoops, "unroll-loops",
321 "Whether the analysis should try to unroll loops with known bounds.", false,
322 shouldUnrollLoops)
323
324ANALYZER_OPTION_GEN_FN(
325 bool, DisplayNotesAsEvents, "notes-as-events",
326 "Whether the bug reporter should transparently treat extra note diagnostic "
327 "pieces as event diagnostic pieces. Useful when the diagnostic consumer "
328 "doesn't support the extra note pieces.",
329 false, shouldDisplayNotesAsEvents)
330
331ANALYZER_OPTION_GEN_FN(
332 bool, AggressivelySimplifyBinaryOperation,
333 "aggressive-binary-operation-simplification",
334 "Whether SValBuilder should rearrange comparisons and additive operations "
335 "of symbolic expressions which consist of a sum of a symbol and a concrete "
336 "integer into the format where symbols are on the left-hand side and the "
337 "integer is on the right. This is only done if both symbols and both "
338 "concrete integers are signed, greater than or equal to the quarter of the "
339 "minimum value of the type and less than or equal to the quarter of the "
340 "maximum value of that type. A + n <OP> B + m becomes A - B <OP> m - n, "
341 "where A and B symbolic, n and m are integers. <OP> is any of '==', '!=', "
342 "'<', '<=', '>', '>=', '+' or '-'. The rearrangement also happens with '-' "
343 "instead of '+' on either or both side and also if any or both integers "
344 "are missing.",
345 false, shouldAggressivelySimplifyBinaryOperation)
346
347ANALYZER_OPTION_GEN_FN(
348 bool, EagerlyAssume, "eagerly-assume",
349 "Whether we should eagerly assume evaluations of conditionals, thus, "
350 "bifurcating the path. This indicates how the engine should handle "
351 "expressions such as: 'x = (y != 0)'. When this is true then the "
352 "subexpression 'y != 0' will be eagerly assumed to be true or false, thus "
353 "evaluating it to the integers 0 or 1 respectively. The upside is that "
354 "this can increase analysis precision until we have a better way to lazily "
355 "evaluate such logic. The downside is that it eagerly bifurcates paths.",
356 true, shouldEagerlyAssume)
357
358ANALYZER_OPTION_GEN_FN(
359 bool, NaiveCTU, "experimental-enable-naive-ctu-analysis",
360 "Whether naive cross translation unit analysis is enabled. This is an "
361 "experimental feature to inline functions from another translation units.",
362 false, naiveCTUEnabled)
363
364ANALYZER_OPTION_GEN_FN(bool, DisplayMacroExpansions, "expand-macros",
365 "Whether macros related to the bugpath should be "
366 "expanded and included in the plist output.",
367 false, shouldDisplayMacroExpansions)
368
369//===----------------------------------------------------------------------===//
370// Unsinged analyzer options.
371//===----------------------------------------------------------------------===//
372
373ANALYZER_OPTION_GEN_FN(
374 unsigned, AlwaysInlineSize, "ipa-always-inline-size",
375 "The size of the functions (in basic blocks), which should be considered "
376 "to be small enough to always inline.",
377 3, getAlwaysInlineSize)
378
379ANALYZER_OPTION_GEN_FN(
380 unsigned, GraphTrimInterval, "graph-trim-interval",
381 "How often nodes in the ExplodedGraph should be recycled to save memory. "
382 "To disable node reclamation, set the option to 0.",
383 1000, getGraphTrimInterval)
384
385ANALYZER_OPTION_GEN_FN(
386 unsigned, MinCFGSizeTreatFunctionsAsLarge,
387 "min-cfg-size-treat-functions-as-large",
388 "The number of basic blocks a function needs to have to be considered "
389 "large for the 'max-times-inline-large' config option.",
390 14, getMinCFGSizeTreatFunctionsAsLarge)
391
392ANALYZER_OPTION_GEN_FN(unsigned, MaxSymbolComplexity, "max-symbol-complexity",
393 "The maximum complexity of symbolic constraint.", 35,
394 getMaxSymbolComplexity)
395
396ANALYZER_OPTION_GEN_FN(unsigned, MaxTimesInlineLarge, "max-times-inline-large",
397 "The maximum times a large function could be inlined.",
398 32, getMaxTimesInlineLarge)
399
400ANALYZER_OPTION_GEN_FN_DEPENDS_ON_USER_MODE(
401 unsigned, MaxInlinableSize, "max-inlinable-size",
402 "The bound on the number of basic blocks in an inlined function.",
403 /* SHALLOW_VAL */ 4, /* DEEP_VAL */ 100, getMaxInlinableSize)
404
405ANALYZER_OPTION_GEN_FN_DEPENDS_ON_USER_MODE(
406 unsigned, MaxNodesPerTopLevelFunction, "max-nodes",
407 "The maximum number of nodes the analyzer can generate while exploring a "
408 "top level function (for each exploded graph). 0 means no limit.",
409 /* SHALLOW_VAL */ 75000, /* DEEP_VAL */ 225000,
410 getMaxNodesPerTopLevelFunction)
411
412ANALYZER_OPTION_GEN_FN(
413 unsigned, RegionStoreSmallStructLimit, "region-store-small-struct-limit",
414 "The largest number of fields a struct can have and still be considered "
415 "small This is currently used to decide whether or not it is worth forcing "
416 "a LazyCompoundVal on bind. To disable all small-struct-dependent "
417 "behavior, set the option to 0.",
418 2, getRegionStoreSmallStructLimit)
419
420//===----------------------------------------------------------------------===//
421// String analyzer options.
422//===----------------------------------------------------------------------===//
423
424ANALYZER_OPTION(StringRef, CTUDir, "ctu-dir",
425 "The directory containing the CTU related files.", "")
426
427ANALYZER_OPTION_GEN_FN(
428 StringRef, CTUIndexName, "ctu-index-name",
429 "the name of the file containing the CTU index of functions.",
430 "externalFnMap.txt", getCTUIndexName)
431
432ANALYZER_OPTION_GEN_FN(
433 StringRef, ModelPath, "model-path",
434 "The analyzer can inline an alternative implementation written in C at the "
435 "call site if the called function's body is not available. This is a path "
436 "where to look for those alternative implementations (called models).",
437 "", getModelPath)
438
439ANALYZER_OPTION(StringRef, UserMode, "mode",
440 "Controls the high-level analyzer mode, which influences the "
441 "default settings for some of the lower-level config options "
442 "(such as IPAMode). Value: \"deep\", \"shallow\".",
443 "deep")
444
445ANALYZER_OPTION(
446 StringRef, CXXMemberInliningMode, "c++-inlining",
447 "Controls which C++ member functions will be considered for inlining. "
448 "Value: \"constructors\", \"destructors\", \"methods\".",
449 "destructors")
450
451ANALYZER_OPTION_DEPENDS_ON_USER_MODE(
452 StringRef, IPAMode, "ipa",
453 "Controls the mode of inter-procedural analysis. Value: \"none\", "
454 "\"basic-inlining\", \"inlining\", \"dynamic\", \"dynamic-bifurcate\".",
455 /* SHALLOW_VAL */ "inlining", /* DEEP_VAL */ "dynamic-bifurcate")
456
457ANALYZER_OPTION(
458 StringRef, ExplorationStrategy, "exploration_strategy",
459 "Value: \"dfs\", \"bfs\", \"unexplored_first\", "
460 "\"unexplored_first_queue\", \"unexplored_first_location_queue\", "
461 "\"bfs_block_dfs_contents\".",
462 "unexplored_first_queue")
463
464#undef ANALYZER_OPTION_GEN_FN_DEPENDS_ON_USER_MODE
465#undef ANALYZER_OPTION_GEN_FN
466#undef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
467#undef ANALYZER_OPTION
468