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

Nathan James via cfe-dev cfe-dev at lists.llvm.org
Sat Oct 10 04:37:46 PDT 2020


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