Libraries used (-library
)
Specify libraries that you use in your program
Since R2021a
Description
Specify libraries that you use in your program.
The analysis uses smart stubs for functions from those libraries instead of generic stubs and does not attempt to check the function implementations. Using this option enables faster analysis without losing precision and triggers library-specific checks on function calls.
Set Option
User interface (desktop products only): In your project configuration, the option is on the Inputs & Stubbing node.
User interface (Polyspace Platform, desktop products only): In your project configuration, the option is on the Static Analysis tab on the Inputs & Stubbing node.
Command line and options file:
Use the option -library
. See Command-Line Information.
Why Use This Option
For faster and library-aware analysis, use this option. Unless you use this option, the analysis either attempts to check the library implementation or if the implementation is not available, uses generic stubs for library functions. Checking the function bodies can increase analysis time significantly while using generic stubs can lead to loss of precision.
The option also triggers library-specific checks on function arguments. For
instance, if you select the option value autosar
, a Bug Finder or
Code Prover analysis checks arguments to functions from the AUTOSAR RTE API for
compliance with the AUTOSAR Standard.
Settings
Default: none
none
The analysis uses smart stubs only for functions from the C Standard Library.
autosar
The analysis uses smart stubs for AUTOSAR RTE API functions even if their implementations are available.
The option also triggers AUTOSAR-specific checks on function arguments. For more information, see the corresponding checkers:
Bug Finder:
Non-compliance with AUTOSAR specification
Besides setting the option, you must also explicitly enable the above checker (or enable all checkers).
Code Prover:
Non-compliance with AUTOSAR specification
(Polyspace Code Prover)Setting the option is sufficient to enable the checker.
stdlibcxx
The analysis uses smart stubs for methods from C++ Standard Library containers even if their implementations are available.
The containers whose methods are stubbed include
std::map
,std::unordered_map
,std::deque
,std::vector
,std::set
,std::unordered_set
, andstd::list
. If you use this option and your code contains C++ container methods, the analysis log contains a message:wheren
methods stubbed for better performance
is the number of methods stubbed.n
Note that unlike functions from the C Standard Library, the stubs of C++ container methods are not used to check for domain errors and other error conditions. The methods are stubbed to avoid the unnecessary performance costs from analyzing their implementation. As a result, if you invoke a C++ container method with incorrect arguments, you do not see errors that refer to the incorrect invocation. But in some cases, you might see other errors that indirectly follow from the incorrect invocation. For instance, if you invoke the
std::stack::top()
method on an empty stack, you see aNon-initialized variable
(Polyspace Code Prover) error even though the stack itself is initialized.This option has effect only on a Code Prover analysis. A Bug Finder analysis discards implementations of C++ container methods immediately after compilation and does not require the smart stubbing.
pstunit
The analysis uses smart stubs for test-specific macros and classes from the Polyspace® Test™ xUnit API. This option is automatically added if you run static analysis on a test in the Polyspace Platform user interface. For more information, see Check for Bugs and Run-Time Errors in C/C++ Tests and Functions Under Test (Polyspace Test).
Command-Line Information
Parameter: -library |
No Default |
Value:
autosar | stdlibcxx | pstunit | Comma-separated list of values |
Example (Bug Finder):
polyspace-bug-finder -sources |
Example (Code Prover): polyspace-code-prover -sources |
Example (Bug Finder Server):
polyspace-bug-finder-server -sources |
Example (Code Prover Server): polyspace-code-prover-server -sources |
Version History
Introduced in R2021a