summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/test
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-07-22 09:54:45 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-07-25 10:04:06 +0200
commit8a843f7e98dfe6bfb04e91e5b16e3a1df18fbf58 (patch)
tree521d82ee0690adc18dd51f2124c57ed3efa72adc /compilerplugins/clang/test
parent0351bec874f7e83c437e485e8d61a41f32718e25 (diff)
loplugin:moveit
make the plugin more conservative, so we see less false+ (although we also miss some possibilities in the process) Change-Id: I91b1806271e7f802d7459834ab7bcc569047da3a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137342 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins/clang/test')
-rw-r--r--compilerplugins/clang/test/moveit.cxx36
1 files changed, 32 insertions, 4 deletions
diff --git a/compilerplugins/clang/test/moveit.cxx b/compilerplugins/clang/test/moveit.cxx
index 06424a6d9cb4..dfe64c42777e 100644
--- a/compilerplugins/clang/test/moveit.cxx
+++ b/compilerplugins/clang/test/moveit.cxx
@@ -16,23 +16,36 @@
struct Movable
{
std::shared_ptr<int> x;
+
+ void method1();
};
-namespace test1
+namespace test1a
{
struct F
{
// expected-note@+1 {{passing to this param [loplugin:moveit]}}
void call_by_value(Movable);
- // expected-note@+1 {{passing to this param [loplugin:moveit]}}
- F(Movable);
void foo()
{
- // expected-note@+2 {{local var declared here [loplugin:moveit]}}
// expected-note@+1 {{local var declared here [loplugin:moveit]}}
Movable m;
// expected-error@+1 {{can std::move this var into this param [loplugin:moveit]}}
call_by_value(m);
+ }
+};
+}
+
+namespace test1b
+{
+struct F
+{
+ // expected-note@+1 {{passing to this param [loplugin:moveit]}}
+ F(Movable);
+ void foo()
+ {
+ // expected-note@+1 {{local var declared here [loplugin:moveit]}}
+ Movable m;
// expected-error@+1 {{can std::move this var into this param [loplugin:moveit]}}
F a(m);
(void)a;
@@ -57,4 +70,19 @@ struct F
};
}
+// No error expected, because referencing after call
+namespace test3
+{
+struct F
+{
+ F(Movable);
+ void foo()
+ {
+ Movable m;
+ F a(m);
+ m.method1();
+ }
+};
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */