[cfe-dev] Clang-tidy Qt Creator Integration

Nikolai Kosjar via cfe-dev cfe-dev at lists.llvm.org
Wed Sep 11 06:32:41 PDT 2019


On 9/11/19 2:25 PM, Maria Kosche via cfe-dev wrote:
> Hi all,
> 
> For checking some code according some custom code conventions, I cloned 
> the llvm repository and wrote two checks for clang-tidy. Using the 
> clang-tidy executable I already know that my checks behave as expected.
> 
> Until now I integrated my custom clang-tidy executable in Qt Creator by 
> using it as an external tool and passing it some options accordingly. 
> This also works.
> 
> Now I know, that the original clang-tidy/clazy is integrated in the Qt 
> Creator. In the documentation on Extra Clang Tools 10 I found a page 
> named „Clang-tidy IDE/Editor Integrations“. Qt Creator is here marked as 
> being to able to use a custom clang-tidy binary and I would like to use 
> that somehow.

I realize that "Custom clang-tidy binary" in that table is ambiguous:

  1. The IDE ships a custom/modified binary
     => Running other checks than provided by that binary might be hard
  2. The IDE allows using YOUR custom/modified binary
     => Pointing the IDE to another/YOUR clang-tidy binary with custom 
checks should work

So what's the intention of that column? I'll correct that for Qt Creator 
if necessary.

Currently, Qt Creator falls into category 1 but I'm working on this just 
now so eventually it will fall into category 2.

> Can I find somewhere any more information about this or 
> has someone already achieved replacing the Qt Creator’s clang and can 
> give me a hint on how to do so? So far I tried to statically link 
> clang-tidy into the clang executable and placed it in the Qt Creator’s 
> clang folder (along some libs), but this is not giving me any results yet.

What's the error message?
How do you invoke your clang-tidy binary?
Do you use the ClangTools plugin?

For the ClangTools plugin

   QT_LOGGING_RULES=qtc.clangtools.runner=true

will produce debugging output for the invocation (set it as run time env).

The way we link tidy into the clang binary is this:

https://code.qt.io/cgit/clang/llvm-project.git/commit/?h=release_80-based&id=daf5c3305335589cb50197b09e39cd0ce0289667

> I would be happy if you could tell me if I’m on the right track or if 
> there is something else I should do or try.
> 
> Thanks and greetings,
> 
> Mia

Nikolai





More information about the cfe-dev mailing list