at master 5.0 kB view raw
1From: Friedemann Kleint <Friedemann.Kleint@qt.io> 2Date: Thu, 27 Apr 2023 13:00:37 +0200 3Subject: shiboken2/clang: Suppress class scope look up for parameters with 4 scope resolution 5 6Add a flag to AbstractMetaBuilderPrivate::findTypeEntriesHelper() 7to suppress the class scope look in case scope resolution. 8 9Task-number: PYSIDE-2288 10Pick-to: 6.5 5.15 11Change-Id: I04a4810d03845fb48393c5efed3641220bd12d87 12Reviewed-by: Christian Tismer <tismer@stackless.com> 13--- 14 sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp | 16 ++++++++++++---- 15 sources/shiboken2/ApiExtractor/abstractmetabuilder.h | 3 ++- 16 sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h | 1 + 17 3 files changed, 15 insertions(+), 5 deletions(-) 18 19diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp 20index 2f34e16..4bf4ab4 100644 21--- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp 22+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp 23@@ -1845,7 +1845,10 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(const Functio 24 return nullptr; 25 } 26 27- AbstractMetaType *type = translateType(returnType, currentClass, {}, &errorMessage); 28+ TranslateTypeFlags flags; 29+ if (functionItem->scopeResolution()) 30+ flags.setFlag(AbstractMetaBuilder::NoClassScopeLookup); 31+ AbstractMetaType *type = translateType(returnType, currentClass, flags, &errorMessage); 32 if (!type) { 33 const QString reason = msgUnmatchedReturnType(functionItem, errorMessage); 34 qCWarning(lcShiboken, "%s", 35@@ -1880,7 +1883,10 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(const Functio 36 return nullptr; 37 } 38 39- AbstractMetaType *metaType = translateType(arg->type(), currentClass, {}, &errorMessage); 40+ TranslateTypeFlags flags; 41+ if (arg->scopeResolution()) 42+ flags.setFlag(AbstractMetaBuilder::NoClassScopeLookup); 43+ AbstractMetaType *metaType = translateType(arg->type(), currentClass, flags, &errorMessage); 44 if (!metaType) { 45 // If an invalid argument has a default value, simply remove it 46 // unless the function is virtual (since the override in the 47@@ -2073,11 +2079,13 @@ static const TypeEntry* findTypeEntryUsingContext(const AbstractMetaClass* metaC 48 // Helper for translateTypeStatic() 49 TypeEntries AbstractMetaBuilderPrivate::findTypeEntries(const QString &qualifiedName, 50 const QString &name, 51+ TranslateTypeFlags flags, 52 AbstractMetaClass *currentClass, 53 AbstractMetaBuilderPrivate *d) 54 { 55 // 5.1 - Try first using the current scope 56- if (currentClass) { 57+ if (currentClass != nullptr 58+ && !flags.testFlag(AbstractMetaBuilder::NoClassScopeLookup)) { 59 if (auto type = findTypeEntryUsingContext(currentClass, qualifiedName)) 60 return {type}; 61 62@@ -2278,7 +2286,7 @@ AbstractMetaType *AbstractMetaBuilderPrivate::translateTypeStatic(const TypeInfo 63 typeInfo.clearInstantiations(); 64 } 65 66- TypeEntries types = findTypeEntries(qualifiedName, name, currentClass, d); 67+ TypeEntries types = findTypeEntries(qualifiedName, name, flags, currentClass, d); 68 if (!flags.testFlag(AbstractMetaBuilder::TemplateArgument)) { 69 // Avoid clashes between QByteArray and enum value QMetaType::QByteArray 70 // unless we are looking for template arguments. 71diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.h b/sources/shiboken2/ApiExtractor/abstractmetabuilder.h 72index 8916eaf..f333ad5 100644 73--- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.h 74+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.h 75@@ -94,7 +94,8 @@ public: 76 77 enum TranslateTypeFlag { 78 DontResolveType = 0x1, 79- TemplateArgument = 0x2 80+ TemplateArgument = 0x2, 81+ NoClassScopeLookup = 0x4 82 }; 83 Q_DECLARE_FLAGS(TranslateTypeFlags, TranslateTypeFlag); 84 85diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h b/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h 86index 8468950..8ddd369 100644 87--- a/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h 88+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h 89@@ -154,6 +154,7 @@ public: 90 TranslateTypeFlags flags = {}, 91 QString *errorMessageIn = nullptr); 92 static TypeEntries findTypeEntries(const QString &qualifiedName, const QString &name, 93+ TranslateTypeFlags flags = {}, 94 AbstractMetaClass *currentClass = nullptr, 95 AbstractMetaBuilderPrivate *d = nullptr); 96