[cfe-dev] how clang-tidy finds clang-format file

Adam Cieszkiel via cfe-dev cfe-dev at lists.llvm.org
Thu Jul 20 14:47:23 PDT 2017


Hello,

Thank you for the answer.

It was my first guess and I was surprised that it did not work.

I have to use '-export-fixes=' so it works. Then the fixes are written into
json file and 'clang-apply-replacements -format -style=file' does the job.
But it does want to work without this exporting.

In version 5.0 I just use option '-format-style=file' and it uses
.clang-format file in the closest parent directory as described in the
documentation:
https://clang.llvm.org/extra/clang-tidy/index.html

But in version 4.0 there is only option "-style" which seems to not offer
such option and does not work with .clang-format from the folder I run
clang-tidy.

-style=<string>              -
Fallback style for reformatting after inserting fixes
               if there is no clang-format config file found.


I am not sure why it it like that.

Best regards,
Adam.




On Thu, Jul 20, 2017 at 11:18 PM, Piotr Padlewski <piotr.padlewski at gmail.com
> wrote:

> Hi Adam,
> it should look for ".clang-format" from the place where you run
> clang-tidy. I hope it helps.
>
> Piotr
>
> 2017-07-20 13:25 GMT-07:00 Adam Cieszkiel via cfe-dev <
> cfe-dev at lists.llvm.org>:
>
>> Hello,
>>
>> I have a question:
>> Do you know maybe how to make clang-tidy in version 4.0 use formatting
>> style for fixes (-fix) from .clang-format file?
>>
>> I tried in many different ways but I failed.
>>
>> Documentation mentions 'clang-format config file to be found' but
>> anywhere I put it, it is still not used by clang-tidy also if I put in in
>> location pointed by '-p' option.
>>
>> http://releases.llvm.org/4.0.0/tools/clang/tools/extra/docs/
>> clang-tidy/index.html
>>
>> -style=<string>              -                                 Fallback style for reformatting after inserting fixes                                 if there is no clang-format config file found.
>>
>> I have no idea where I should put .clang-format file so it could be used
>> by clang-tidy for applying clang-tidy fixes.
>>
>> Thank you in advance.
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170720/120a5a90/attachment.html>


More information about the cfe-dev mailing list