MCPcopy Create free account
hub / github.com/KDE/kdevelop / testTypeDeductionInTemplateInstantiation

Method testTypeDeductionInTemplateInstantiation

plugins/clang/tests/test_duchain.cpp:614–650  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

612}
613
614void TestDUChain::testTypeDeductionInTemplateInstantiation()
615{
616 // see: http://clang-developers.42468.n3.nabble.com/RFC-missing-libclang-query-functions-features-td2504253.html
617 TestFile file(QStringLiteral("template<typename T> struct foo { T member; } foo<int> f; auto i = f.member;"), QStringLiteral("cpp"));
618 QVERIFY(file.parseAndWait());
619
620 DUChainReadLocker lock;
621
622 DUContext* ctx = file.topContext().data();
623 QVERIFY(ctx);
624 QCOMPARE(ctx->localDeclarations().size(), 3);
625 Declaration* decl = nullptr;
626
627 // check 'foo' declaration
628 decl = ctx->localDeclarations()[0];
629 QVERIFY(decl);
630 QCOMPARE(decl->identifier(), Identifier(u"foo< T >"));
631
632 // check type of 'member' inside declaration-scope
633 QCOMPARE(ctx->childContexts().size(), 1);
634 DUContext* fooCtx = ctx->childContexts().first();
635 QVERIFY(fooCtx);
636 // Should there really be two declarations?
637 QCOMPARE(fooCtx->localDeclarations().size(), 2);
638 decl = fooCtx->localDeclarations()[1];
639 QCOMPARE(decl->identifier(), Identifier(u"member"));
640
641 // check type of 'member' in definition of 'f'
642 decl = ctx->localDeclarations()[1];
643 QCOMPARE(decl->identifier(), Identifier(u"f"));
644 decl = ctx->localDeclarations()[2];
645 QCOMPARE(decl->identifier(), Identifier(u"i"));
646#if CINDEX_VERSION_MINOR < 31
647 QEXPECT_FAIL("", "No type deduction here unfortunately, missing API in Clang", Continue);
648#endif
649 QVERIFY(decl->type<IntegralType>());
650}
651
652void TestDUChain::testVirtualMemberFunction()
653{

Callers

nothing calls this directly

Calls 9

parseAndWaitMethod · 0.80
localDeclarationsMethod · 0.80
childContextsMethod · 0.80
IdentifierFunction · 0.50
dataMethod · 0.45
topContextMethod · 0.45
sizeMethod · 0.45
identifierMethod · 0.45
firstMethod · 0.45

Tested by

no test coverage detected