Coverage Report

Created: 2018-09-25 23:22

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
Line
Count
Source
1
//===- AnalyzerOptions.h - Analysis Engine Options --------------*- 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 header defines various options for the static analyzer that are set
11
// by the frontend and are consulted throughout the analyzer.
12
//
13
//===----------------------------------------------------------------------===//
14
15
#ifndef LLVM_CLANG_STATICANALYZER_CORE_ANALYZEROPTIONS_H
16
#define LLVM_CLANG_STATICANALYZER_CORE_ANALYZEROPTIONS_H
17
18
#include "clang/Basic/LLVM.h"
19
#include "llvm/ADT/IntrusiveRefCntPtr.h"
20
#include "llvm/ADT/Optional.h"
21
#include "llvm/ADT/StringMap.h"
22
#include "llvm/ADT/StringRef.h"
23
#include <string>
24
#include <utility>
25
#include <vector>
26
27
namespace clang {
28
29
namespace ento {
30
31
class CheckerBase;
32
33
} // namespace ento
34
35
/// Analysis - Set of available source code analyses.
36
enum Analyses {
37
#define ANALYSIS(NAME, CMDFLAG, DESC, SCOPE) NAME,
38
#include "clang/StaticAnalyzer/Core/Analyses.def"
39
NumAnalyses
40
};
41
42
/// AnalysisStores - Set of available analysis store models.
43
enum AnalysisStores {
44
#define ANALYSIS_STORE(NAME, CMDFLAG, DESC, CREATFN) NAME##Model,
45
#include "clang/StaticAnalyzer/Core/Analyses.def"
46
NumStores
47
};
48
49
/// AnalysisConstraints - Set of available constraint models.
50
enum AnalysisConstraints {
51
#define ANALYSIS_CONSTRAINTS(NAME, CMDFLAG, DESC, CREATFN) NAME##Model,
52
#include "clang/StaticAnalyzer/Core/Analyses.def"
53
NumConstraints
54
};
55
56
/// AnalysisDiagClients - Set of available diagnostic clients for rendering
57
///  analysis results.
58
enum AnalysisDiagClients {
59
#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATFN) PD_##NAME,
60
#include "clang/StaticAnalyzer/Core/Analyses.def"
61
PD_NONE,
62
NUM_ANALYSIS_DIAG_CLIENTS
63
};
64
65
/// AnalysisPurgeModes - Set of available strategies for dead symbol removal.
66
enum AnalysisPurgeMode {
67
#define ANALYSIS_PURGE(NAME, CMDFLAG, DESC) NAME,
68
#include "clang/StaticAnalyzer/Core/Analyses.def"
69
NumPurgeModes
70
};
71
72
/// AnalysisInlineFunctionSelection - Set of inlining function selection heuristics.
73
enum AnalysisInliningMode {
74
#define ANALYSIS_INLINING_MODE(NAME, CMDFLAG, DESC) NAME,
75
#include "clang/StaticAnalyzer/Core/Analyses.def"
76
NumInliningModes
77
};
78
79
/// Describes the different kinds of C++ member functions which can be
80
/// considered for inlining by the analyzer.
81
///
82
/// These options are cumulative; enabling one kind of member function will
83
/// enable all kinds with lower enum values.
84
enum CXXInlineableMemberKind {
85
  // Uninitialized = 0,
86
87
  /// A dummy mode in which no C++ inlining is enabled.
88
  CIMK_None = 1,
89
90
  /// Refers to regular member function and operator calls.
91
  CIMK_MemberFunctions,
92
93
  /// Refers to constructors (implicit or explicit).
94
  ///
95
  /// Note that a constructor will not be inlined if the corresponding
96
  /// destructor is non-trivial.
97
  CIMK_Constructors,
98
99
  /// Refers to destructors (implicit or explicit).
100
  CIMK_Destructors
101
};
102
103
/// Describes the different modes of inter-procedural analysis.
104
enum IPAKind {
105
  IPAK_NotSet = 0,
106
107
  /// Perform only intra-procedural analysis.
108
  IPAK_None = 1,
109
110
  /// Inline C functions and blocks when their definitions are available.
111
  IPAK_BasicInlining = 2,
112
113
  /// Inline callees(C, C++, ObjC) when their definitions are available.
114
  IPAK_Inlining = 3,
115
116
  /// Enable inlining of dynamically dispatched methods.
117
  IPAK_DynamicDispatch = 4,
118
119
  /// Enable inlining of dynamically dispatched methods, bifurcate paths when
120
  /// exact type info is unavailable.
121
  IPAK_DynamicDispatchBifurcate = 5
122
};
123
124
class AnalyzerOptions : public RefCountedBase<AnalyzerOptions> {
125
public:
126
  using ConfigTable = llvm::StringMap<std::string>;
127
128
  static std::vector<StringRef>
129
  getRegisteredCheckers(bool IncludeExperimental = false);
130
131
  /// Pair of checker name and enable/disable.
132
  std::vector<std::pair<std::string, bool>> CheckersControlList;
133
134
  /// A key-value table of use-specified configuration values.
135
  ConfigTable Config;
136
  AnalysisStores AnalysisStoreOpt = RegionStoreModel;
137
  AnalysisConstraints AnalysisConstraintsOpt = RangeConstraintsModel;
138
  AnalysisDiagClients AnalysisDiagOpt = PD_HTML;
139
  AnalysisPurgeMode AnalysisPurgeOpt = PurgeStmt;
140
141
  std::string AnalyzeSpecificFunction;
142
143
  /// Store full compiler invocation for reproducible instructions in the
144
  /// generated report.
145
  std::string FullCompilerInvocation;
146
147
  /// The maximum number of times the analyzer visits a block.
148
  unsigned maxBlockVisitOnPath;
149
150
  /// Disable all analyzer checks.
151
  ///
152
  /// This flag allows one to disable analyzer checks on the code processed by
153
  /// the given analysis consumer. Note, the code will get parsed and the
154
  /// command-line options will get checked.
155
  unsigned DisableAllChecks : 1;
156
157
  unsigned ShowCheckerHelp : 1;
158
  unsigned ShowEnabledCheckerList : 1;
159
  unsigned AnalyzeAll : 1;
160
  unsigned AnalyzerDisplayProgress : 1;
161
  unsigned AnalyzeNestedBlocks : 1;
162
163
  unsigned eagerlyAssumeBinOpBifurcation : 1;
164
165
  unsigned TrimGraph : 1;
166
  unsigned visualizeExplodedGraphWithGraphViz : 1;
167
  unsigned UnoptimizedCFG : 1;
168
  unsigned PrintStats : 1;
169
170
  /// Do not re-analyze paths leading to exhausted nodes with a different
171
  /// strategy. We get better code coverage when retry is enabled.
172
  unsigned NoRetryExhausted : 1;
173
174
  /// The inlining stack depth limit.
175
  // Cap the stack depth at 4 calls (5 stack frames, base + 4 calls).
176
  unsigned InlineMaxStackDepth = 5;
177
178
  /// The mode of function selection used during inlining.
179
  AnalysisInliningMode InliningMode = NoRedundancy;
180
181
  enum class ExplorationStrategyKind {
182
    DFS,
183
    BFS,
184
    UnexploredFirst,
185
    UnexploredFirstQueue,
186
    BFSBlockDFSContents,
187
    NotSet
188
  };
189
190
private:
191
  ExplorationStrategyKind ExplorationStrategy = ExplorationStrategyKind::NotSet;
192
193
  /// Describes the kinds for high-level analyzer mode.
194
  enum UserModeKind {
195
    UMK_NotSet = 0,
196
197
    /// Perform shallow but fast analyzes.
198
    UMK_Shallow = 1,
199
200
    /// Perform deep analyzes.
201
    UMK_Deep = 2
202
  };
203
204
  /// Controls the high-level analyzer mode, which influences the default
205
  /// settings for some of the lower-level config options (such as IPAMode).
206
  /// \sa getUserMode
207
  UserModeKind UserMode = UMK_NotSet;
208
209
  /// Controls the mode of inter-procedural analysis.
210
  IPAKind IPAMode = IPAK_NotSet;
211
212
  /// Controls which C++ member functions will be considered for inlining.
213
  CXXInlineableMemberKind CXXMemberInliningMode;
214
215
  /// \sa includeImplicitDtorsInCFG
216
  Optional<bool> IncludeImplicitDtorsInCFG;
217
218
  /// \sa includeTemporaryDtorsInCFG
219
  Optional<bool> IncludeTemporaryDtorsInCFG;
220
221
  /// \sa IncludeLifetimeInCFG
222
  Optional<bool> IncludeLifetimeInCFG;
223
224
  /// \sa IncludeLoopExitInCFG
225
  Optional<bool> IncludeLoopExitInCFG;
226
227
  /// \sa IncludeRichConstructorsInCFG
228
  Optional<bool> IncludeRichConstructorsInCFG;
229
230
  /// \sa mayInlineCXXStandardLibrary
231
  Optional<bool> InlineCXXStandardLibrary;
232
233
  /// \sa includeScopesInCFG
234
  Optional<bool> IncludeScopesInCFG;
235
236
  /// \sa mayInlineTemplateFunctions
237
  Optional<bool> InlineTemplateFunctions;
238
239
  /// \sa mayInlineCXXAllocator
240
  Optional<bool> InlineCXXAllocator;
241
242
  /// \sa mayInlineCXXContainerMethods
243
  Optional<bool> InlineCXXContainerMethods;
244
245
  /// \sa mayInlineCXXSharedPtrDtor
246
  Optional<bool> InlineCXXSharedPtrDtor;
247
248
  /// \sa mayInlineCXXTemporaryDtors
249
  Optional<bool> InlineCXXTemporaryDtors;
250
251
  /// \sa mayInlineObjCMethod
252
  Optional<bool> ObjCInliningMode;
253
254
  // Cache of the "ipa-always-inline-size" setting.
255
  // \sa getAlwaysInlineSize
256
  Optional<unsigned> AlwaysInlineSize;
257
258
  /// \sa shouldSuppressNullReturnPaths
259
  Optional<bool> SuppressNullReturnPaths;
260
261
  // \sa getMaxInlinableSize
262
  Optional<unsigned> MaxInlinableSize;
263
264
  /// \sa shouldAvoidSuppressingNullArgumentPaths
265
  Optional<bool> AvoidSuppressingNullArgumentPaths;
266
267
  /// \sa shouldSuppressInlinedDefensiveChecks
268
  Optional<bool> SuppressInlinedDefensiveChecks;
269
270
  /// \sa shouldSuppressFromCXXStandardLibrary
271
  Optional<bool> SuppressFromCXXStandardLibrary;
272
273
  /// \sa shouldCrosscheckWithZ3
274
  Optional<bool> CrosscheckWithZ3;
275
276
  /// \sa reportIssuesInMainSourceFile
277
  Optional<bool> ReportIssuesInMainSourceFile;
278
279
  /// \sa StableReportFilename
280
  Optional<bool> StableReportFilename;
281
282
  Optional<bool> SerializeStats;
283
284
  /// \sa getGraphTrimInterval
285
  Optional<unsigned> GraphTrimInterval;
286
287
  /// \sa getMaxSymbolComplexity
288
  Optional<unsigned> MaxSymbolComplexity;
289
290
  /// \sa getMaxTimesInlineLarge
291
  Optional<unsigned> MaxTimesInlineLarge;
292
293
  /// \sa getMinCFGSizeTreatFunctionsAsLarge
294
  Optional<unsigned> MinCFGSizeTreatFunctionsAsLarge;
295
296
  /// \sa getMaxNodesPerTopLevelFunction
297
  Optional<unsigned> MaxNodesPerTopLevelFunction;
298
299
  /// \sa shouldInlineLambdas
300
  Optional<bool> InlineLambdas;
301
302
  /// \sa shouldWidenLoops
303
  Optional<bool> WidenLoops;
304
305
  /// \sa shouldUnrollLoops
306
  Optional<bool> UnrollLoops;
307
308
  /// \sa shouldDisplayNotesAsEvents
309
  Optional<bool> DisplayNotesAsEvents;
310
311
  /// \sa shouldAggressivelySimplifyBinaryOperation
312
  Optional<bool> AggressiveBinaryOperationSimplification;
313
314
  /// \sa shouldEagerlyAssume
315
  Optional<bool> EagerlyAssumeBinOpBifurcation;
316
317
  /// \sa getCTUDir
318
  Optional<StringRef> CTUDir;
319
320
  /// \sa getCTUIndexName
321
  Optional<StringRef> CTUIndexName;
322
323
  /// \sa naiveCTUEnabled
324
  Optional<bool> NaiveCTU;
325
326
  /// \sa shouldElideConstructors
327
  Optional<bool> ElideConstructors;
328
329
330
  /// A helper function that retrieves option for a given full-qualified
331
  /// checker name.
332
  /// Options for checkers can be specified via 'analyzer-config' command-line
333
  /// option.
334
  /// Example:
335
  /// @code-analyzer-config unix.Malloc:OptionName=CheckerOptionValue @endcode
336
  /// or @code-analyzer-config unix:OptionName=GroupOptionValue @endcode
337
  /// for groups of checkers.
338
  /// @param [in] CheckerName  Full-qualified checker name, like
339
  /// alpha.unix.StreamChecker.
340
  /// @param [in] OptionName  Name of the option to get.
341
  /// @param [in] Default  Default value if no option is specified.
342
  /// @param [in] SearchInParents If set to true and the searched option was not
343
  /// specified for the given checker the options for the parent packages will
344
  /// be searched as well. The inner packages take precedence over the outer
345
  /// ones.
346
  /// @retval CheckerOptionValue  An option for a checker if it was specified.
347
  /// @retval GroupOptionValue  An option for group if it was specified and no
348
  /// checker-specific options were found. The closer group to checker,
349
  /// the more priority it has. For example, @c coregroup.subgroup has more
350
  /// priority than @c coregroup for @c coregroup.subgroup.CheckerName checker.
351
  /// @retval Default  If nor checker option, nor group option was found.
352
  StringRef getCheckerOption(StringRef CheckerName, StringRef OptionName,
353
                             StringRef Default,
354
                             bool SearchInParents = false);
355
356
public:
357
  AnalyzerOptions()
358
      : DisableAllChecks(false), ShowCheckerHelp(false),
359
        ShowEnabledCheckerList(false), AnalyzeAll(false),
360
        AnalyzerDisplayProgress(false), AnalyzeNestedBlocks(false),
361
        eagerlyAssumeBinOpBifurcation(false), TrimGraph(false),
362
        visualizeExplodedGraphWithGraphViz(false),
363
        UnoptimizedCFG(false),
364
50.1k
        PrintStats(false), NoRetryExhausted(false), CXXMemberInliningMode() {}
365
366
  /// Interprets an option's string value as a boolean. The "true" string is
367
  /// interpreted as true and the "false" string is interpreted as false.
368
  ///
369
  /// If an option value is not provided, returns the given \p DefaultVal.
370
  /// @param [in] Name Name for option to retrieve.
371
  /// @param [in] DefaultVal Default value returned if no such option was
372
  /// specified.
373
  /// @param [in] C The optional checker parameter that can be used to restrict
374
  /// the search to the options of this particular checker (and its parents
375
  /// depending on search mode).
376
  /// @param [in] SearchInParents If set to true and the searched option was not
377
  /// specified for the given checker the options for the parent packages will
378
  /// be searched as well. The inner packages take precedence over the outer
379
  /// ones.
380
  bool getBooleanOption(StringRef Name, bool DefaultVal,
381
                        const ento::CheckerBase *C = nullptr,
382
                        bool SearchInParents = false);
383
384
  /// Variant that accepts a Optional value to cache the result.
385
  ///
386
  /// @param [in,out] V Return value storage, returned if parameter contains
387
  /// an existing valid option, else it is used to store a return value
388
  /// @param [in] Name Name for option to retrieve.
389
  /// @param [in] DefaultVal Default value returned if no such option was
390
  /// specified.
391
  /// @param [in] C The optional checker parameter that can be used to restrict
392
  /// the search to the options of this particular checker (and its parents
393
  /// depending on search mode).
394
  /// @param [in] SearchInParents If set to true and the searched option was not
395
  /// specified for the given checker the options for the parent packages will
396
  /// be searched as well. The inner packages take precedence over the outer
397
  /// ones.
398
  bool getBooleanOption(Optional<bool> &V, StringRef Name, bool DefaultVal,
399
                        const ento::CheckerBase *C  = nullptr,
400
                        bool SearchInParents = false);
401
402
  /// Interprets an option's string value as an integer value.
403
  ///
404
  /// If an option value is not provided, returns the given \p DefaultVal.
405
  /// @param [in] Name Name for option to retrieve.
406
  /// @param [in] DefaultVal Default value returned if no such option was
407
  /// specified.
408
  /// @param [in] C The optional checker parameter that can be used to restrict
409
  /// the search to the options of this particular checker (and its parents
410
  /// depending on search mode).
411
  /// @param [in] SearchInParents If set to true and the searched option was not
412
  /// specified for the given checker the options for the parent packages will
413
  /// be searched as well. The inner packages take precedence over the outer
414
  /// ones.
415
  int getOptionAsInteger(StringRef Name, int DefaultVal,
416
                         const ento::CheckerBase *C = nullptr,
417
                         bool SearchInParents = false);
418
419
  /// Query an option's string value.
420
  ///
421
  /// If an option value is not provided, returns the given \p DefaultVal.
422
  /// @param [in] Name Name for option to retrieve.
423
  /// @param [in] DefaultVal Default value returned if no such option was
424
  /// specified.
425
  /// @param [in] C The optional checker parameter that can be used to restrict
426
  /// the search to the options of this particular checker (and its parents
427
  /// depending on search mode).
428
  /// @param [in] SearchInParents If set to true and the searched option was not
429
  /// specified for the given checker the options for the parent packages will
430
  /// be searched as well. The inner packages take precedence over the outer
431
  /// ones.
432
  StringRef getOptionAsString(StringRef Name, StringRef DefaultVal,
433
                              const ento::CheckerBase *C = nullptr,
434
                              bool SearchInParents = false);
435
436
  /// Retrieves and sets the UserMode. This is a high-level option,
437
  /// which is used to set other low-level options. It is not accessible
438
  /// outside of AnalyzerOptions.
439
  UserModeKind getUserMode();
440
441
  ExplorationStrategyKind getExplorationStrategy();
442
443
  /// Returns the inter-procedural analysis mode.
444
  IPAKind getIPAMode();
445
446
  /// Returns the option controlling which C++ member functions will be
447
  /// considered for inlining.
448
  ///
449
  /// This is controlled by the 'c++-inlining' config option.
450
  ///
451
  /// \sa CXXMemberInliningMode
452
  bool mayInlineCXXMemberFunction(CXXInlineableMemberKind K);
453
454
  /// Returns true if ObjectiveC inlining is enabled, false otherwise.
455
  bool mayInlineObjCMethod();
456
457
  /// Returns whether or not the destructors for C++ temporary objects should
458
  /// be included in the CFG.
459
  ///
460
  /// This is controlled by the 'cfg-temporary-dtors' config option, which
461
  /// accepts the values "true" and "false".
462
  bool includeTemporaryDtorsInCFG();
463
464
  /// Returns whether or not implicit destructors for C++ objects should
465
  /// be included in the CFG.
466
  ///
467
  /// This is controlled by the 'cfg-implicit-dtors' config option, which
468
  /// accepts the values "true" and "false".
469
  bool includeImplicitDtorsInCFG();
470
471
  /// Returns whether or not end-of-lifetime information should be included in
472
  /// the CFG.
473
  ///
474
  /// This is controlled by the 'cfg-lifetime' config option, which accepts
475
  /// the values "true" and "false".
476
  bool includeLifetimeInCFG();
477
478
  /// Returns whether or not the end of the loop information should be included
479
  /// in the CFG.
480
  ///
481
  /// This is controlled by the 'cfg-loopexit' config option, which accepts
482
  /// the values "true" and "false".
483
  bool includeLoopExitInCFG();
484
485
  /// Returns whether or not construction site information should be included
486
  /// in the CFG C++ constructor elements.
487
  ///
488
  /// This is controlled by the 'cfg-rich-constructors' config options,
489
  /// which accepts the values "true" and "false".
490
  bool includeRichConstructorsInCFG();
491
492
  /// Returns whether or not scope information should be included in the CFG.
493
  ///
494
  /// This is controlled by the 'cfg-scope-info' config option, which accepts
495
  /// the values "true" and "false".
496
  bool includeScopesInCFG();
497
498
  /// Returns whether or not C++ standard library functions may be considered
499
  /// for inlining.
500
  ///
501
  /// This is controlled by the 'c++-stdlib-inlining' config option, which
502
  /// accepts the values "true" and "false".
503
  bool mayInlineCXXStandardLibrary();
504
505
  /// Returns whether or not templated functions may be considered for inlining.
506
  ///
507
  /// This is controlled by the 'c++-template-inlining' config option, which
508
  /// accepts the values "true" and "false".
509
  bool mayInlineTemplateFunctions();
510
511
  /// Returns whether or not allocator call may be considered for inlining.
512
  ///
513
  /// This is controlled by the 'c++-allocator-inlining' config option, which
514
  /// accepts the values "true" and "false".
515
  bool mayInlineCXXAllocator();
516
517
  /// Returns whether or not methods of C++ container objects may be considered
518
  /// for inlining.
519
  ///
520
  /// This is controlled by the 'c++-container-inlining' config option, which
521
  /// accepts the values "true" and "false".
522
  bool mayInlineCXXContainerMethods();
523
524
  /// Returns whether or not the destructor of C++ 'shared_ptr' may be
525
  /// considered for inlining.
526
  ///
527
  /// This covers std::shared_ptr, std::tr1::shared_ptr, and boost::shared_ptr,
528
  /// and indeed any destructor named "~shared_ptr".
529
  ///
530
  /// This is controlled by the 'c++-shared_ptr-inlining' config option, which
531
  /// accepts the values "true" and "false".
532
  bool mayInlineCXXSharedPtrDtor();
533
534
  /// Returns true if C++ temporary destructors should be inlined during
535
  /// analysis.
536
  ///
537
  /// If temporary destructors are disabled in the CFG via the
538
  /// 'cfg-temporary-dtors' option, temporary destructors would not be
539
  /// inlined anyway.
540
  ///
541
  /// This is controlled by the 'c++-temp-dtor-inlining' config option, which
542
  /// accepts the values "true" and "false".
543
  bool mayInlineCXXTemporaryDtors();
544
545
  /// Returns whether or not paths that go through null returns should be
546
  /// suppressed.
547
  ///
548
  /// This is a heuristic for avoiding bug reports with paths that go through
549
  /// inlined functions that are more defensive than their callers.
550
  ///
551
  /// This is controlled by the 'suppress-null-return-paths' config option,
552
  /// which accepts the values "true" and "false".
553
  bool shouldSuppressNullReturnPaths();
554
555
  /// Returns whether a bug report should \em not be suppressed if its path
556
  /// includes a call with a null argument, even if that call has a null return.
557
  ///
558
  /// This option has no effect when #shouldSuppressNullReturnPaths() is false.
559
  ///
560
  /// This is a counter-heuristic to avoid false negatives.
561
  ///
562
  /// This is controlled by the 'avoid-suppressing-null-argument-paths' config
563
  /// option, which accepts the values "true" and "false".
564
  bool shouldAvoidSuppressingNullArgumentPaths();
565
566
  /// Returns whether or not diagnostics containing inlined defensive NULL
567
  /// checks should be suppressed.
568
  ///
569
  /// This is controlled by the 'suppress-inlined-defensive-checks' config
570
  /// option, which accepts the values "true" and "false".
571
  bool shouldSuppressInlinedDefensiveChecks();
572
573
  /// Returns whether or not diagnostics reported within the C++ standard
574
  /// library should be suppressed.
575
  ///
576
  /// This is controlled by the 'suppress-c++-stdlib' config option,
577
  /// which accepts the values "true" and "false".
578
  bool shouldSuppressFromCXXStandardLibrary();
579
580
  /// Returns whether bug reports should be crosschecked with the Z3
581
  /// constraint manager backend.
582
  ///
583
  /// This is controlled by the 'crosscheck-with-z3' config option,
584
  /// which accepts the values "true" and "false".
585
  bool shouldCrosscheckWithZ3();
586
587
  /// Returns whether or not the diagnostic report should be always reported
588
  /// in the main source file and not the headers.
589
  ///
590
  /// This is controlled by the 'report-in-main-source-file' config option,
591
  /// which accepts the values "true" and "false".
592
  bool shouldReportIssuesInMainSourceFile();
593
594
  /// Returns whether or not the report filename should be random or not.
595
  ///
596
  /// This is controlled by the 'stable-report-filename' config option,
597
  /// which accepts the values "true" and "false". Default = false
598
  bool shouldWriteStableReportFilename();
599
600
  /// \return Whether the analyzer should
601
  /// serialize statistics to plist output.
602
  /// Statistics would be serialized in JSON format inside the main dictionary
603
  /// under the \c statistics key.
604
  /// Available only if compiled in assert mode or with LLVM statistics
605
  /// explicitly enabled.
606
  bool shouldSerializeStats();
607
608
  /// Returns whether irrelevant parts of a bug report path should be pruned
609
  /// out of the final output.
610
  ///
611
  /// This is controlled by the 'prune-paths' config option, which accepts the
612
  /// values "true" and "false".
613
  bool shouldPrunePaths();
614
615
  /// Returns true if 'static' initializers should be in conditional logic
616
  /// in the CFG.
617
  bool shouldConditionalizeStaticInitializers();
618
619
  // Returns the size of the functions (in basic blocks), which should be
620
  // considered to be small enough to always inline.
621
  //
622
  // This is controlled by "ipa-always-inline-size" analyzer-config option.
623
  unsigned getAlwaysInlineSize();
624
625
  // Returns the bound on the number of basic blocks in an inlined function
626
  // (50 by default).
627
  //
628
  // This is controlled by "-analyzer-config max-inlinable-size" option.
629
  unsigned getMaxInlinableSize();
630
631
  /// Returns true if the analyzer engine should synthesize fake bodies
632
  /// for well-known functions.
633
  bool shouldSynthesizeBodies();
634
635
  /// Returns how often nodes in the ExplodedGraph should be recycled to save
636
  /// memory.
637
  ///
638
  /// This is controlled by the 'graph-trim-interval' config option. To disable
639
  /// node reclamation, set the option to "0".
640
  unsigned getGraphTrimInterval();
641
642
  /// Returns the maximum complexity of symbolic constraint (50 by default).
643
  ///
644
  /// This is controlled by "-analyzer-config max-symbol-complexity" option.
645
  unsigned getMaxSymbolComplexity();
646
647
  /// Returns the maximum times a large function could be inlined.
648
  ///
649
  /// This is controlled by the 'max-times-inline-large' config option.
650
  unsigned getMaxTimesInlineLarge();
651
652
  /// Returns the number of basic blocks a function needs to have to be
653
  /// considered large for the 'max-times-inline-large' config option.
654
  ///
655
  /// This is controlled by the 'min-cfg-size-treat-functions-as-large' config
656
  /// option.
657
  unsigned getMinCFGSizeTreatFunctionsAsLarge();
658
659
  /// Returns the maximum number of nodes the analyzer can generate while
660
  /// exploring a top level function (for each exploded graph).
661
  /// 150000 is default; 0 means no limit.
662
  ///
663
  /// This is controlled by the 'max-nodes' config option.
664
  unsigned getMaxNodesPerTopLevelFunction();
665
666
  /// Returns true if lambdas should be inlined. Otherwise a sink node will be
667
  /// generated each time a LambdaExpr is visited.
668
  bool shouldInlineLambdas();
669
670
  /// Returns true if the analysis should try to widen loops.
671
  /// This is controlled by the 'widen-loops' config option.
672
  bool shouldWidenLoops();
673
674
  /// Returns true if the analysis should try to unroll loops with known bounds.
675
  /// This is controlled by the 'unroll-loops' config option.
676
  bool shouldUnrollLoops();
677
678
  /// Returns true if the bug reporter should transparently treat extra note
679
  /// diagnostic pieces as event diagnostic pieces. Useful when the diagnostic
680
  /// consumer doesn't support the extra note pieces.
681
  ///
682
  /// This is controlled by the 'extra-notes-as-events' option, which defaults
683
  /// to false when unset.
684
  bool shouldDisplayNotesAsEvents();
685
686
  /// Returns true if SValBuilder should rearrange comparisons and additive
687
  /// operations of symbolic expressions which consist of a sum of a symbol and
688
  /// a concrete integer into the format where symbols are on the left-hand
689
  /// side and the integer is on the right. This is only done if both symbols
690
  /// and both concrete integers are signed, greater than or equal to the
691
  /// quarter of the minimum value of the type and less than or equal to the
692
  /// quarter of the maximum value of that type.
693
  ///
694
  /// A + n <OP> B + m becomes A - B <OP> m - n, where A and B symbolic,
695
  /// n and m are integers. <OP> is any of '==', '!=', '<', '<=', '>', '>=',
696
  /// '+' or '-'. The rearrangement also happens with '-' instead of '+' on
697
  // either or both side and also if any or both integers are missing.
698
  bool shouldAggressivelySimplifyBinaryOperation();
699
700
  /// Returns true if we should eagerly assume evaluations of
701
  /// conditionals, thus, bifurcating the path.
702
  ///
703
  /// This indicates how the engine should handle expressions such as: 'x =
704
  /// (y != 0)'.  When this is true then the subexpression 'y != 0' will be
705
  /// eagerly assumed to be true or false, thus evaluating it to the integers 0
706
  /// or 1 respectively.  The upside is that this can increase analysis
707
  /// precision until we have a better way to lazily evaluate such logic.  The
708
  /// downside is that it eagerly bifurcates paths.
709
  bool shouldEagerlyAssume();
710
711
  /// Returns the directory containing the CTU related files.
712
  StringRef getCTUDir();
713
714
  /// Returns the name of the file containing the CTU index of functions.
715
  StringRef getCTUIndexName();
716
717
  /// Returns true when naive cross translation unit analysis is enabled.
718
  /// This is an experimental feature to inline functions from another
719
  /// translation units.
720
  bool naiveCTUEnabled();
721
722
  /// Returns true if elidable C++ copy-constructors and move-constructors
723
  /// should be actually elided during analysis. Both behaviors are allowed
724
  /// by the C++ standard, and the analyzer, like CodeGen, defaults to eliding.
725
  /// Starting with C++17 some elisions become mandatory, and in these cases
726
  /// the option will be ignored.
727
  bool shouldElideConstructors();
728
};
729
730
using AnalyzerOptionsRef = IntrusiveRefCntPtr<AnalyzerOptions>;
731
732
} // namespace clang
733
734
#endif // LLVM_CLANG_STATICANALYZER_CORE_ANALYZEROPTIONS_H