diff options
author | Sergio Martins <smartins@kde.org> | 2018-01-15 23:03:25 +0000 |
---|---|---|
committer | Sergio Martins <smartins@kde.org> | 2018-01-15 23:03:25 +0000 |
commit | 3e2edaa8f7048b25f6a2b501c794043409eff524 (patch) | |
tree | 96940c499e464308859f4c25ee8da18b1a594835 /tests/unused-non-trivial-variable | |
parent | e847520dcf734c384aa6607317133faa1d73eb86 (diff) |
unused-non-trivial-variable: Add user blacklist and whitelist
You can now use CLAZY_UNUSED_NON_TRIVIAL_VARIABLE_WHITELIST to
set a comma separated list of user types which you want to warn on.
Conversly, if you disabled the whitelist via export CLAZY_EXTRA_OPTIONS=unused-non-trivial-variable-no-whitelist
then you'll want a blacklist, that's the env variable CLAZY_UNUSED_NON_TRIVIAL_VARIABLE_BLACKLIST, which also
accepts comma separated list.
BUG: 388979
Diffstat (limited to 'tests/unused-non-trivial-variable')
-rw-r--r-- | tests/unused-non-trivial-variable/config.json | 7 | ||||
-rw-r--r-- | tests/unused-non-trivial-variable/main.cpp | 13 | ||||
-rw-r--r-- | tests/unused-non-trivial-variable/main.cpp.expected | 1 | ||||
-rw-r--r-- | tests/unused-non-trivial-variable/no-whitelist.cpp | 11 |
4 files changed, 29 insertions, 3 deletions
diff --git a/tests/unused-non-trivial-variable/config.json b/tests/unused-non-trivial-variable/config.json index d9b88142..7066b559 100644 --- a/tests/unused-non-trivial-variable/config.json +++ b/tests/unused-non-trivial-variable/config.json @@ -1,11 +1,14 @@ { "tests" : [ { - "filename" : "main.cpp" + "filename" : "main.cpp", + "env" :{ "CLAZY_UNUSED_NON_TRIVIAL_VARIABLE_WHITELIST" : "MyWhitelistedType" } }, { "filename" : "no-whitelist.cpp", - "env" : { "CLAZY_EXTRA_OPTIONS" : "unused-non-trivial-variable-no-whitelist" } + "env" : { "CLAZY_EXTRA_OPTIONS" : "unused-non-trivial-variable-no-whitelist", + "CLAZY_UNUSED_NON_TRIVIAL_VARIABLE_BLACKLIST" : "MyBlacklistedType" + } } ] } diff --git a/tests/unused-non-trivial-variable/main.cpp b/tests/unused-non-trivial-variable/main.cpp index 12febdab..850c6b8d 100644 --- a/tests/unused-non-trivial-variable/main.cpp +++ b/tests/unused-non-trivial-variable/main.cpp @@ -30,7 +30,7 @@ struct MyRAII void testRAII() { - MyRAII m; // OK + MyRAII m; // OK, not whitelisted } void testFor() @@ -53,3 +53,14 @@ void test4() FOO(QRect) r2; // OK r2.setX(0); } + +struct MyWhitelistedType +{ + MyWhitelistedType(); + ~MyWhitelistedType(); +}; + +void testUserWhitelist() +{ + MyWhitelistedType m; // OK, whitelisted +} diff --git a/tests/unused-non-trivial-variable/main.cpp.expected b/tests/unused-non-trivial-variable/main.cpp.expected index f6400390..0177a663 100644 --- a/tests/unused-non-trivial-variable/main.cpp.expected +++ b/tests/unused-non-trivial-variable/main.cpp.expected @@ -4,3 +4,4 @@ unused-non-trivial-variable/main.cpp:49:5: warning: unused QList<int> [-Wclazy-u unused-non-trivial-variable/main.cpp:50:5: warning: unused QVector<int> [-Wclazy-unused-non-trivial-variable] unused-non-trivial-variable/main.cpp:51:5: warning: unused QByteArray [-Wclazy-unused-non-trivial-variable] unused-non-trivial-variable/main.cpp:52:5: warning: unused QRect [-Wclazy-unused-non-trivial-variable] +unused-non-trivial-variable/main.cpp:65:5: warning: unused MyWhitelistedType [-Wclazy-unused-non-trivial-variable] diff --git a/tests/unused-non-trivial-variable/no-whitelist.cpp b/tests/unused-non-trivial-variable/no-whitelist.cpp index 6a645690..9cb7ee18 100644 --- a/tests/unused-non-trivial-variable/no-whitelist.cpp +++ b/tests/unused-non-trivial-variable/no-whitelist.cpp @@ -60,3 +60,14 @@ void mutex() QMutexLocker ml(&m); // OK, is uninteresting QScopedPointer<QMutex> p(&m); // OK, is uninteresting } + +struct MyBlacklistedType +{ + MyBlacklistedType(); + ~MyBlacklistedType(); +}; + +void testUserWhitelist() +{ + MyBlacklistedType m; // OK, blacklisted +} |