Re: [PATCH] scripts: run-clang-tools: add file filtering option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Masahiro,

On Sat Aug 3, 2024 at 10:42 AM CEST, Masahiro Yamada wrote:
> On Thu, Jul 4, 2024 at 6:28 PM Théo Lebrun <theo.lebrun@xxxxxxxxxxx> wrote:
> > +def filter_entries(datastore, filters):
> > +    for entry in datastore:
> > +        if filters == []:
> > +            yield entry
> > +            continue
>
> Maybe, this can be checked on the caller side.
> (Note, I did not test this at all)
>
> if args.file_filter:
>         datastore = filter_entries(datastore, args.file_filter)

Agreed.

> > +
> > +        assert entry['file'].startswith(entry['directory'])
> > +        # filepath is relative to the directory, to avoid matching on the absolute path
>
> Does this assertion work with the separate output directory
> (O= option)?
>
> Just try this command:
>
>  $ make LLVM=1 O=/tmp/foo clang-tidy

Indeed this does not work. It requires some changes to Makefiles to see
that it does not work, as this assertion is only used when a filter is
passed (which current cmd_clang_tools cannot do).

What would you recommend to fix that? If we take the first entry:

  {
    "command": "clang ...",
    "directory": "/tmp/foo",
    "file": "/ABSOLUTE/PATH/linux-clang-tidy/arch/mips/crypto/crc32-mips.c"
  },

I don't see an easy way to know that "/ABSOLUTE/PATH/linux-clang-tidy/"
should be removed. We could probably compute it from the command value
but that isn't a great way forward.

There are some entries that look like this. Those are easy to deal with.

  {
    "command": "clang ...",
    "directory": "/tmp/foo",
    "file": "/tmp/foo/drivers/tty/vt/defkeymap.c"
  }

Regards,

--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com






[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux