From 002e68898c22211c8195d2b50752fbf479b482df Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 22 Feb 2017 13:57:00 +0100 Subject: AbstractMetaBuilderPrivate::traverseDom(): Fix crash AbstractMetaBuilderPrivate::traverseOperatorFunction() would crash when encountering: class QTreeWidgetItemIterator { public: inline QTreeWidgetItem *operator*() const; since it expects operator* with arguments. Rewrite the code compiling the list of operators filtering out the ones without arguments. Task-number: PYSIDE-323 Change-Id: I16fb8a15f892d385713a7487f9d996d6488954b7 Reviewed-by: Alexandru Croitor --- ApiExtractor/abstractmetabuilder.cpp | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/ApiExtractor/abstractmetabuilder.cpp b/ApiExtractor/abstractmetabuilder.cpp index 98c91f7..43c3890 100644 --- a/ApiExtractor/abstractmetabuilder.cpp +++ b/ApiExtractor/abstractmetabuilder.cpp @@ -653,20 +653,28 @@ void AbstractMetaBuilderPrivate::traverseDom(const FileModelItem &dom) } { - FunctionList binaryOperators = dom->findFunctions(QLatin1String("operator==")) - + dom->findFunctions(QLatin1String("operator!=")) - + dom->findFunctions(QLatin1String("operator<=")) - + dom->findFunctions(QLatin1String("operator>=")) - + dom->findFunctions(QLatin1String("operator<")) - + dom->findFunctions(QLatin1String("operator+")) - + dom->findFunctions(QLatin1String("operator/")) - + dom->findFunctions(QLatin1String("operator*")) - + dom->findFunctions(QLatin1String("operator-")) - + dom->findFunctions(QLatin1String("operator&")) - + dom->findFunctions(QLatin1String("operator|")) - + dom->findFunctions(QLatin1String("operator^")) - + dom->findFunctions(QLatin1String("operator~")) - + dom->findFunctions(QLatin1String("operator>")); + FunctionList binaryOperators = dom->findFunctions(QStringLiteral("operator==")); + binaryOperators.append(dom->findFunctions(QStringLiteral("operator!="))); + binaryOperators.append(dom->findFunctions(QStringLiteral("operator<="))); + binaryOperators.append(dom->findFunctions(QStringLiteral("operator>="))); + binaryOperators.append(dom->findFunctions(QStringLiteral("operator<"))); + binaryOperators.append(dom->findFunctions(QStringLiteral("operator+"))); + binaryOperators.append(dom->findFunctions(QStringLiteral("operator/"))); + // Filter binary operators, skipping for example + // class Iterator { ... Value *operator*() ... }; + const FunctionList potentiallyBinaryOperators = + dom->findFunctions(QStringLiteral("operator*")) + + dom->findFunctions(QStringLiteral("operator&")); + foreach (const FunctionModelItem &item, potentiallyBinaryOperators) { + if (!item->arguments().isEmpty()) + binaryOperators.append(item); + } + binaryOperators.append(dom->findFunctions(QStringLiteral("operator-"))); + binaryOperators.append(dom->findFunctions(QStringLiteral("operator&"))); + binaryOperators.append(dom->findFunctions(QStringLiteral("operator|"))); + binaryOperators.append(dom->findFunctions(QStringLiteral("operator^"))); + binaryOperators.append(dom->findFunctions(QStringLiteral("operator~"))); + binaryOperators.append(dom->findFunctions(QStringLiteral("operator>"))); foreach (const FunctionModelItem &item, binaryOperators) traverseOperatorFunction(item); -- cgit v1.2.3