Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

Using Static Analysis in Visual Studio*

$
0
0

Static Analysis is a deprecated feature.

Static Analysis is not supported on OS X* systems.

To build your application for static analysis in Microsoft Visual Studio*, use the Build for Intel Static Analysis menu option.

There are several forms of the Build for Intel Static Analysis menu option, including:

  • Build solution for Intel Static Analysis.
  • Rebuild solution for Intel Static Analysis.
  • Build <projectname> for Intel Static Analysis.
  • Rebuild <projectname> for Intel Static Analysis.
These forms appear in all menus that can build projects or solutions, including the Build menu and the popup menu that appears when you right click on selected project(s) or the solution.

Setting the Intel_SSA Configuration

The first time Build for Intel Static Analysis is selected, a Create configuration dialog box appears to create a new build configuration for static analysis called Intel_SSA with the required properties for Visual Studio*.

In the Create configuration dialog box, set the following:

Copy configuration settings from: Specify the configuration from which settings should be copied.

Level of Static Analysis: Select the desired level of analysis.

Mode of Static Analysis: Choose one of the following modes:

  • Full Security Scan: Minimize false negatives or missed errors but also increases chances of false positives. Use this option for security assurance.
  • Concise: Reduce false positives by tolerating a higher number of false negatives. Use this option for general error detection.
  • Precise: Minimize false positives but also increases the chances of false negatives. Use this option for quick source screening.

Additional Options: Choose these options to analyze include files, individual files, or to treat enumerations as known ranges.

  • Analyze Include Files: Select this box to report errors in the system include files.
  • Analyze Files Individually: Select this box to analyze files individually. This option requires less analysis time and memory on large programs but can also result in finding fewer errors.
  • Treat Enumerations As Known Ranges: Select this box to treat enumeration variables like known range-bound values. This option finds more real errors but increases the chances of false positives.

Build for Static Analysis after creating configuration: Check this box to create a new configuration called Intel_SSA build the selected project(s) using static analysis. If the checkbox is not checked, configuration for static analysis will be created and will run the next time Build for Intel Static Analysis is selected.

Performing static analysis for an Intel® C++ Solution

To perform static analysis on Intel® C++ solutions and projects:

  1. Choose Build for Intel Static Analysis (or one of the variant forms).
  2. Configure the Intel_SSAConfiguration (if prompted).

Analysis results will open automatically in the Intel® Inspector XE user interface.

Using static analysis for a Visual C++* Solution or a Mixed Solution

To perform static analysis on Visual C++* only solutions and projects or on a mixed solution containing both Intel® C++ and Visual C++* projects, do the following:

  1. Choose Build for Intel Static Analysis.

    Note

    Existing configurations will not be modified. The Solution Explorer view will show a different icon to indicate that a project configuration is built by the Intel® C++ Compiler.

Analysis results will open automatically in the Intel® Inspector XE user interface.

Note

Preparing a Visual C++* project for use with static analysis does not cause the existing configurations to build with the Intel compiler. However, it does modify the solution (.sln) file and adds an Intel project (.icproj) file for each prepared project. After these changes, the solution will no longer build on systems where the Intel® C++ Compiler is not installed. In a team environment where some team members will not install the Intel® C++ Compiler, it is best to treat these modifications as temporary and discard them after running static analysis. You can always use the menu item to perform the preparation step again as needed.

Modifying the Intel_SSA Configuration

There are several Visual Studio* IDE property pages related to static analysis. You can change the options for static analysis by modifying the properties for the Intel_SSA configuration. To do this, use the following property pages:

  • C/C++> Diagnostics> Level of Static Analysis
  • C/C++> Diagnostics> Analyze Include Files

  • C/C++> Diagnostics> Analysis results container

    The default location is My Inspector XE Results-<product name> directory in the project root directory.

  • C/C++> Diagnostics> Mode of Static Analysis

  • C/C++> Diagnostics> Analyze Files Individually

  • C/C++> Diagnostics> Treat Enumerations as Known Ranges

Inglés

Viewing all articles
Browse latest Browse all 1616

Trending Articles