DescriptionAdd __analysis_assume support to CHECK macros to reduce warnings with /analyze.
Due to bugs and quirks in the analysis engine this is a very delicate dance.
The __analysis_assume invocation has to evaluate !!(condition) instead
of just condition because otherwise it fails on overloaded operators
such as with smart pointers. See this post for details:
http://randomascii.wordpress.com/2011/09/13/analyze-for-visual-studio-the-ugly-part-5/
The evaluation of condition in the 'regular' part of the macro has to
be removed during the /analyze phase in order to avoid confusing the
analysis engine which thinks that branching on the condition implies
uncertainty about the condition.
None of this is documented -- thinking like a compiler is required.
Wrapping this with #ifdef _PREFAST_ makes it easy to guarantee that this
will not affect regular builds.
To build add win_debug_extra_cflags="/analyze" to GYP_DEFINES, rebuild
the project files and then build.
Committed: https://crrev.com/9d1602515adc3e797d71c3a0e29cc175432eb8fe
Cr-Commit-Position: refs/heads/master@{#300937}
Patch Set 1 #
Total comments: 3
Patch Set 2 : Fixed spacing of #else/#endif comments per style-guide/thestig@ #Patch Set 3 : Change to #if defined and other small tweaks from code-review. #Messages
Total messages: 15 (3 generated)
|