Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2076569rdb; Mon, 9 Oct 2023 11:39:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE0NdlKxfXt0oUTUvSHIgRzpN7Q6wipwgjHd6YZ7QcPAcnE/63x9MnXbQUc9MHpWyyc1SxR X-Received: by 2002:a17:902:dac9:b0:1bf:4582:90d with SMTP id q9-20020a170902dac900b001bf4582090dmr20379655plx.46.1696876793714; Mon, 09 Oct 2023 11:39:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696876793; cv=none; d=google.com; s=arc-20160816; b=rlEwnhK3UgKtU+zsUbHPomKC2xqO0uZ1vxR+VvKDOeK5a0Ae0EpQRo9y1+DATeCnoV YBaRfyL83L4W/rTjULwU9vavOSU9gnpuQ5bA6eBMCJ1vyIRgseQhcno5oIy8pLsXYUlK ihJXZeAHTJRZxgekpU5lGOf8OJeo2M5Veem3EMi3XxtInzy71f7nazrsJdLIJL8H6vA6 OFH4BeIpDcDi1M190m1w8lTJBgA4ttS3am0wG28z9L93fP5s5nzqN4ibPvN5swLhJae4 ekvC2cgnQt22XVmTIBMJxFw4QZr0FfFS09QShxWlEPRcXBdWkB3PxDO8yUJYhUboitFL /S+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=husYgJZI8HkXIeEAlVmrxb2HP2ESjHLdcuso9o2l4OQ=; fh=8uoRd8OfBKdrcgzCS0TCbKG83gg6rx5b6zeE6Tx82zI=; b=DRs57nlfW5E51J1uCLXbQaNtn+rcUfYzwbYYtP+grnq7R9AsiThJBq7iCFRuo9EGll r8oBhY/IRPqCzdf+/gjhReQEaG5RcaWfXMSsnNuwWk7TurVptZgIqV8lWiA6MIuFLbIU voB411MJUqHAAxAIWKI4ACDq6C0XJzaN1I+5htZ91KS6bm7Kx80IXRJ5RULy5fyNlvRp +wZgu3JpOAvCfmtWQjldIDv8e4hHey8fINBEYRi6h5mly4JOikgX0FM5hUpeS5xW5lkD VifvVFW92g3JRck6pBk8EbFk5zj7dTL07qsAZDSdeRvJFQyjxkhpdq9NM3Uu+Nizm4x8 ShdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=pbgOyqyv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id h8-20020a170902f54800b001b895fc0cfdsi35277plf.388.2023.10.09.11.39.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 11:39:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=pbgOyqyv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 9E05B801B43E; Mon, 9 Oct 2023 11:39:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378307AbjJISjq (ORCPT + 99 others); Mon, 9 Oct 2023 14:39:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378229AbjJISjk (ORCPT ); Mon, 9 Oct 2023 14:39:40 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99F33A4 for ; Mon, 9 Oct 2023 11:39:36 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-59b5a586da6so39519087b3.1 for ; Mon, 09 Oct 2023 11:39:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696876776; x=1697481576; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=husYgJZI8HkXIeEAlVmrxb2HP2ESjHLdcuso9o2l4OQ=; b=pbgOyqyvlD011FRFCZ/wnDOEV5NneFzPc1aVqQOX6e9vd71ycHrFTGtTrzsDZpbS51 bRy1bc23HNVBTWBUNkbaWEyH0I0zxun1ux+KOKqJdfWvCiDaZO9S4CbXOwftQbK1Fbew G23hRCOPe+DEonYi44XWLaeZ1p+gdsUNgOChZUfpNqKZLan1DooqYNIvPUDMJDMFqB1V jMgQk0o1Ileg0vhoIrVvllaRXwzBaEhJAiwIAP5sWVw9AmMJ7KRmvOcrEaf4nZ0e0AIA ENkf4UU409d3SGJ6YzaCbgQqFvY63FzZkGo6S/PQ5g8GIpqgku46+K3o655OJ3C/qArk IqmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696876776; x=1697481576; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=husYgJZI8HkXIeEAlVmrxb2HP2ESjHLdcuso9o2l4OQ=; b=O9X41lfo7jG0zDljaGTwkRWLlYhVpra2xrRy/v5jU4k/NuJN2Qg3+B9SuZZf1fwvBh UXXgyh7qaTz/av6EmwpbwCMggfao5STCDnh6wNDjy2A/cOHHzQAXo85vqHoANJY4MTIc 1/fiLvk9NnA8ZTZWHoSmWgRzisWQmdTadTDKOqZTi/3w3aj9EWPAujnZQjMxCXwZFgb8 GEaO+OdqikJhs9YL/WNzZtTd5gsQfNURTh6k4dlMQisGcfQ9ymWC6msynWplDYVAvF2D X9yvfj66Vbj7idDwGjOMNROm0bcve5RQA4HX9rhfJgQu2FoWhXiKTSiVvErXLtdVFaB3 PUOw== X-Gm-Message-State: AOJu0YwNGS64e0QVT2f9nsBOySnUtCICCLOjJLk3zgXs4xMP/xE1u/T7 T09MoAfCWOPp4XMSjiyvQ/pIEEgaYSqC X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:ac4a:9b94:7158:3f4e]) (user=irogers job=sendgmr) by 2002:a05:690c:c90:b0:59b:b0b1:d75a with SMTP id cm16-20020a05690c0c9000b0059bb0b1d75amr262884ywb.4.1696876775752; Mon, 09 Oct 2023 11:39:35 -0700 (PDT) Date: Mon, 9 Oct 2023 11:39:05 -0700 In-Reply-To: <20231009183920.200859-1-irogers@google.com> Message-Id: <20231009183920.200859-5-irogers@google.com> Mime-Version: 1.0 References: <20231009183920.200859-1-irogers@google.com> X-Mailer: git-send-email 2.42.0.609.gbb76f46606-goog Subject: [PATCH v3 03/18] run-clang-tools: Add pass through checks and header-filter arguments From: Ian Rogers To: Nathan Chancellor , Nick Desaulniers , Tom Rix , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Yang Jihong , Huacai Chen , Ming Wang , Kan Liang , Ravi Bangoria , llvm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 09 Oct 2023 11:39:52 -0700 (PDT) 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 Reviewed-by: Nick Desaulniers --- 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