Main Content

polyspace.Options Class

Namespace: polyspace

Create object for running Polyspace analysis on handwritten code

Description

Create an object that specifies Polyspace® options. When running a Polyspace analysis from MATLAB®, specify the configuration by using this options object. To specify source files and customize analysis options, change the object properties.

polyspace.Options object apply to handwritten code. To analyze model-generated code (using the Polyspace desktop products), use polyspace.ModelLinkOptions instead.

Note

Before you run Polyspace from MATLAB, you must link your Polyspace and MATLAB installations. See Integrate Polyspace with MATLAB and Simulink or Integrate Polyspace Server Products with MATLAB.

Construction

opts = polyspace.Options creates an object whose properties correspond to options for running a Polyspace analysis.

proj = polyspace.Project creates a polyspace.Project object. The object has a property Configuration, which is a polyspace.Options object.

opts = polyspace.Options(lang) creates a Polyspace options object with options that are applicable to the language lang.

opts = polyspace.loadProject(projectFile) creates a Polyspace options object from an existing Polyspace project projectFile. You set the options in your project in the Polyspace user interface and create the options object from that project for programmatically running the analysis.

Input Arguments

expand all

The language of the analysis specified as 'C-CPP', 'C', or 'CPP'. This argument determines the object properties.

Data Types: char

Name of Polyspace project file with extension .psprj, specified as a character vector.

If the file is not in the current folder, projectFile must include a full or relative path. To identify the current folder, use pwd. To change the current folder, use cd.

Note

You cannot use the loadProject method on a project file that is created from a build command by using polyspace-configure.

Example: 'C:\projects\myProject.psprj'

Properties

The object properties correspond to the analysis options for Polyspace projects. The properties are organized in the same categories as the Polyspace interface. The property names are a shortened version of the DOS/UNIX command-line name. For syntax details, see polyspace.Project.Configuration Properties.

Methods

copyToCopy common settings between Polyspace options objects
generateProjectGenerate psprj project from options object
toScriptAdd Polyspace options object definition to a script

Examples

collapse all

Create a Polyspace analysis options object and customize the properties. Then, run an analysis.

Create object and customize properties. In case you do not have write access to your current folder, a temporary folder is being used for storing analysis results.

sources = fullfile(polyspaceroot, 'polyspace','examples','cxx','Bug_Finder_Example','sources','numerical.c');
opts = polyspace.Options();
opts.Prog = 'MyProject';
opts.Sources = {sources};
opts.TargetCompiler.Compiler = 'gnu4.7';
opts.ResultsDir = tempname;

Run a Bug Finder analysis. To run a Code Prover analysis, use polyspaceCodeProver instead of polyspaceBugFinder.

results = polyspaceBugFinder(opts);

With the Polyspace Server products, you can use the functions polyspaceBugFinderServer or polyspaceCodeProverServer.

Open the results in the Polyspace user interface of the desktop products.

polyspaceBugFinder('-results-dir',opts.ResultsDir);

Create a Polyspace analysis options object and customize the properties. Then, run a Bug Finder analysis.

Create object and customize properties.

sources=fullfile(polyspaceroot,'polyspace','examples','cxx','Bug_Finder_Example','sources','numerical.c');
opts = polyspace.Options();
opts.Prog = 'MyProject';
opts.Sources = {sources};
opts.TargetCompiler.Compiler = 'gnu4.7';
opts.ResultsDir = tempname;

Generate a Polyspace project, name it using the Prog property, and open the project in the Polyspace interface.

psprj = opts.generateProject(opts.Prog);
polyspaceBugFinder(psprj);

You can also analyze the project from the command line. Run the analysis and open the results in the Polyspace interface.

results = polyspaceBugFinder(psprj, '-nodesktop');
polyspaceBugFinder('-results-dir',opts.ResultsDir);

Alternatives

If you are analyzing code generated from a model, use polyspace.ModelLinkOptions instead.

Version History

Introduced in R2017a