aboutsummaryrefslogtreecommitdiffstats
path: root/tests/reserve-candidates
diff options
context:
space:
mode:
authorSergio Martins <sergio.martins@kdab.com>2015-08-28 19:49:00 +0100
committerSergio Martins <sergio.martins@kdab.com>2015-08-28 19:49:00 +0100
commit2167108e24d14c4a9b1e2a3a592951bc7ba6b751 (patch)
tree847cf69bc66071ce66555e720b09c861ea7b3f38 /tests/reserve-candidates
parent4c74cf9ff9beca991a01dd99c926cb8c9b195d30 (diff)
reserve-candidates: Widen the criteria to include some member variables
If they are appended inside the CTOR or DTOR it's fine because those methods are only called once, so no risk of performing worse then the built-in exponential growth in the case of appends happening in a method that's being called in a loop somewhere.
Diffstat (limited to 'tests/reserve-candidates')
-rw-r--r--tests/reserve-candidates/main.cpp37
-rw-r--r--tests/reserve-candidates/test.expected2
2 files changed, 39 insertions, 0 deletions
diff --git a/tests/reserve-candidates/main.cpp b/tests/reserve-candidates/main.cpp
index 653c1677..2d777bcc 100644
--- a/tests/reserve-candidates/main.cpp
+++ b/tests/reserve-candidates/main.cpp
@@ -116,3 +116,40 @@ void test_misc()
v2 << i; // OK
}
}
+
+
+class B
+{
+public:
+ QVector<int> v;
+};
+
+
+class A
+{
+ A()
+ {
+ for (int i = 0; i < 10; ++i)
+ v << i; // Warning
+
+ for (int i = 0; i < 10; ++i)
+ b.v << i; // OK
+ }
+
+ ~A()
+ {
+ for (int i = 0; i < 10; ++i)
+ v << i; // Warning
+ }
+
+ void foo()
+ {
+ for (int i = 0; i < 10; ++i)
+ v << i; // OK
+ }
+
+public:
+ QVector<int> v;
+ B b;
+};
+
diff --git a/tests/reserve-candidates/test.expected b/tests/reserve-candidates/test.expected
index 63d6dc5b..0e7512b6 100644
--- a/tests/reserve-candidates/test.expected
+++ b/tests/reserve-candidates/test.expected
@@ -6,3 +6,5 @@ main.cpp:69:9: warning: Reserve candidate [-Wclazy-reserve-candidates]
main.cpp:73:9: warning: Reserve candidate [-Wclazy-reserve-candidates]
main.cpp:88:13: warning: Reserve candidate [-Wclazy-reserve-candidates]
main.cpp:109:9: warning: Reserve candidate [-Wclazy-reserve-candidates]
+main.cpp:133:13: warning: Reserve candidate [-Wclazy-reserve-candidates]
+main.cpp:142:13: warning: Reserve candidate [-Wclazy-reserve-candidates]