Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2076544rdb; Mon, 9 Oct 2023 11:39:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHGkLX8w0Uv3Hp0lWiljn0L2KYfAL5cYl/slLQupvD4Uh4jhfVbLJRaZYrYjG1+L1mMobtn X-Received: by 2002:a05:6a00:2d89:b0:68f:da2a:6370 with SMTP id fb9-20020a056a002d8900b0068fda2a6370mr15375645pfb.13.1696876789958; Mon, 09 Oct 2023 11:39:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696876789; cv=none; d=google.com; s=arc-20160816; b=yqoEOd+qhqTnPfncrYq8x9UgOeXL11oMfg79b+Cd+fWZYSLCNM2YSixywQKCJcDhoO yiMNHU9DsJ5O3iUJbH15KmlOikz7f9uFa5kIneiWtAVYJhmLJYf2ymPSTOUAN55p8jSm /o4PeK1GuU+lPN3SzGj1mLBqiusmarsAHMKyUOzGkcJOlarCx4C5glIVL8sPRVO65h/J +30xyAW4CEAIZLZEmCT3iMArv50tOHRtqHv0dYhSuGcIK85u3B5fm6XYzwzEB6/LBpKc ri+/f1s3g1dUi8hxXKjN/Zh2Don960QJzS2QODRzmMbyMQTIxZWiyyvT6bEgD5IEuL/U SfiA== 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=iWAQj7a9DLEF9vrHRkVnP4YA5VLiDUri89cAUpce9USunejW1Wl2gRajv1M9BLEh8f JULwTPjfGe3gCGIr3T4xyi4mGRmlqK6HXpwab8iumS4ZZ27Mr5JfzZQ2Gla/gvGe762B IPtGBHq/+/qES/CtqsX6hvNs5Fzz4+OZ4a6mJ2sBS2IPhC75Akdkisr5EV69oeGRzI1s jSWRqS2/xUvAgcGZ5vjP0GO/pURmn38eqkhZq/2vlZilvdRPJVpMu+UEcR6DCP/MzEGe PK4xkZx3eFHnfNFni5vNe32rBhuzns9qV1NiZ0ZqhxxeKETj4AmFpO8VMLH5bKPxcd5w Crzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=q3MwS5Sq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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. [23.128.96.37]) by mx.google.com with ESMTPS id x6-20020a63fe46000000b00573f7e9d75asi9914847pgj.646.2023.10.09.11.39.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 11:39:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=q3MwS5Sq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 18C62801B42E; Mon, 9 Oct 2023 11:39:49 -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 S1378209AbjJISjm (ORCPT + 99 others); Mon, 9 Oct 2023 14:39:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378230AbjJISjg (ORCPT ); Mon, 9 Oct 2023 14:39:36 -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 0F1E3CA for ; Mon, 9 Oct 2023 11:39:34 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-59f7d109926so74264337b3.2 for ; Mon, 09 Oct 2023 11:39:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696876773; x=1697481573; 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=q3MwS5SqifOzUElLTHKWkRfZVws4YDTwoeM6IgNevANP0y+8+EOzK57e63WLiODxJX 1on8wng9ck5yUo113CPYVkTKH/vhDJ379EuFMBNkjoY0YkSFQES/4+t75/mTtQSYKgup fmS7T4Y2mgfC3jhkaoVNsapb1CXkI48j6qiIeMCcQ9FmAmyG3EiBk+U9rh8u9ilgf+Xn 4g8GXp0lmJJvv92MH7iNbyntf/eMtK64JTgXeu1yprg8Eg3uRJwOAo0f5uBCH2UUylry pgwiCXEbuKYjwsN3qvchhjRWYz2TbUwrIKVqyHfUdcwMGVr9K7u+RmLzg1+0vHmu9qD1 ZM3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696876773; x=1697481573; 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=sqRlUzrGL5Hq7BpezTP7j/w4r/mZnOJSTmBzoZ7dReiRuIVkb7RmMIL9A7qAhNL/Fw AUZejaZ7TA8rexS0vwTwCOI+K6cAE+DWm0hdNDegCXCRpUVSJrBv6ip3EEbc8l7Ej/5E wcKKYCP2u17oAOzr9wefiEeodoQbbNAzGAKKHpkVqQnzkpKKwLouPVOIezh0GEe3ityW +1hA/WkCSIxTsPw3XTlmvwOTL70Ig0YhaYf5zs9JZxnPYdG2NieYLZhFyIoklRFJO3wd RdfTzlN/0M0v1XWk1omVIvYPE7qwm9yJwNqrwycVJ1sv8x47txola/SO7OkXgNsRj8RS nhPg== X-Gm-Message-State: AOJu0YyTKT6LBWY/4ByxgtHClgzCU1a5+logBVLb3pPRWDBzWKC7lQa6 d0YAweh/r7dK/Unb2/6fZubyXUO2yn+i X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:ac4a:9b94:7158:3f4e]) (user=irogers job=sendgmr) by 2002:a05:6902:212:b0:d89:b072:d06f with SMTP id j18-20020a056902021200b00d89b072d06fmr251520ybs.7.1696876773275; Mon, 09 Oct 2023 11:39:33 -0700 (PDT) Date: Mon, 9 Oct 2023 11:39:04 -0700 In-Reply-To: <20231009183920.200859-1-irogers@google.com> Message-Id: <20231009183920.200859-4-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 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=unavailable 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:49 -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