diff options
author | Sergio Martins <smartins@kde.org> | 2021-10-13 23:19:06 +0100 |
---|---|---|
committer | Sergio Martins <smartins@kde.org> | 2021-10-13 23:22:51 +0100 |
commit | d86b9dc6b5ae57e204f6715d2f6113cc196d2d98 (patch) | |
tree | f0a2ce00f450e9f04eb7433e786cac6b95ce1a28 | |
parent | 5cc42e7c22013410470b05c424449d917e6ef1d1 (diff) |
Remove inefficient-qlist check, the issue has been fixed in Qt6
Newer project can use Qt6.
Old Qt5 projects shouldn't be doing such invasive changes.
If this check was about uncovering bugs instead of reducing
performance pessimisation then we could keep it for Qt5 code in
production, that's not the case however.
BUG: 443399
-rw-r--r-- | Changelog | 1 | ||||
-rw-r--r-- | CheckSources.cmake | 2 | ||||
-rw-r--r-- | ClazySources.cmake | 1 | ||||
-rw-r--r-- | ClazyTests.cmake | 2 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | checks.json | 12 | ||||
-rw-r--r-- | docs/checks/README-inefficient-qlist-soft.md | 7 | ||||
-rw-r--r-- | docs/checks/README-inefficient-qlist.md | 5 | ||||
-rw-r--r-- | readmes.cmake | 2 | ||||
-rw-r--r-- | src/Checks.h | 4 | ||||
-rw-r--r-- | src/checks/inefficientqlistbase.cpp | 117 | ||||
-rw-r--r-- | src/checks/inefficientqlistbase.h | 63 | ||||
-rw-r--r-- | src/checks/level1/inefficient-qlist-soft.cpp | 34 | ||||
-rw-r--r-- | src/checks/level1/inefficient-qlist-soft.h | 47 | ||||
-rw-r--r-- | src/checks/manuallevel/inefficient-qlist.cpp | 35 | ||||
-rw-r--r-- | src/checks/manuallevel/inefficient-qlist.h | 46 | ||||
-rw-r--r-- | tests/inefficient-qlist-soft/config.json | 7 | ||||
-rw-r--r-- | tests/inefficient-qlist-soft/main.cpp | 91 | ||||
-rw-r--r-- | tests/inefficient-qlist-soft/main.cpp.expected | 3 | ||||
-rw-r--r-- | tests/inefficient-qlist/config.json | 8 | ||||
-rw-r--r-- | tests/inefficient-qlist/main.cpp | 55 | ||||
-rw-r--r-- | tests/inefficient-qlist/main.cpp.expected | 4 | ||||
-rw-r--r-- | tests/inefficient-qlist/main.cpp.expected.x86 | 4 |
23 files changed, 1 insertions, 551 deletions
@@ -5,6 +5,7 @@ - use-arrow-operator-instead-of-data - use-static-qregularexpression - unexpected-flag-enumerator-value + - Removed inefficient-qlist check (Fixed in Qt6) * v1.10 (July 20th 2021) - Requires C++17 diff --git a/CheckSources.cmake b/CheckSources.cmake index 8de99923..9c321878 100644 --- a/CheckSources.cmake +++ b/CheckSources.cmake @@ -4,7 +4,6 @@ set(CLAZY_CHECKS_SRCS ${CLAZY_CHECKS_SRCS} ${CMAKE_CURRENT_LIST_DIR}/src/checks/manuallevel/detaching-member.cpp ${CMAKE_CURRENT_LIST_DIR}/src/checks/manuallevel/heap-allocated-small-trivial-type.cpp ${CMAKE_CURRENT_LIST_DIR}/src/checks/manuallevel/ifndef-define-typo.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/checks/manuallevel/inefficient-qlist.cpp ${CMAKE_CURRENT_LIST_DIR}/src/checks/manuallevel/isempty-vs-count.cpp ${CMAKE_CURRENT_LIST_DIR}/src/checks/manuallevel/jnisignatures.cpp ${CMAKE_CURRENT_LIST_DIR}/src/checks/manuallevel/qhash-with-char-pointer-key.cpp @@ -64,7 +63,6 @@ set(CLAZY_CHECKS_SRCS ${CLAZY_CHECKS_SRCS} ${CMAKE_CURRENT_LIST_DIR}/src/checks/level1/detaching-temporary.cpp ${CMAKE_CURRENT_LIST_DIR}/src/checks/level1/foreach.cpp ${CMAKE_CURRENT_LIST_DIR}/src/checks/level1/incorrect-emit.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/checks/level1/inefficient-qlist-soft.cpp ${CMAKE_CURRENT_LIST_DIR}/src/checks/level1/install-event-filter.cpp ${CMAKE_CURRENT_LIST_DIR}/src/checks/level1/non-pod-global-static.cpp ${CMAKE_CURRENT_LIST_DIR}/src/checks/level1/overridden-signal.cpp diff --git a/ClazySources.cmake b/ClazySources.cmake index 7969d56d..42f90e78 100644 --- a/ClazySources.cmake +++ b/ClazySources.cmake @@ -17,7 +17,6 @@ set(CLAZY_LIB_SRC set(CLAZY_CHECKS_SRCS ${CMAKE_CURRENT_LIST_DIR}/src/checks/detachingbase.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/checks/inefficientqlistbase.cpp ${CMAKE_CURRENT_LIST_DIR}/src/checks/ruleofbase.cpp ) include(CheckSources.cmake) diff --git a/ClazyTests.cmake b/ClazyTests.cmake index 92946b1a..ae104f9b 100644 --- a/ClazyTests.cmake +++ b/ClazyTests.cmake @@ -5,7 +5,6 @@ add_test(NAME container-inside-loop COMMAND python3 run_tests.py container-insid add_test(NAME detaching-member COMMAND python3 run_tests.py detaching-member WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/) add_test(NAME heap-allocated-small-trivial-type COMMAND python3 run_tests.py heap-allocated-small-trivial-type WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/) add_test(NAME ifndef-define-typo COMMAND python3 run_tests.py ifndef-define-typo WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/) -add_test(NAME inefficient-qlist COMMAND python3 run_tests.py inefficient-qlist WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/) add_test(NAME isempty-vs-count COMMAND python3 run_tests.py isempty-vs-count WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/) add_test(NAME jni-signatures COMMAND python3 run_tests.py jni-signatures WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/) add_test(NAME qhash-with-char-pointer-key COMMAND python3 run_tests.py qhash-with-char-pointer-key WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/) @@ -65,7 +64,6 @@ add_test(NAME const-signal-or-slot COMMAND python3 run_tests.py const-signal-or- add_test(NAME detaching-temporary COMMAND python3 run_tests.py detaching-temporary WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/) add_test(NAME foreach COMMAND python3 run_tests.py foreach WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/) add_test(NAME incorrect-emit COMMAND python3 run_tests.py incorrect-emit WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/) -add_test(NAME inefficient-qlist-soft COMMAND python3 run_tests.py inefficient-qlist-soft WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/) add_test(NAME install-event-filter COMMAND python3 run_tests.py install-event-filter WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/) add_test(NAME non-pod-global-static COMMAND python3 run_tests.py non-pod-global-static WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/) add_test(NAME overridden-signal COMMAND python3 run_tests.py overridden-signal WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/) @@ -227,7 +227,6 @@ clazy runs all checks from level1 by default. - [detaching-member](docs/checks/README-detaching-member.md) - [heap-allocated-small-trivial-type](docs/checks/README-heap-allocated-small-trivial-type.md) - [ifndef-define-typo](docs/checks/README-ifndef-define-typo.md) - - [inefficient-qlist](docs/checks/README-inefficient-qlist.md) - [isempty-vs-count](docs/checks/README-isempty-vs-count.md) - [jni-signatures](docs/checks/README-jni-signatures.md) - [qhash-with-char-pointer-key](docs/checks/README-qhash-with-char-pointer-key.md) @@ -291,7 +290,6 @@ clazy runs all checks from level1 by default. - [detaching-temporary](docs/checks/README-detaching-temporary.md) - [foreach](docs/checks/README-foreach.md) - [incorrect-emit](docs/checks/README-incorrect-emit.md) - - [inefficient-qlist-soft](docs/checks/README-inefficient-qlist-soft.md) - [install-event-filter](docs/checks/README-install-event-filter.md) - [non-pod-global-static](docs/checks/README-non-pod-global-static.md) - [overridden-signal](docs/checks/README-overridden-signal.md) diff --git a/checks.json b/checks.json index a1afaab4..1b7f91a9 100644 --- a/checks.json +++ b/checks.json @@ -28,12 +28,6 @@ "categories" : ["bug"] }, { - "name" : "inefficient-qlist", - "level" : -1, - "categories" : ["containers", "performance"], - "visits_decls" : true - }, - { "name" : "isempty-vs-count", "class_name" : "IsEmptyVSCount", "level" : -1, @@ -409,12 +403,6 @@ "visits_stmts" : true }, { - "name" : "inefficient-qlist-soft", - "level" : 1, - "categories" : ["containers", "performance"], - "visits_decls" : true - }, - { "name" : "install-event-filter", "level" : 1, "categories" : ["bug"], diff --git a/docs/checks/README-inefficient-qlist-soft.md b/docs/checks/README-inefficient-qlist-soft.md deleted file mode 100644 index beebb3d1..00000000 --- a/docs/checks/README-inefficient-qlist-soft.md +++ /dev/null @@ -1,7 +0,0 @@ -# inefficient-qlist-soft - -A less aggressive version of the **inefficient-qlist** check. - -Finds `QList<T>` where `sizeof(T) > sizeof(void*)`. `QVector<T>` should be used instead. -Only warns if the container is a local variable and isn't passed to any method or returned, -unlike **inefficient-qlist**. This makes it easier to fix the warnings without concern about source and binary compatibility. diff --git a/docs/checks/README-inefficient-qlist.md b/docs/checks/README-inefficient-qlist.md deleted file mode 100644 index 3bfe3f1c..00000000 --- a/docs/checks/README-inefficient-qlist.md +++ /dev/null @@ -1,5 +0,0 @@ -# inefficient-qlist - -Finds `QList<T>` where `sizeof(T) > sizeof(void*)`. `QVector<T>` should be used instead. - -This is a very noisy check and hence disabled by default. See **inefficient-qlist-soft** for a more useful check. diff --git a/readmes.cmake b/readmes.cmake index 8c21ba32..e403c7ff 100644 --- a/readmes.cmake +++ b/readmes.cmake @@ -4,7 +4,6 @@ SET(README_manuallevel_FILES ${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-detaching-member.md ${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-heap-allocated-small-trivial-type.md ${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-ifndef-define-typo.md - ${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-inefficient-qlist.md ${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-isempty-vs-count.md ${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-jni-signatures.md ${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-qhash-with-char-pointer-key.md @@ -70,7 +69,6 @@ SET(README_LEVEL1_FILES ${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-detaching-temporary.md ${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-foreach.md ${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-incorrect-emit.md - ${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-inefficient-qlist-soft.md ${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-install-event-filter.md ${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-non-pod-global-static.md ${CMAKE_CURRENT_LIST_DIR}/docs/checks/README-overridden-signal.md diff --git a/src/Checks.h b/src/Checks.h index c088433e..a5efbfca 100644 --- a/src/Checks.h +++ b/src/Checks.h @@ -32,7 +32,6 @@ #include "checks/manuallevel/detaching-member.h" #include "checks/manuallevel/heap-allocated-small-trivial-type.h" #include "checks/manuallevel/ifndef-define-typo.h" -#include "checks/manuallevel/inefficient-qlist.h" #include "checks/manuallevel/isempty-vs-count.h" #include "checks/manuallevel/jnisignatures.h" #include "checks/manuallevel/qhash-with-char-pointer-key.h" @@ -92,7 +91,6 @@ #include "checks/level1/detaching-temporary.h" #include "checks/level1/foreach.h" #include "checks/level1/incorrect-emit.h" -#include "checks/level1/inefficient-qlist-soft.h" #include "checks/level1/install-event-filter.h" #include "checks/level1/non-pod-global-static.h" #include "checks/level1/overridden-signal.h" @@ -138,7 +136,6 @@ void CheckManager::registerChecks() registerCheck(check<DetachingMember>("detaching-member", ManualCheckLevel, RegisteredCheck::Option_VisitsStmts)); registerCheck(check<HeapAllocatedSmallTrivialType>("heap-allocated-small-trivial-type", ManualCheckLevel, RegisteredCheck::Option_VisitsDecls)); registerCheck(check<IfndefDefineTypo>("ifndef-define-typo", ManualCheckLevel, RegisteredCheck::Option_None)); - registerCheck(check<InefficientQList>("inefficient-qlist", ManualCheckLevel, RegisteredCheck::Option_VisitsDecls)); registerCheck(check<IsEmptyVSCount>("isempty-vs-count", ManualCheckLevel, RegisteredCheck::Option_VisitsStmts)); registerCheck(check<JniSignatures>("jni-signatures", ManualCheckLevel, RegisteredCheck::Option_VisitsStmts)); registerCheck(check<QHashWithCharPointerKey>("qhash-with-char-pointer-key", ManualCheckLevel, RegisteredCheck::Option_VisitsDecls)); @@ -211,7 +208,6 @@ void CheckManager::registerChecks() registerCheck(check<DetachingTemporary>("detaching-temporary", CheckLevel1, RegisteredCheck::Option_VisitsStmts)); registerCheck(check<Foreach>("foreach", CheckLevel1, RegisteredCheck::Option_VisitsStmts)); registerCheck(check<IncorrectEmit>("incorrect-emit", CheckLevel1, RegisteredCheck::Option_VisitsStmts)); - registerCheck(check<InefficientQListSoft>("inefficient-qlist-soft", CheckLevel1, RegisteredCheck::Option_VisitsDecls)); registerCheck(check<InstallEventFilter>("install-event-filter", CheckLevel1, RegisteredCheck::Option_VisitsStmts)); registerCheck(check<NonPodGlobalStatic>("non-pod-global-static", CheckLevel1, RegisteredCheck::Option_VisitsStmts)); registerCheck(check<OverriddenSignal>("overridden-signal", CheckLevel1, RegisteredCheck::Option_VisitsDecls)); diff --git a/src/checks/inefficientqlistbase.cpp b/src/checks/inefficientqlistbase.cpp deleted file mode 100644 index 1d753e4f..00000000 --- a/src/checks/inefficientqlistbase.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - This file is part of the clazy static checker. - - Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com - Author: Sérgio Martins <sergio.martins@kdab.com> - - Copyright (C) 2015 Sergio Martins <smartins@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "inefficientqlistbase.h" -#include "Utils.h" -#include "TypeUtils.h" -#include "ContextUtils.h" -#include "TemplateUtils.h" -#include "StmtBodyRange.h" -#include "SourceCompatibilityHelpers.h" -#include "StringUtils.h" - -#include <clang/AST/Decl.h> -#include <clang/AST/DeclCXX.h> -#include <clang/AST/ASTContext.h> -#include <clang/AST/DeclBase.h> -#include <clang/AST/Type.h> -#include <clang/Basic/LLVM.h> -#include <llvm/ADT/StringRef.h> -#include <llvm/Support/Casting.h> - -#include <vector> - -class ClazyContext; -namespace clang { -class Stmt; -} // namespace clang - -using namespace clang; -using namespace std; - -InefficientQListBase::InefficientQListBase(const std::string &name, ClazyContext *context, int ignoreMode) - : CheckBase(name, context) - , m_ignoreMode(ignoreMode) -{ -} - -bool InefficientQListBase::shouldIgnoreVariable(VarDecl *varDecl) const -{ - DeclContext *context = varDecl->getDeclContext(); - FunctionDecl *fDecl = context ? dyn_cast<FunctionDecl>(context) : nullptr; - - if ((m_ignoreMode & IgnoreNonLocalVariable) && !clazy::isValueDeclInFunctionContext(varDecl)) { - return true; - } - - if ((m_ignoreMode & IgnoreInFunctionWithSameReturnType) && fDecl && fDecl->getReturnType().getCanonicalType() == varDecl->getType().getCanonicalType()) { - return true; - } - - Stmt *body = fDecl ? fDecl->getBody() : nullptr; - if ((m_ignoreMode & IgnoreIsAssignedToInFunction) && Utils::isAssignedFrom(body, varDecl)) { - return true; - } - - if ((m_ignoreMode & IgnoreIsPassedToFunctions) && Utils::isPassedToFunction(StmtBodyRange(body), varDecl, /*by-ref=*/ false)) { - return true; - } - - if ((m_ignoreMode & IgnoreIsInitializedByFunctionCall) && Utils::isInitializedExternally(varDecl)) { - return true; - } - - return false; -} - -void InefficientQListBase::VisitDecl(clang::Decl *decl) -{ - auto varDecl = dyn_cast<VarDecl>(decl); - if (!varDecl) - return; - - QualType type = varDecl->getType(); - const Type *t = type.getTypePtrOrNull(); - if (!t) - return; - - CXXRecordDecl *recordDecl = t->getAsCXXRecordDecl(); - if (!recordDecl || clazy::name(recordDecl) != "QList" || type.getAsString() == "QVariantList") - return; - - const std::vector<clang::QualType> types = clazy::getTemplateArgumentsTypes(recordDecl); - if (types.empty()) - return; - QualType qt2 = types[0]; - if (!qt2.getTypePtrOrNull() || qt2->isIncompleteType()) - return; - - const int size_of_ptr = clazy::sizeOfPointer(&m_astContext, qt2); // in bits - const int size_of_T = m_astContext.getTypeSize(qt2); - - if (size_of_T > size_of_ptr && !shouldIgnoreVariable(varDecl)) { - string s = string("Use QVector instead of QList for type with size " + to_string(size_of_T / 8) + " bytes"); - emitWarning(clazy::getLocStart(decl), s.c_str()); - } -} diff --git a/src/checks/inefficientqlistbase.h b/src/checks/inefficientqlistbase.h deleted file mode 100644 index 1faa1a31..00000000 --- a/src/checks/inefficientqlistbase.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - This file is part of the clazy static checker. - - Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com - Author: Sérgio Martins <sergio.martins@kdab.com> - - Copyright (C) 2015 Sergio Martins <smartins@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef INEFFICIENT_QLIST_BASE_H -#define INEFFICIENT_QLIST_BASE_H - -#include "checkbase.h" - -#include <string> - -class ClazyContext; - -namespace clang { -class VarDecl; -class Decl; -} - -/** - * Base class for inefficient-qlist and inefficient-qlist-soft - */ -class InefficientQListBase - : public CheckBase -{ -public: - enum IgnoreMode { - IgnoreNone = 0, - IgnoreNonLocalVariable = 1, - IgnoreInFunctionWithSameReturnType = 2, - IgnoreIsAssignedToInFunction = 4, - IgnoreIsPassedToFunctions = 8, - IgnoreIsInitializedByFunctionCall = 16 - }; - - explicit InefficientQListBase(const std::string &name, ClazyContext *context, int ignoreMode); - void VisitDecl(clang::Decl *decl) override; - -private: - bool shouldIgnoreVariable(clang::VarDecl *varDecl) const; - const int m_ignoreMode; -}; - -#endif diff --git a/src/checks/level1/inefficient-qlist-soft.cpp b/src/checks/level1/inefficient-qlist-soft.cpp deleted file mode 100644 index fef89102..00000000 --- a/src/checks/level1/inefficient-qlist-soft.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - This file is part of the clazy static checker. - - Copyright (C) 2016 Sergio Martins <smartins@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "inefficient-qlist-soft.h" - -class ClazyContext; - -using namespace clang; -using namespace std; - -InefficientQListSoft::InefficientQListSoft(const std::string &name, ClazyContext *context) - : InefficientQListBase(name, context, IgnoreNonLocalVariable | IgnoreInFunctionWithSameReturnType | - IgnoreIsAssignedToInFunction | IgnoreIsPassedToFunctions| - IgnoreIsInitializedByFunctionCall) -{ -} diff --git a/src/checks/level1/inefficient-qlist-soft.h b/src/checks/level1/inefficient-qlist-soft.h deleted file mode 100644 index ed1b58f3..00000000 --- a/src/checks/level1/inefficient-qlist-soft.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - This file is part of the clazy static checker. - - Copyright (C) 2016 Sergio Martins <smartins@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef CLAZY_INEFFICIENT_QLIST_SOFT_H -#define CLAZY_INEFFICIENT_QLIST_SOFT_H - -#include "checks/inefficientqlistbase.h" - -#include <string> - -class ClazyContext; - -namespace clang { -class Stmt; -} - -/** - * Less noisy version of inefficient-qlist. - * - * See README-inefficient-qlist-soft and README-inefficient-qlist for more information. - */ -class InefficientQListSoft - : public InefficientQListBase -{ -public: - explicit InefficientQListSoft(const std::string &name, ClazyContext *context); -}; - -#endif diff --git a/src/checks/manuallevel/inefficient-qlist.cpp b/src/checks/manuallevel/inefficient-qlist.cpp deleted file mode 100644 index bd49e2d8..00000000 --- a/src/checks/manuallevel/inefficient-qlist.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - This file is part of the clazy static checker. - - Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com - Author: Sérgio Martins <sergio.martins@kdab.com> - - Copyright (C) 2015 Sergio Martins <smartins@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "inefficient-qlist.h" - -class ClazyContext; - -using namespace clang; -using namespace std; - -InefficientQList::InefficientQList(const std::string &name, ClazyContext *context) - : InefficientQListBase(name, context, IgnoreNone) -{ -} diff --git a/src/checks/manuallevel/inefficient-qlist.h b/src/checks/manuallevel/inefficient-qlist.h deleted file mode 100644 index 3a2b2cf5..00000000 --- a/src/checks/manuallevel/inefficient-qlist.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - This file is part of the clazy static checker. - - Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com - Author: Sérgio Martins <sergio.martins@kdab.com> - - Copyright (C) 2015 Sergio Martins <smartins@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef INEFFICIENT_QLIST_H -#define INEFFICIENT_QLIST_H - -#include "checks/inefficientqlistbase.h" - -#include <string> - -class ClazyContext; - -/** - * Finds usages of QList<T> where T is bigger than sizeof(void*), where QVector should be used instead. - * - * See README-inefficient-qlist. - */ -class InefficientQList - : public InefficientQListBase -{ -public: - explicit InefficientQList(const std::string &name, ClazyContext *context); -}; - -#endif diff --git a/tests/inefficient-qlist-soft/config.json b/tests/inefficient-qlist-soft/config.json deleted file mode 100644 index e7e6e0cb..00000000 --- a/tests/inefficient-qlist-soft/config.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "tests" : [ - { - "filename" : "main.cpp" - } - ] -} diff --git a/tests/inefficient-qlist-soft/main.cpp b/tests/inefficient-qlist-soft/main.cpp deleted file mode 100644 index 9da19d0d..00000000 --- a/tests/inefficient-qlist-soft/main.cpp +++ /dev/null @@ -1,91 +0,0 @@ -#include <QtCore/QList> - - - - - - - - - - -struct SmallType { - char a[sizeof(void*)]; -}; - - -struct BigType { - char a[9]; -}; - - -void foo() -{ - QList<BigType> bigT; // Warning - QList<SmallType> smallT; // OK -} - -class A { -public: - void foo() - { - m_big.clear(); - } - - QList<BigType> m_big; // OK -}; - -void foo1(QList<BigType> big2) -{ - QList<BigType> bigt; // OK - bigt = big2; -} - -QList<BigType> foo2() -{ - QList<BigType> bigt; // OK - return bigt; -} - -static QList<BigType> s_big; -extern void takesBig(QList<BigType>); -void foo3() -{ - QList<BigType> bigt; // OK - s_big = bigt; - s_big = QList<BigType>(); // OK - - QList<BigType> bigt2; // OK - takesBig(bigt2); -} -extern QList<BigType> returnsBig(); -void foo4() -{ - QList<BigType> b; // Warning - for (auto a : b) {} - - QList<BigType> b2 = returnsBig(); // OK - QList<BigType> b3 = { BigType() }; // Warning - QList<BigType> b4 = b2; // Ok -} - -struct A1 -{ - QList<BigType> a(); -}; - -struct B1 -{ - A1 b(); -}; - -void foo5() -{ - QList<BigType> b5 = B1().b().a(); -} - -void test_bug358740() -{ - QList<int> list; // OK - int a, b; -} diff --git a/tests/inefficient-qlist-soft/main.cpp.expected b/tests/inefficient-qlist-soft/main.cpp.expected deleted file mode 100644 index 13df97ea..00000000 --- a/tests/inefficient-qlist-soft/main.cpp.expected +++ /dev/null @@ -1,3 +0,0 @@ -inefficient-qlist-soft/main.cpp:24:5: warning: Use QVector instead of QList for type with size 9 bytes [-Wclazy-inefficient-qlist-soft] -inefficient-qlist-soft/main.cpp:64:5: warning: Use QVector instead of QList for type with size 9 bytes [-Wclazy-inefficient-qlist-soft] -inefficient-qlist-soft/main.cpp:68:5: warning: Use QVector instead of QList for type with size 9 bytes [-Wclazy-inefficient-qlist-soft] diff --git a/tests/inefficient-qlist/config.json b/tests/inefficient-qlist/config.json deleted file mode 100644 index bd7aeb66..00000000 --- a/tests/inefficient-qlist/config.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "tests" : [ - { - "filename" : "main.cpp", - "should_run_on_32bit" : false - } - ] -} diff --git a/tests/inefficient-qlist/main.cpp b/tests/inefficient-qlist/main.cpp deleted file mode 100644 index ab6ba550..00000000 --- a/tests/inefficient-qlist/main.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include <QtCore/QList> -#include <QtCore/QVariant> - - - - - - - - - -struct SmallType { - char a[sizeof(void*)]; -}; - - -struct BigType { - char a[9]; -}; - - -void foo() -{ - QList<BigType> bigT; // Warning - QList<SmallType> smallT; // OK -} - -class A { -public: - void foo() - { - m_big.clear(); - } - - QList<BigType> m_big; // Warning -}; - -void foo1(QList<BigType> big2) -{ - QList<BigType> bigt; // Warning - bigt = big2; -} - - -void test_bug358740() -{ - QList<int> list; // OK - int a, b; -} - -void testQVariantList() -{ - QList<QVariant> list1; // Warn - QVariantList list2; // OK, to interact with Qt api probably -} diff --git a/tests/inefficient-qlist/main.cpp.expected b/tests/inefficient-qlist/main.cpp.expected deleted file mode 100644 index 8d9ad803..00000000 --- a/tests/inefficient-qlist/main.cpp.expected +++ /dev/null @@ -1,4 +0,0 @@ -inefficient-qlist/main.cpp:24:5: warning: Use QVector instead of QList for type with size 9 bytes [-Wclazy-inefficient-qlist] -inefficient-qlist/main.cpp:38:11: warning: Use QVector instead of QList for type with size 9 bytes [-Wclazy-inefficient-qlist] -inefficient-qlist/main.cpp:40:5: warning: Use QVector instead of QList for type with size 9 bytes [-Wclazy-inefficient-qlist] -inefficient-qlist/main.cpp:53:5: warning: Use QVector instead of QList for type with size 16 bytes [-Wclazy-inefficient-qlist] diff --git a/tests/inefficient-qlist/main.cpp.expected.x86 b/tests/inefficient-qlist/main.cpp.expected.x86 deleted file mode 100644 index 81519a19..00000000 --- a/tests/inefficient-qlist/main.cpp.expected.x86 +++ /dev/null @@ -1,4 +0,0 @@ -inefficient-qlist/main.cpp:24:5: warning: Use QVector instead of QList for type with size 9 bytes [-Wclazy-inefficient-qlist] -inefficient-qlist/main.cpp:38:11: warning: Use QVector instead of QList for type with size 9 bytes [-Wclazy-inefficient-qlist] -inefficient-qlist/main.cpp:40:5: warning: Use QVector instead of QList for type with size 9 bytes [-Wclazy-inefficient-qlist] -inefficient-qlist/main.cpp:53:5: warning: Use QVector instead of QList for type with size 12 bytes [-Wclazy-inefficient-qlist] |