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 "other.h" 0007 0008 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; // OK, not whitelisted 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 struct MyWhitelistedType 0058 { 0059 MyWhitelistedType(); 0060 ~MyWhitelistedType(); 0061 }; 0062 0063 void testUserWhitelist() 0064 { 0065 MyWhitelistedType m; // OK, whitelisted 0066 }