aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergio Martins <smartins@kde.org>2019-05-09 19:48:17 +0100
committerSergio Martins <smartins@kde.org>2019-05-09 20:10:11 +0100
commit52c35819162bd23b3b4e406784fa5cbc17cedfcc (patch)
treeb871c5e839816090f6412d0d3944ff7adda16baa
parent948a23ae1b1553cf67dc8b523236cc0e7dc74994 (diff)
qvariant-template-instantiation: Move out of level 0, since it has false-positives
This check has really been noise since its creation. The rate of false-positives don't justify the insignificant compilation performance gains. Moved to manual level now. Currently it has a bug, which doesn't seem possible to solve, as the instantiated template doesn't carry over the information about the qint32 typedef. And the CallExpr doesn't have any template related getters. Also removed this check from the "performance" category in checks.json, since this category is for runtime performance. CCBUG: 407321
-rw-r--r--CheckSources.cmake2
-rw-r--r--README.md2
-rw-r--r--checks.json3
-rw-r--r--docs/checks/README-qvariant-template-instantiation.md7
-rw-r--r--readmes.cmake2
-rw-r--r--src/Checks.h4
-rw-r--r--src/checks/manuallevel/qvariant-template-instantiation.cpp (renamed from src/checks/level0/qvariant-template-instantiation.cpp)0
-rw-r--r--src/checks/manuallevel/qvariant-template-instantiation.h (renamed from src/checks/level0/qvariant-template-instantiation.h)0
8 files changed, 12 insertions, 8 deletions
diff --git a/CheckSources.cmake b/CheckSources.cmake
index 69f05299..5f8d3d62 100644
--- a/CheckSources.cmake
+++ b/CheckSources.cmake
@@ -10,6 +10,7 @@ set(CLAZY_CHECKS_SRCS ${CLAZY_CHECKS_SRCS}
${CMAKE_CURRENT_LIST_DIR}/src/checks/manuallevel/qstring-varargs.cpp
${CMAKE_CURRENT_LIST_DIR}/src/checks/manuallevel/qt-keywords.cpp
${CMAKE_CURRENT_LIST_DIR}/src/checks/manuallevel/qt4-qstring-from-array.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/src/checks/manuallevel/qvariant-template-instantiation.cpp
${CMAKE_CURRENT_LIST_DIR}/src/checks/manuallevel/raw-environment-function.cpp
${CMAKE_CURRENT_LIST_DIR}/src/checks/manuallevel/reserve-candidates.cpp
${CMAKE_CURRENT_LIST_DIR}/src/checks/manuallevel/thread-with-slots.cpp
@@ -35,7 +36,6 @@ set(CLAZY_CHECKS_SRCS ${CLAZY_CHECKS_SRCS}
${CMAKE_CURRENT_LIST_DIR}/src/checks/level0/qstring-insensitive-allocation.cpp
${CMAKE_CURRENT_LIST_DIR}/src/checks/level0/qstring-ref.cpp
${CMAKE_CURRENT_LIST_DIR}/src/checks/level0/qt-macros.cpp
- ${CMAKE_CURRENT_LIST_DIR}/src/checks/level0/qvariant-template-instantiation.cpp
${CMAKE_CURRENT_LIST_DIR}/src/checks/level0/strict-iterators.cpp
${CMAKE_CURRENT_LIST_DIR}/src/checks/level0/temporary-iterator.cpp
${CMAKE_CURRENT_LIST_DIR}/src/checks/level0/unused-non-trivial-variable.cpp
diff --git a/README.md b/README.md
index 62e44e91..4c13b628 100644
--- a/README.md
+++ b/README.md
@@ -226,6 +226,7 @@ clazy runs all checks from level1 by default.
- [qstring-varargs](docs/checks/README-qstring-varargs.md)
- [qt-keywords](docs/checks/README-qt-keywords.md) (fix-qt-keywords)
- [qt4-qstring-from-array](docs/checks/README-qt4-qstring-from-array.md) (fix-qt4-qstring-from-array)
+ - [qvariant-template-instantiation](docs/checks/README-qvariant-template-instantiation.md)
- [raw-environment-function](docs/checks/README-raw-environment-function.md)
- [reserve-candidates](docs/checks/README-reserve-candidates.md)
- [thread-with-slots](docs/checks/README-thread-with-slots.md)
@@ -253,7 +254,6 @@ clazy runs all checks from level1 by default.
- [qstring-insensitive-allocation](docs/checks/README-qstring-insensitive-allocation.md)
- [qstring-ref](docs/checks/README-qstring-ref.md) (fix-missing-qstringref)
- [qt-macros](docs/checks/README-qt-macros.md)
- - [qvariant-template-instantiation](docs/checks/README-qvariant-template-instantiation.md)
- [strict-iterators](docs/checks/README-strict-iterators.md)
- [temporary-iterator](docs/checks/README-temporary-iterator.md)
- [unused-non-trivial-variable](docs/checks/README-unused-non-trivial-variable.md)
diff --git a/checks.json b/checks.json
index 310a306a..66ebbe1d 100644
--- a/checks.json
+++ b/checks.json
@@ -148,8 +148,7 @@
},
{
"name" : "qvariant-template-instantiation",
- "level" : 0,
- "categories" : ["performance"],
+ "level" : -1,
"visits_stmts" : true
},
{
diff --git a/docs/checks/README-qvariant-template-instantiation.md b/docs/checks/README-qvariant-template-instantiation.md
index 9a8f5e9a..4b8387e0 100644
--- a/docs/checks/README-qvariant-template-instantiation.md
+++ b/docs/checks/README-qvariant-template-instantiation.md
@@ -2,4 +2,9 @@
Detects when you're using `QVariant::value<Foo>()` instead of `QVariant::toFoo()`.
-The former results in more code being generated.
+The former results in more code being generated in theory.
+
+## False-Positives
+Beware that this function doesn't work well when typedefs are involved, for example
+it suggests that `v.toUlongLong()` should replace `v.value<quintptr>()`, which
+isn't semantically correct.
diff --git a/readmes.cmake b/readmes.cmake
index 49a03fc6..b0dd5871 100644
--- a/readmes.cmake
+++ b/readmes.cmake
@@ -10,6 +10,7 @@ SET(README_manuallevel_FILES
${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-qstring-varargs.md
${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-qt-keywords.md
${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-qt4-qstring-from-array.md
+ ${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-qvariant-template-instantiation.md
${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-raw-environment-function.md
${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-reserve-candidates.md
${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-thread-with-slots.md
@@ -38,7 +39,6 @@ SET(README_LEVEL0_FILES
${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-qstring-insensitive-allocation.md
${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-qstring-ref.md
${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-qt-macros.md
- ${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-qvariant-template-instantiation.md
${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-strict-iterators.md
${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-temporary-iterator.md
${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-unused-non-trivial-variable.md
diff --git a/src/Checks.h b/src/Checks.h
index 709d66cb..1bb85ee5 100644
--- a/src/Checks.h
+++ b/src/Checks.h
@@ -38,6 +38,7 @@
#include "checks/manuallevel/qstring-varargs.h"
#include "checks/manuallevel/qt-keywords.h"
#include "checks/manuallevel/qt4-qstring-from-array.h"
+#include "checks/manuallevel/qvariant-template-instantiation.h"
#include "checks/manuallevel/raw-environment-function.h"
#include "checks/manuallevel/reserve-candidates.h"
#include "checks/manuallevel/thread-with-slots.h"
@@ -63,7 +64,6 @@
#include "checks/level0/qstring-insensitive-allocation.h"
#include "checks/level0/qstring-ref.h"
#include "checks/level0/qt-macros.h"
-#include "checks/level0/qvariant-template-instantiation.h"
#include "checks/level0/strict-iterators.h"
#include "checks/level0/temporary-iterator.h"
#include "checks/level0/unused-non-trivial-variable.h"
@@ -130,6 +130,7 @@ void CheckManager::registerChecks()
registerFixIt(1, "fix-qt-keywords", "qt-keywords");
registerCheck(check<Qt4QStringFromArray>("qt4-qstring-from-array", ManualCheckLevel, RegisteredCheck::Option_VisitsStmts));
registerFixIt(1, "fix-qt4-qstring-from-array", "qt4-qstring-from-array");
+ registerCheck(check<QVariantTemplateInstantiation>("qvariant-template-instantiation", ManualCheckLevel, RegisteredCheck::Option_VisitsStmts));
registerCheck(check<RawEnvironmentFunction>("raw-environment-function", ManualCheckLevel, RegisteredCheck::Option_VisitsStmts));
registerCheck(check<ReserveCandidates>("reserve-candidates", ManualCheckLevel, RegisteredCheck::Option_VisitsStmts));
registerCheck(check<ThreadWithSlots>("thread-with-slots", ManualCheckLevel, RegisteredCheck::Option_VisitsStmts | RegisteredCheck::Option_VisitsDecls));
@@ -160,7 +161,6 @@ void CheckManager::registerChecks()
registerCheck(check<StringRefCandidates>("qstring-ref", CheckLevel0, RegisteredCheck::Option_VisitsStmts));
registerFixIt(1, "fix-missing-qstringref", "qstring-ref");
registerCheck(check<QtMacros>("qt-macros", CheckLevel0, RegisteredCheck::Option_None));
- registerCheck(check<QVariantTemplateInstantiation>("qvariant-template-instantiation", CheckLevel0, RegisteredCheck::Option_VisitsStmts));
registerCheck(check<StrictIterators>("strict-iterators", CheckLevel0, RegisteredCheck::Option_VisitsStmts));
registerCheck(check<TemporaryIterator>("temporary-iterator", CheckLevel0, RegisteredCheck::Option_VisitsStmts));
registerCheck(check<UnusedNonTrivialVariable>("unused-non-trivial-variable", CheckLevel0, RegisteredCheck::Option_VisitsStmts));
diff --git a/src/checks/level0/qvariant-template-instantiation.cpp b/src/checks/manuallevel/qvariant-template-instantiation.cpp
index 170d1e50..170d1e50 100644
--- a/src/checks/level0/qvariant-template-instantiation.cpp
+++ b/src/checks/manuallevel/qvariant-template-instantiation.cpp
diff --git a/src/checks/level0/qvariant-template-instantiation.h b/src/checks/manuallevel/qvariant-template-instantiation.h
index 9059ea79..9059ea79 100644
--- a/src/checks/level0/qvariant-template-instantiation.h
+++ b/src/checks/manuallevel/qvariant-template-instantiation.h