summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/test/unusedfields.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-09-18 09:43:18 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-09-18 09:45:15 +0200
commit1ff0f0ba29cc14c265fd74c49710a079e67ee943 (patch)
tree1d888efb9fc5b88d021216a297dd4d251e5c0932 /compilerplugins/clang/test/unusedfields.cxx
parentafeff9102c2935139de4efd40fd2286dce396706 (diff)
improve unusedfields loplugin
(*) IsPassedByNonConst was completely wrong, not even sure why it worked before. (*) treat a field passed to operator>>= as being written to, but not read Change-Id: Id3a5f2f35222986fe5edba3f5a58215a1815d401
Diffstat (limited to 'compilerplugins/clang/test/unusedfields.cxx')
-rw-r--r--compilerplugins/clang/test/unusedfields.cxx33
1 files changed, 26 insertions, 7 deletions
diff --git a/compilerplugins/clang/test/unusedfields.cxx b/compilerplugins/clang/test/unusedfields.cxx
index ff1eee5ad94c..71489b018843 100644
--- a/compilerplugins/clang/test/unusedfields.cxx
+++ b/compilerplugins/clang/test/unusedfields.cxx
@@ -9,6 +9,7 @@
#include <vector>
#include <ostream>
+#include <com/sun/star/uno/Any.hxx>
struct Foo
// expected-error@-1 {{read m_foo1 [loplugin:unusedfields]}}
@@ -23,13 +24,15 @@ struct Bar
// expected-error@-4 {{read m_bar6 [loplugin:unusedfields]}}
// expected-error@-5 {{read m_barfunctionpointer [loplugin:unusedfields]}}
// expected-error@-6 {{read m_bar8 [loplugin:unusedfields]}}
-// expected-error@-7 {{write m_bar1 [loplugin:unusedfields]}}
-// expected-error@-8 {{write m_bar2 [loplugin:unusedfields]}}
-// expected-error@-9 {{write m_bar3 [loplugin:unusedfields]}}
-// expected-error@-10 {{write m_bar3b [loplugin:unusedfields]}}
-// expected-error@-11 {{write m_bar4 [loplugin:unusedfields]}}
-// expected-error@-12 {{write m_bar7 [loplugin:unusedfields]}}
-// expected-error@-13 {{write m_barfunctionpointer [loplugin:unusedfields]}}
+// expected-error@-7 {{read m_bar10 [loplugin:unusedfields]}}
+// expected-error@-8 {{write m_bar1 [loplugin:unusedfields]}}
+// expected-error@-9 {{write m_bar2 [loplugin:unusedfields]}}
+// expected-error@-10 {{write m_bar3 [loplugin:unusedfields]}}
+// expected-error@-11 {{write m_bar3b [loplugin:unusedfields]}}
+// expected-error@-12 {{write m_bar4 [loplugin:unusedfields]}}
+// expected-error@-13 {{write m_bar7 [loplugin:unusedfields]}}
+// expected-error@-14 {{write m_barfunctionpointer [loplugin:unusedfields]}}
+// expected-error@-15 {{write m_bar9 [loplugin:unusedfields]}}
{
int m_bar1;
int m_bar2 = 1;
@@ -42,6 +45,8 @@ struct Bar
int m_bar7[5];
int m_bar8;
int m_barstream;
+ int m_bar9;
+ int m_bar10;
// check that we see reads of fields like m_foo1 when referred to via constructor initializer
Bar(Foo const & foo) : m_bar1(foo.m_foo1) {}
@@ -81,6 +86,20 @@ struct Bar
char tmp[5];
return tmp[m_bar8];
}
+
+ // check that we don't see reads when calling operator>>=
+ void bar9()
+ {
+ css::uno::Any any;
+ any >>= m_bar9;
+ }
+
+ // check that we see don't see writes when calling operator<<=
+ void bar10()
+ {
+ css::uno::Any any;
+ any <<= m_bar10;
+ }
};
// check that we __dont__ see a read of m_barstream