<p dir="ltr">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. </p>
<br><div class="gmail_quote"><div dir="ltr">On Thu, Nov 12, 2015, 12:39 AM Evgeniy Dushistov via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
recently I submit patch to review that implement<br>
Qt signal/slot checker:<br>
<br>
<a href="http://reviews.llvm.org/D14592" rel="noreferrer" target="_blank">http://reviews.llvm.org/D14592</a><br>
<br>
It basically checks that if you call QObject connect<br>
method, like this:<br>
connect(&send, SIGNAL(f2(int, double*)), &recv, SLOT(onf2(int,<br>
double*)));<br>
<br>
then `decltype(send)` have method `f2` with such signature<br>
and `decltype(recv)` have method `onf2` with matched signature,<br>
plus signatures of `f2` and `onf2` matches each other (actually<br>
param pack of `onf2` should be prefix of param pack of `f2`).<br>
<br>
SIGNAL and SLOT macroses convert their arguments to string,<br>
so in the checker I have two string and have to normalize them,<br>
for example convert types of function argument like this:<br>
`int const` -> `int`<br>
`const int` -> `int`<br>
<br>
Currently for normalization I use algorithm, similar to Qt:<br>
handed written parser around ~ 200 lines of code (<br>
of course it has some unhandled cases, like handling of `volatile`).<br>
<br>
The expected input and output of such normalize algorithm<br>
can be found via patch review URL in file:<br>
unittests/StaticAnalyzer/QtSignalSlotCheckerTest.cpp<br>
<br>
And I wonder how many efforts and lines of code will be take<br>
"parse + print in desired way"<br>
inside Checker with libclang help?<br>
<br>
By `libclang help` I mean I receive control via<br>
`void checkPostCall(const CallEvent &Call, CheckerContext &C) const`<br>
<br>
and I found `connect` call with string like this:<br>
"f(const QString&, QVarint)"<br>
<br>
after that I ask libclang parse such forward function declaration:<br>
"extern void f(const QString&, QVariant);"<br>
and use types like `QString` and `QVariant` from current context.<br>
<br>
--<br>
/Evgeniy<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>