I'd find a check which warns on certain unused Qt objects which are created but never used very helpful. For instance, QString, Qt containers, QColor, QVariant. Interestingly, Qt Creator highlights these unused variables but I can't find any way of listing them in bulk for removal...
can you attach a test-case ?
clang already warns on unused variables, so clazy won't duplicate functionality
Here's a simple test case: #include <QVariant> #include <QIcon> int main(int, char **) { QString string; //no warning QList<int> list; //no warning QVariant var; //no warning QIcon i; //no warning int num; //warning } building this with clang 3.7 warns only about the unused int variable, not the unused QString/QList/QVariant etc.
We could have a [warn_unused] attribute and tag Qt containers with it: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55203
Git commit ff28b66ce5ce8b6f76487c62c21063676df41cc0 by Sergio Martins. Committed on 28/02/2016 at 13:32. Pushed by smartins into branch 'master'. Introduce unused-non-trivial-variable check Because the compilers don't warn for unused non-trivial Qt value classes. This check has a whitelist of classes and warns when they there are unused variables. M +2 -1 CMakeLists.txt A +8 -0 checks/README-unused-non-trivial-variable A +95 -0 checks/unused-non-trivial-variable.cpp [License: LGPL (v2+)] A +49 -0 checks/unused-non-trivial-variable.h [License: LGPL (v2+)] M +11 -11 tests/clazy/test_requested_checks.sh.expected A +7 -0 tests/unused-non-trivial-variable/config.json A +36 -0 tests/unused-non-trivial-variable/main.cpp [License: UNKNOWN] * A +2 -0 tests/unused-non-trivial-variable/main.cpp.expected The files marked with a * at the end have a non valid license. Please read: http://techbase.kde.org/Policies/Licensing_Policy and use the headers which are listed at that page. http://commits.kde.org/clazy/ff28b66ce5ce8b6f76487c62c21063676df41cc0