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