This note is obsolete. Please read "PVS-Studio's incremental analysis mode" in documentation.
One among newest features in the latest versions of MSBuild/Visual Studio for Visual C++ compilers is the new minimal rebuild system (also known is an incremental assembly), which is based on tracing of dependencies between compiler's input and output data. It allows performing the rebuilding only for the files untouched by modifications or lacking output object files tied to them. In comparison to the old method of minimal rebuild which was based on compiler state files generated by the cl.exe (idb-files, Minimal Rebuild Dependancy Database, /Gm command line switch) and had several shortcomings (among them are the difficulty of performing parallel builds due to the file access conflicts and the lack of direct tracing for output object files), the new system is independent from build tools being used (it can be used together with the compiler as well as with the linker) and possesses an open API. This new feature in the latest version of Visual Studio 2010 allowed us to integrate PVS-Studio source code verification into C/C++ development process with incremental rebuilding. This feature was added in PVS-Studio 4.30.
One of the major problems with regular verification of actively developed large-scale projects by the static analyzer is the necessity to invest huge amounts of time into the analysis of project's files after each modification. In spite of the fact that the verification of the entire project could be (and should be!) performed regularly, for example during night builds, the maximum benefit from using the analyzer can be obtained only by detecting and correcting any detected errors as soon as possible, as the earlier you manage to detect the error, the less code you have to modify in the end. Thereby the most effective way of using the static analyzer is the verification of source code immediately after its creation. Such a use case is undoubtedly complicated by the necessity of constant manual launching of the analysis for every source file being modified and waiting for the completion of this analysis. All of this is of course incompatible with the intense development and debugging of new source code.
The usage of PVS-Studio analyzer together with MSBuild incremental building system allows us to solve all aforementioned issues. The activation of such incremental analysis mode could be done through PVS-Studio/Incremental Analysis After Build menu item (Only for Visual Studio 2010). The incremental analysis in Visual Studio 2010 can also be used with previous versions of Visual C++ compiler by setting Platform Toolset of the corresponding version for the projects required.
After activating the incremental analysis mode PVS-Studio will automatically start to commence the verification of all modified files in background every time after the completion of project's minimal rebuild. It should be noted however that the analysis is only possible for files which are free of syntax errors, therefore in case of compiler errors being generated during the build, the analysis will not be launched. The errors during building steps following the compilation (the linking errors for instance) do not affect the operation of PVS-Studio.
In case the analyzer detects errors in source code during incremental analysis, the number of detected errors will be reflected in the name of PVS-Studio toolwindow tab which will be opened in background. You can then star working with them without waiting for the analysis to be completed. But for the error list not to be filled with useless and senseless messages, one should always remember that after first full project's verification it is necessary to review all of the diagnostic messages for all the files, to correct the errors found in source code and mark the rest of the remaining messages as false alarms, or to disable the detection of errors' codes or analyzers' types which are not relevant for the project entirely. Only then the incremental analysis will allow you to detect defects immediately after writing new source code and assembling it successfully for the first time.
In fact this new PVS-Studio mode brings our tool's usability close to the /analyze key of various Visual Studio versions. Now you can simply engage in developing the source code and compiling it, simultaneously receiving messages containing potential source code issues from the analyzer. As the analyzer operates in background (and the number of processor's cores being used for the analysis can be configured), the usage of PVS-Studio becomes a lot more comfortable. This means that our tool can be easily installed on workstations of a large part (or even everyone) of the developers in the department to allow the detection of source code issues immediately at their emergence.
UPDATE: Incremental Analysis feature available for all versions of Microsoft Visual Studio (2005/2008/2010) in PVS-Studio 4.33.
I develop the PVS-Studio static code analyzer intended for analyzing C/C++ software. After we implemented general analysis in PVS-Studio 4.00, we received a lot of responses, both positive and negative. By the way, you are welcome to download a new version of PVS-Studio where we have fixed a lot of errors and defects thanks to users who told us about ...