diff options
author | Sergio Martins <iamsergio@gmail.com> | 2018-12-03 11:30:49 +0000 |
---|---|---|
committer | Sergio Martins <iamsergio@gmail.com> | 2018-12-03 11:30:49 +0000 |
commit | 8dc3294379f0a2a95fc49573512ee1514bae13d7 (patch) | |
tree | 3126aceae786f59b9f1ae6f87be527490da236fe | |
parent | 9713a15f65424f06e45c78fc1bf1c2d2b27f4e36 (diff) |
Revert "inefficient-qlist: Use 64 as the limit, instead of sizeof(void*)"
This reverts commit 9713a15f65424f06e45c78fc1bf1c2d2b27f4e36.
This doesn't make sense, I mixed up the logic.
CCBUG: 401494
-rw-r--r-- | docs/checks/README-inefficient-qlist-soft.md | 2 | ||||
-rw-r--r-- | docs/checks/README-inefficient-qlist.md | 5 | ||||
-rw-r--r-- | src/QtUtils.h | 4 | ||||
-rw-r--r-- | src/checks/inefficientqlistbase.cpp | 5 |
4 files changed, 5 insertions, 11 deletions
diff --git a/docs/checks/README-inefficient-qlist-soft.md b/docs/checks/README-inefficient-qlist-soft.md index 1795c3a7..beebb3d1 100644 --- a/docs/checks/README-inefficient-qlist-soft.md +++ b/docs/checks/README-inefficient-qlist-soft.md @@ -2,6 +2,6 @@ A less aggressive version of the **inefficient-qlist** check. -Finds `QList<T>` where `sizeof(T) > 64`. `QVector<T>` should be used instead. +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 index fc7dbf76..3bfe3f1c 100644 --- a/docs/checks/README-inefficient-qlist.md +++ b/docs/checks/README-inefficient-qlist.md @@ -1,8 +1,5 @@ # inefficient-qlist -Finds `QList<T>` where `sizeof(T) > 64`. `QVector<T>` should be used instead. - -This check uses 64 as the limit instead of `sizeof(void*)` so that it gives the same -results in 32-bit platforms. Making your 32-bit code portable to 64-bit without pessimizations. +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/src/QtUtils.h b/src/QtUtils.h index c3704e40..5aa6ce88 100644 --- a/src/QtUtils.h +++ b/src/QtUtils.h @@ -187,9 +187,7 @@ CLAZYLIB_EXPORT bool isJavaIterator(clang::CXXMemberCallExpr *call); */ inline bool isTooBigForQList(clang::QualType qt, const clang::ASTContext *context) { - // Assume size of pointer is 64, even on 32-bit. So code is portable to 64-bit too. - const uint64_t sizeOfPointer = 64; // TypeUtils::sizeOfPointer(context, qt; - return context->getTypeSize(qt) <= sizeOfPointer; + return (int)context->getTypeSize(qt) <= TypeUtils::sizeOfPointer(context, qt); } /** diff --git a/src/checks/inefficientqlistbase.cpp b/src/checks/inefficientqlistbase.cpp index 33cbedf1..da771aaa 100644 --- a/src/checks/inefficientqlistbase.cpp +++ b/src/checks/inefficientqlistbase.cpp @@ -107,9 +107,8 @@ void InefficientQListBase::VisitDecl(clang::Decl *decl) if (!qt2.getTypePtrOrNull() || qt2->isIncompleteType()) return; - // Assume size of pointer is 64, even on 32-bit. So code is portable to 64-bit too. - const uint64_t size_of_ptr = 64; // TypeUtils::sizeOfPointer(&m_astContext, qt2); // in bits - const uint64_t size_of_T = m_astContext.getTypeSize(qt2); + const int size_of_ptr = TypeUtils::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"); |