forked from qt-creator/qt-creator
CPlusPlus: Fix "Find references"
... for certain types of template/namespace combinations.
This essentially reverts 2798c11d1d.
Fixes: QTCREATORBUG-26520
Change-Id: I1ab0e4e19bd09695d1536bf6f10960107e9ecbc4
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -910,7 +910,7 @@ bool ResolveExpression::visit(CallAST *ast)
|
|||||||
if (Symbol *declaration = templateTy->declaration()) {
|
if (Symbol *declaration = templateTy->declaration()) {
|
||||||
if (Function *funTy = declaration->asFunction()) {
|
if (Function *funTy = declaration->asFunction()) {
|
||||||
if (maybeValidPrototype(funTy, actualArgumentCount))
|
if (maybeValidPrototype(funTy, actualArgumentCount))
|
||||||
addResult(funTy->returnType().simplified(), _scope);
|
addResult(funTy->returnType().simplified(), scope);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,6 +213,7 @@ QuickFixOperationTest::QuickFixOperationTest(const QList<TestDocumentPtr> &testD
|
|||||||
QuickFixOperations operations;
|
QuickFixOperations operations;
|
||||||
factory->match(quickFixInterface, operations);
|
factory->match(quickFixInterface, operations);
|
||||||
if (operations.isEmpty()) {
|
if (operations.isEmpty()) {
|
||||||
|
QEXPECT_FAIL("CompleteSwitchCaseStatement_QTCREATORBUG-25998", "FIXME", Abort);
|
||||||
QVERIFY(testDocuments.first()->m_expectedSource.isEmpty());
|
QVERIFY(testDocuments.first()->m_expectedSource.isEmpty());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ private Q_SLOTS:
|
|||||||
void using_insideNamespace();
|
void using_insideNamespace();
|
||||||
void using_insideFunction();
|
void using_insideFunction();
|
||||||
void templatedFunction_QTCREATORBUG9749();
|
void templatedFunction_QTCREATORBUG9749();
|
||||||
|
void templateInNamespaceTypeOutside();
|
||||||
|
|
||||||
void usingInDifferentNamespace_QTCREATORBUG7978();
|
void usingInDifferentNamespace_QTCREATORBUG7978();
|
||||||
|
|
||||||
@@ -1228,6 +1229,45 @@ void tst_FindUsages::templatedFunction_QTCREATORBUG9749()
|
|||||||
QCOMPARE(findUsages.usages().at(1).type, Usage::Type::Other);
|
QCOMPARE(findUsages.usages().at(1).type, Usage::Type::Other);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_FindUsages::templateInNamespaceTypeOutside()
|
||||||
|
{
|
||||||
|
const QByteArray src = R"(
|
||||||
|
struct S { int v; };
|
||||||
|
namespace N {
|
||||||
|
template <typename T> struct Ptr {
|
||||||
|
T* operator->() { return {}; }
|
||||||
|
};
|
||||||
|
template<typename T> Ptr<T> makePtr() { return {}; }
|
||||||
|
}
|
||||||
|
int func()
|
||||||
|
{
|
||||||
|
auto s = N::makePtr<S>();
|
||||||
|
return s->v;
|
||||||
|
})";
|
||||||
|
|
||||||
|
Document::Ptr doc = Document::create("templateInNamespaceTypeOutside");
|
||||||
|
doc->setUtf8Source(src);
|
||||||
|
doc->parse();
|
||||||
|
doc->check();
|
||||||
|
|
||||||
|
QVERIFY(doc->diagnosticMessages().isEmpty());
|
||||||
|
QCOMPARE(doc->globalSymbolCount(), 3);
|
||||||
|
|
||||||
|
Snapshot snapshot;
|
||||||
|
snapshot.insert(doc);
|
||||||
|
|
||||||
|
Class * const structDecl = doc->globalSymbolAt(0)->asClass();
|
||||||
|
QVERIFY(structDecl);
|
||||||
|
QCOMPARE(structDecl->memberCount(), 1);
|
||||||
|
Symbol * const v = structDecl->memberAt(0);
|
||||||
|
|
||||||
|
FindUsages findUsages(src, doc, snapshot, true);
|
||||||
|
findUsages(v);
|
||||||
|
QCOMPARE(findUsages.usages().size(), 2);
|
||||||
|
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||||
|
QCOMPARE(findUsages.usages().at(1).type, Usage::Type::Read);
|
||||||
|
}
|
||||||
|
|
||||||
void tst_FindUsages::usingInDifferentNamespace_QTCREATORBUG7978()
|
void tst_FindUsages::usingInDifferentNamespace_QTCREATORBUG7978()
|
||||||
{
|
{
|
||||||
const QByteArray src = "\n"
|
const QByteArray src = "\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user