2022-10-11 19:32:20

by Guru Das Srinagesh

[permalink] [raw]
Subject: [PATCH 1/1] scripts/clang-tools: Convert clang-tidy args to list

Convert list of clang-tidy arguments to a list for ease of adding to
them and extending them as required.

Signed-off-by: Guru Das Srinagesh <[email protected]>
Suggested-by: Nick Desaulniers <[email protected]>
---
scripts/clang-tools/run-clang-tools.py | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/scripts/clang-tools/run-clang-tools.py b/scripts/clang-tools/run-clang-tools.py
index bb78c9b..56f2ec8 100755
--- a/scripts/clang-tools/run-clang-tools.py
+++ b/scripts/clang-tools/run-clang-tools.py
@@ -45,13 +45,14 @@ def init(l, a):

def run_analysis(entry):
# Disable all checks, then re-enable the ones we want
- checks = "-checks=-*,"
+ checks = []
+ checks.append("-checks=-*")
if args.type == "clang-tidy":
- checks += "linuxkernel-*"
+ checks.append("linuxkernel-*")
else:
- checks += "clang-analyzer-*"
- checks += ",-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling"
- p = subprocess.run(["clang-tidy", "-p", args.path, checks, entry["file"]],
+ checks.append("clang-analyzer-*")
+ checks.append("-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling")
+ p = subprocess.run(["clang-tidy", "-p", args.path, ",".join(checks), entry["file"]],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
cwd=entry["directory"])
--
2.7.4


2022-10-11 20:41:01

by Nick Desaulniers

[permalink] [raw]
Subject: Re: [PATCH 1/1] scripts/clang-tools: Convert clang-tidy args to list

On Tue, Oct 11, 2022 at 12:06 PM Guru Das Srinagesh
<[email protected]> wrote:
>
> Convert list of clang-tidy arguments to a list for ease of adding to
> them and extending them as required.
>
> Signed-off-by: Guru Das Srinagesh <[email protected]>
> Suggested-by: Nick Desaulniers <[email protected]>

Thanks for the patch!
Reviewed-by: Nick Desaulniers <[email protected]>

Masahiro, would you please be able to carry this up through the kbuild tree?

> ---
> scripts/clang-tools/run-clang-tools.py | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/scripts/clang-tools/run-clang-tools.py b/scripts/clang-tools/run-clang-tools.py
> index bb78c9b..56f2ec8 100755
> --- a/scripts/clang-tools/run-clang-tools.py
> +++ b/scripts/clang-tools/run-clang-tools.py
> @@ -45,13 +45,14 @@ def init(l, a):
>
> def run_analysis(entry):
> # Disable all checks, then re-enable the ones we want
> - checks = "-checks=-*,"
> + checks = []
> + checks.append("-checks=-*")
> if args.type == "clang-tidy":
> - checks += "linuxkernel-*"
> + checks.append("linuxkernel-*")
> else:
> - checks += "clang-analyzer-*"
> - checks += ",-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling"
> - p = subprocess.run(["clang-tidy", "-p", args.path, checks, entry["file"]],
> + checks.append("clang-analyzer-*")
> + checks.append("-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling")
> + p = subprocess.run(["clang-tidy", "-p", args.path, ",".join(checks), entry["file"]],
> stdout=subprocess.PIPE,
> stderr=subprocess.STDOUT,
> cwd=entry["directory"])
> --
> 2.7.4
>


--
Thanks,
~Nick Desaulniers

2022-10-11 21:58:06

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH 1/1] scripts/clang-tools: Convert clang-tidy args to list

On Wed, Oct 12, 2022 at 5:34 AM Nick Desaulniers
<[email protected]> wrote:
>
> On Tue, Oct 11, 2022 at 12:06 PM Guru Das Srinagesh
> <[email protected]> wrote:
> >
> > Convert list of clang-tidy arguments to a list for ease of adding to
> > them and extending them as required.
> >
> > Signed-off-by: Guru Das Srinagesh <[email protected]>
> > Suggested-by: Nick Desaulniers <[email protected]>
>
> Thanks for the patch!
> Reviewed-by: Nick Desaulniers <[email protected]>
>
> Masahiro, would you please be able to carry this up through the kbuild tree?


Applied to linux-kbuild. Thanks.



> > ---
> > scripts/clang-tools/run-clang-tools.py | 11 ++++++-----
> > 1 file changed, 6 insertions(+), 5 deletions(-)
> >
> > diff --git a/scripts/clang-tools/run-clang-tools.py b/scripts/clang-tools/run-clang-tools.py
> > index bb78c9b..56f2ec8 100755
> > --- a/scripts/clang-tools/run-clang-tools.py
> > +++ b/scripts/clang-tools/run-clang-tools.py
> > @@ -45,13 +45,14 @@ def init(l, a):
> >
> > def run_analysis(entry):
> > # Disable all checks, then re-enable the ones we want
> > - checks = "-checks=-*,"
> > + checks = []
> > + checks.append("-checks=-*")
> > if args.type == "clang-tidy":
> > - checks += "linuxkernel-*"
> > + checks.append("linuxkernel-*")
> > else:
> > - checks += "clang-analyzer-*"
> > - checks += ",-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling"
> > - p = subprocess.run(["clang-tidy", "-p", args.path, checks, entry["file"]],
> > + checks.append("clang-analyzer-*")
> > + checks.append("-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling")
> > + p = subprocess.run(["clang-tidy", "-p", args.path, ",".join(checks), entry["file"]],
> > stdout=subprocess.PIPE,
> > stderr=subprocess.STDOUT,
> > cwd=entry["directory"])
> > --
> > 2.7.4
> >
>
>
> --
> Thanks,
> ~Nick Desaulniers



--
Best Regards
Masahiro Yamada