www.gusucode.com > polyspace_bf 案例源码 matlab代码程序 > polyspace_bf/RunPolyspaceAnalysisWithCodingRuleCheckingExample.m

    %% Run Polyspace Analysis with Coding Rule Checking
% This example shows two different ways to customize an analysis at the command-line. You can customize as many additional options as you want by changing properties in an options object or by using Name-Value pairs. Here you specify checking of MISRA C:2012 coding rules.

%%
% Create variables for source file path and results folder path you can use for either method.
sourceFileName = fullfile(matlabroot, 'polyspace','examples', 'cxx', 'Bug_Finder_Example','sources','dataflow.c');
resFolder1 = fullfile('Polyspace_Results_1');
resFolder2 = fullfile('Polyspace_Results_2');

%%
% Analyze coding rules with an options object.
opts = polyspace.BugFinderOptions();
opts.Sources = {sourceFileName};
opts.ResultsDir = resFolder1;
opts.CodingRulesCodeMetrics.MisraC3Subset = 'mandatory';
opts.CodingRulesCodeMetrics.EnableMisraC3 = true;
polyspaceBugFinder(opts);
%polyspaceBugFinder('-results-dir', resFolder1);

%%
% Analyze coding rules with DOS/UNIX options.
polyspaceBugFinder('-sources',sourceFileName,'-results-dir',resFolder2,'-misra3','mandatory');
%polyspaceBugFinder('-results-dir',resFolder2);