[cfe-dev] Clang-tidy Qt Creator Integration

Maria Kosche via cfe-dev cfe-dev at lists.llvm.org
Mon Oct 14 05:31:33 PDT 2019


Thank you very much for your hints. So far everything works now. I made the stupid mistake to have Clang 10.0.0 copied into the Qt Creator directory, but the include files where still used from version 8.0.1, which lead to some errors.
Now I just stumbled across an error regarding the llvm-header-guard check. I wrote a similar check by myself to check for the header guard format, and the whole time I thought I was doing something wrong in my check, because I get an error containing  the following excerpt:

0x025A3862 (0x0000003F 0x77841F3E 0x00000000 0x00000000), ?emitDiagnostic at DiagnosticRenderer@clang@@QAEXVFullSourceLoc at 2@W4Level at DiagnosticsEngine@2 at VStringRef@llvm@@V?$ArrayRef at VCharSourceRange@clang@@@7 at V?$ArrayRef at VFixItHint@clang@@@7 at V?$PointerUnion at PBVDiagnostic@clang@@PBVStoredDiagnostic at 2@@7@@Z() + 0x22 bytes(s)
0x77841F3E (0x05370000 0x00000000 0x00000040 0x0000003E), RtlAllocateHeap() + 0x3E bytes(s)
0x76C3FDF6 (0x0118E9A4 0x0000003E 0x0126040A 0x073C24B8), _malloc_base() + 0x26 bytes(s)
0x03690268 (0x073C24B8 0x0118E580 0x0000003E 0x073C2590), ?discoverTypeIndicesInSymbol at codeview@llvm@@YA_NV?$ArrayRef at E@2 at AAV?$SmallVectorImpl at VTypeIndex@codeview at llvm@@@2@@Z() + 0x11D8 bytes(s)
0x0126040A (0x0118E580 0x073C24B8 0x00003A5A 0x000059BC), ?IncludeInDiagnosticCounts at ChainedDiagnosticConsumer@clang@@UBE_NXZ() + 0x40A bytes(s)
0x02D75D88 (0x053C86C0 0x00000000 0x0512B930 0x0118E580), ?onBodySynthesis at ModelInjector@ento at clang@@AAEXPBVNamedDecl at 3@@Z() + 0x948 bytes(s)
0x02D75DB2 (0x0118E5D8 0x0118EA1C 0x00000012 0x00000002), ?onBodySynthesis at ModelInjector@ento at clang@@AAEXPBVNamedDecl at 3@@Z() + 0x972 bytes(s)
0x021426DC (0x00000000 0x00000000 0x0118E5EC 0x00000000), ?has_root_name at path@sys at llvm@@YA_NABVTwine at 3@W4Style at 123@@Z() + 0x5C bytes(s)
0x0214270D (0x0118EB20 0x08FF84D0 0xBB9208F2 0x033C3F80), ?has_root_name at path@sys at llvm@@YA_NABVTwine at 3@W4Style at 123@@Z() + 0x8D bytes(s)
0x033BD520 (0x0000001B 0x00000012 0x000059BC 0x000059D7), ??MDynTypedNode at ast_type_traits@clang@@QBE_NABV012@@Z() + 0xFF80 bytes(s)
0x778450C1 (0x778450A0 0x053CE468 0x00000000 0x053C0001), RtlFreeHeap() + 0x201 bytes(s)
0x778465E5 (0x053CE468 0x00000000 0x053C0001 0x073C2590), RtlFreeUnicodeString() + 0x1A5 bytes(s)
0x778450A0 (0x08BA9200 0x00000000 0x0000000F 0x025B6000), RtlFreeHeap() + 0x1E0 bytes(s)
0x02AD07E4 (0x05148880 0x053CA178 0x053C8E40 0x05376728), ?matches@?$HasDescendantMatcher at VFunctionDecl@clang@@VStmt at 2@@internal at ast_matchers@clang@@UBE_NABVFunctionDecl at 4@PAVASTMatchFinder at 234@PAVBoundNodesTreeBuilder at 234@@Z() + 0x1C894 bytes(s)
0x025BCD01 (0x00000000 0x00000000 0x00000000 0x05376728), ?EndSourceFile at FrontendAction@clang@@QAEXXZ() + 0x31 bytes(s)
0x025BD0E9 (0x05148880 0x053CA178 0xBB92012A 0x025965C7), ?ExecuteAction at ASTFrontendAction@clang@@MAEXXZ() + 0x69 bytes(s)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 8.0.1 
Target: i686-w64-windows-gnu
Thread model: posix
InstalledDir: C:\Qt\Tools\QtCreator\bin\clang\bin
clang: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: C:\Users\macio\AppData\Local\Temp\main-69856e.cpp
clang: note: diagnostic msg: C:\Users\macio\AppData\Local\Temp\main-69856e.sh
clang: note: diagnostic msg: 

********************


I now had to realise that this error is also produced with the clang executable originally shipped with the Qt Creator when using the llvm-header-guard check. Since the check is working out of the command line, I'm afraid this has something to do with the Clang plugin in Qt Creator and not with the check itself. Is there anything I can do about it or should I better make a bug report ready for the Qt developers? 

Thanks and greetings,
Maria

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