diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-02-21 14:07:42 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-02-22 07:23:57 +0100 |
commit | 331b4603be47fe059095307b2b3e2c1d399b04f9 (patch) | |
tree | 89edb58ed42d9b25558a3651cac8a3234629ad96 /compilerplugins/clang | |
parent | 8ec0f90a287febe661c89e098be457c5d593ded3 (diff) |
loplugin:redundantcopy extend to Color
Change-Id: I224cc955d49ee100d328e0171da710f38068d2d4
Reviewed-on: https://gerrit.libreoffice.org/50114
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins/clang')
-rw-r--r-- | compilerplugins/clang/redundantcopy.cxx | 1 | ||||
-rw-r--r-- | compilerplugins/clang/test/redundantcopy.cxx | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/compilerplugins/clang/redundantcopy.cxx b/compilerplugins/clang/redundantcopy.cxx index 4466339095cc..bffe89014eeb 100644 --- a/compilerplugins/clang/redundantcopy.cxx +++ b/compilerplugins/clang/redundantcopy.cxx @@ -33,6 +33,7 @@ public: } auto tc = loplugin::TypeCheck(t1); if (!(tc.Class("OUString").Namespace("rtl").GlobalNamespace() + || tc.Class("Color").GlobalNamespace() || tc.Class("unique_ptr").StdNamespace())) { return true; diff --git a/compilerplugins/clang/test/redundantcopy.cxx b/compilerplugins/clang/test/redundantcopy.cxx index 24207a60be69..0e3e7f0377c2 100644 --- a/compilerplugins/clang/test/redundantcopy.cxx +++ b/compilerplugins/clang/test/redundantcopy.cxx @@ -12,6 +12,9 @@ #include <memory> #include "rtl/ustring.hxx" +#include "tools/color.hxx" + +void method1(OUString const &); int main() { OUString s; @@ -22,6 +25,16 @@ int main() { (void) T2(s); // expected-error {{redundant copy construction from 'rtl::OUString' to 'T2' (aka 'const rtl::OUString') [loplugin:redundantcopy]}} (void) std::unique_ptr<int>(std::unique_ptr<int>(new int{})); // expected-error {{redundant copy construction from 'std::unique_ptr<int>' to 'std::unique_ptr<int>' [loplugin:redundantcopy]}} + + OUString s1; + method1( OUString(s1) ); // expected-error {{redundant copy construction from 'rtl::OUString' to 'rtl::OUString' [loplugin:redundantcopy]}} + + OUString s2; + s2 = OUString(s1); // expected-error {{redundant copy construction from 'rtl::OUString' to 'rtl::OUString' [loplugin:redundantcopy]}} + + Color col1; + Color col2 = Color(col1); // expected-error {{redundant copy construction from 'Color' to 'Color' [loplugin:redundantcopy]}} + (void)col2; } /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |