aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unused-non-trivial-variable/no-whitelist.cpp
blob: 9cb7ee18d50e39d547a152e8fbc77218071d0435 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <QtCore/QString>
#include <QtCore/QList>
#include <QtCore/QVector>
#include <QtCore/QByteArray>
#include <QtCore/QRect>
#include <QtCore/QMutex>
#include <QtCore/QScopedPointer>
#include "other.h"



extern void external(QString);

QString test()
{
    QString s; // Warning
    QString s1, s2; // Warning for s2
    QString s3; // OK
    external(s1);

    return s3;
    return {};
}

struct MyRAII
{
    MyRAII();
    ~MyRAII();
};

void testRAII()
{
    MyRAII m; // Warn, not blacklisted
}

void testFor()
{
    QStringList l;
    for (QString s : l) // OK
        s;

    foreach (QString s,  l) // OK
        s;
}


void test4()
{
    QList<int> l; //Warn
    QVector<int> v; //Warn
    QByteArray b; //Warn
    QRect r; // Warn
    FOO(QRect) r2; // OK
    r2.setX(0);
}

void mutex()
{
    QMutex m;
    QMutexLocker ml(&m); // OK, is uninteresting
    QScopedPointer<QMutex> p(&m);  // OK, is uninteresting
}

struct MyBlacklistedType
{
    MyBlacklistedType();
    ~MyBlacklistedType();
};

void testUserWhitelist()
{
    MyBlacklistedType m; // OK, blacklisted
}