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