diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-02-26 14:36:54 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-02-27 07:36:12 +0100 |
commit | 57ac2fcdda9fdc9f1c2840796c24783add08e38c (patch) | |
tree | 86108e78b03f294422fe5ec0472b62db244dee37 | |
parent | 7f2e5c9ad2ca1d4a57163d0375b1c03772ef5b0a (diff) |
loplugin:unusedfields fix read/write when dealing with r<<= and >>=
Change-Id: I103bcc2f21741d0a52a0bdf053fdbddf5a3e9ea0
Reviewed-on: https://gerrit.libreoffice.org/68387
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | compilerplugins/clang/test/unusedfields.cxx | 32 | ||||
-rw-r--r-- | compilerplugins/clang/unusedfields.cxx | 2 |
2 files changed, 26 insertions, 8 deletions
diff --git a/compilerplugins/clang/test/unusedfields.cxx b/compilerplugins/clang/test/unusedfields.cxx index d756272f792c..6b4c64623c52 100644 --- a/compilerplugins/clang/test/unusedfields.cxx +++ b/compilerplugins/clang/test/unusedfields.cxx @@ -30,13 +30,15 @@ struct Bar // expected-error@-5 {{read m_barfunctionpointer [loplugin:unusedfields]}} // expected-error@-6 {{read m_bar8 [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_bar9 [loplugin:unusedfields]}} +// expected-error@-8 {{read m_bar11 [loplugin:unusedfields]}} +// expected-error@-9 {{write m_bar1 [loplugin:unusedfields]}} +// expected-error@-10 {{write m_bar2 [loplugin:unusedfields]}} +// expected-error@-11 {{write m_bar3 [loplugin:unusedfields]}} +// expected-error@-12 {{write m_bar3b [loplugin:unusedfields]}} +// expected-error@-13 {{write m_bar4 [loplugin:unusedfields]}} +// expected-error@-14 {{write m_bar7 [loplugin:unusedfields]}} +// expected-error@-15 {{write m_bar9 [loplugin:unusedfields]}} +// expected-error@-16 {{write m_bar12 [loplugin:unusedfields]}} { int m_bar1; int m_bar2 = 1; @@ -51,6 +53,8 @@ struct Bar int m_barstream; sal_Int32 m_bar9; sal_Int32 m_bar10; + css::uno::Any m_bar11; + css::uno::Any m_bar12; // 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) {} @@ -104,6 +108,20 @@ struct Bar css::uno::Any any; any <<= m_bar10; } + + // check that we see reads of the LHS when calling operator>>= + void bar11() + { + int x; + m_bar11 >>= x; + } + + // check that we see writes of the LHS when calling operator<<= + void bar12() + { + int x; + m_bar12 <<= x; + } }; // check that we __dont__ see a read of m_barstream diff --git a/compilerplugins/clang/unusedfields.cxx b/compilerplugins/clang/unusedfields.cxx index 4f7a49648a10..a0796fe95547 100644 --- a/compilerplugins/clang/unusedfields.cxx +++ b/compilerplugins/clang/unusedfields.cxx @@ -594,7 +594,7 @@ void UnusedFields::checkIfReadFrom(const FieldDecl* fieldDecl, const Expr* membe const bool assignmentOp = op == OO_Equal || op == OO_StarEqual || op == OO_SlashEqual || op == OO_PercentEqual || op == OO_PlusEqual || op == OO_MinusEqual || - op == OO_LessLessEqual || op == OO_GreaterGreaterEqual || + op == OO_LessLessEqual || op == OO_AmpEqual || op == OO_CaretEqual || op == OO_PipeEqual; if (operatorCallExpr->getArg(0) == child && assignmentOp) |