diff options
author | Noel <noel.grandin@collabora.co.uk> | 2021-02-24 15:44:52 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-03-05 08:09:21 +0100 |
commit | 5146d482a20494069670496786a1ba3037e979ce (patch) | |
tree | e23716bfb1e1fada668dc3210163d234892803cf /compilerplugins/clang/test | |
parent | 8e49505fa7352023c252bf794ae84c9082d7264e (diff) |
loplugin:refcounting return objects properly
check that when we return ref-counted objects, we do so using
rtl::Reference, so that the object actually has a non-zero
ref count.
Change-Id: Ib3ffae0d2502f6d117550c82fde5449729c27324
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111487
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins/clang/test')
-rw-r--r-- | compilerplugins/clang/test/refcounting.cxx | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/compilerplugins/clang/test/refcounting.cxx b/compilerplugins/clang/test/refcounting.cxx index ca27ac0614a7..4c133023b0b8 100644 --- a/compilerplugins/clang/test/refcounting.cxx +++ b/compilerplugins/clang/test/refcounting.cxx @@ -18,6 +18,7 @@ namespace cppu { class OWeakObject { +public: void acquire(); void release(); }; @@ -83,4 +84,15 @@ void foo4() p = new UnoObject; } +UnoObject* foo5() +{ + // expected-error@+1 {{new object of cppu::OWeakObject subclass 'UnoObject' being returned via raw pointer, should be returned by via rtl::Reference [loplugin:refcounting]}} + return new UnoObject; +} +rtl::Reference<UnoObject> foo6() +{ + // no warning expected + return new UnoObject; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |