loplugin:unusedfields fix more false +
deal with fields assigned to local variables, and some general cleanup Change-Id: I894c74a01e9e28935ecd84308c2e92b080afafc6
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <rtl/ustring.hxx>
|
||||
#include <vector>
|
||||
|
||||
struct Foo
|
||||
// expected-error@-1 {{read m_foo1 [loplugin:unusedfields]}}
|
||||
@@ -19,25 +19,37 @@ struct Bar
|
||||
// expected-error@-1 {{read m_bar2 [loplugin:unusedfields]}}
|
||||
// expected-error@-2 {{read m_bar3 [loplugin:unusedfields]}}
|
||||
// expected-error@-3 {{read m_bar4 [loplugin:unusedfields]}}
|
||||
// expected-error@-4 {{read m_functionpointer [loplugin:unusedfields]}}
|
||||
// expected-error@-4 {{read m_bar5 [loplugin:unusedfields]}}
|
||||
// expected-error@-5 {{read m_bar6 [loplugin:unusedfields]}}
|
||||
// expected-error@-6 {{read m_barfunctionpointer [loplugin:unusedfields]}}
|
||||
{
|
||||
int m_bar1;
|
||||
int m_bar2 = 1;
|
||||
int m_bar1;
|
||||
int m_bar2 = 1;
|
||||
int* m_bar3;
|
||||
int m_bar4;
|
||||
void (*m_functionpointer)(int&);
|
||||
int m_bar4;
|
||||
void (*m_barfunctionpointer)(int&);
|
||||
int m_bar5;
|
||||
std::vector<int> m_bar6;
|
||||
|
||||
//check that we see reads of fields when referred to via constructor initializer
|
||||
Bar(Foo const & foo) : m_bar1(foo.m_foo1) {}
|
||||
|
||||
int bar1() { return m_bar2; }
|
||||
// check that we DONT see reads here
|
||||
int bar2() { return m_bar2; }
|
||||
|
||||
// check that we see reads of fields when operated on via pointer de-ref
|
||||
void bar2() { *m_bar3 = 2; }
|
||||
// check that we DONT see reads here
|
||||
void bar3() { *m_bar3 = 2; }
|
||||
void bar3b() { m_bar3 = nullptr; }
|
||||
|
||||
// check that we see reads of field when passed to a function pointer
|
||||
// check that we see read of a field that is a function pointer
|
||||
void bar3() { m_functionpointer(m_bar4); }
|
||||
void bar4() { m_barfunctionpointer(m_bar4); }
|
||||
|
||||
// check that we see reads of a field when used in variable init
|
||||
void bar5() { int x = m_bar5; (void) x; }
|
||||
|
||||
// check that we see reads of a field when used in ranged-for
|
||||
void bar6() { for (auto i : m_bar6) { (void)i; } }
|
||||
};
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
||||
|
Reference in New Issue
Block a user