ClangCodeModel: Do not offer completion for inaccessible symbols

We should not offer to auto-complete e.g. private members from contexts
where they cannot legally be accessed. This is also consistent with the
existing behavior of not offering non-const members on const objects.

Fixes: QTCREATORBUG-1984
Change-Id: Ic58c1ba2dc0b8023299feebc20bec4f2a5a6ea38
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Christian Kandeler
2020-06-04 17:15:10 +02:00
parent df703b8a5a
commit ca3ad20e64
7 changed files with 77 additions and 0 deletions

View File

@@ -552,6 +552,30 @@ void ClangCodeCompletionTest::testCompleteMembers()
QVERIFY(!hasSnippet(t.proposal, "class")); // Snippet
}
void ClangCodeCompletionTest::testCompleteMembersFromInside()
{
ProjectLessCompletionTest t("membercompletion-inside.cpp");
QVERIFY(hasItem(t.proposal, "publicFunc"));
QVERIFY(hasItem(t.proposal, "privateFunc"));
}
void ClangCodeCompletionTest::testCompleteMembersFromOutside()
{
ProjectLessCompletionTest t("membercompletion-outside.cpp");
QVERIFY(hasItem(t.proposal, "publicFunc"));
QVERIFY(!hasItem(t.proposal, "privateFunc"));
}
void ClangCodeCompletionTest::testCompleteMembersFromFriend()
{
ProjectLessCompletionTest t("membercompletion-friend.cpp");
QVERIFY(hasItem(t.proposal, "publicFunc"));
QVERIFY(hasItem(t.proposal, "privateFunc"));
}
void ClangCodeCompletionTest::testCompleteFunctions()
{
ProjectLessCompletionTest t("functionCompletion.cpp");