Remove use_clang_static_analyzer and use_vs_code_analysis.

The clang we ship no longer includes the static analyzer, so this flag
hasn't been working for a while. Remove it, and mb stuff for an FYI bot
that uses it.

The plan is to run the static analyzer through clang-tidy instead.

While here, also remove the 'win analyze' bot src bits, since that
bot depends on MSVC which we haven't supported in a while either,
and the little bit of GN code kept alive by it.

Bug: 925145,687243
Change-Id: I042d3cc9f512a024a6eae6a8e7d43aa2f9a74fea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1538987
Commit-Queue: Nico Weber <thakis@chromium.org>
Reviewed-by: Hans Wennborg <hans@chromium.org>
Auto-Submit: Nico Weber <thakis@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#644866}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: db1eca94f6af3ebca12da507180ed20afe038b5d
This commit is contained in:
Nico Weber 2019-03-27 17:06:19 +00:00
Родитель 6d94f9dd4f
Коммит 53f08836a0
9 изменённых файлов: 10 добавлений и 201 удалений

Просмотреть файл

@ -447,7 +447,6 @@ if (is_win) {
"//build/config/win:nominmax",
"//build/config/win:unicode",
"//build/config/win:winver",
"//build/config/win:vs_code_analysis",
]
}

Просмотреть файл

@ -14,12 +14,6 @@ import("//build/toolchain/toolchain.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
# Turn this on to have the linker output extra timing information.
win_linker_timing = false
@ -212,46 +206,6 @@ config("compiler") {
]
}
config("vs_code_analysis") {
if (use_vs_code_analysis && !is_clang) {
# 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
@ -278,11 +232,9 @@ config("runtime_library") {
"_SECURE_ATL",
]
if (!use_vs_code_analysis) {
# This is required for ATL to use XP-safe versions of its functions.
# However it is prohibited when using /analyze
defines += [ "_USING_V110_SDK71_" ]
}
# This is required for ATL to use XP-safe versions of its functions.
# TODO(thakis): We no longer support XP; try removing this.
defines += [ "_USING_V110_SDK71_" ]
if (current_os == "winuwp") {
# When targeting Windows Runtime, certain compiler/linker flags are

Просмотреть файл

@ -1,11 +0,0 @@
# Copyright (c) 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Defines the configuration of Clang static analysis tools.
# See docs/clang_static_analyzer.md for more information.
declare_args() {
# Uses the Clang static analysis tools during compilation.
use_clang_static_analyzer = false
}

Просмотреть файл

@ -1,71 +0,0 @@
#!/usr/bin/env python
# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Adds an analysis build step to invocations of the Clang C/C++ compiler.
Usage: clang_static_analyzer_wrapper.py <compiler> [args...]
"""
import argparse
import fnmatch
import itertools
import os
import sys
import wrapper_utils
# Flags used to enable analysis for Clang invocations.
analyzer_enable_flags = [
'--analyze',
]
# Flags used to configure the analyzer's behavior.
analyzer_option_flags = [
'-fdiagnostics-show-option',
'-analyzer-checker=cplusplus',
'-analyzer-opt-analyze-nested-blocks',
'-analyzer-output=text',
'-analyzer-config',
'suppress-c++-stdlib=true',
# List of checkers to execute.
# The full list of checkers can be found at
# https://clang-analyzer.llvm.org/available_checks.html.
'-analyzer-checker=core',
'-analyzer-checker=unix',
'-analyzer-checker=deadcode',
]
# Prepends every element of a list |args| with |token|.
# e.g. ['-analyzer-foo', '-analyzer-bar'] => ['-Xanalyzer', '-analyzer-foo',
# '-Xanalyzer', '-analyzer-bar']
def interleave_args(args, token):
return list(sum(zip([token] * len(args), args), ()))
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--mode',
choices=['clang', 'cl'],
required=True,
help='Specifies the compiler argument convention to use.')
parser.add_argument('args', nargs=argparse.REMAINDER)
parsed_args = parser.parse_args()
prefix = '-Xclang' if parsed_args.mode == 'cl' else '-Xanalyzer'
cmd = parsed_args.args + analyzer_enable_flags + \
interleave_args(analyzer_option_flags, prefix)
returncode, stderr = wrapper_utils.CaptureCommandStderr(
wrapper_utils.CommandToRun(cmd))
sys.stderr.write(stderr)
returncode, stderr = wrapper_utils.CaptureCommandStderr(
wrapper_utils.CommandToRun(parsed_args.args))
sys.stderr.write(stderr)
return returncode
if __name__ == '__main__':
sys.exit(main())

Просмотреть файл

@ -8,7 +8,6 @@ import("//build/config/coverage/coverage.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//build/config/v8_target_cpu.gni")
import("//build/toolchain/cc_wrapper.gni")
import("//build/toolchain/clang_static_analyzer.gni")
import("//build/toolchain/goma.gni")
import("//build/toolchain/toolchain.gni")
@ -37,13 +36,6 @@ if (is_linux && target_os == "android") {
enable_resource_whitelist_generation = false
}
# Path to the Clang static analysis wrapper script.
# REVIEWERS: can you suggest a better location for this?
# GN is really picky about dead stores of variables except at the global scope.
analyzer_wrapper =
rebase_path("//build/toolchain/clang_static_analyzer_wrapper.py",
root_build_dir) + " --mode=clang"
# This template defines a toolchain for something that works like gcc
# (including clang).
#
@ -181,19 +173,10 @@ template("gcc_toolchain") {
compiler_prefix = "${toolchain_cc_wrapper} "
}
# Create a distinct variable for "asm", since analysis runs pass # a bunch
# of flags to clang/clang++ that are nonsensical on assembler runs.
# Create a distinct variable for "asm", since coverage runs pass a bunch of
# flags to clang/clang++ that are nonsensical on assembler runs.
asm_prefix = compiler_prefix
# Use the static analysis script if static analysis is turned on
# AND the tool has not opted out by setting
# 'is_clang_static_analysis_supported' to false.
if (is_clang && use_clang_static_analyzer &&
(!defined(invoker.is_clang_analysis_supported) ||
invoker.is_clang_analysis_supported)) {
compiler_prefix = "${analyzer_wrapper} " + compiler_prefix
}
# A specific toolchain may wish to avoid coverage instrumentation, so we
# allow the global "use_clang_coverage" arg to be overridden.
if (defined(toolchain_args.use_clang_coverage)) {
@ -205,10 +188,6 @@ template("gcc_toolchain") {
# For a coverage build, we use the wrapper script globally so that it can
# remove coverage cflags from files that should not have them.
if (toolchain_use_clang_coverage) {
assert(!use_clang_static_analyzer,
"Clang static analyzer wrapper and Clang code coverage wrapper " +
"cannot be used together.")
# "coverage_instrumentation_input_file" is set in args.gn, but it can be
# overridden by a toolchain config.
if (defined(toolchain_args.coverage_instrumentation_input_file)) {
@ -647,7 +626,6 @@ template("clang_toolchain") {
forward_variables_from(invoker,
[
"strip",
"is_clang_analysis_supported",
"default_shlib_subdir",
"enable_linker_map",
"use_unstripped_as_runtime_outputs",

Просмотреть файл

@ -18,7 +18,6 @@ import("//build/config/mac/symbols.gni")
assert(host_os == "mac")
import("//build/toolchain/cc_wrapper.gni")
import("//build/toolchain/clang_static_analyzer.gni")
import("//build/toolchain/concurrent_links.gni")
import("//build/toolchain/goma.gni")
import("//build/toolchain/toolchain.gni")
@ -126,16 +125,6 @@ template("mac_toolchain") {
cxx = compiler_prefix + _cxx
ld = _cxx
if (use_clang_static_analyzer) {
analyzer_wrapper =
rebase_path("//build/toolchain/clang_static_analyzer_wrapper.py",
root_build_dir) + " --mode=clang"
cc = analyzer_wrapper + " ${cc}"
cxx = analyzer_wrapper + " ${cxx}"
ld = cxx
}
if (defined(toolchain_args.coverage_instrumentation_input_file)) {
toolchain_coverage_instrumentation_input_file =
toolchain_args.coverage_instrumentation_input_file
@ -146,10 +135,6 @@ template("mac_toolchain") {
_use_clang_coverage_wrapper =
toolchain_coverage_instrumentation_input_file != ""
if (_use_clang_coverage_wrapper) {
assert(!use_clang_static_analyzer,
"Clang static analyzer wrapper and Clang code coverage wrapper " +
"cannot be used together.")
_coverage_wrapper =
rebase_path("//build/toolchain/clang_code_coverage_wrapper.py",
root_build_dir) + " --files-to-instrument=" +
@ -188,8 +173,8 @@ template("mac_toolchain") {
dsym_switch = " -Wcrl,dsym,{{root_out_dir}} "
if (is_mac) {
dsym_switch += "-Wcrl,dsymutilpath," +
rebase_path("//tools/clang/dsymutil/bin/dsymutil",
root_build_dir) + " "
rebase_path("//tools/clang/dsymutil/bin/dsymutil",
root_build_dir) + " "
}
dsym_output_dir =

Просмотреть файл

@ -2,8 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/sysroot.gni")
import("//build/config/nacl/config.gni")
import("//build/config/sysroot.gni")
import("//build/toolchain/nacl_toolchain.gni")
# Add the toolchain revision as a preprocessor define so that sources are
@ -108,10 +108,6 @@ pnacl_toolchain("newlib_pnacl") {
pnacl_toolchain("newlib_pnacl_nonsfi") {
executable_extension = ""
strip = "strip"
if (use_clang_static_analyzer) {
is_clang_analysis_supported = false
}
}
template("nacl_glibc_toolchain") {

Просмотреть файл

@ -32,7 +32,6 @@ template("nacl_toolchain") {
"cc",
"cxx",
"deps",
"is_clang_analysis_supported",
"ld",
"link_outputs",
"nm",

Просмотреть файл

@ -7,7 +7,6 @@ import("//build/config/compiler/compiler.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//build/config/win/visual_studio_version.gni")
import("//build/toolchain/cc_wrapper.gni")
import("//build/toolchain/clang_static_analyzer.gni")
import("//build/toolchain/goma.gni")
import("//build/toolchain/toolchain.gni")
@ -91,26 +90,8 @@ template("msvc_toolchain") {
env = invoker.environment
# When the invoker has explicitly overridden use_goma or cc_wrapper in the
# toolchain args, use those values, otherwise default to the global one.
# This works because the only reasonable override that toolchains might
# supply for these values are to force-disable them.
if (defined(toolchain_args.is_clang)) {
toolchain_uses_clang = toolchain_args.is_clang
} else {
toolchain_uses_clang = is_clang
}
cl = invoker.cl
if (toolchain_uses_clang && use_clang_static_analyzer) {
analyzer_prefix =
"$python_path " +
rebase_path("//build/toolchain/clang_static_analyzer_wrapper.py",
root_build_dir) + " --mode=cl"
cl = "${analyzer_prefix} ${cl}"
}
if (use_lld) {
if (host_os == "win") {
lld_link = "lld-link.exe"
@ -141,7 +122,8 @@ template("msvc_toolchain") {
sys_include_flags = "${invoker.sys_include_flags} " # Note trailing space.
} else {
# clang-cl doesn't need this env hoop, so omit it there.
assert(!toolchain_uses_clang)
assert((defined(toolchain_args.is_clang) && !toolchain_args.is_clang) ||
!is_clang)
env_wrapper = "ninja -t msvc -e $env -- " # Note trailing space.
sys_include_flags = ""
}