summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/test/unusedfields.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'compilerplugins/clang/test/unusedfields.cxx')
-rw-r--r--compilerplugins/clang/test/unusedfields.cxx37
1 files changed, 37 insertions, 0 deletions
diff --git a/compilerplugins/clang/test/unusedfields.cxx b/compilerplugins/clang/test/unusedfields.cxx
index 2ec4ab815414..6efb17334e21 100644
--- a/compilerplugins/clang/test/unusedfields.cxx
+++ b/compilerplugins/clang/test/unusedfields.cxx
@@ -15,6 +15,8 @@
#include <ostream>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/uno/XInterface.hpp>
+#include <rtl/ref.hxx>
struct Foo
// expected-error@-1 {{read m_foo1 [loplugin:unusedfields]}}
@@ -258,6 +260,41 @@ namespace WriteOnlyAnalysis3
};
};
+// Check that writes to fields that are wrapped by conditional checks are ignored,
+// where those conditional checks use an 'operator bool'
+namespace ReadOnlyAnalysis5
+{
+ struct RefTarget
+ {
+ void acquire();
+ void release();
+ };
+ struct Foo1
+ // expected-error@-1 {{read m_field1 [loplugin:unusedfields]}}
+ // expected-error@-2 {{read m_field2 [loplugin:unusedfields]}}
+ // expected-error@-3 {{read m_field3xx [loplugin:unusedfields]}}
+ {
+ std::unique_ptr<int> m_field1;
+ rtl::Reference<RefTarget> m_field2;
+ css::uno::Reference<css::uno::XInterface> m_field3xx;
+ void f1(css::uno::Reference<css::uno::XInterface> a)
+ {
+ if (m_field1)
+ m_field1.reset(new int);
+ if (m_field1.get())
+ m_field1.reset(new int);
+ if (m_field2)
+ m_field2 = new RefTarget;
+ if (m_field2.get())
+ m_field2 = new RefTarget;
+ if (m_field3xx)
+ m_field3xx = a;
+ if (m_field3xx.get())
+ m_field3xx = a;
+ }
+ };
+};
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */