diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-12-09 15:35:20 +0100 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-12-10 11:18:21 +0100 |
| commit | e05e948fbeccdb98493d51ed51a1a6b566a9924d (patch) | |
| tree | 4c6868ef8a7c2c2777cdd30ae96b0abc0954bfc6 | |
| parent | 05e3e8445443df26fb902d7e14c8103d38fc57d6 (diff) | |
shiboken6: Restrict warning about const mismatch in function modifications
Prevent it from triggering for operators synthesized from free operators
using some heuristic (',' in parameter list indicating several parameters).
Amends 7c358ca13760c9e422c38d8c28e56b197663debf.
Task-number: PYSIDE-3245
Change-Id: If5e9c283bff6fe2a26350f6781cdef9684d8a1ca
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
| -rw-r--r-- | sources/shiboken6_generator/ApiExtractor/abstractmetabuilder.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/sources/shiboken6_generator/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken6_generator/ApiExtractor/abstractmetabuilder.cpp index deb6acbec..b6767b79c 100644 --- a/sources/shiboken6_generator/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken6_generator/ApiExtractor/abstractmetabuilder.cpp @@ -160,6 +160,14 @@ const QMultiHash<QString, QString> &AbstractMetaBuilder::typedefTargetToName() c return d->m_typedefTargetToName; } +static inline bool warnAboutConstMismatch(const AbstractMetaFunctionCPtr &function, + const QString &signature) +{ + return function->isConstant() && !signature.startsWith(u'^') && signature.endsWith(u')') + // An operator synthesized from a free operator? + && !(function->isOperatorOverload() && signature.contains(u',')); +} + // Check whether a function modification can be found in a class, else // warn with candidates. static void checkModification(const FunctionModification &modification, @@ -176,7 +184,7 @@ static void checkModification(const FunctionModification &modification, const QString &signature = modification.signature(); auto it = std::find_if(functions.cbegin(), functions.cend(), modificationPredicate); if (it != functions.cend()) { - if ((*it)->isConstant() && signature.endsWith(u')')) // Warn about missing const + if (warnAboutConstMismatch(*it, signature)) qCWarning(lcShiboken, "%s", qPrintable(msgModificationConstMismatch(*it, signature))); return; } |
