aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-10-19 17:25:02 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-10-20 07:27:43 +0200
commit556c13f39244b4eb75638cd8f4434167eadf0c98 (patch)
tree2bf67519681112055664b3e6407c814995772314
parent3c96d427722b5492ac675dfebe8557768b2f82ad (diff)
shiboken2: Ensure there are no AbstractMetaType with Invalid usage
Introduce new values for the pattern enum representing template parameters, which were previously invalid and add a missing call to decideUsagePattern(). Change-Id: I7edeb80a67ab1edfe895e96311d54c9128fad5a3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp6
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetalang.cpp8
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetalang.h4
3 files changed, 14 insertions, 4 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
index 8ef2866c2..15710de4c 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
@@ -1981,14 +1981,13 @@ AbstractMetaType *AbstractMetaBuilderPrivate::translateType(const AddedFunction:
{
Q_ASSERT(!typeInfo.name.isEmpty());
TypeDatabase* typeDb = TypeDatabase::instance();
- TypeEntry* type;
QString typeName = typeInfo.name;
if (typeName == QLatin1String("void"))
return AbstractMetaType::createVoid();
- type = typeDb->findType(typeName);
+ TypeEntry *type = typeDb->findType(typeName);
if (!type)
type = typeDb->findFlagsType(typeName);
@@ -2049,6 +2048,8 @@ AbstractMetaType *AbstractMetaBuilderPrivate::translateType(const AddedFunction:
metaType->addInstantiation(metaArgType);
}
metaType->setTypeUsagePattern(AbstractMetaType::ContainerPattern);
+ } else {
+ metaType->decideUsagePattern();
}
return metaType;
@@ -2369,6 +2370,7 @@ AbstractMetaType *AbstractMetaBuilderPrivate::translateTypeStatic(const TypeInfo
}
}
+ Q_ASSERT(metaType->typeUsagePattern() != AbstractMetaType::InvalidPattern);
return metaType.take();
}
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
index 458e54626..baeab19fd 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
+++ b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
@@ -312,9 +312,15 @@ QString AbstractMetaType::pythonSignature() const
AbstractMetaType::TypeUsagePattern AbstractMetaType::determineUsagePattern() const
{
- if (m_typeEntry->isTemplateArgument() || m_referenceType == RValueReference)
+ if (m_referenceType == RValueReference)
return InvalidPattern;
+ if (m_typeEntry->isTemplateArgument())
+ return TemplateArgument;
+
+ if (m_typeEntry->type() == TypeEntry::ConstantValueType)
+ return NonTypeTemplateArgument;
+
if (m_typeEntry->isPrimitive() && (actualIndirections() == 0 || passByConstRef()))
return PrimitivePattern;
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.h b/sources/shiboken2/ApiExtractor/abstractmetalang.h
index 988815dd3..c100c63a1 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetalang.h
+++ b/sources/shiboken2/ApiExtractor/abstractmetalang.h
@@ -294,7 +294,9 @@ public:
SmartPointerPattern,
VarargsPattern,
ArrayPattern,
- VoidPattern // Plain "void", no "void *" or similar.
+ VoidPattern, // Plain "void", no "void *" or similar.
+ TemplateArgument, // 'T' in std::array<T,2>
+ NonTypeTemplateArgument // '2' in in std::array<T,2>
};
Q_ENUM(TypeUsagePattern)