[cfe-dev] Static Analyzer Checker Options Proposal
ganna at apple.com
Fri Oct 10 17:17:20 PDT 2014
Background & Problem:
Clang has support for static analyzer options though "-analyzer-config” front-end option, which is followed by the option name and value:
-analyzer-config <Option Name>=<Value>
This option is also available through scan-build.
Currently, there is no way to pass command line options to specific checkers. We work around it by creating new checker kinds (for example, MallocPessimistic, MallocOptimistic).
The proposal (partially authored and implemented by Aleksei Sidorin http://reviews.llvm.org/D3967) is to extend "-analyzer-config" to support checker-specific options as following:
-analyzer-config <Full Checker Name / Package Name>:<Option Name>=<Value>
To avoid ambiguities with regular options, we should enforce the following:
1) <Option Name> should be an identifier
2) Checker names should be identifiers.
3) Package names should be identifiers joined with '.’.
4) <Full Checker Name> has the same form as package names.
Specifying options on a package will be allowed. However, there will be no inheritance (i.e. the setting 'unix:Optimistic' is entirely distinct from the setting ‘unix.Malloc:Optimistic’). Each checker will be able to query options of its package when needed. For this, we propose changing the getOption API to work with package and checker names as well as CheckerBase.
Comments and suggestions are welcome!
More information about the cfe-dev