[cfe-dev] clang-tidy -- using custom path config file
Nathan James via cfe-dev
cfe-dev at lists.llvm.org
Sat Oct 10 06:09:45 PDT 2020
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
$ 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.
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.
> -----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
> > cd mr-project-dir
> > ln -s /some/path/to/my-tidy-config .clang-tidy
> 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
More information about the cfe-dev