]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
MFC r355940:
[FreeBSD/FreeBSD.git] / contrib / llvm-project / clang / include / clang / StaticAnalyzer / Core / AnalyzerOptions.def
1 //===-- AnalyzerOptions.def - Metadata about Static Analyses ----*- 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 the analyzer options avaible with -analyzer-config.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #ifndef LLVM_ADT_STRINGREF_H
14 #error This .def file is expected to be included in translation units where \
15 "llvm/ADT/StringRef.h" is already included!
16 #endif
17
18 #ifdef ANALYZER_OPTION
19 #ifndef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
20 #error If you didnt include this file with the intent of generating methods, \
21 define both 'ANALYZER_OPTION' and 'ANALYZER_OPTION_DEPENDS_ON_USER_MODE' macros!
22 #endif
23 #endif
24
25 #ifndef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
26 #ifdef ANALYZER_OPTION
27 #error If you didnt include this file with the intent of generating methods, \
28 define both 'ANALYZER_OPTION' and 'ANALYZER_OPTION_DEPENDS_ON_USER_MODE' macros!
29 #endif
30 #endif
31
32 #ifndef ANALYZER_OPTION
33 /// Create a new analyzer option, but dont generate a method for it in
34 /// AnalyzerOptions.
35 ///
36 ///   TYPE - The type of the option object that will be stored in
37 ///          AnalyzerOptions. This file is expected to be icluded in translation
38 ///          units where AnalyzerOptions.h is included, so types from that
39 ///          header should be used.
40 ///   NAME - The name of the option object.
41 ///   CMDFLAG - The command line flag for the option.
42 ///             (-analyzer-config CMDFLAG=VALUE)
43 ///   DESC - Description of the flag.
44 ///   DEFAULT_VAL - The default value for CMDFLAG.
45 #define ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC, DEFAULT_VAL)
46 #endif
47
48 #ifndef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
49 /// Create a new analyzer option, but dont generate a method for it in
50 /// AnalyzerOptions. It's value depends on the option "user-mode".
51 ///
52 ///   TYPE - The type of the option object that will be stored in
53 ///          AnalyzerOptions. This file is expected to be icluded in translation
54 ///          units where AnalyzerOptions.h is included, so types from that
55 ///          header should be used.
56 ///   NAME - The name of the option object.
57 ///   CMDFLAG - The command line flag for the option.
58 ///             (-analyzer-config CMDFLAG=VALUE)
59 ///   DESC - Description of the flag.
60 ///   SHALLOW_VAL - The default value for CMDFLAG, when "user-mode" was set to
61 ///                 "shallow".
62 ///   DEEP_VAL - The default value for CMDFLAG, when "user-mode" was set to
63 ///              "deep".
64 #define ANALYZER_OPTION_DEPENDS_ON_USER_MODE(TYPE, NAME, CMDFLAG, DESC,        \
65                                              SHALLOW_VAL, DEEP_VAL)
66 #endif
67
68 //===----------------------------------------------------------------------===//
69 // The "mode" option. Since some options depend on this, we list it on top of
70 // this file in order to make sure that the generated field for it is
71 // initialized before the rest.
72 //===----------------------------------------------------------------------===//
73
74 ANALYZER_OPTION(
75     StringRef, UserMode, "mode",
76     "(string) Controls the high-level analyzer mode, which influences the "
77     "default settings for some of the lower-level config options (such as "
78     "IPAMode). Value: \"deep\", \"shallow\".",
79     "deep")
80
81 //===----------------------------------------------------------------------===//
82 // Boolean analyzer options.
83 //===----------------------------------------------------------------------===//
84
85 ANALYZER_OPTION(bool, ShouldIncludeImplicitDtorsInCFG, "cfg-implicit-dtors",
86                 "Whether or not implicit destructors for C++ objects "
87                 "should be included in the CFG.",
88                 true)
89
90 ANALYZER_OPTION(bool, ShouldIncludeTemporaryDtorsInCFG, "cfg-temporary-dtors",
91                 "Whether or not the destructors for C++ temporary "
92                 "objects should be included in the CFG.",
93                 true)
94
95 ANALYZER_OPTION(
96     bool, ShouldIncludeLifetimeInCFG, "cfg-lifetime",
97     "Whether or not end-of-lifetime information should be included in the CFG.",
98     false)
99
100 ANALYZER_OPTION(bool, ShouldIncludeLoopExitInCFG, "cfg-loopexit",
101                 "Whether or not the end of the loop information should "
102                 "be included in the CFG.",
103                 false)
104
105 ANALYZER_OPTION(bool, ShouldIncludeRichConstructorsInCFG,
106                 "cfg-rich-constructors",
107                 "Whether or not construction site information should be "
108                 "included in the CFG C++ constructor elements.",
109                 true)
110
111 ANALYZER_OPTION(
112     bool, ShouldIncludeScopesInCFG, "cfg-scopes",
113     "Whether or not scope information should be included in the CFG.", false)
114
115 ANALYZER_OPTION(
116     bool, MayInlineTemplateFunctions, "c++-template-inlining",
117     "Whether or not templated functions may be considered for inlining.", true)
118
119 ANALYZER_OPTION(bool, MayInlineCXXStandardLibrary, "c++-stdlib-inlining",
120                 "Whether or not C++ standard library functions may be "
121                 "considered for inlining.",
122                 true)
123
124 ANALYZER_OPTION(bool, MayInlineCXXAllocator, "c++-allocator-inlining",
125                 "Whether or not allocator call may be considered for inlining.",
126                 true)
127
128 ANALYZER_OPTION(
129     bool, MayInlineCXXSharedPtrDtor, "c++-shared_ptr-inlining",
130     "Whether or not the destructor of C++ 'shared_ptr' may be considered for "
131     "inlining. This covers std::shared_ptr, std::tr1::shared_ptr, and "
132     "boost::shared_ptr, and indeed any destructor named '~shared_ptr'.",
133     false)
134
135 ANALYZER_OPTION(bool, MayInlineCXXTemporaryDtors, "c++-temp-dtor-inlining",
136                 "Whether C++ temporary destructors should be inlined "
137                 "during analysis. If temporary destructors are disabled "
138                 "in the CFG via the 'cfg-temporary-dtors' option, "
139                 "temporary destructors would not be inlined anyway.",
140                 true)
141
142 ANALYZER_OPTION(
143     bool, ShouldSuppressNullReturnPaths, "suppress-null-return-paths",
144     "Whether or not paths that go through null returns should be suppressed. "
145     "This is a heuristic for avoiding bug reports with paths that go through "
146     "inlined functions that are more defensive than their callers.",
147     true)
148
149 ANALYZER_OPTION(
150     bool, ShouldAvoidSuppressingNullArgumentPaths,
151     "avoid-suppressing-null-argument-paths",
152     "Whether a bug report should not be suppressed if its path includes a call "
153     "with a null argument, even if that call has a null return. This option "
154     "has no effect when ShouldSuppressNullReturnPaths is false. This is a "
155     "counter-heuristic to avoid false negatives.",
156     false)
157
158 ANALYZER_OPTION(bool, ShouldSuppressInlinedDefensiveChecks,
159                 "suppress-inlined-defensive-checks",
160                 "Whether or not diagnostics containing inlined "
161                 "defensive NULL checks should be suppressed.",
162                 true)
163
164 ANALYZER_OPTION(bool, MayInlineCXXContainerMethods, "c++-container-inlining",
165                 "Whether or not methods of C++ container objects may be "
166                 "considered for inlining.",
167                 false)
168
169 ANALYZER_OPTION(bool, ShouldSuppressFromCXXStandardLibrary,
170                 "suppress-c++-stdlib",
171                 "Whether or not diagnostics reported within the C++ "
172                 "standard library should be suppressed.",
173                 true)
174
175 ANALYZER_OPTION(bool, ShouldCrosscheckWithZ3, "crosscheck-with-z3",
176                 "Whether bug reports should be crosschecked with the Z3 "
177                 "constraint manager backend.",
178                 false)
179
180 ANALYZER_OPTION(bool, ShouldReportIssuesInMainSourceFile,
181                 "report-in-main-source-file",
182                 "Whether or not the diagnostic report should be always "
183                 "reported in the main source file and not the headers.",
184                 false)
185
186 ANALYZER_OPTION(bool, ShouldWriteStableReportFilename, "stable-report-filename",
187                 "Whether or not the report filename should be random or not.",
188                 false)
189
190 ANALYZER_OPTION(
191     bool, ShouldSerializeStats, "serialize-stats",
192     "Whether the analyzer should serialize statistics to plist output. "
193     "Statistics would be serialized in JSON format inside the main dictionary "
194     "under the statistics key. Available only if compiled in assert mode or "
195     "with LLVM statistics explicitly enabled.",
196     false)
197
198 ANALYZER_OPTION(bool, MayInlineObjCMethod, "objc-inlining",
199                 "Whether ObjectiveC inlining is enabled, false otherwise.",
200                 true)
201
202 ANALYZER_OPTION(bool, ShouldPrunePaths, "prune-paths",
203                 "Whether irrelevant parts of a bug report path should "
204                 "be pruned out of the final output.",
205                 true)
206
207 ANALYZER_OPTION(bool, ShouldAddPopUpNotes, "add-pop-up-notes",
208                 "Whether pop-up notes should be added to the final output.",
209                 true)
210
211 ANALYZER_OPTION(
212     bool, ShouldConditionalizeStaticInitializers,
213     "cfg-conditional-static-initializers",
214     "Whether 'static' initializers should be in conditional logic in the CFG.",
215     true)
216
217 ANALYZER_OPTION(bool, ShouldSynthesizeBodies, "faux-bodies",
218                 "Whether the analyzer engine should synthesize fake "
219                 "bodies for well-known functions.",
220                 true)
221
222 ANALYZER_OPTION(
223     bool, ShouldElideConstructors, "elide-constructors",
224     "Whether elidable C++ copy-constructors and move-constructors should be "
225     "actually elided during analysis. Both behaviors are allowed by the C++ "
226     "standard, and the analyzer, like CodeGen, defaults to eliding. Starting "
227     "with C++17 some elisions become mandatory, and in these cases the option "
228     "will be ignored.",
229     true)
230
231 ANALYZER_OPTION(
232     bool, ShouldInlineLambdas, "inline-lambdas",
233     "Whether lambdas should be inlined. Otherwise a sink node will be "
234     "generated each time a LambdaExpr is visited.",
235     true)
236
237 ANALYZER_OPTION(bool, ShouldWidenLoops, "widen-loops",
238                 "Whether the analysis should try to widen loops.", false)
239
240 ANALYZER_OPTION(
241     bool, ShouldUnrollLoops, "unroll-loops",
242     "Whether the analysis should try to unroll loops with known bounds.", false)
243
244 ANALYZER_OPTION(
245     bool, ShouldDisplayNotesAsEvents, "notes-as-events",
246     "Whether the bug reporter should transparently treat extra note diagnostic "
247     "pieces as event diagnostic pieces. Useful when the diagnostic consumer "
248     "doesn't support the extra note pieces.",
249     false)
250
251 ANALYZER_OPTION(
252     bool, ShouldAggressivelySimplifyBinaryOperation,
253     "aggressive-binary-operation-simplification",
254     "Whether SValBuilder should rearrange comparisons and additive operations "
255     "of symbolic expressions which consist of a sum of a symbol and a concrete "
256     "integer into the format where symbols are on the left-hand side and the "
257     "integer is on the right. This is only done if both symbols and both "
258     "concrete integers are signed, greater than or equal to the quarter of the "
259     "minimum value of the type and less than or equal to the quarter of the "
260     "maximum value of that type. A + n <OP> B + m becomes A - B <OP> m - n, "
261     "where A and B symbolic, n and m are integers. <OP> is any of '==', '!=', "
262     "'<', '<=', '>', '>=', '+' or '-'. The rearrangement also happens with '-' "
263     "instead of '+' on either or both side and also if any or both integers "
264     "are missing.",
265     false)
266
267 ANALYZER_OPTION(
268     bool, ShouldEagerlyAssume, "eagerly-assume",
269     "Whether we should eagerly assume evaluations of conditionals, thus, "
270     "bifurcating the path. This indicates how the engine should handle "
271     "expressions such as: 'x = (y != 0)'. When this is true then the "
272     "subexpression 'y != 0' will be eagerly assumed to be true or false, thus "
273     "evaluating it to the integers 0 or 1 respectively. The upside is that "
274     "this can increase analysis precision until we have a better way to lazily "
275     "evaluate such logic. The downside is that it eagerly bifurcates paths.",
276     true)
277
278 ANALYZER_OPTION(
279     bool, IsNaiveCTUEnabled, "experimental-enable-naive-ctu-analysis",
280     "Whether naive cross translation unit analysis is enabled. This is an "
281     "experimental feature to inline functions from other translation units.",
282     false)
283
284 ANALYZER_OPTION(bool, ShouldDisplayMacroExpansions, "expand-macros",
285                 "Whether macros related to the bugpath should be "
286                 "expanded and included in the plist output.",
287                 false)
288
289 ANALYZER_OPTION(bool, DisplayCTUProgress, "display-ctu-progress",
290                 "Whether to emit verbose output about "
291                 "the analyzer's progress related to ctu.",
292                 false)
293
294 ANALYZER_OPTION(bool, ShouldTrackConditions, "track-conditions",
295                 "Whether to track conditions that are a control dependency of "
296                 "an already tracked variable.",
297                 false)
298
299 ANALYZER_OPTION(bool, ShouldTrackConditionsDebug, "track-conditions-debug",
300                 "Whether to place an event at each tracked condition.",
301                 false)
302
303 ANALYZER_OPTION(unsigned, CTUImportThreshold, "ctu-import-threshold",
304                 "The maximal amount of translation units that is considered "
305                 "for import when inlining functions during CTU analysis. "
306                 "Lowering this threshold can alleviate the memory burder of "
307                 "analysis with many interdependent definitions located in "
308                 "various translation units.",
309                 100u)
310
311 //===----------------------------------------------------------------------===//
312 // Unsinged analyzer options.
313 //===----------------------------------------------------------------------===//
314
315 ANALYZER_OPTION(
316     unsigned, AlwaysInlineSize, "ipa-always-inline-size",
317     "The size of the functions (in basic blocks), which should be considered "
318     "to be small enough to always inline.",
319     3)
320
321 ANALYZER_OPTION(
322     unsigned, GraphTrimInterval, "graph-trim-interval",
323     "How often nodes in the ExplodedGraph should be recycled to save memory. "
324     "To disable node reclamation, set the option to 0.",
325     1000)
326
327 ANALYZER_OPTION(
328     unsigned, MinCFGSizeTreatFunctionsAsLarge,
329     "min-cfg-size-treat-functions-as-large",
330     "The number of basic blocks a function needs to have to be considered "
331     "large for the 'max-times-inline-large' config option.",
332     14)
333
334 ANALYZER_OPTION(unsigned, MaxSymbolComplexity, "max-symbol-complexity",
335                 "The maximum complexity of symbolic constraint.", 35)
336
337 ANALYZER_OPTION(unsigned, MaxTimesInlineLarge, "max-times-inline-large",
338                 "The maximum times a large function could be inlined.", 32)
339
340 ANALYZER_OPTION_DEPENDS_ON_USER_MODE(
341     unsigned, MaxInlinableSize, "max-inlinable-size",
342     "The bound on the number of basic blocks in an inlined function.",
343     /* SHALLOW_VAL */ 4, /* DEEP_VAL */ 100)
344
345 ANALYZER_OPTION_DEPENDS_ON_USER_MODE(
346     unsigned, MaxNodesPerTopLevelFunction, "max-nodes",
347     "The maximum number of nodes the analyzer can generate while exploring a "
348     "top level function (for each exploded graph). 0 means no limit.",
349     /* SHALLOW_VAL */ 75000, /* DEEP_VAL */ 225000)
350
351 ANALYZER_OPTION(
352     unsigned, RegionStoreSmallStructLimit, "region-store-small-struct-limit",
353     "The largest number of fields a struct can have and still be considered "
354     "small This is currently used to decide whether or not it is worth forcing "
355     "a LazyCompoundVal on bind. To disable all small-struct-dependent "
356     "behavior, set the option to 0.",
357     2)
358
359 //===----------------------------------------------------------------------===//
360 // String analyzer options.
361 //===----------------------------------------------------------------------===//
362
363 ANALYZER_OPTION(StringRef, CTUDir, "ctu-dir",
364                 "The directory containing the CTU related files.", "")
365
366 ANALYZER_OPTION(StringRef, CTUIndexName, "ctu-index-name",
367                 "the name of the file containing the CTU index of definitions.",
368                 "externalDefMap.txt")
369
370 ANALYZER_OPTION(
371     StringRef, ModelPath, "model-path",
372     "The analyzer can inline an alternative implementation written in C at the "
373     "call site if the called function's body is not available. This is a path "
374     "where to look for those alternative implementations (called models).",
375     "")
376
377 ANALYZER_OPTION(
378     StringRef, CXXMemberInliningMode, "c++-inlining",
379     "Controls which C++ member functions will be considered for inlining. "
380     "Value: \"constructors\", \"destructors\", \"methods\".",
381     "destructors")
382
383 ANALYZER_OPTION_DEPENDS_ON_USER_MODE(
384     StringRef, IPAMode, "ipa",
385     "Controls the mode of inter-procedural analysis. Value: \"none\", "
386     "\"basic-inlining\", \"inlining\", \"dynamic\", \"dynamic-bifurcate\".",
387     /* SHALLOW_VAL */ "inlining", /* DEEP_VAL */ "dynamic-bifurcate")
388
389 ANALYZER_OPTION(
390     StringRef, ExplorationStrategy, "exploration_strategy",
391     "Value: \"dfs\", \"bfs\", \"unexplored_first\", "
392     "\"unexplored_first_queue\", \"unexplored_first_location_queue\", "
393     "\"bfs_block_dfs_contents\".",
394     "unexplored_first_queue")
395
396 #undef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
397 #undef ANALYZER_OPTION