| Index: build/config/win/BUILD.gn
|
| diff --git a/build/config/win/BUILD.gn b/build/config/win/BUILD.gn
|
| index bdbf7eabe809583af7fb0d7ef470bea2cadf1b2d..079e7a32769c13dcecd4c09eb2574addcb5ca2f4 100644
|
| --- a/build/config/win/BUILD.gn
|
| +++ b/build/config/win/BUILD.gn
|
| @@ -8,6 +8,14 @@ import("//build/config/win/visual_studio_version.gni")
|
|
|
| assert(is_win)
|
|
|
| +declare_args() {
|
| + # Set this to true to enable static analysis through Visual Studio's
|
| + # /analyze. This dramatically slows compiles and reports thousands of
|
| + # warnings, so normally this is done on a build machine and only the new
|
| + # warnings are examined.
|
| + use_vs_code_analysis = false
|
| +}
|
| +
|
| # This is included by reference in the //build/config/compiler config that
|
| # is applied to all targets. It is here to separate out the logic that is
|
| # Windows-only.
|
| @@ -80,6 +88,46 @@ config("compiler") {
|
| }
|
| }
|
|
|
| +config("vs_code_analysis") {
|
| + if (use_vs_code_analysis) {
|
| + # When use_vs_code_analysis is specified add the /analyze switch to enable
|
| + # static analysis. Specifying /analyze:WX- says that /analyze warnings
|
| + # should not be treated as errors.
|
| + cflags = [ "/analyze:WX-" ]
|
| +
|
| + # Also, disable various noisy warnings that have low value.
|
| + cflags += [
|
| + "/wd6011", # Dereferencing NULL pointer
|
| +
|
| + # C6285 is ~16% of raw warnings and has low value
|
| + "/wd6285", # non-zero constant || non-zero constant
|
| + "/wd6308", # realloc might return null pointer
|
| +
|
| + # Possible infinite loop: use of the constant
|
| + # EXCEPTION_CONTINUE_EXECUTION in the exception-filter
|
| + "/wd6312",
|
| +
|
| + "/wd6322", # Empty _except block
|
| + "/wd6330", # 'char' used instead of 'unsigned char' for istype() call
|
| +
|
| + # C6334 is ~80% of raw warnings and has low value
|
| + "/wd6334", # sizeof applied to an expression with an operator
|
| + "/wd6326", # Potential comparison of constant with constant
|
| + "/wd6340", # Sign mismatch in function parameter
|
| + "/wd28159", # Consider using 'GetTickCount64'
|
| + "/wd28196", # The precondition is not satisfied
|
| + "/wd28204", # Inconsistent SAL annotations
|
| + "/wd28251", # Inconsistent SAL annotations
|
| + "/wd28252", # Inconsistent SAL annotations
|
| + "/wd28253", # Inconsistent SAL annotations
|
| + "/wd28278", # Function appears with no prototype in scope
|
| + "/wd28285", # syntax error in SAL annotation (in algorithm)
|
| + "/wd28301", # Inconsistent SAL annotations
|
| + "/wd28182", # Dereferencing NULL pointer
|
| + ]
|
| + }
|
| +}
|
| +
|
| # This is included by reference in the //build/config/compiler:runtime_library
|
| # config that is applied to all targets. It is here to separate out the logic
|
| # that is Windows-only. Please see that target for advice on what should go in
|
| @@ -105,10 +153,13 @@ config("runtime_library") {
|
| "PSAPI_VERSION=1",
|
| "WIN32",
|
| "_SECURE_ATL",
|
| + ]
|
|
|
| + if (!use_vs_code_analysis) {
|
| # This is required for ATL to use XP-safe versions of its functions.
|
| - "_USING_V110_SDK71_",
|
| - ]
|
| + # However it is prohibited when using /analyze
|
| + defines += [ "_USING_V110_SDK71_" ]
|
| + }
|
|
|
| if (is_component_build) {
|
| # Component mode: dynamic CRT. Since the library is shared, it requires
|
|
|