[cfe-dev] Qt signal/slots checker impelmentation question

Manuel Klimek via cfe-dev cfe-dev at lists.llvm.org
Wed Nov 11 21:22:28 PST 2015


Just fyi: I do believe this would be simpler as a clang tidy check,  as it
seems to be purely AST based, and doesn't need path diagnostics.

On Thu, Nov 12, 2015, 12:39 AM Evgeniy Dushistov via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Hi,
>
> recently I submit patch to review that implement
> Qt signal/slot checker:
>
> http://reviews.llvm.org/D14592
>
> It basically checks that if you call QObject connect
> method, like this:
> connect(&send, SIGNAL(f2(int, double*)), &recv, SLOT(onf2(int,
> double*)));
>
> then `decltype(send)` have method `f2` with such signature
> and `decltype(recv)` have method `onf2` with matched signature,
> plus signatures of `f2` and `onf2` matches each other (actually
> param pack of `onf2` should be prefix of param pack of `f2`).
>
> SIGNAL and SLOT macroses convert their arguments to string,
> so in the checker I have two string and have to normalize them,
> for example convert types of function argument like this:
> `int const` -> `int`
> `const int` -> `int`
>
> Currently for normalization I use algorithm, similar to Qt:
> handed written parser around ~ 200 lines of code (
> of course it  has some unhandled cases, like handling of `volatile`).
>
> The expected input and output of such normalize algorithm
> can be found via patch review URL in file:
> unittests/StaticAnalyzer/QtSignalSlotCheckerTest.cpp
>
> And I wonder how many efforts and lines of code will be take
> "parse + print in desired way"
> inside Checker with libclang help?
>
> By `libclang help` I mean I receive control via
> `void checkPostCall(const CallEvent &Call, CheckerContext &C) const`
>
> and I found `connect` call with string like this:
> "f(const QString&, QVarint)"
>
> after that I ask libclang parse such forward function declaration:
> "extern void f(const QString&, QVariant);"
> and use types like `QString` and `QVariant` from current context.
>
> --
> /Evgeniy
> _______________________________________________
> 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/20151112/0166778d/attachment.html>


More information about the cfe-dev mailing list