From 5b87b64f6a6a2404d01f24b2c5a2189e406bddf8 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 13 Oct 2020 14:05:04 +0200 Subject: shiboken2: Improve error messages about cyclic dependencies Return a struct instead of a plain list from Graph::topologicalSort() which contains the offending indexes and output the elements in case of failure. Task-number: PYSIDE-1202 Change-Id: Ib7f70c78be0e84272f31d802677c7fc333aa32f4 Reviewed-by: Christian Tismer --- sources/shiboken2/generator/shiboken2/overloaddata.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'sources/shiboken2/generator') diff --git a/sources/shiboken2/generator/shiboken2/overloaddata.cpp b/sources/shiboken2/generator/shiboken2/overloaddata.cpp index 50e82b1e6..dd0cb39eb 100644 --- a/sources/shiboken2/generator/shiboken2/overloaddata.cpp +++ b/sources/shiboken2/generator/shiboken2/overloaddata.cpp @@ -155,13 +155,16 @@ static QString getImplicitConversionTypeName(const AbstractMetaType &containerTy // overloaddata.cpp static QString msgCyclicDependency(const QString &funcName, const QString &graphName, + const AbstractMetaFunctionCList &cyclic, const OverloadData::MetaFunctionList &involvedConversions) { QString result; QTextStream str(&result); str << "Cyclic dependency found on overloaddata for \"" << funcName << "\" method! The graph boy saved the graph at \"" << QDir::toNativeSeparators(graphName) - << "\"."; + << "\". Cyclic functions:"; + for (auto c : cyclic) + str << ' ' << c->signature(); if (const int count = involvedConversions.size()) { str << " Implicit conversions (" << count << "): "; for (int i = 0; i < count; ++i) { @@ -431,7 +434,7 @@ void OverloadData::sortNextOverloads() // sort the overloads topologically based on the dependency graph. const auto unmappedResult = graph.topologicalSort(); - if (unmappedResult.isEmpty()) { + if (!unmappedResult.isValid()) { QString funcName = referenceFunction()->name(); if (referenceFunction()->ownerClass()) funcName.prepend(referenceFunction()->ownerClass()->name() + QLatin1Char('.')); @@ -442,11 +445,14 @@ void OverloadData::sortNextOverloads() for (auto it = sortData.map.cbegin(), end = sortData.map.cend(); it != end; ++it) nodeNames.insert(it.value(), it.key()); graph.dumpDot(nodeNames, graphName); - qCWarning(lcShiboken).noquote() << qPrintable(msgCyclicDependency(funcName, graphName, involvedConversions)); + AbstractMetaFunctionCList cyclic; + for (int c : unmappedResult.cyclic) + cyclic.append(sortData.reverseMap.value(c)->referenceFunction()); + qCWarning(lcShiboken, "%s", qPrintable(msgCyclicDependency(funcName, graphName, cyclic, involvedConversions))); } m_nextOverloadData.clear(); - for (int i : unmappedResult) { + for (int i : unmappedResult.result) { if (!sortData.reverseMap[i]) continue; m_nextOverloadData << sortData.reverseMap[i]; -- cgit v1.2.3