/analyze (Code Analysis)
Enables code analysis and control options.
/analyze[-][:WX-][:log filename][:quiet][:stacksize number][:max_paths number][:only][:ruleset]
Turns on analysis in the default mode. Analysis output goes to the Output window like other error messages. Use /analyze- to explicitly turn off analysis.
Specifying /analyze:WX- means that code analysis warnings are not treated as errors when you compile by using /WX. For more information, see /w, /W0, /W1, /W2, /W3, /W4, /w1, /w2, /w3, /w4, /Wall, /wd, /we, /wo, /Wv, /WX (Warning Level).
Detailed analyzer results are written as XML to the file that is specified by
Turns off analyzer output to the Output window.
number parameter that is used with this option specifies the size, in bytes, of the stack frame for which warning C6262 is generated. If this parameter is not specified, the stack frame size is 16KB by default.
number parameter that is used with this option specifies the maximum number of code paths to be analyzed. If this parameter is not specified, the number is 256 by default. Larger values perform more thorough checking, but the analysis might take longer.
Typically, the compiler generates code and does more syntax checking after it runs the analyzer. The /analyze:only option turns off this code generation pass; this makes analysis faster but compile errors and warnings that might have been discovered by the code generation pass of the compiler are not emitted. If the program is not free of code-generation errors, analysis results might be unreliable; therefore, we recommend that you use this option only if the code already passes code-generation syntax checking without errors.
Enables you to specify which rule sets to analyze, including custom rule sets that you can create yourself. When this switch is set, the rules engine is more efficient because it excludes non-members of the specified rule set before running. When the switch is not set, the engine checks all rules.
The rulesets that ship with Visual Studio are found in %VSINSTALLDIR%\Team Tools\Static Analysis Tools\Rule Sets.
The following sample custom rule set tells the rules engine to check for C6001 and C26494. You can place this file anywhere as long as it has a
.ruleset extension and you provide the full path in the argument.
<?xml version="1.0" encoding="utf-8"?> <RuleSet Name="New Rule Set" Description=" " ToolsVersion="15.0"> <Rules AnalyzerId="Microsoft.Analyzers.NativeCodeAnalysis" RuleNamespace="Microsoft.Rules.Native"> <Rule Id="C6001" Action="Warning" /> <Rule Id="C26494" Action="Warning" /> </Rules> </RuleSet>
Enables the specified PREfast plugin as part of code analysis runs. LocalEspC.dll is the plugin that implements concurrency-related code analysis checks in the range of C261XX warnings. For example, C26100, C26101, ..., C26167.
To run LocalEspC.dll, use this compiler option: /analyze:plugin LocalEspC.dll
To run CppCoreCheck.dll, first run this command from a developer command prompt:
Then use this compiler option: /analyze:plugin EspXEngine.dll.
To set this compiler option in the Visual Studio development environment
Open the project's Property Pages dialog box. For details, see Working with Project Properties.
Expand the Configuration Properties node.
Expand the Code Analysis node.
Select the General property page.
Modify one or more of the Code Analysis properties.
To set this compiler option programmatically
- See EnablePREfast.