[cfe-dev] clang-tidy: adding "--clang-tidy-config=<file-path>" to specify custom config file (was RE: clang-tidy -- using custom path config file)
Oza, Hiral via cfe-dev
cfe-dev at lists.llvm.org
Thu Oct 22 00:26:05 PDT 2020
Thanks James for your suggestions.
I have raised review request for adding support of '--clang-tidy-config=<file-path>'.
Review request is -- https://reviews.llvm.org/D89936
<patch_summary>
clang-tidy: adding "--clang-tidy-config=<file-path>" to specify custom config file.
Let clang-tidy to read config from specified file.
Example:
$ clang-tidy --clang-tidy-config=/some/path/myTidyConfig --list-checks --
...this will read config from '/some/path/myTidyConfig'.
May speed-up tidy runtime since now it will just look-up <file-path>
instead of searching ".clang-tidy" in parent-dir(s).
Directly specifying config path helps setting build dependencies.
</patch_summary>
As suggested in patch submission page (via git blame), I have also added Alexander Kornienko, Haojian Wu, Dmitry Polukhin and you.
Please let me know if I missed to add any other person in reviewer's list.
Thank you in advance for your kind review.
-Hiral
-----Original Message-----
From: Nathan James <n.james93 at hotmail.co.uk>
Sent: Saturday, October 10, 2020 6:40 PM
To: Oza, Hiral <Hiral.Oza at netapp.com>; cfe-dev at lists.llvm.org
Subject: Re: [cfe-dev] clang-tidy -- using custom path config file
NetApp Security WARNING: This is an external email. Do not click links or open attachments unless you recognize the sender and know the content is safe.
Hi Hiral,
Unfortunately such an option doesn't exist. While it is trivial to add one, I'm not too sure it would add enough value to justify it.
There is actually an alternative that could work for your use case without adding the option or symlinks by piping the file contents into the config option. It may look a little on the hacky side but does the job.
$ clang-tidy <input_files> --config="`cat </some/path/to/.clang-tidy>`"
The downside of this approach is it wont integrate nicely with tools taht use clang-tidy internally(clangd) or tools that handle invoking clang-tidy on their own (editor integrations etc). However for manually invoking clang-tidy it should do the job.
~Nathan
On Sat, 2020-10-10 at 12:56 +0000, Oza, Hiral via cfe-dev wrote:
> Thanks Nathan for reply.
>
> > The `--config` command line option is specifying the config inplace
> > that clang-tidy should use.
> Got it.
>
> Thanks for suggesting symlink :)
>
> I am looking for some option with clang-tidy such that $ clang-tidy
> --config-file-path </some/path/to/.clang-tidy> -- pick '.clang-tidy'
> from custom location not from parent(s) directories for a file name.
>
> Thanks,
>
>
> -----Original Message-----
> From: Nathan James <n.james93 at hotmail.co.uk>
> Sent: Saturday, October 10, 2020 5:08 PM
> To: Oza, Hiral <Hiral.Oza at netapp.com>; cfe-dev at lists.llvm.org
> Subject: Re: [cfe-dev] clang-tidy -- using custom path config file
>
> Hi Hiral,
>
> The `--config` command line option is specifying the config inplace
> that clang-tidy should use. Alot of the clang-tidy lit tests use this
> functionality, have a look at some tests files in `/clang-tools-
> extra/test/clang-tidy/checkers` for how this is done.
>
> If that option isn't specified, clang-tidy will fall back to recursing
> the parent directories for a file name .clang-tidy and use that as its
> config, in much the same way that clang-format does.
>
> I guess if you want to share a clang-tidy config across multiple
> projects your best bet is to symlink it to the root directory of each
> project
> > cd mr-project-dir
> > ln -s /some/path/to/my-tidy-config .clang-tidy
>
> ~Nathan
>
> On Sat, 2020-10-10 at 09:28 +0000, Oza, Hiral via cfe-dev wrote:
> > Greetings!
> >
> > Does clang-tidy accepts config (i.e. .clang-tidy) file from custom
> > path?
> > I am planning to use to have “.clang-tidy” maintained as
> > “/some/path/to/my-tidy-config” and need to pass
> > “/some/path/to/my-tidy-config” to clang-tidy.
> >
> > Tried :::
> > $ clang-tidy --config=/some/path/to/my-tidy-config
> > YAML:1:1: error: not a mapping
> > /some/path/to/my-tidy-config
> > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > Error: invalid configuration specified.
> > Invalid argument
> >
> > Any suggestion? Or existing patch?
> >
> > Thank you.
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list