Add a flag indicating whether a type was specified with a leading "::"
(scope resolution). Such parameters previously caused the function to
rejected due to the "::TypeName" not being found. The type resolution
added for clang 16 strips these qualifiers though, so, the information
needs to be stored.
Task-number: PYSIDE-2288
Pick-to: 6.5 5.15
Change-Id: I27d27c94ec43bcc4cb3b79e6e9ce6706c749a1e9
Reviewed-by: Christian Tismer <tismer@stackless.com>
(cherry picked from commit
075d8ad4660f05e6d2583ff1c05e9987ad624bfe)
Gbp-Pq: Name shiboken2-clang-Record-scope-resolution-of-arguments-func.patch
name = fixTypeName(name);
FunctionModelItem result(new _FunctionModelItem(m_model, name));
setFileName(cursor, result.data());
- result->setType(createTypeInfoHelper(clang_getCursorResultType(cursor)));
+ const auto type = clang_getCursorResultType(cursor);
+ result->setType(createTypeInfoHelper(type));
+ result->setScopeResolution(hasScopeResolution(type));
result->setFunctionType(t);
result->setScope(m_scope);
result->setStatic(clang_Cursor_getStorageClass(cursor) == CX_SC_Static);
if (d->m_currentArgument.isNull() && !d->m_currentFunction.isNull()) {
const QString name = getCursorSpelling(cursor);
d->m_currentArgument.reset(new _ArgumentModelItem(d->m_model, name));
- d->m_currentArgument->setType(d->createTypeInfo(cursor));
+ const auto type = clang_getCursorType(cursor);
+ d->m_currentArgument->setScopeResolution(hasScopeResolution(type));
+ d->m_currentArgument->setType(d->createTypeInfo(type));
d->m_currentFunction->addArgument(d->m_currentArgument);
QString defaultValueExpression = d->cursorValueExpression(this, cursor);
if (!defaultValueExpression.isEmpty()) {
return result;
}
+// Quick check for "::Type"
+bool hasScopeResolution(const CXType &type)
+{
+ CXString typeSpelling = clang_getTypeSpelling(type);
+ const QString spelling = QString::fromUtf8(clang_getCString(typeSpelling));
+ const bool result = spelling.startsWith(QLatin1String("::"))
+ || spelling.contains(QLatin1String(" ::"));
+ clang_disposeString(typeSpelling);
+ return result;
+}
+
// Resolve elaborated types occurring with clang 16
QString getResolvedTypeName(const CXType &type)
{
QString getCursorSpelling(const CXCursor &cursor);
QString getCursorDisplayName(const CXCursor &cursor);
QString getTypeName(const CXType &type);
+bool hasScopeResolution(const CXType &type);
QString getResolvedTypeName(const CXType &type);
inline QString getCursorTypeName(const CXCursor &cursor)
{ return getTypeName(clang_getCursorType(cursor)); }
m_defaultValue = defaultValue;
}
+bool _ArgumentModelItem::scopeResolution() const
+{
+ return m_scopeResolution;
+}
+
+void _ArgumentModelItem::setScopeResolution(bool v)
+{
+ m_scopeResolution = v;
+}
+
#ifndef QT_NO_DEBUG_STREAM
void _ArgumentModelItem::formatDebug(QDebug &d) const
{
_CodeModelItem::formatDebug(d);
d << ", type=" << m_type;
+ if (m_scopeResolution)
+ d << ", [m_scope resolution]";
if (m_defaultValue)
d << ", defaultValue=\"" << m_defaultValueExpression << '"';
}
m_isVariadics = isVariadics;
}
+bool _FunctionModelItem::scopeResolution() const
+{
+ return m_scopeResolution;
+}
+
+void _FunctionModelItem::setScopeResolution(bool v)
+{
+ m_scopeResolution = v;
+}
+
bool _FunctionModelItem::isNoExcept() const
{
return m_exceptionSpecification == ExceptionSpecification::NoExcept;
d << " [explicit]";
if (m_isInvokable)
d << " [invokable]";
+ if (m_scopeResolution)
+ d << " [scope resolution]";
formatModelItemList(d, ", arguments=", m_arguments);
if (m_isVariadics)
d << ",...";
QString defaultValueExpression() const { return m_defaultValueExpression; }
void setDefaultValueExpression(const QString &expr) { m_defaultValueExpression = expr; }
+ // Argument type has scope resolution "::ArgumentType"
+ bool scopeResolution() const;
+ void setScopeResolution(bool v);
+
#ifndef QT_NO_DEBUG_STREAM
void formatDebug(QDebug &d) const override;
#endif
TypeInfo m_type;
QString m_defaultValueExpression;
bool m_defaultValue;
+ bool m_scopeResolution = false;
};
class _MemberModelItem: public _CodeModelItem
bool isVariadics() const;
void setVariadics(bool isVariadics);
+ bool scopeResolution() const; // Return type has scope resolution "::ReturnType"
+ void setScopeResolution(bool v);
bool isSimilar(const FunctionModelItem &other) const;
uint m_isExplicit: 1;
uint m_isVariadics: 1;
uint m_isInvokable : 1; // Qt
+ uint m_scopeResolution: 1;
};
uint m_flags;
};