forked from qt-creator/qt-creator
C++: fix findusage for member of typedefed anonymous struct
Task-number: QTCREATORBUG-11859
Task-number: QTCREATORBUG-11860
Change-Id: I7484b3b88daefbb3c76bb86a9b573e8291072872
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
(cherry picked from commit 5416557a0b)
Reviewed-by: Przemyslaw Gorszkowski <pgorszkowski@gmail.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
b455518c38
commit
df5d9f99fb
@@ -104,6 +104,7 @@ private Q_SLOTS:
|
||||
void templateFunctionParameters();
|
||||
|
||||
void anonymousClass_QTCREATORBUG8963();
|
||||
void anonymousClass_QTCREATORBUG11859();
|
||||
void using_insideGlobalNamespace();
|
||||
void using_insideNamespace();
|
||||
void using_insideFunction();
|
||||
@@ -562,6 +563,49 @@ void tst_FindUsages::anonymousClass_QTCREATORBUG8963()
|
||||
QCOMPARE(findUsages.usages().size(), 2);
|
||||
}
|
||||
|
||||
void tst_FindUsages::anonymousClass_QTCREATORBUG11859()
|
||||
{
|
||||
const QByteArray src =
|
||||
"struct Foo {\n"
|
||||
"};\n"
|
||||
"typedef struct {\n"
|
||||
" int Foo;\n"
|
||||
"} Struct;\n"
|
||||
"void foo()\n"
|
||||
"{\n"
|
||||
" Struct s;\n"
|
||||
" s.Foo;\n"
|
||||
"}\n"
|
||||
;
|
||||
|
||||
Document::Ptr doc = Document::create("anonymousClass_QTCREATORBUG11859");
|
||||
doc->setUtf8Source(src);
|
||||
doc->parse();
|
||||
doc->check();
|
||||
|
||||
QVERIFY(doc->diagnosticMessages().isEmpty());
|
||||
QCOMPARE(doc->globalSymbolCount(), 4U);
|
||||
|
||||
Snapshot snapshot;
|
||||
snapshot.insert(doc);
|
||||
|
||||
Class *fooAsStruct = doc->globalSymbolAt(0)->asClass();
|
||||
QVERIFY(fooAsStruct);
|
||||
Class *structSymbol = doc->globalSymbolAt(1)->asClass();
|
||||
QVERIFY(structSymbol);
|
||||
QCOMPARE(structSymbol->memberCount(), 1U);
|
||||
Declaration *fooAsMemberOfAnonymousStruct = structSymbol->memberAt(0)->asDeclaration();
|
||||
QVERIFY(fooAsMemberOfAnonymousStruct);
|
||||
QCOMPARE(fooAsMemberOfAnonymousStruct->name()->identifier()->chars(), "Foo");
|
||||
|
||||
FindUsages findUsages(src, doc, snapshot);
|
||||
findUsages(fooAsStruct);
|
||||
QCOMPARE(findUsages.references().size(), 1);
|
||||
|
||||
findUsages(fooAsMemberOfAnonymousStruct);
|
||||
QCOMPARE(findUsages.references().size(), 2);
|
||||
}
|
||||
|
||||
void tst_FindUsages::using_insideGlobalNamespace()
|
||||
{
|
||||
const QByteArray src =
|
||||
|
||||
Reference in New Issue
Block a user