summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2021-11-06 20:01:54 +0200
committerIvan Komissarov <ABBAPOH@gmail.com>2021-11-08 11:29:03 +0000
commitc8108730b3363757c8abdbbdef02b3cfd4cf73aa (patch)
tree74d04719a9baae04a32e310d3b1b80c93aa58fe0
parentc0f2da3065fd00b4d4193786865f7603e07c4515 (diff)
downloadqbs-c8108730b3363757c8abdbbdef02b3cfd4cf73aa.tar.gz
Fix size_t -> uint conversion warnings with Qt 6
Example: codelocation.h(88): warning C4267: 'return': conversion from 'size_t' to 'uint', possible loss of data Change-Id: I06fa98d1e6d8eec85720bd6c5150a505ea98bdd1 Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
-rw-r--r--src/lib/corelib/CMakeLists.txt1
-rw-r--r--src/lib/corelib/api/project.h5
-rw-r--r--src/lib/corelib/corelib.qbs1
-rw-r--r--src/lib/corelib/generators/generatorversioninfo.h2
-rw-r--r--src/lib/corelib/language/forward_decls.h4
-rw-r--r--src/lib/corelib/language/itemtype.h2
-rw-r--r--src/lib/corelib/language/jsimports.h2
-rw-r--r--src/lib/corelib/language/language.cpp2
-rw-r--r--src/lib/corelib/language/language.h3
-rw-r--r--src/lib/corelib/language/property.h2
-rw-r--r--src/lib/corelib/language/qualifiedid.h2
-rw-r--r--src/lib/corelib/language/scriptengine.cpp6
-rw-r--r--src/lib/corelib/language/scriptengine.h5
-rw-r--r--src/lib/corelib/tools/codelocation.h2
-rw-r--r--src/lib/corelib/tools/error.h2
-rw-r--r--src/lib/corelib/tools/id.cpp4
-rw-r--r--src/lib/corelib/tools/id.h3
-rw-r--r--src/lib/corelib/tools/porting.h55
-rw-r--r--src/lib/corelib/tools/qttools.cpp7
-rw-r--r--src/lib/corelib/tools/qttools.h13
-rw-r--r--src/lib/corelib/tools/tools.pri1
-rw-r--r--src/lib/corelib/tools/visualstudioversioninfo.cpp2
-rw-r--r--src/lib/corelib/tools/visualstudioversioninfo.h3
23 files changed, 99 insertions, 30 deletions
diff --git a/src/lib/corelib/CMakeLists.txt b/src/lib/corelib/CMakeLists.txt
index d4b2d8d38..3a658db98 100644
--- a/src/lib/corelib/CMakeLists.txt
+++ b/src/lib/corelib/CMakeLists.txt
@@ -334,6 +334,7 @@ set(TOOLS_SOURCES
pathutils.h
persistence.cpp
persistence.h
+ porting.h
preferences.cpp
processresult.cpp
processresult_p.h
diff --git a/src/lib/corelib/api/project.h b/src/lib/corelib/api/project.h
index 380806f3a..7ea7645a7 100644
--- a/src/lib/corelib/api/project.h
+++ b/src/lib/corelib/api/project.h
@@ -43,6 +43,7 @@
#include "transformerdata.h"
#include "../language/forward_decls.h"
#include "../tools/error.h"
+#include "../tools/porting.h"
#include "../tools/qbs_export.h"
#include <QtCore/qshareddata.h>
@@ -83,7 +84,7 @@ class ProjectPrivate;
class QBS_EXPORT Project
{
friend class SetupProjectJob;
- friend uint qHash(const Project &p);
+ friend QHashValueType qHash(const Project &p);
public:
SetupProjectJob *setupProject(const SetupProjectParameters &parameters,
ILogSink *logSink, QObject *jobOwner);
@@ -173,7 +174,7 @@ private:
};
inline bool operator!=(const Project &p1, const Project &p2) { return !(p1 == p2); }
-inline uint qHash(const Project &p) { return QT_PREPEND_NAMESPACE(qHash)(p.d.data()); }
+inline QHashValueType qHash(const Project &p) { return QT_PREPEND_NAMESPACE(qHash)(p.d.data()); }
} // namespace qbs
diff --git a/src/lib/corelib/corelib.qbs b/src/lib/corelib/corelib.qbs
index 6656d638b..b50b1e18b 100644
--- a/src/lib/corelib/corelib.qbs
+++ b/src/lib/corelib/corelib.qbs
@@ -438,6 +438,7 @@ QbsLibrary {
"pathutils.h",
"persistence.cpp",
"persistence.h",
+ "porting.h",
"preferences.cpp",
"processresult.cpp",
"processresult_p.h",
diff --git a/src/lib/corelib/generators/generatorversioninfo.h b/src/lib/corelib/generators/generatorversioninfo.h
index 38616eb98..5c867326f 100644
--- a/src/lib/corelib/generators/generatorversioninfo.h
+++ b/src/lib/corelib/generators/generatorversioninfo.h
@@ -74,7 +74,7 @@ private:
utils::ArchitectureFlags m_archs;
};
-inline quint32 qHash(const VersionInfo &info)
+inline auto qHash(const VersionInfo &info)
{
return qHash(info.version().toString());
}
diff --git a/src/lib/corelib/language/forward_decls.h b/src/lib/corelib/language/forward_decls.h
index 6697ac8c9..6ee22a5a6 100644
--- a/src/lib/corelib/language/forward_decls.h
+++ b/src/lib/corelib/language/forward_decls.h
@@ -142,12 +142,14 @@ class PersistentPool;
} // namespace qbs
#ifdef QT_CORE_LIB
+#include "../tools/porting.h"
+
#include <QtCore/qhash.h>
namespace qbs {
namespace Internal {
-template <typename T> inline static uint qHash(const std::shared_ptr<T> &p, uint seed = 0)
+template <typename T> inline static QHashValueType qHash(const std::shared_ptr<T> &p, QHashValueType seed = 0)
{
return ::qHash(p.get(), seed);
}
diff --git a/src/lib/corelib/language/itemtype.h b/src/lib/corelib/language/itemtype.h
index 724666cb4..465396f45 100644
--- a/src/lib/corelib/language/itemtype.h
+++ b/src/lib/corelib/language/itemtype.h
@@ -82,7 +82,7 @@ enum class ItemType {
Unknown
};
-inline uint qHash(ItemType t) { return QT_PREPEND_NAMESPACE(qHash)(uint(t)); }
+inline auto qHash(ItemType t) { return QT_PREPEND_NAMESPACE(qHash)(uint(t)); }
} // namespace Internal
} // namespace qbs
diff --git a/src/lib/corelib/language/jsimports.h b/src/lib/corelib/language/jsimports.h
index a892e0ec0..a4a045f2b 100644
--- a/src/lib/corelib/language/jsimports.h
+++ b/src/lib/corelib/language/jsimports.h
@@ -71,7 +71,7 @@ public:
pool.serializationOp<opType>(scopeName, filePaths, location);
}
};
-inline uint qHash(const JsImport &jsi) { return qHash(jsi.scopeName); }
+inline auto qHash(const JsImport &jsi) { return qHash(jsi.scopeName); }
inline bool operator<(const JsImport &lhs, const JsImport &rhs)
{
diff --git a/src/lib/corelib/language/language.cpp b/src/lib/corelib/language/language.cpp
index f0b6d3e27..9e0619083 100644
--- a/src/lib/corelib/language/language.cpp
+++ b/src/lib/corelib/language/language.cpp
@@ -904,7 +904,7 @@ bool operator==(const RuleArtifact::Binding &b1, const RuleArtifact::Binding &b2
return b1.code == b2.code && b1.name == b2.name;
}
-uint qHash(const RuleArtifact::Binding &b)
+QHashValueType qHash(const RuleArtifact::Binding &b)
{
return qHash(std::make_pair(b.code, b.name.join(QLatin1Char(','))));
}
diff --git a/src/lib/corelib/language/language.h b/src/lib/corelib/language/language.h
index e50691560..146f00f89 100644
--- a/src/lib/corelib/language/language.h
+++ b/src/lib/corelib/language/language.h
@@ -52,6 +52,7 @@
#include <tools/filetime.h>
#include <tools/joblimits.h>
#include <tools/persistence.h>
+#include <tools/porting.h>
#include <tools/set.h>
#include <tools/weakpointer.h>
@@ -212,7 +213,7 @@ private:
: alwaysUpdated(true)
{}
};
-uint qHash(const RuleArtifact::Binding &b);
+QHashValueType qHash(const RuleArtifact::Binding &b);
bool operator==(const RuleArtifact::Binding &b1, const RuleArtifact::Binding &b2);
inline bool operator!=(const RuleArtifact::Binding &b1, const RuleArtifact::Binding &b2) {
return !(b1 == b2);
diff --git a/src/lib/corelib/language/property.h b/src/lib/corelib/language/property.h
index 78061bf6f..302973d19 100644
--- a/src/lib/corelib/language/property.h
+++ b/src/lib/corelib/language/property.h
@@ -94,7 +94,7 @@ inline bool operator==(const Property &p1, const Property &p2)
}
bool operator<(const Property &p1, const Property &p2);
-inline uint qHash(const Property &p)
+inline auto qHash(const Property &p)
{
return QT_PREPEND_NAMESPACE(qHash)(p.productName + p.moduleName + p.propertyName);
}
diff --git a/src/lib/corelib/language/qualifiedid.h b/src/lib/corelib/language/qualifiedid.h
index 2b4c9d286..7e8b388d3 100644
--- a/src/lib/corelib/language/qualifiedid.h
+++ b/src/lib/corelib/language/qualifiedid.h
@@ -60,7 +60,7 @@ public:
QString toString() const;
};
-inline uint qHash(const QualifiedId &qid) { return qHash(qid.toString()); }
+inline auto qHash(const QualifiedId &qid) { return qHash(qid.toString()); }
using QualifiedIdSet = Set<QualifiedId>;
diff --git a/src/lib/corelib/language/scriptengine.cpp b/src/lib/corelib/language/scriptengine.cpp
index 8b3d6fa76..95e0a21c1 100644
--- a/src/lib/corelib/language/scriptengine.cpp
+++ b/src/lib/corelib/language/scriptengine.cpp
@@ -85,13 +85,15 @@ bool operator==(const ScriptEngine::PropertyCacheKey &lhs,
&& lhs.m_propertyName == rhs.m_propertyName;
}
-static inline uint combineHash(uint h1, uint h2, uint seed)
+
+
+static inline QHashValueType combineHash(QHashValueType h1, QHashValueType h2, QHashValueType seed)
{
// stolen from qHash(QPair)
return ((h1 << 16) | (h1 >> 16)) ^ h2 ^ seed;
}
-uint qHash(const ScriptEngine::PropertyCacheKey &k, uint seed = 0)
+QHashValueType qHash(const ScriptEngine::PropertyCacheKey &k, QHashValueType seed = 0)
{
return combineHash(qHash(k.m_moduleName),
combineHash(qHash(k.m_propertyName), qHash(k.m_propertyMap), seed), seed);
diff --git a/src/lib/corelib/language/scriptengine.h b/src/lib/corelib/language/scriptengine.h
index 4f096376e..7c6e646b2 100644
--- a/src/lib/corelib/language/scriptengine.h
+++ b/src/lib/corelib/language/scriptengine.h
@@ -47,6 +47,7 @@
#include <logging/logger.h>
#include <tools/codelocation.h>
#include <tools/filetime.h>
+#include <tools/porting.h>
#include <tools/set.h>
#include <QtCore/qdir.h>
@@ -311,11 +312,11 @@ private:
const PropertyMapConstPtr m_propertyMap;
friend bool operator==(const PropertyCacheKey &lhs, const PropertyCacheKey &rhs);
- friend uint qHash(const ScriptEngine::PropertyCacheKey &k, uint seed);
+ friend QHashValueType qHash(const ScriptEngine::PropertyCacheKey &k, QHashValueType seed);
};
friend bool operator==(const PropertyCacheKey &lhs, const PropertyCacheKey &rhs);
- friend uint qHash(const ScriptEngine::PropertyCacheKey &k, uint seed);
+ friend QHashValueType qHash(const ScriptEngine::PropertyCacheKey &k, QHashValueType seed);
static std::mutex m_creationDestructionMutex;
ScriptImporter *m_scriptImporter;
diff --git a/src/lib/corelib/tools/codelocation.h b/src/lib/corelib/tools/codelocation.h
index 3e84ce2d1..158b90766 100644
--- a/src/lib/corelib/tools/codelocation.h
+++ b/src/lib/corelib/tools/codelocation.h
@@ -85,7 +85,7 @@ QBS_EXPORT bool operator==(const CodeLocation &cl1, const CodeLocation &cl2);
QBS_EXPORT bool operator!=(const CodeLocation &cl1, const CodeLocation &cl2);
QBS_EXPORT bool operator<(const CodeLocation &cl1, const CodeLocation &cl2);
-inline uint qHash(const CodeLocation &cl) { return qHash(cl.toString()); }
+inline auto qHash(const CodeLocation &cl) { return qHash(cl.toString()); }
QDebug operator<<(QDebug debug, const CodeLocation &location);
diff --git a/src/lib/corelib/tools/error.h b/src/lib/corelib/tools/error.h
index ea8ddb5ec..4c6370b1e 100644
--- a/src/lib/corelib/tools/error.h
+++ b/src/lib/corelib/tools/error.h
@@ -126,7 +126,7 @@ void appendError(ErrorInfo &dst, const ErrorInfo &src);
void handlePropertyError(
const ErrorInfo &error, const SetupProjectParameters &params, Internal::Logger &logger);
-inline uint qHash(const ErrorInfo &e) { return qHash(e.toString()); }
+inline auto qHash(const ErrorInfo &e) { return qHash(e.toString()); }
inline bool operator==(const ErrorInfo &e1, const ErrorInfo &e2) {
return e1.toString() == e2.toString();
}
diff --git a/src/lib/corelib/tools/id.cpp b/src/lib/corelib/tools/id.cpp
index 33cfd60f7..c82fc22b6 100644
--- a/src/lib/corelib/tools/id.cpp
+++ b/src/lib/corelib/tools/id.cpp
@@ -75,7 +75,7 @@ public:
: n(length), str(s)
{
if (!n)
- length = n = qstrlen(s);
+ length = n = int(qstrlen(s));
h = 0;
while (length--) {
h = (h << 4) + *s++;
@@ -95,7 +95,7 @@ static bool operator==(const StringHolder &sh1, const StringHolder &sh2)
}
-static uint qHash(const StringHolder &sh)
+QHashValueType qHash(const StringHolder &sh)
{
return sh.h;
}
diff --git a/src/lib/corelib/tools/id.h b/src/lib/corelib/tools/id.h
index aa327833f..845ed60df 100644
--- a/src/lib/corelib/tools/id.h
+++ b/src/lib/corelib/tools/id.h
@@ -41,6 +41,7 @@
#define QBS_TOOLS_ID_H
#include "qbs_export.h"
+#include <tools/porting.h>
#include <QtCore/qmetatype.h>
#include <QtCore/qstring.h>
@@ -84,7 +85,7 @@ private:
int m_id;
};
-inline uint qHash(const Id &id) { return id.uniqueIdentifier(); }
+inline QHashValueType qHash(const Id &id) { return id.uniqueIdentifier(); }
} // namespace Internal
} // namespace qbs
diff --git a/src/lib/corelib/tools/porting.h b/src/lib/corelib/tools/porting.h
new file mode 100644
index 000000000..37582e8d3
--- /dev/null
+++ b/src/lib/corelib/tools/porting.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qbs.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBS_TOOLS_PORTING_H
+#define QBS_TOOLS_PORTING_H
+
+#include <QtCore/qglobal.h>
+
+namespace qbs {
+
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+using QHashValueType = uint;
+#else
+using QHashValueType = size_t;
+#endif
+
+}
+
+#endif
diff --git a/src/lib/corelib/tools/qttools.cpp b/src/lib/corelib/tools/qttools.cpp
index c2ef91f16..40e0d0778 100644
--- a/src/lib/corelib/tools/qttools.cpp
+++ b/src/lib/corelib/tools/qttools.cpp
@@ -38,6 +38,7 @@
****************************************************************************/
#include "qttools.h"
+#include "porting.h"
#include <QtCore/qprocess.h>
@@ -64,15 +65,15 @@ size_t hash<QVariant>::operator()(const QVariant &v) const noexcept
QT_BEGIN_NAMESPACE
-uint qHash(const QStringList &list)
+qbs::QHashValueType qHash(const QStringList &list)
{
- uint s = 0;
+ qbs::QHashValueType s = 0;
for (const QString &n : list)
s ^= qHash(n) + 0x9e3779b9 + (s << 6) + (s >> 2);
return s;
}
-uint qHash(const QProcessEnvironment &env)
+qbs::QHashValueType qHash(const QProcessEnvironment &env)
{
return qHash(env.toStringList());
}
diff --git a/src/lib/corelib/tools/qttools.h b/src/lib/corelib/tools/qttools.h
index 86e81936b..bc1210d53 100644
--- a/src/lib/corelib/tools/qttools.h
+++ b/src/lib/corelib/tools/qttools.h
@@ -41,6 +41,7 @@
#define QBSQTTOOLS_H
#include <tools/qbsassert.h>
+#include <tools/porting.h>
#include <tools/stlutils.h>
#include <QtCore/qhash.h>
@@ -136,26 +137,26 @@ template<> struct hash<QVariantHash>
QT_BEGIN_NAMESPACE
-uint qHash(const QStringList &list);
-uint qHash(const QProcessEnvironment &env);
+qbs::QHashValueType qHash(const QStringList &list);
+qbs::QHashValueType qHash(const QProcessEnvironment &env);
template<typename... Args>
-uint qHash(const std::tuple<Args...> &tuple)
+qbs::QHashValueType qHash(const std::tuple<Args...> &tuple)
{
return std::hash<std::tuple<Args...>>()(tuple) % std::numeric_limits<uint>::max();
}
-inline uint qHash(const QVariant &v)
+inline qbs::QHashValueType qHash(const QVariant &v)
{
return std::hash<QVariant>()(v) % std::numeric_limits<uint>::max();
}
-inline uint qHash(const QVariantMap &v)
+inline qbs::QHashValueType qHash(const QVariantMap &v)
{
return std::hash<QVariantMap>()(v) % std::numeric_limits<uint>::max();
}
-inline uint qHash(const QVariantHash &v)
+inline qbs::QHashValueType qHash(const QVariantHash &v)
{
return std::hash<QVariantHash>()(v) % std::numeric_limits<uint>::max();
}
diff --git a/src/lib/corelib/tools/tools.pri b/src/lib/corelib/tools/tools.pri
index 00d87ecc7..1fdacc016 100644
--- a/src/lib/corelib/tools/tools.pri
+++ b/src/lib/corelib/tools/tools.pri
@@ -30,6 +30,7 @@ HEADERS += \
$$PWD/launchersocket.h \
$$PWD/msvcinfo.h \
$$PWD/persistence.h \
+ $$PWD/porting.h \
$$PWD/scannerpluginmanager.h \
$$PWD/scripttools.h \
$$PWD/set.h \
diff --git a/src/lib/corelib/tools/visualstudioversioninfo.cpp b/src/lib/corelib/tools/visualstudioversioninfo.cpp
index b5ee3e719..1c51cc4b9 100644
--- a/src/lib/corelib/tools/visualstudioversioninfo.cpp
+++ b/src/lib/corelib/tools/visualstudioversioninfo.cpp
@@ -181,7 +181,7 @@ QString VisualStudioVersionInfo::platformToolsetVersion() const
return QStringLiteral("v%1").arg(m_version.majorVersion() * 10);
}
-quint32 qHash(const VisualStudioVersionInfo &info)
+QHashValueType qHash(const VisualStudioVersionInfo &info)
{
return qHash(info.version().toString());
}
diff --git a/src/lib/corelib/tools/visualstudioversioninfo.h b/src/lib/corelib/tools/visualstudioversioninfo.h
index d4b226623..92eecb388 100644
--- a/src/lib/corelib/tools/visualstudioversioninfo.h
+++ b/src/lib/corelib/tools/visualstudioversioninfo.h
@@ -43,6 +43,7 @@
#include "qbs_export.h"
+#include <tools/porting.h>
#include <tools/version.h>
#include <QtCore/qstring.h>
@@ -78,7 +79,7 @@ private:
Version m_version;
};
-quint32 qHash(const VisualStudioVersionInfo &info);
+QHashValueType qHash(const VisualStudioVersionInfo &info);
} // namespace Internal
} // namespace qbs