From 59f92c2133ad1d43ba2f6a7a32c5b70fc6aba614 Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Sun, 11 Apr 2021 14:32:09 +0200 Subject: shiboken: get rid of some warnings A few warnings are from libshiboken: Fix some clang analzyer warnings where const_cast is still needed in Python 3. Thanks for helping with auto writeConversionRegister = [this, &s](const AbstractMetaType &sourceType, const QString &targetTypeName, const QString &targetConverter) Change-Id: I487c9a5234dd1378c3a834076dd3bb204bb76cb8 Reviewed-by: Friedemann Kleint --- .../ApiExtractor/clangparser/compilersupport.cpp | 15 ++++--- .../shiboken6/ApiExtractor/typesystemparser.cpp | 1 - sources/shiboken6/libshiboken/basewrapper.cpp | 14 +++--- sources/shiboken6/libshiboken/sbkenum.cpp | 2 +- .../libshiboken/signature/signature_extend.cpp | 50 +++++++++++----------- .../tests/qtxmltosphinxtest/qtxmltosphinxtest.h | 2 +- 6 files changed, 44 insertions(+), 40 deletions(-) (limited to 'sources') diff --git a/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp b/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp index 02a66b40e..7631916fb 100644 --- a/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp +++ b/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp @@ -95,7 +95,7 @@ static bool runProcess(const QString &program, const QStringList &arguments, static QByteArray frameworkPath() { return QByteArrayLiteral(" (framework directory)"); } -#if defined(Q_OS_MACOS) +# if defined(Q_OS_MACOS) static void filterHomebrewHeaderPaths(HeaderPaths &headerPaths) { QByteArray homebrewPrefix = qgetenv("HOMEBREW_OPT"); @@ -123,7 +123,7 @@ static void filterHomebrewHeaderPaths(HeaderPaths &headerPaths) } } } -#endif +# endif // Determine g++'s internal include paths from the output of // g++ -E -x c++ - -v (Sbk_TypeGet___signature__), - nullptr, nullptr, nullptr}, - {"__doc__", reinterpret_cast(Sbk_TypeGet___doc__), - reinterpret_cast(type_set_doc), nullptr, nullptr}, - {"__dict__", reinterpret_cast(Sbk_TypeGet___dict__), - nullptr, nullptr, nullptr}, + {const_cast("__signature__"), reinterpret_cast(Sbk_TypeGet___signature__), + nullptr, nullptr, nullptr}, + {const_cast("__doc__"), reinterpret_cast(Sbk_TypeGet___doc__), + reinterpret_cast(type_set_doc), nullptr, nullptr}, + {const_cast("__dict__"), reinterpret_cast(Sbk_TypeGet___dict__), + nullptr, nullptr, nullptr}, {nullptr, nullptr, nullptr, nullptr, nullptr} // Sentinel }; @@ -191,7 +191,7 @@ static PyObject *SbkObjectGetDict(PyObject *pObj, void *) } static PyGetSetDef SbkObjectGetSetList[] = { - {"__dict__", SbkObjectGetDict, nullptr, nullptr, nullptr}, + {const_cast("__dict__"), SbkObjectGetDict, nullptr, nullptr, nullptr}, {nullptr, nullptr, nullptr, nullptr, nullptr} // Sentinel }; diff --git a/sources/shiboken6/libshiboken/sbkenum.cpp b/sources/shiboken6/libshiboken/sbkenum.cpp index c9243d652..a3d17ea2e 100644 --- a/sources/shiboken6/libshiboken/sbkenum.cpp +++ b/sources/shiboken6/libshiboken/sbkenum.cpp @@ -261,7 +261,7 @@ static Py_hash_t enum_hash(PyObject *pyObj) } static PyGetSetDef SbkEnumGetSetList[] = { - {"name", SbkEnumObject_name, nullptr, nullptr, nullptr}, + {const_cast("name"), SbkEnumObject_name, nullptr, nullptr, nullptr}, {nullptr, nullptr, nullptr, nullptr, nullptr} // Sentinel }; diff --git a/sources/shiboken6/libshiboken/signature/signature_extend.cpp b/sources/shiboken6/libshiboken/signature/signature_extend.cpp index 1c50c0d72..43a78ed21 100644 --- a/sources/shiboken6/libshiboken/signature/signature_extend.cpp +++ b/sources/shiboken6/libshiboken/signature/signature_extend.cpp @@ -222,47 +222,47 @@ static int pyside_set___signature__(PyObject *op, PyObject *value) } static PyGetSetDef new_PyCFunction_getsets[] = { - {"__doc__", reinterpret_cast(pyside_cf_get___doc__), - nullptr, nullptr, nullptr}, - {"__signature__", reinterpret_cast(pyside_cf_get___signature__), - reinterpret_cast(pyside_set___signature__), - nullptr, nullptr}, + {const_cast("__doc__"), reinterpret_cast(pyside_cf_get___doc__), + nullptr, nullptr, nullptr}, + {const_cast("__signature__"), reinterpret_cast(pyside_cf_get___signature__), + reinterpret_cast(pyside_set___signature__), + nullptr, nullptr}, {nullptr, nullptr, nullptr, nullptr, nullptr} }; static PyGetSetDef new_PyStaticMethod_getsets[] = { - {"__doc__", reinterpret_cast(pyside_sm_get___doc__), - nullptr, nullptr, nullptr}, - {"__signature__", reinterpret_cast(pyside_sm_get___signature__), - reinterpret_cast(pyside_set___signature__), - nullptr, nullptr}, + {const_cast("__doc__"), reinterpret_cast(pyside_sm_get___doc__), + nullptr, nullptr, nullptr}, + {const_cast("__signature__"), reinterpret_cast(pyside_sm_get___signature__), + reinterpret_cast(pyside_set___signature__), + nullptr, nullptr}, {nullptr, nullptr, nullptr, nullptr, nullptr} }; static PyGetSetDef new_PyMethodDescr_getsets[] = { - {"__doc__", reinterpret_cast(pyside_md_get___doc__), - nullptr, nullptr, nullptr}, - {"__signature__", reinterpret_cast(pyside_md_get___signature__), - reinterpret_cast(pyside_set___signature__), - nullptr, nullptr}, + {const_cast("__doc__"), reinterpret_cast(pyside_md_get___doc__), + nullptr, nullptr, nullptr}, + {const_cast("__signature__"), reinterpret_cast(pyside_md_get___signature__), + reinterpret_cast(pyside_set___signature__), + nullptr, nullptr}, {nullptr, nullptr, nullptr, nullptr, nullptr} }; static PyGetSetDef new_PyType_getsets[] = { - {"__doc__", reinterpret_cast(pyside_tp_get___doc__), - nullptr, nullptr, nullptr}, - {"__signature__", reinterpret_cast(pyside_tp_get___signature__), - reinterpret_cast(pyside_set___signature__), - nullptr, nullptr}, + {const_cast("__doc__"), reinterpret_cast(pyside_tp_get___doc__), + nullptr, nullptr, nullptr}, + {const_cast("__signature__"), reinterpret_cast(pyside_tp_get___signature__), + reinterpret_cast(pyside_set___signature__), + nullptr, nullptr}, {nullptr, nullptr, nullptr, nullptr, nullptr} }; static PyGetSetDef new_PyWrapperDescr_getsets[] = { - {"__doc__", reinterpret_cast(pyside_wd_get___doc__), - nullptr, nullptr, nullptr}, - {"__signature__", reinterpret_cast(pyside_wd_get___signature__), - reinterpret_cast(pyside_set___signature__), - nullptr, nullptr}, + {const_cast("__doc__"), reinterpret_cast(pyside_wd_get___doc__), + nullptr, nullptr, nullptr}, + {const_cast("__signature__"), reinterpret_cast(pyside_wd_get___signature__), + reinterpret_cast(pyside_set___signature__), + nullptr, nullptr}, {nullptr, nullptr, nullptr, nullptr, nullptr} }; diff --git a/sources/shiboken6/tests/qtxmltosphinxtest/qtxmltosphinxtest.h b/sources/shiboken6/tests/qtxmltosphinxtest/qtxmltosphinxtest.h index 083ebb091..dffbd86c0 100644 --- a/sources/shiboken6/tests/qtxmltosphinxtest/qtxmltosphinxtest.h +++ b/sources/shiboken6/tests/qtxmltosphinxtest/qtxmltosphinxtest.h @@ -39,7 +39,7 @@ class QtXmlToSphinxTest : public QObject, public QtXmlToSphinxDocGeneratorInterf public: // QtXmlToSphinxDocGeneratorInterface QString expandFunction(const QString &) const override; - QString expandClass(const QString &, const QString &) const; + QString expandClass(const QString &, const QString &) const override; QString resolveContextForMethod(const QString &, const QString &) const override; const QLoggingCategory &loggingCategory() const override; -- cgit v1.2.3