clang  10.0.0svn
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
clang::AnalyzerOptions Class Reference

Stores options for the analyzer from the command line. More...

#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"

Inheritance diagram for clang::AnalyzerOptions:
Inheritance graph
[legend]
Collaboration diagram for clang::AnalyzerOptions:
Collaboration graph
[legend]

Public Types

using ConfigTable = llvm::StringMap< std::string >
 

Public Member Functions

bool isUnknownAnalyzerConfig (StringRef Name) const
 
 AnalyzerOptions ()
 
bool getCheckerBooleanOption (StringRef CheckerName, StringRef OptionName, bool SearchInParents=false) const
 Interprets an option's string value as a boolean. More...
 
bool getCheckerBooleanOption (const ento::CheckerBase *C, StringRef OptionName, bool SearchInParents=false) const
 
int getCheckerIntegerOption (StringRef CheckerName, StringRef OptionName, bool SearchInParents=false) const
 Interprets an option's string value as an integer value. More...
 
int getCheckerIntegerOption (const ento::CheckerBase *C, StringRef OptionName, bool SearchInParents=false) const
 
StringRef getCheckerStringOption (StringRef CheckerName, StringRef OptionName, bool SearchInParents=false) const
 Query an option's string value. More...
 
StringRef getCheckerStringOption (const ento::CheckerBase *C, StringRef OptionName, bool SearchInParents=false) const
 
UserModeKind getUserMode () const
 Retrieves and sets the UserMode. More...
 
ExplorationStrategyKind getExplorationStrategy () const
 
IPAKind getIPAMode () const
 Returns the inter-procedural analysis mode. More...
 
bool mayInlineCXXMemberFunction (CXXInlineableMemberKind K) const
 Returns the option controlling which C++ member functions will be considered for inlining. More...
 

Static Public Member Functions

static std::vector< StringRef > getRegisteredCheckers (bool IncludeExperimental=false)
 Retrieves the list of checkers generated from Checkers.td. More...
 
static std::vector< StringRef > getRegisteredPackages (bool IncludeExperimental=false)
 Retrieves the list of packages generated from Checkers.td. More...
 
static void printFormattedEntry (llvm::raw_ostream &Out, std::pair< StringRef, StringRef > EntryDescPair, size_t EntryWidth, size_t InitialPad, size_t MinLineWidth=0)
 Convenience function for printing options or checkers and their description in a formatted manner. More...
 

Public Attributes

std::vector< std::pair< std::string, bool > > CheckersAndPackages
 Pairs of checker/package name and enable/disable. More...
 
std::vector< std::string > SilencedCheckersAndPackages
 Vector of checker/package names which will not emit warnings. More...
 
ConfigTable Config
 A key-value table of use-specified configuration values. More...
 
AnalysisStores AnalysisStoreOpt = RegionStoreModel
 
AnalysisConstraints AnalysisConstraintsOpt = RangeConstraintsModel
 
AnalysisDiagClients AnalysisDiagOpt = PD_HTML
 
AnalysisPurgeMode AnalysisPurgeOpt = PurgeStmt
 
std::string AnalyzeSpecificFunction
 
std::string DumpExplodedGraphTo
 File path to which the exploded graph should be dumped. More...
 
std::string FullCompilerInvocation
 Store full compiler invocation for reproducible instructions in the generated report. More...
 
unsigned maxBlockVisitOnPath
 The maximum number of times the analyzer visits a block. More...
 
unsigned DisableAllCheckers: 1
 Disable all analyzer checkers. More...
 
unsigned ShowCheckerHelp: 1
 
unsigned ShowCheckerHelpAlpha: 1
 
unsigned ShowCheckerHelpDeveloper: 1
 
unsigned ShowCheckerOptionList: 1
 
unsigned ShowCheckerOptionAlphaList: 1
 
unsigned ShowCheckerOptionDeveloperList: 1
 
unsigned ShowEnabledCheckerList: 1
 
unsigned ShowConfigOptionsList: 1
 
unsigned ShouldEmitErrorsOnInvalidConfigValue: 1
 
unsigned AnalyzeAll: 1
 
unsigned AnalyzerDisplayProgress: 1
 
unsigned AnalyzeNestedBlocks: 1
 
unsigned eagerlyAssumeBinOpBifurcation: 1
 
unsigned TrimGraph: 1
 
unsigned visualizeExplodedGraphWithGraphViz: 1
 
unsigned UnoptimizedCFG: 1
 
unsigned PrintStats: 1
 
unsigned NoRetryExhausted: 1
 Do not re-analyze paths leading to exhausted nodes with a different strategy. More...
 
unsigned AnalyzerWerror: 1
 Emit analyzer warnings as errors. More...
 
unsigned InlineMaxStackDepth = 5
 The inlining stack depth limit. More...
 
AnalysisInliningMode InliningMode = NoRedundancy
 The mode of function selection used during inlining. More...
 
std::vector< StringRef > AnalyzerConfigCmdFlags
 

Detailed Description

Stores options for the analyzer from the command line.

Some options are frontend flags (e.g.: -analyzer-output), but some are analyzer configuration options, which are preceded by -analyzer-config (e.g.: -analyzer-config notes-as-events=true).

If you'd like to add a new frontend flag, add it to include/clang/Driver/CC1Options.td, add a new field to store the value of that flag in this class, and initialize it in lib/Frontend/CompilerInvocation.cpp.

If you'd like to add a new non-checker configuration, register it in include/clang/StaticAnalyzer/Core/AnalyzerOptions.def, and refer to the top of the file for documentation.

If you'd like to add a new checker option, call getChecker*Option() whenever.

Some of the options are controlled by raw frontend flags for no good reason, and should be eventually converted into -analyzer-config flags. New analyzer options should not be implemented as frontend flags. Frontend flags still make sense for things that do not affect the actual analysis.

Definition at line 162 of file AnalyzerOptions.h.

Member Typedef Documentation

◆ ConfigTable

using clang::AnalyzerOptions::ConfigTable = llvm::StringMap<std::string>

Definition at line 164 of file AnalyzerOptions.h.

Constructor & Destructor Documentation

◆ AnalyzerOptions()

clang::AnalyzerOptions::AnalyzerOptions ( )
inline

Definition at line 303 of file AnalyzerOptions.h.

Member Function Documentation

◆ getCheckerBooleanOption() [1/2]

bool AnalyzerOptions::getCheckerBooleanOption ( StringRef  CheckerName,
StringRef  OptionName,
bool  SearchInParents = false 
) const

Interprets an option's string value as a boolean.

The "true" string is interpreted as true and the "false" string is interpreted as false.

If an option value is not provided, returns the given DefaultVal.

Parameters
[in]CheckerNameThe full name of the checker. One may retrieve this from the checker object's field Name, or through CheckerManager::getCurrentCheckerName within the checker's registry function. Checker options are retrieved in the following format: `-analyzer-config CheckerName:OptionName=Value.
[in]OptionNameName for option to retrieve.
[in]SearchInParentsIf set to true and the searched option was not specified for the given checker the options for the parent packages will be searched as well. The inner packages take precedence over the outer ones.

Definition at line 151 of file AnalyzerOptions.cpp.

References Ret().

Referenced by clang::ento::registerInnerPointerCheckerAux().

◆ getCheckerBooleanOption() [2/2]

bool AnalyzerOptions::getCheckerBooleanOption ( const ento::CheckerBase C,
StringRef  OptionName,
bool  SearchInParents = false 
) const

◆ getCheckerIntegerOption() [1/2]

int AnalyzerOptions::getCheckerIntegerOption ( StringRef  CheckerName,
StringRef  OptionName,
bool  SearchInParents = false 
) const

Interprets an option's string value as an integer value.

If an option value is not provided, returns the given DefaultVal.

Parameters
[in]CheckerNameThe full name of the checker. One may retrieve this from the checker object's field Name, or through CheckerManager::getCurrentCheckerName within the checker's registry function. Checker options are retrieved in the following format: `-analyzer-config CheckerName:OptionName=Value.
[in]OptionNameName for option to retrieve.
[in]SearchInParentsIf set to true and the searched option was not specified for the given checker the options for the parent packages will be searched as well. The inner packages take precedence over the outer ones.

Definition at line 175 of file AnalyzerOptions.cpp.

References Ret().

◆ getCheckerIntegerOption() [2/2]

int AnalyzerOptions::getCheckerIntegerOption ( const ento::CheckerBase C,
StringRef  OptionName,
bool  SearchInParents = false 
) const

◆ getCheckerStringOption() [1/2]

StringRef AnalyzerOptions::getCheckerStringOption ( StringRef  CheckerName,
StringRef  OptionName,
bool  SearchInParents = false 
) const

Query an option's string value.

If an option value is not provided, returns the given DefaultVal.

Parameters
[in]CheckerNameThe full name of the checker. One may retrieve this from the checker object's field Name, or through CheckerManager::getCurrentCheckerName within the checker's registry function. Checker options are retrieved in the following format: `-analyzer-config CheckerName:OptionName=Value.
[in]OptionNameName for option to retrieve.
[in]SearchInParentsIf set to true and the searched option was not specified for the given checker the options for the parent packages will be searched as well. The inner packages take precedence over the outer ones.

Definition at line 117 of file AnalyzerOptions.cpp.

◆ getCheckerStringOption() [2/2]

StringRef AnalyzerOptions::getCheckerStringOption ( const ento::CheckerBase C,
StringRef  OptionName,
bool  SearchInParents = false 
) const

◆ getExplorationStrategy()

ExplorationStrategyKind AnalyzerOptions::getExplorationStrategy ( ) const

◆ getIPAMode()

IPAKind AnalyzerOptions::getIPAMode ( ) const

◆ getRegisteredCheckers()

std::vector< StringRef > clang::AnalyzerOptions::getRegisteredCheckers ( bool  IncludeExperimental = false)
inlinestatic

Retrieves the list of checkers generated from Checkers.td.

This doesn't contain statically linked but non-generated checkers and plugin checkers!

Definition at line 417 of file AnalyzerOptions.h.

Referenced by parseAnalyzerConfigs().

◆ getRegisteredPackages()

std::vector< StringRef > clang::AnalyzerOptions::getRegisteredPackages ( bool  IncludeExperimental = false)
inlinestatic

Retrieves the list of packages generated from Checkers.td.

This doesn't contain statically linked but non-generated packages and plugin packages!

Definition at line 435 of file AnalyzerOptions.h.

Referenced by parseAnalyzerConfigs().

◆ getUserMode()

UserModeKind clang::AnalyzerOptions::getUserMode ( ) const
inline

Retrieves and sets the UserMode.

This is a high-level option, which is used to set other low-level options. It is not accessible outside of AnalyzerOptions.

Definition at line 407 of file AnalyzerOptions.h.

References clang::UMK_Deep, and clang::UMK_Shallow.

◆ isUnknownAnalyzerConfig()

bool clang::AnalyzerOptions::isUnknownAnalyzerConfig ( StringRef  Name) const
inline

Definition at line 294 of file AnalyzerOptions.h.

◆ mayInlineCXXMemberFunction()

bool AnalyzerOptions::mayInlineCXXMemberFunction ( CXXInlineableMemberKind  K) const

Returns the option controlling which C++ member functions will be considered for inlining.

This is controlled by the 'c++-inlining' config option.

See also
CXXMemberInliningMode

Definition at line 98 of file AnalyzerOptions.cpp.

References clang::CIMK_Constructors, clang::CIMK_Destructors, clang::CIMK_MemberFunctions, clang::CIMK_None, and clang::IPAK_Inlining.

Referenced by clang::ento::ExprEngine::bindReturnValue().

◆ printFormattedEntry()

void AnalyzerOptions::printFormattedEntry ( llvm::raw_ostream &  Out,
std::pair< StringRef, StringRef >  EntryDescPair,
size_t  EntryWidth,
size_t  InitialPad,
size_t  MinLineWidth = 0 
)
static

Convenience function for printing options or checkers and their description in a formatted manner.

If MinLineWidth is set to 0, no line breaks are introduced for the description.

Format, depending whether the option name's length is less then OptionWidth:

<padding>EntryName<padding>Description <------—padding------—>Description <------—padding------—>Description

<padding>VeryVeryLongOptionName <------—padding------—>Description <------—padding------—>Description ^~~~~~~~ InitialPad ^~~~~~~~~~~~~~~~~~~~~~~~~~ EntryWidth ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~MinLineWidth

Definition at line 33 of file AnalyzerOptions.cpp.

Referenced by clang::ento::printAnalyzerConfigList(), clang::ento::CheckerRegistry::printCheckerOptionList(), and clang::ento::CheckerRegistry::printCheckerWithDescList().

Member Data Documentation

◆ AnalysisConstraintsOpt

AnalysisConstraints clang::AnalyzerOptions::AnalysisConstraintsOpt = RangeConstraintsModel

Definition at line 208 of file AnalyzerOptions.h.

◆ AnalysisDiagOpt

AnalysisDiagClients clang::AnalyzerOptions::AnalysisDiagOpt = PD_HTML

Definition at line 209 of file AnalyzerOptions.h.

◆ AnalysisPurgeOpt

AnalysisPurgeMode clang::AnalyzerOptions::AnalysisPurgeOpt = PurgeStmt

Definition at line 210 of file AnalyzerOptions.h.

Referenced by clang::ento::ExprEngine::processCallExit().

◆ AnalysisStoreOpt

AnalysisStores clang::AnalyzerOptions::AnalysisStoreOpt = RegionStoreModel

Definition at line 207 of file AnalyzerOptions.h.

◆ AnalyzeAll

unsigned clang::AnalyzerOptions::AnalyzeAll

Definition at line 242 of file AnalyzerOptions.h.

Referenced by CompactMacroExpandedPieces().

◆ AnalyzeNestedBlocks

unsigned clang::AnalyzerOptions::AnalyzeNestedBlocks

Definition at line 244 of file AnalyzerOptions.h.

◆ AnalyzerConfigCmdFlags

std::vector<StringRef> clang::AnalyzerOptions::AnalyzerConfigCmdFlags
Initial value:
= {
#define ANALYZER_OPTION_DEPENDS_ON_USER_MODE(TYPE, NAME, CMDFLAG, DESC, SHALLOW_VAL, DEEP_VAL)
#define ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC, DEFAULT_VAL)
}

Definition at line 281 of file AnalyzerOptions.h.

◆ AnalyzerDisplayProgress

unsigned clang::AnalyzerOptions::AnalyzerDisplayProgress

Definition at line 243 of file AnalyzerOptions.h.

◆ AnalyzerWerror

unsigned clang::AnalyzerOptions::AnalyzerWerror

Emit analyzer warnings as errors.

Definition at line 258 of file AnalyzerOptions.h.

◆ AnalyzeSpecificFunction

std::string clang::AnalyzerOptions::AnalyzeSpecificFunction

Definition at line 212 of file AnalyzerOptions.h.

◆ CheckersAndPackages

std::vector<std::pair<std::string, bool> > clang::AnalyzerOptions::CheckersAndPackages

Pairs of checker/package name and enable/disable.

Definition at line 199 of file AnalyzerOptions.h.

Referenced by clang::ento::CheckerRegistry::CheckerRegistry().

◆ Config

ConfigTable clang::AnalyzerOptions::Config

A key-value table of use-specified configuration values.

Definition at line 206 of file AnalyzerOptions.h.

Referenced by insertAndValidate(), and clang::ento::CheckerRegistry::validateCheckerOptions().

◆ DisableAllCheckers

unsigned clang::AnalyzerOptions::DisableAllCheckers

Disable all analyzer checkers.

This flag allows one to disable analyzer checkers on the code processed by the given analysis consumer. Note, the code will get parsed and the command-line options will get checked.

Definition at line 229 of file AnalyzerOptions.h.

◆ DumpExplodedGraphTo

std::string clang::AnalyzerOptions::DumpExplodedGraphTo

File path to which the exploded graph should be dumped.

Definition at line 215 of file AnalyzerOptions.h.

◆ eagerlyAssumeBinOpBifurcation

unsigned clang::AnalyzerOptions::eagerlyAssumeBinOpBifurcation

Definition at line 246 of file AnalyzerOptions.h.

◆ FullCompilerInvocation

std::string clang::AnalyzerOptions::FullCompilerInvocation

Store full compiler invocation for reproducible instructions in the generated report.

Definition at line 219 of file AnalyzerOptions.h.

◆ InlineMaxStackDepth

unsigned clang::AnalyzerOptions::InlineMaxStackDepth = 5

The inlining stack depth limit.

Definition at line 262 of file AnalyzerOptions.h.

Referenced by isCXXSharedPtrDtor().

◆ InliningMode

AnalysisInliningMode clang::AnalyzerOptions::InliningMode = NoRedundancy

The mode of function selection used during inlining.

Definition at line 265 of file AnalyzerOptions.h.

◆ maxBlockVisitOnPath

unsigned clang::AnalyzerOptions::maxBlockVisitOnPath

The maximum number of times the analyzer visits a block.

Definition at line 222 of file AnalyzerOptions.h.

◆ NoRetryExhausted

unsigned clang::AnalyzerOptions::NoRetryExhausted

Do not re-analyze paths leading to exhausted nodes with a different strategy.

We get better code coverage when retry is enabled.

Definition at line 255 of file AnalyzerOptions.h.

◆ PrintStats

unsigned clang::AnalyzerOptions::PrintStats

Definition at line 251 of file AnalyzerOptions.h.

◆ ShouldEmitErrorsOnInvalidConfigValue

unsigned clang::AnalyzerOptions::ShouldEmitErrorsOnInvalidConfigValue

Definition at line 241 of file AnalyzerOptions.h.

Referenced by insertAndValidate(), and isOptionContainedIn().

◆ ShowCheckerHelp

unsigned clang::AnalyzerOptions::ShowCheckerHelp

◆ ShowCheckerHelpAlpha

unsigned clang::AnalyzerOptions::ShowCheckerHelpAlpha

◆ ShowCheckerHelpDeveloper

unsigned clang::AnalyzerOptions::ShowCheckerHelpDeveloper

◆ ShowCheckerOptionAlphaList

unsigned clang::AnalyzerOptions::ShowCheckerOptionAlphaList

◆ ShowCheckerOptionDeveloperList

unsigned clang::AnalyzerOptions::ShowCheckerOptionDeveloperList

◆ ShowCheckerOptionList

unsigned clang::AnalyzerOptions::ShowCheckerOptionList

◆ ShowConfigOptionsList

unsigned clang::AnalyzerOptions::ShowConfigOptionsList

Definition at line 240 of file AnalyzerOptions.h.

◆ ShowEnabledCheckerList

unsigned clang::AnalyzerOptions::ShowEnabledCheckerList

Definition at line 239 of file AnalyzerOptions.h.

◆ SilencedCheckersAndPackages

std::vector<std::string> clang::AnalyzerOptions::SilencedCheckersAndPackages

Vector of checker/package names which will not emit warnings.

Definition at line 202 of file AnalyzerOptions.h.

Referenced by parseAnalyzerConfigs(), and updateExecutedLinesWithDiagnosticPieces().

◆ TrimGraph

unsigned clang::AnalyzerOptions::TrimGraph

Definition at line 248 of file AnalyzerOptions.h.

◆ UnoptimizedCFG

unsigned clang::AnalyzerOptions::UnoptimizedCFG

Definition at line 250 of file AnalyzerOptions.h.

◆ visualizeExplodedGraphWithGraphViz

unsigned clang::AnalyzerOptions::visualizeExplodedGraphWithGraphViz

Definition at line 249 of file AnalyzerOptions.h.

Referenced by clang::ento::AnalysisManager::shouldVisualize().


The documentation for this class was generated from the following files: