diff options
author | Simo Fält <simo.falt@qt.io> | 2023-02-01 15:24:01 +0200 |
---|---|---|
committer | Simo Fält <simo.falt@qt.io> | 2023-02-01 15:24:01 +0200 |
commit | 4ff8ac45ac541471d5ec967e529e24a6bee87eba (patch) | |
tree | 23149a480cb8dbf15d86e24b2f107a88881ebefb /sources/shiboken2/ApiExtractor/clangparser | |
parent | d526f801ced4687d5413907a93dedcd782ef72fa (diff) | |
parent | ac0db13c20529d09a715985b2a2d4579f415369c (diff) |
Merge tag 'v5.15.3-lts' into tqtc/lts-5.15-opensource
Qt For Python Release 5.15.3
Change-Id: Ia936efcdfa8196b02528905c12cc7764553d6ca8
Diffstat (limited to 'sources/shiboken2/ApiExtractor/clangparser')
10 files changed, 64 insertions, 112 deletions
diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp index 73b1aca63..cca1d6127 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp +++ b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp @@ -1,11 +1,12 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of Qt for Python. ** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** $QT_BEGIN_LICENSE:COMM$ +** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the @@ -14,14 +15,6 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -245,8 +238,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; @@ -921,16 +922,17 @@ BaseVisitor::StartTokenResult Builder::startToken(const CXCursor &cursor) case CXCursor_ClassDecl: case CXCursor_UnionDecl: case CXCursor_StructDecl: - if (clang_isCursorDefinition(cursor) == 0) + if (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 (clang_isCursorDefinition(cursor) == 0) + if (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; diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.h b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.h index dc37dff0f..54803f7a2 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.h +++ b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.h @@ -1,11 +1,12 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of Qt for Python. ** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** $QT_BEGIN_LICENSE:COMM$ +** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the @@ -14,14 +15,6 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangdebugutils.cpp b/sources/shiboken2/ApiExtractor/clangparser/clangdebugutils.cpp index d6915daab..5605131b0 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/clangdebugutils.cpp +++ b/sources/shiboken2/ApiExtractor/clangparser/clangdebugutils.cpp @@ -1,11 +1,12 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of Qt for Python. ** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** $QT_BEGIN_LICENSE:COMM$ +** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the @@ -14,14 +15,6 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangdebugutils.h b/sources/shiboken2/ApiExtractor/clangparser/clangdebugutils.h index 2bbe526f7..0d44bdcb6 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/clangdebugutils.h +++ b/sources/shiboken2/ApiExtractor/clangparser/clangdebugutils.h @@ -1,11 +1,12 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of Qt for Python. ** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** $QT_BEGIN_LICENSE:COMM$ +** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the @@ -14,14 +15,6 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangparser.cpp b/sources/shiboken2/ApiExtractor/clangparser/clangparser.cpp index d0c5bc1b8..5a21899b7 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/clangparser.cpp +++ b/sources/shiboken2/ApiExtractor/clangparser/clangparser.cpp @@ -1,11 +1,12 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of Qt for Python. ** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** $QT_BEGIN_LICENSE:COMM$ +** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the @@ -14,14 +15,6 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangparser.h b/sources/shiboken2/ApiExtractor/clangparser/clangparser.h index 825de331c..47c1b63f9 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/clangparser.h +++ b/sources/shiboken2/ApiExtractor/clangparser/clangparser.h @@ -1,11 +1,12 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of Qt for Python. ** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** $QT_BEGIN_LICENSE:COMM$ +** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the @@ -14,14 +15,6 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangutils.cpp b/sources/shiboken2/ApiExtractor/clangparser/clangutils.cpp index 6bf2e3ab0..ea6f17787 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/clangutils.cpp +++ b/sources/shiboken2/ApiExtractor/clangparser/clangutils.cpp @@ -1,11 +1,12 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of Qt for Python. ** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** $QT_BEGIN_LICENSE:COMM$ +** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the @@ -14,14 +15,6 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -139,8 +132,9 @@ QString getTypeName(const CXType &type) } Diagnostic::Diagnostic(const QString &m, const CXCursor &c, CXDiagnosticSeverity s) - : message(m), location(getCursorLocation(c)), source(Other), severity(s) + : message(m), source(Other), severity(s) { + setLocation(getCursorLocation(c)); } Diagnostic Diagnostic::fromCXDiagnostic(CXDiagnostic cd) @@ -151,7 +145,7 @@ Diagnostic Diagnostic::fromCXDiagnostic(CXDiagnostic cd) result.message = QString::fromUtf8(clang_getCString(spelling)); clang_disposeString(spelling); result.severity = clang_getDiagnosticSeverity(cd); - result.location = getExpansionLocation(clang_getDiagnosticLocation(cd)); + result.setLocation(getExpansionLocation(clang_getDiagnosticLocation(cd))); CXDiagnosticSet childDiagnostics = clang_getChildDiagnostics(cd); if (const unsigned childCount = clang_getNumDiagnosticsInSet(childDiagnostics)) { @@ -169,6 +163,14 @@ Diagnostic Diagnostic::fromCXDiagnostic(CXDiagnostic cd) return result; } +void Diagnostic::setLocation(const SourceLocation &sourceLocation) +{ + file = getFileName(sourceLocation.file); + line = sourceLocation.line; + column = sourceLocation.column; + offset = sourceLocation.offset; +} + QVector<Diagnostic> getDiagnostics(CXTranslationUnit tu) { QVector<Diagnostic> result; @@ -249,7 +251,7 @@ QDebug operator<<(QDebug s, const Diagnostic &d) QDebugStateSaver saver(s); s.nospace(); s.noquote(); - s << d.location << ": "; + s << d.file << ':'<< d.line << ':' << d.column << ": "; switch (d.severity) { case CXDiagnostic_Ignored: s << "ignored"; diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangutils.h b/sources/shiboken2/ApiExtractor/clangparser/clangutils.h index 41d0af460..239136da9 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/clangutils.h +++ b/sources/shiboken2/ApiExtractor/clangparser/clangutils.h @@ -1,11 +1,12 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of Qt for Python. ** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** $QT_BEGIN_LICENSE:COMM$ +** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the @@ -14,14 +15,6 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -68,7 +61,7 @@ struct SourceLocation { bool equals(const SourceLocation &rhs) const; - CXFile file; + CXFile file = nullptr; unsigned line = 0; unsigned column = 0; unsigned offset = 0; @@ -96,10 +89,14 @@ struct Diagnostic { static Diagnostic fromCXDiagnostic(CXDiagnostic cd); // Other explicit Diagnostic(const QString &m, const CXCursor &c, CXDiagnosticSeverity s = CXDiagnostic_Warning); + void setLocation(const SourceLocation &); QString message; QStringList childMessages; - SourceLocation location; + QString file; + unsigned line = 0; + unsigned column = 0; + unsigned offset = 0; Source source = Clang; CXDiagnosticSeverity severity = CXDiagnostic_Warning; }; diff --git a/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp b/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp index 0b58cf5a5..4435f7e6c 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp +++ b/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp @@ -1,11 +1,12 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of Qt for Python. ** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** $QT_BEGIN_LICENSE:COMM$ +** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the @@ -14,14 +15,6 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/sources/shiboken2/ApiExtractor/clangparser/compilersupport.h b/sources/shiboken2/ApiExtractor/clangparser/compilersupport.h index d9e213e73..708ca6267 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/compilersupport.h +++ b/sources/shiboken2/ApiExtractor/clangparser/compilersupport.h @@ -1,11 +1,12 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of Qt for Python. ** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** $QT_BEGIN_LICENSE:COMM$ +** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the @@ -14,14 +15,6 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** ** $QT_END_LICENSE$ ** ****************************************************************************/ |