Warning, /sdk/clazy/tests/fully-qualified-moc-types/main.cpp.fixed.expected is written in an unsupported language. File is not indexed.
0001 #include <QtCore/QObject> 0002 #include <QtDBus/QDBusPendingReply> 0003 #include <memory> 0004 struct A {}; 0005 struct NonNamespacedGadget { 0006 Q_GADGET 0007 }; 0008 0009 namespace NS { 0010 struct MyType {}; 0011 0012 struct NamespacedGadget { 0013 Q_GADGET 0014 }; 0015 0016 enum EnumFoo { EnumFoo1 }; 0017 0018 class MyObject : public QObject 0019 { 0020 Q_OBJECT 0021 Q_PROPERTY(NS::MyType foo READ foo) // OK, not gadget 0022 Q_PROPERTY(MyType foo1 READ foo) // OK, not gadget 0023 Q_PROPERTY(EnumFoo enumFoo READ enumFoo CONSTANT) // OK 0024 Q_PROPERTY(NamespacedGadget namespacedGadget READ namespacedGadget CONSTANT) // Warn, gadget 0025 Q_PROPERTY(NS::NamespacedGadget namespacedGadget2 READ namespacedGadget2 CONSTANT) // OK 0026 Q_PROPERTY(NonNamespacedGadget nonNamespacedGadget READ nonNamespacedGadget CONSTANT) // OK 0027 Q_SIGNALS: 0028 void mysig(NS::MyType); 0029 void mysig2(NS::MyType &); // Warn 0030 void mysig3(NS::MyType); 0031 void mysig4(const NS::MyType &); 0032 void mysig5(A); 0033 void mysig6(const A); 0034 void mysig7(const A *); 0035 void mysig8(A *); 0036 public Q_SLOTS: 0037 void myslot1(NS::MyType); 0038 void myslot2(NS::MyType); // Warn 0039 void myslot3(NS::MyType); 0040 void myslot4(const NS::MyType &); 0041 void myslot5(A); 0042 void myslot6(const A); 0043 void myslot7(const A *); 0044 void myslot8(A *); 0045 public: 0046 Q_INVOKABLE void myinvokable1(NS::MyType); 0047 Q_INVOKABLE void myinvokable2(NS::MyType); // Warn 0048 Q_INVOKABLE void myinvokable3(NS::MyType); 0049 Q_INVOKABLE void myinvokable4(const NS::MyType &); 0050 Q_INVOKABLE void myinvokable5(A); 0051 Q_INVOKABLE void myinvokable6(const A); 0052 Q_INVOKABLE void myinvokable7(const A *); 0053 Q_INVOKABLE void myinvokable8(A *); 0054 Q_INVOKABLE NS::MyType* myinvokable9(NS::MyType); // Warn 0055 NS::MyType foo(); 0056 NamespacedGadget namespacedGadget() const; 0057 NamespacedGadget namespacedGadget2() const; 0058 NonNamespacedGadget nonNamespacedGadget() const; 0059 EnumFoo enumFoo() const; 0060 }; 0061 } 0062 0063 0064 0065 namespace { // annonymous 0066 struct AnnonFoo {}; 0067 }; 0068 0069 using namespace std; // pair<bool,QualMe> is returned for one method, the check should warn about the missing "std::" prefix 0070 class MyObj2 : public QObject 0071 { 0072 public: 0073 struct QualMe {}; 0074 using MyList = QList<QualMe>; // QualMe is not fully qualified here, but it shouldn't matter when using the typedef 0075 Q_OBJECT 0076 Q_SIGNALS: 0077 void mySig(AnnonFoo); 0078 public Q_SLOTS: 0079 inline std::pair<bool, MyObj2::QualMe> unqualPairParam() {return {};} // Warn 0080 inline std::pair<bool, MyObj2::QualMe> unqualPairClass() {return {};} // Warn 0081 inline std::pair<bool, MyObj2::QualMe> fullyQUalPair() {return {};} // OK 0082 inline MyObj2::MyList typeAlias() {return {};} // WARN 0083 inline QList<MyObj2::QualMe> genericWithoutFullyQual() {return {};} // WARN 0084 inline QList<MyObj2::QualMe> genericFullyQual() {return {};} // OK 0085 inline QStringList qstringListTypealias() {return {};} // OK 0086 inline MyObj2::MyList fullTypeAlias() {return {};} // OK 0087 inline QDBusPendingReply<MyObj2::QualMe> unqualGenericDbusReply() {return {};} // WARN 0088 inline QDBusPendingReply<bool> boolDbusReply() {return {};} // OK 0089 inline QDBusPendingReply<> voidDbusReply() {return {};} // OK 0090 inline QDBusPendingReply<MyObj2::MyList> typedefInGeneric() {return {};} // WARN 0091 inline void nestedGeneric(QDBusPendingReply<std::shared_ptr<MyObj2>>) {} // OK 0092 inline void nestedNotFullyQualifiedGeneric(QDBusPendingReply<std::shared_ptr<MyObj2::MyList>>) {} // WARN 0093 inline const MyObj2::MyList& notQualWithModifier() {return lst;}; 0094 private: 0095 MyList lst; 0096 }; 0097 0098 Q_DECLARE_METATYPE(MyObj2::QualMe); 0099 Q_DECLARE_METATYPE(std::shared_ptr<MyObj2::MyList>); 0100 0101 #if QT_VERSION_MAJOR == 5 0102 #include "main.qt5.moc_" 0103 #else 0104 #include "main.qt6.moc_" 0105 #endif