aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2020-09-11 16:18:51 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2020-09-18 11:01:47 +0000
commitf244a7ea4c1babd6ad24f15004f9878a77f4e34b (patch)
tree5b8ac3ca459dae145cbf1f068b29956a8a2e35b7 /tests/auto
parentd4c7dee48a12a2004a7d144cac57c3f9b090f369 (diff)
CPlusPlus: Consider member initializations
... when checking usage types. Change-Id: Ic875f3bcae9cf045dbb062670e8cf941de533404 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/cplusplus/findusages/tst_findusages.cpp40
1 files changed, 27 insertions, 13 deletions
diff --git a/tests/auto/cplusplus/findusages/tst_findusages.cpp b/tests/auto/cplusplus/findusages/tst_findusages.cpp
index e45d579184..185d5cc554 100644
--- a/tests/auto/cplusplus/findusages/tst_findusages.cpp
+++ b/tests/auto/cplusplus/findusages/tst_findusages.cpp
@@ -2023,7 +2023,9 @@ void tst_FindUsages::writableRefs()
{
const QByteArray src = R"(
struct S {
+ S() : value2(value) {}
static int value;
+ int value2;
static void *p;
static const void *p2;
struct Nested {
@@ -2095,33 +2097,44 @@ int main()
Class * const structS = doc->globalSymbolAt(0)->asClass();
QVERIFY(structS);
QCOMPARE(structS->name()->identifier()->chars(), "S");
- QCOMPARE(structS->memberCount(), 7);
+ QCOMPARE(structS->memberCount(), 9);
- Declaration * const sv = structS->memberAt(0)->asDeclaration();
+ Declaration * const sv = structS->memberAt(1)->asDeclaration();
QVERIFY(sv);
QCOMPARE(sv->name()->identifier()->chars(), "value");
// Access to struct member
FindUsages find(src, doc, snapshot);
find(sv);
- QCOMPARE(find.usages().size(), 17);
- QCOMPARE(find.usages().at(0).type, Usage::Type::Declaration);
- QCOMPARE(find.usages().at(1).type, Usage::Type::WritableRef);
+ QCOMPARE(find.usages().size(), 18);
+ QCOMPARE(find.usages().at(0).type, Usage::Type::Read);
+ QCOMPARE(find.usages().at(1).type, Usage::Type::Declaration);
QCOMPARE(find.usages().at(2).type, Usage::Type::WritableRef);
QCOMPARE(find.usages().at(3).type, Usage::Type::WritableRef);
QCOMPARE(find.usages().at(4).type, Usage::Type::WritableRef);
QCOMPARE(find.usages().at(5).type, Usage::Type::WritableRef);
- QCOMPARE(find.usages().at(6).type, Usage::Type::Read);
+ QCOMPARE(find.usages().at(6).type, Usage::Type::WritableRef);
QCOMPARE(find.usages().at(7).type, Usage::Type::Read);
- QCOMPARE(find.usages().at(8).type, Usage::Type::WritableRef);
+ QCOMPARE(find.usages().at(8).type, Usage::Type::Read);
QCOMPARE(find.usages().at(9).type, Usage::Type::WritableRef);
- QCOMPARE(find.usages().at(10).type, Usage::Type::Read);
- QCOMPARE(find.usages().at(11).type, Usage::Type::WritableRef);
- QCOMPARE(find.usages().at(12).type, Usage::Type::Read);
- QCOMPARE(find.usages().at(13).type, Usage::Type::WritableRef);
- QCOMPARE(find.usages().at(14).type, Usage::Type::Read);
+ QCOMPARE(find.usages().at(10).type, Usage::Type::WritableRef);
+ QCOMPARE(find.usages().at(11).type, Usage::Type::Read);
+ QCOMPARE(find.usages().at(12).type, Usage::Type::WritableRef);
+ QCOMPARE(find.usages().at(13).type, Usage::Type::Read);
+ QCOMPARE(find.usages().at(14).type, Usage::Type::WritableRef);
QCOMPARE(find.usages().at(15).type, Usage::Type::Read);
QCOMPARE(find.usages().at(16).type, Usage::Type::Read);
+ QCOMPARE(find.usages().at(17).type, Usage::Type::Read);
+
+ Declaration * const sv2 = structS->memberAt(2)->asDeclaration();
+ QVERIFY(sv2);
+ QCOMPARE(sv2->name()->identifier()->chars(), "value2");
+
+ // Member initialization in constructor
+ find(sv2);
+ QCOMPARE(find.usages().size(), 2);
+ QCOMPARE(find.usages().at(0).type, Usage::Type::Write);
+ QCOMPARE(find.usages().at(1).type, Usage::Type::Declaration);
Function * const main = doc->globalSymbolAt(6)->asFunction();
QVERIFY(main);
@@ -2193,11 +2206,12 @@ int main()
// Usages of struct type
find(structS);
- QCOMPARE(find.usages().size(), 4);
+ QCOMPARE(find.usages().size(), 5);
QCOMPARE(find.usages().at(0).type, Usage::Type::Declaration);
QCOMPARE(find.usages().at(1).type, Usage::Type::Other);
QCOMPARE(find.usages().at(2).type, Usage::Type::Other);
QCOMPARE(find.usages().at(3).type, Usage::Type::Other);
+ QCOMPARE(find.usages().at(4).type, Usage::Type::Other);
}
QTEST_APPLESS_MAIN(tst_FindUsages)