From: Ian Rogers <irogers@google.com>
To: Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Tom Rix <trix@redhat.com>, Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Yicong Yang <yangyicong@hisilicon.com>,
Jonathan Cameron <jonathan.cameron@huawei.com>,
Yang Jihong <yangjihong1@huawei.com>,
Kan Liang <kan.liang@linux.intel.com>,
Ming Wang <wangming01@loongson.cn>,
Huacai Chen <chenhuacai@kernel.org>,
Sean Christopherson <seanjc@google.com>,
K Prateek Nayak <kprateek.nayak@amd.com>,
Yanteng Si <siyanteng@loongson.cn>,
Yuan Can <yuancan@huawei.com>,
Ravi Bangoria <ravi.bangoria@amd.com>,
James Clark <james.clark@arm.com>,
llvm@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-perf-users@vger.kernel.org, bpf@vger.kernel.org
Subject: [PATCH v2 03/18] run-clang-tools: Add pass through checks and and header-filter arguments
Date: Thu, 5 Oct 2023 16:08:36 -0700 [thread overview]
Message-ID: <20231005230851.3666908-4-irogers@google.com> (raw)
In-Reply-To: <20231005230851.3666908-1-irogers@google.com>
Add a -checks argument to allow the checks passed to the clang-tool to
be set on the command line.
Add a pass through -header-filter option.
Don't run analysis on non-C or CPP files.
Signed-off-by: Ian Rogers <irogers@google.com>
---
scripts/clang-tools/run-clang-tools.py | 32 ++++++++++++++++++++------
1 file changed, 25 insertions(+), 7 deletions(-)
diff --git a/scripts/clang-tools/run-clang-tools.py b/scripts/clang-tools/run-clang-tools.py
index 3266708a8658..f31ffd09e1ea 100755
--- a/scripts/clang-tools/run-clang-tools.py
+++ b/scripts/clang-tools/run-clang-tools.py
@@ -33,6 +33,11 @@ def parse_arguments():
path_help = "Path to the compilation database to parse"
parser.add_argument("path", type=str, help=path_help)
+ checks_help = "Checks to pass to the analysis"
+ parser.add_argument("-checks", type=str, default=None, help=checks_help)
+ header_filter_help = "Pass the -header-filter value to the tool"
+ parser.add_argument("-header-filter", type=str, default=None, help=header_filter_help)
+
return parser.parse_args()
@@ -45,14 +50,27 @@ def init(l, a):
def run_analysis(entry):
# Disable all checks, then re-enable the ones we want
- checks = []
- checks.append("-checks=-*")
- if args.type == "clang-tidy":
- checks.append("linuxkernel-*")
+ global args
+ checks = None
+ if args.checks:
+ checks = args.checks.split(',')
else:
- checks.append("clang-analyzer-*")
- checks.append("-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling")
- p = subprocess.run(["clang-tidy", "-p", args.path, ",".join(checks), entry["file"]],
+ checks = ["-*"]
+ if args.type == "clang-tidy":
+ checks.append("linuxkernel-*")
+ else:
+ checks.append("clang-analyzer-*")
+ checks.append("-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling")
+ file = entry["file"]
+ if not file.endswith(".c") and not file.endswith(".cpp"):
+ with lock:
+ print(f"Skipping non-C file: '{file}'", file=sys.stderr)
+ return
+ pargs = ["clang-tidy", "-p", args.path, "-checks=" + ",".join(checks)]
+ if args.header_filter:
+ pargs.append("-header-filter=" + args.header_filter)
+ pargs.append(file)
+ p = subprocess.run(pargs,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
cwd=entry["directory"])
--
2.42.0.609.gbb76f46606-goog
next prev parent reply other threads:[~2023-10-05 23:09 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-05 23:08 [PATCH v2 00/18] clang-tools support in tools Ian Rogers
2023-10-05 23:08 ` [PATCH v2 01/18] gen_compile_commands: Allow the line prefix to still be cmd_ Ian Rogers
2023-10-05 23:08 ` [PATCH v2 02/18] gen_compile_commands: Sort output compile commands by file name Ian Rogers
2023-10-05 23:08 ` Ian Rogers [this message]
2023-10-06 21:22 ` [PATCH v2 03/18] run-clang-tools: Add pass through checks and and header-filter arguments Nick Desaulniers
2023-10-05 23:08 ` [PATCH v2 04/18] perf hisi-ptt: Fix potential memory leak Ian Rogers
2023-10-09 5:41 ` Namhyung Kim
2023-10-09 15:45 ` Ian Rogers
2023-10-05 23:08 ` [PATCH v2 05/18] perf bench uprobe: Fix potential use of memory after free Ian Rogers
2023-10-09 5:51 ` Namhyung Kim
2023-10-09 16:13 ` Ian Rogers
2023-10-05 23:08 ` [PATCH v2 06/18] perf buildid-cache: Fix use of uninitialized value Ian Rogers
2023-10-09 6:06 ` Namhyung Kim
2023-10-09 16:22 ` Ian Rogers
2023-10-05 23:08 ` [PATCH v2 07/18] perf env: Remove unnecessary NULL tests Ian Rogers
2023-10-09 6:14 ` Namhyung Kim
2023-10-09 16:33 ` Ian Rogers
2023-10-05 23:08 ` [PATCH v2 08/18] perf jitdump: Avoid memory leak Ian Rogers
2023-10-05 23:08 ` [PATCH v2 09/18] perf mem-events: Avoid uninitialized read Ian Rogers
2023-10-05 23:08 ` [PATCH v2 10/18] perf dlfilter: Be defensive against potential NULL dereference Ian Rogers
2023-10-09 6:21 ` Namhyung Kim
2023-10-05 23:08 ` [PATCH v2 11/18] perf hists browser: Reorder variables to reduce padding Ian Rogers
2023-10-05 23:08 ` [PATCH v2 12/18] perf hists browser: Avoid potential NULL dereference Ian Rogers
2023-10-05 23:08 ` [PATCH v2 13/18] perf svghelper: Avoid memory leak Ian Rogers
2023-10-09 6:31 ` Namhyung Kim
2023-10-09 16:37 ` Ian Rogers
2023-10-05 23:08 ` [PATCH v2 14/18] perf parse-events: Fix unlikely memory leak when cloning terms Ian Rogers
2023-10-05 23:08 ` [PATCH v2 15/18] tools api: Avoid potential double free Ian Rogers
2023-10-05 23:08 ` [PATCH v2 16/18] perf trace-event-info: Avoid passing NULL value to closedir Ian Rogers
2023-10-05 23:08 ` [PATCH v2 17/18] perf header: Fix various error path memory leaks Ian Rogers
2023-10-09 6:57 ` Namhyung Kim
2023-10-09 17:13 ` Ian Rogers
2023-10-05 23:08 ` [PATCH v2 18/18] perf bpf_counter: Fix a few " Ian Rogers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231005230851.3666908-4-irogers@google.com \
--to=irogers@google.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=bpf@vger.kernel.org \
--cc=chenhuacai@kernel.org \
--cc=james.clark@arm.com \
--cc=jolsa@kernel.org \
--cc=jonathan.cameron@huawei.com \
--cc=kan.liang@linux.intel.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=peterz@infradead.org \
--cc=ravi.bangoria@amd.com \
--cc=seanjc@google.com \
--cc=siyanteng@loongson.cn \
--cc=trix@redhat.com \
--cc=wangming01@loongson.cn \
--cc=yangjihong1@huawei.com \
--cc=yangyicong@hisilicon.com \
--cc=yuancan@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).