metatype: Do not try analyze T in Q*Pointer<T> if T is incomplete

Change-Id: I41737ce470f6d2b071ad5e85f8cad1da3869241c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
bb10
Fabian Kosmale 2020-06-05 14:24:31 +02:00
parent 910804a420
commit 4c32443bc9
5 changed files with 86 additions and 1 deletions

View File

@ -2839,11 +2839,29 @@ struct is_complete_helper {
template <typename T, typename ODR_VIOLATION_PREVENTER>
struct is_complete : detail::is_complete_helper<T, ODR_VIOLATION_PREVENTER>::type {};
template<typename T>
struct qRemovePointerLike
{
using type = std::remove_pointer_t<T>;
};
#define Q_REMOVE_POINTER_LIKE_IMPL(Pointer) \
template <typename T> \
struct qRemovePointerLike<Pointer<T>> \
{ \
using type = T; \
};
QT_FOR_EACH_AUTOMATIC_TEMPLATE_SMART_POINTER(Q_REMOVE_POINTER_LIKE_IMPL)
template<typename T>
using qRemovePointerLike_t = typename qRemovePointerLike<T>::type;
#undef Q_REMOVE_POINTER_LIKE_IMPL
template<typename Unique, typename T>
constexpr QMetaTypeInterface *qTryMetaTypeInterfaceForType()
{
using Ty = std::remove_cv_t<std::remove_reference_t<T>>;
using Tz = std::remove_pointer_t<Ty>;
using Tz = qRemovePointerLike_t<Ty>;
if constexpr (!is_complete<Tz, Unique>::value) {
return nullptr;
} else {

View File

@ -1592,6 +1592,23 @@
"inputFile": "plugin_metadata.h",
"outputRevision": 67
},
{
"classes": [
{
"className": "TestPointeeCanBeIncomplete",
"object": true,
"qualifiedClassName": "TestPointeeCanBeIncomplete",
"superClasses": [
{
"access": "public",
"name": "QObject"
}
]
}
],
"inputFile": "pointery_to_incomplete.h",
"outputRevision": 67
},
{
"classes": [
{

View File

@ -32,6 +32,7 @@ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-n
namespace.h cxx17-namespaces.h \
cxx-attributes.h \
enum_inc.h enum_with_include.h \
pointery_to_incomplete.h \
moc_include.h
# No platform specifics in the JSON files, so that we can compare them

View File

@ -0,0 +1,48 @@
/****************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** 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$
**
****************************************************************************/
#ifndef POINTERY_TO_INCOMPLETE_H
#define POINTERY_TO_INCOMPLETE_H
#include <QObject>
#include <QSharedPointer>
#include <QWeakPointer>
#include <QPointer>
class FwdClass;
class TestPointeeCanBeIncomplete : public QObject
{
Q_OBJECT
public:
void setProp1(QPointer<FwdClass>) {};
void setProp2(QSharedPointer<FwdClass>) {};
void setProp3(const QWeakPointer<FwdClass> &) {};
};
#endif // POINTERY_TO_INCOMPLETE_H

View File

@ -75,6 +75,7 @@
#include "cxx-attributes.h"
#include "moc_include.h"
#include "pointery_to_incomplete.h"
#include "fwdclass1.h"
#include "fwdclass2.h"
#include "fwdclass3.h"