diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-02-11 13:58:47 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-02-11 15:53:50 +0000 |
commit | c61284e82ff9c5fdb98009ba167ee62239f342ba (patch) | |
tree | 82646ffcf631c03b0f0d0a00e63b56eb034f0787 | |
parent | 84eaf8c056b01f91cbd29ff5a363829710688510 (diff) |
shiboken6: Do not fail when containing template class of inner class cannot be found
Change the error about not finding containing class to a warning for
templates as it can happen for weird constellations in boost.
Fixes: PYSIDE-1501
Change-Id: Ie446ebb6f22edbcd1c97a89c6a50eb9fe5d1b245
Reviewed-by: Christian Tismer <tismer@stackless.com>
(cherry picked from commit b6ab1bb8fc44e9c3c58b9c7cc946ebf626124df2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp b/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp index cf489eb2e..ee34b29ae 100644 --- a/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp +++ b/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp @@ -247,8 +247,16 @@ bool BuilderPrivate::addClass(const CXCursor &cursor, CodeModel::ClassType t) if (isClassCursor(semPar)) { const CursorClassHash::const_iterator it = m_cursorClassHash.constFind(semPar); if (it == m_cursorClassHash.constEnd()) { - const QString message = QStringLiteral("Unable to find parent of inner class ") + className; - const Diagnostic d(message, cursor, CXDiagnostic_Error); + QString message; + QTextStream(&message) << "Unable to find containing class \"" + << getCursorSpelling(semPar) << "\" of inner class \"" + << className << "\"."; + // PYSIDE-1501: Has been observed to fail for inner class of + // template with separated implementation where a forward + // declaration of the outer template is reported (Boost). + const auto severity = semPar.kind == CXCursor_ClassTemplate + ? CXDiagnostic_Warning : CXDiagnostic_Error; + const Diagnostic d(message, cursor, severity); qWarning() << d; m_baseVisitor->appendDiagnostic(d); return false; @@ -965,16 +973,17 @@ BaseVisitor::StartTokenResult Builder::startToken(const CXCursor &cursor) case CXCursor_ClassDecl: case CXCursor_UnionDecl: case CXCursor_StructDecl: - if (d->m_withinFriendDecl || clang_isCursorDefinition(cursor) == 0) + if (d->m_withinFriendDecl || clang_isCursorDefinition(cursor) == 0 + || !d->addClass(cursor, codeModelClassTypeFromCursor(cursor.kind))) { return Skip; - if (!d->addClass(cursor, codeModelClassTypeFromCursor(cursor.kind))) - return Error; + } break; case CXCursor_ClassTemplate: case CXCursor_ClassTemplatePartialSpecialization: - if (d->m_withinFriendDecl || clang_isCursorDefinition(cursor) == 0) + if (d->m_withinFriendDecl || clang_isCursorDefinition(cursor) == 0 + || !d->addClass(cursor, CodeModel::Class)) { return Skip; - d->addClass(cursor, CodeModel::Class); + } d->m_currentClass->setName(d->m_currentClass->name() + templateBrackets()); d->m_scope.back() += templateBrackets(); break; |