[cfe-dev] clang-tidy -- using custom path config file

Oza, Hiral via cfe-dev cfe-dev at lists.llvm.org
Sat Oct 10 05:56:53 PDT 2020


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



More information about the cfe-dev mailing list