Clang-tidy Qt Creator Integration

> 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@DiagnosticRenderer@clang@@QAEXVFullSourceLoc@2@
W4Level
>
@DiagnosticsEngine@2@VStringRef@llvm@@V?$ArrayRef@VCharSourceRa
nge@cla
>
ng@@@7@V?$ArrayRef@VFixItHint@clang@@@7@V?$PointerUnion@PBV
Diagnostic@
> clang@@PBVStoredDiagnostic@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@codeview@llvm@@YA_NV?$ArrayRef@E@
2@AAV?$S
> mallVectorImpl@VTypeIndex@codeview@llvm@@@2@@Z() + 0x11D8
bytes(s)
> 0x0126040A (0x0118E580 0x073C24B8 0x00003A5A 0x000059BC),
>
?IncludeInDiagnosticCounts@ChainedDiagnosticConsumer@clang@@UBE_N
XZ()
> + 0x40A bytes(s)
> 0x02D75D88 (0x053C86C0 0x00000000 0x0512B930 0x0118E580),
>
?onBodySynthesis@ModelInjector@ento@clang@@AAEXPBVNamedDecl@
3@@Z() +
> 0x948 bytes(s)
> 0x02D75DB2 (0x0118E5D8 0x0118EA1C 0x00000012 0x00000002),
>
?onBodySynthesis@ModelInjector@ento@clang@@AAEXPBVNamedDecl@
3@@Z() +
> 0x972 bytes(s) 0x021426DC (0x00000000 0x00000000 0x0118E5EC
> 0x00000000),
>
?has_root_name@path@sys@llvm@@YA_NABVTwine@3@W4Style@123@
@Z() + 0x5C
> bytes(s) 0x0214270D (0x0118EB20 0x08FF84D0 0xBB9208F2 0x033C3F80),
>
?has_root_name@path@sys@llvm@@YA_NABVTwine@3@W4Style@123@
@Z() + 0x8D
> bytes(s)
> 0x033BD520 (0x0000001B 0x00000012 0x000059BC 0x000059D7),
> ??MDynTypedNode@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@VFunctionDecl@clang@@VStmt@2
@@internal
>
@ast_matchers@clang@@UBE_NABVFunctionDecl@4@PAVASTMatchFinde
r@234@PAVB
> oundNodesTreeBuilder@234@@Z() + 0x1C894 bytes(s)
> 0x025BCD01 (0x00000000 0x00000000 0x00000000 0x05376728),
> ?EndSourceFile@FrontendAction@clang@@QAEXXZ() + 0x31 bytes(s)
> 0x025BD0E9 (0x05148880 0x053CA178 0xBB92012A 0x025965C7),
> ?ExecuteAction@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?

Qt Creator 4.10 and earlier versions invoke clang-tidy through clang's plugin
interface (calling clang.exe and providing args to invoke the clang-tidy plugin).
If the check is fine with an invocation of clang-tidy.exe on the command line,
but fails in Qt Creator, the invocation via the plugin interface might be the
problem and should be investigated.

Qt Creator 4.11, which is not released yet, invokes clang-tidy through the
clang-tidy binary. If the plugin interface is the culprit, I would assume that it
should work with Qt Creator 4.11 (current snapshot at
http://download.qt.io/snapshots/qtcreator/4.11/4.11.0-beta1/). If it doesn't,
yes, feel free to report at

   https://bugreports.qt.io/
   Project: Qt Creator
   Component: Clang-Tidy & Clazy Analyzer

Nikolai

I already tried out the 4.11 beta, and it seems to work. However, the process of managing the checks to use or how to use a .clang-tidy configuration file instead has changed a bit, so I will have to take a closer look at that, but I no longer get the weird error from above and finally get some check warnings.

Thanks and greetings,
Maria