forked from qt-creator/qt-creator
CppTools: Categorize the delete operator as a write access
... in the "Find Usages" results. Change-Id: Ib399bf762c717b7d4439be26b9180574aefce7e3 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -348,6 +348,8 @@ Usage::Type FindUsages::getType(int line, int column, int tokenIndex)
|
|||||||
}
|
}
|
||||||
if ((*it)->asCall())
|
if ((*it)->asCall())
|
||||||
return checkPotentialWrite(getUsageTypeForCall(it), it + 1);
|
return checkPotentialWrite(getUsageTypeForCall(it), it + 1);
|
||||||
|
if ((*it)->asDeleteExpression())
|
||||||
|
return Usage::Type::Write;
|
||||||
if (const auto binExpr = (*it)->asBinaryExpression()) {
|
if (const auto binExpr = (*it)->asBinaryExpression()) {
|
||||||
if (binExpr->left_expression == *(it - 1) && isAssignment(binExpr->binary_op_token))
|
if (binExpr->left_expression == *(it - 1) && isAssignment(binExpr->binary_op_token))
|
||||||
return checkPotentialWrite(Usage::Type::Write, it + 1);
|
return checkPotentialWrite(Usage::Type::Write, it + 1);
|
||||||
|
@@ -2081,6 +2081,7 @@ int main()
|
|||||||
s.n.constFunc();
|
s.n.constFunc();
|
||||||
s.n.nonConstFunc();
|
s.n.nonConstFunc();
|
||||||
s.n.constFunc(s.value);
|
s.n.constFunc(s.value);
|
||||||
|
delete s.p;
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
@@ -2165,7 +2166,7 @@ int main()
|
|||||||
QVERIFY(varS);
|
QVERIFY(varS);
|
||||||
QCOMPARE(varS->name()->identifier()->chars(), "s");
|
QCOMPARE(varS->name()->identifier()->chars(), "s");
|
||||||
find(varS);
|
find(varS);
|
||||||
QCOMPARE(find.usages().size(), 30);
|
QCOMPARE(find.usages().size(), 31);
|
||||||
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::WritableRef);
|
QCOMPARE(find.usages().at(1).type, Usage::Type::WritableRef);
|
||||||
QCOMPARE(find.usages().at(2).type, Usage::Type::WritableRef);
|
QCOMPARE(find.usages().at(2).type, Usage::Type::WritableRef);
|
||||||
@@ -2184,6 +2185,7 @@ int main()
|
|||||||
QCOMPARE(find.usages().at(15).type, Usage::Type::WritableRef);
|
QCOMPARE(find.usages().at(15).type, Usage::Type::WritableRef);
|
||||||
QCOMPARE(find.usages().at(16).type, Usage::Type::Read);
|
QCOMPARE(find.usages().at(16).type, Usage::Type::Read);
|
||||||
QCOMPARE(find.usages().at(17).type, Usage::Type::Read);
|
QCOMPARE(find.usages().at(17).type, Usage::Type::Read);
|
||||||
|
QCOMPARE(find.usages().at(18).type, Usage::Type::Write);
|
||||||
|
|
||||||
// Direct access to struct variable
|
// Direct access to struct variable
|
||||||
QCOMPARE(find.usages().at(18).type, Usage::Type::Write);
|
QCOMPARE(find.usages().at(18).type, Usage::Type::Write);
|
||||||
|
Reference in New Issue
Block a user