forked from qt-creator/qt-creator
CPlusPlus: Correctly categorize post-increment and -decrement accesses
Change-Id: Id21c13ea58f6747c226d91aff2b00c3409faa880 Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
@@ -375,6 +375,8 @@ Usage::Type FindUsages::getType(int line, int column, int tokenIndex)
|
|||||||
return Usage::Type::Read;
|
return Usage::Type::Read;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (const auto postIncrDecrOp = (*it)->asPostIncrDecr())
|
||||||
|
return checkPotentialWrite(Usage::Type::Write, it + 1);
|
||||||
if (const auto declaratorId = (*it)->asDeclaratorId()) {
|
if (const auto declaratorId = (*it)->asDeclaratorId()) {
|
||||||
// We don't want to classify constructors and destructors as declarations
|
// We don't want to classify constructors and destructors as declarations
|
||||||
// when listing class usages.
|
// when listing class usages.
|
||||||
|
@@ -2086,6 +2086,8 @@ int main()
|
|||||||
}
|
}
|
||||||
if (S::value) {}
|
if (S::value) {}
|
||||||
if (S::value = 0) {}
|
if (S::value = 0) {}
|
||||||
|
++S::value;
|
||||||
|
S::value--;
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
@@ -2111,7 +2113,7 @@ int main()
|
|||||||
// Access to struct member
|
// Access to struct member
|
||||||
FindUsages find(src, doc, snapshot);
|
FindUsages find(src, doc, snapshot);
|
||||||
find(sv);
|
find(sv);
|
||||||
QCOMPARE(find.usages().size(), 23);
|
QCOMPARE(find.usages().size(), 25);
|
||||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Read);
|
QCOMPARE(find.usages().at(0).type, Usage::Type::Read);
|
||||||
QCOMPARE(find.usages().at(1).type, Usage::Type::Declaration);
|
QCOMPARE(find.usages().at(1).type, Usage::Type::Declaration);
|
||||||
QCOMPARE(find.usages().at(2).type, Usage::Type::WritableRef);
|
QCOMPARE(find.usages().at(2).type, Usage::Type::WritableRef);
|
||||||
@@ -2135,6 +2137,8 @@ int main()
|
|||||||
QCOMPARE(find.usages().at(20).type, Usage::Type::Write);
|
QCOMPARE(find.usages().at(20).type, Usage::Type::Write);
|
||||||
QCOMPARE(find.usages().at(21).type, Usage::Type::Read);
|
QCOMPARE(find.usages().at(21).type, Usage::Type::Read);
|
||||||
QCOMPARE(find.usages().at(22).type, Usage::Type::Write);
|
QCOMPARE(find.usages().at(22).type, Usage::Type::Write);
|
||||||
|
QCOMPARE(find.usages().at(23).type, Usage::Type::Write);
|
||||||
|
QCOMPARE(find.usages().at(24).type, Usage::Type::Write);
|
||||||
|
|
||||||
Declaration * const sv2 = structS->memberAt(2)->asDeclaration();
|
Declaration * const sv2 = structS->memberAt(2)->asDeclaration();
|
||||||
QVERIFY(sv2);
|
QVERIFY(sv2);
|
||||||
@@ -2217,7 +2221,7 @@ int main()
|
|||||||
|
|
||||||
// Usages of struct type
|
// Usages of struct type
|
||||||
find(structS);
|
find(structS);
|
||||||
QCOMPARE(find.usages().size(), 10);
|
QCOMPARE(find.usages().size(), 12);
|
||||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Declaration);
|
QCOMPARE(find.usages().at(0).type, Usage::Type::Declaration);
|
||||||
QCOMPARE(find.usages().at(1).type, Usage::Type::Other);
|
QCOMPARE(find.usages().at(1).type, Usage::Type::Other);
|
||||||
QCOMPARE(find.usages().at(2).type, Usage::Type::Other);
|
QCOMPARE(find.usages().at(2).type, Usage::Type::Other);
|
||||||
@@ -2231,6 +2235,8 @@ int main()
|
|||||||
QCOMPARE(find.usages().at(7).type, Usage::Type::Write);
|
QCOMPARE(find.usages().at(7).type, Usage::Type::Write);
|
||||||
QCOMPARE(find.usages().at(8).type, Usage::Type::Read);
|
QCOMPARE(find.usages().at(8).type, Usage::Type::Read);
|
||||||
QCOMPARE(find.usages().at(9).type, Usage::Type::Write);
|
QCOMPARE(find.usages().at(9).type, Usage::Type::Write);
|
||||||
|
QCOMPARE(find.usages().at(10).type, Usage::Type::Write);
|
||||||
|
QCOMPARE(find.usages().at(11).type, Usage::Type::Write);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTEST_APPLESS_MAIN(tst_FindUsages)
|
QTEST_APPLESS_MAIN(tst_FindUsages)
|
||||||
|
Reference in New Issue
Block a user