[PATCH] D14592: Qt (version 4 or 5) signal/method checker
Evgeniy Dushistov via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 11 15:30:49 PST 2015
Dushistov created this revision.
Dushistov added reviewers: dcoughlin, Ayal, xazax.hun, zaks.anna.
Dushistov added a subscriber: cfe-commits.
In Qt 4/5 it is possible connect classes methods in such way:
connect(ObjectPointer1, SIGNAL(methodOfObject1()), ObjectPointer2, SLOT(methodOfObject2());
and when you call this method -> `ObjectPointer1->methodOfObject1()` method of `ObjectPointer2->methodOfObject2()` will be called automatically.
The only problem that you can check of correctness of method name and its argument only
at runtime (more details can be found here http://doc.qt.io/qt-4.8/signalsandslots.html).
So I implement this checker to help re factoring large Qt based projects.
Note: Qt 4 have only such method to connect signals and slots.
Qt 5 uses two methods, described above and based on function pointers, but because of SIGNAL/SLOT syntax with disadvantages
have also advantages (see http://doc.qt.io/qt-5/signalsandslots-syntaxes.html) sometime Qt5 also
have not compile time checked signal/slot connection.
What this checker do exactly:
1)It checks that such methods with such signatures exists in both classes
2)It checks that slot subset of parameters match the first parameters of signal
3)It checks that signature of method written in proper way (normalized), this improve performance,
see https://marcmutz.wordpress.com/effective-qt/prefer-to-use-normalised-signalslot-signatures/ and http://doc.qt.io/qt-5/qmetaobject.html#normalizedSignature
http://reviews.llvm.org/D14592
Files:
lib/StaticAnalyzer/Checkers/CMakeLists.txt
lib/StaticAnalyzer/Checkers/Checkers.td
lib/StaticAnalyzer/Checkers/QtSignalSlotChecker.cpp
test/Analysis/qt_connect.cpp
unittests/StaticAnalyzer/CMakeLists.txt
unittests/StaticAnalyzer/QtSignalSlotCheckerTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14592.39980.patch
Type: text/x-patch
Size: 24091 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151111/90d929fe/attachment-0001.bin>
More information about the cfe-commits
mailing list