| 612 | } |
| 613 | |
| 614 | void 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 | |
| 652 | void TestDUChain::testVirtualMemberFunction() |
| 653 | { |
nothing calls this directly
no test coverage detected