File indexing completed on 2024-05-12 17:13:29
0001 #include <QtCore/QString> 0002 #include <QtCore/QList> 0003 #include <QtCore/QVector> 0004 #include <QtCore/QByteArray> 0005 #include <QtCore/QRect> 0006 #include <QtCore/QMutex> 0007 #include <QtCore/QScopedPointer> 0008 #include "other.h" 0009 0010 0011 0012 extern void external(QString); 0013 0014 QString test() 0015 { 0016 QString s; // Warning 0017 QString s1, s2; // Warning for s2 0018 QString s3; // OK 0019 external(s1); 0020 0021 return s3; 0022 return {}; 0023 } 0024 0025 struct MyRAII 0026 { 0027 MyRAII(); 0028 ~MyRAII(); 0029 }; 0030 0031 void testRAII() 0032 { 0033 MyRAII m; // Warn, not blacklisted 0034 } 0035 0036 void testFor() 0037 { 0038 QStringList l; 0039 for (QString s : l) // OK 0040 s; 0041 0042 foreach (QString s, l) // OK 0043 s; 0044 } 0045 0046 0047 void test4() 0048 { 0049 QList<int> l; //Warn 0050 QVector<int> v; //Warn 0051 QByteArray b; //Warn 0052 QRect r; // Warn 0053 FOO(QRect) r2; // OK 0054 r2.setX(0); 0055 } 0056 0057 void mutex() 0058 { 0059 QMutex m; 0060 QMutexLocker ml(&m); // OK, is uninteresting 0061 QScopedPointer<QMutex> p(&m); // OK, is uninteresting 0062 } 0063 0064 struct MyBlacklistedType 0065 { 0066 MyBlacklistedType(); 0067 ~MyBlacklistedType(); 0068 }; 0069 0070 void testUserWhitelist() 0071 { 0072 MyBlacklistedType m; // OK, blacklisted 0073 }