| 1826 | } |
| 1827 | |
| 1828 | void TestDUChain::testIncludeExternC() |
| 1829 | { |
| 1830 | TestFile header(QStringLiteral("int foo() { return 42; }\n"), QStringLiteral("h")); |
| 1831 | // NOTE: header is _not_ explicitly being parsed, instead the impl job does that |
| 1832 | |
| 1833 | const auto code = R"( |
| 1834 | extern "C" { |
| 1835 | #include "%1" |
| 1836 | } |
| 1837 | int main() { return foo(); } |
| 1838 | )"; |
| 1839 | TestFile impl(QString::fromUtf8(code).arg(header.url().str()), QStringLiteral("cpp"), &header); |
| 1840 | impl.parse(TopDUContext::AllDeclarationsContextsAndUses); |
| 1841 | QVERIFY(impl.waitForParsed()); |
| 1842 | |
| 1843 | DUChainReadLocker lock; |
| 1844 | |
| 1845 | auto implCtx = impl.topContext(); |
| 1846 | QVERIFY(implCtx); |
| 1847 | QCOMPARE(implCtx->localDeclarations().size(), 1); |
| 1848 | |
| 1849 | auto headerCtx = DUChain::self()->chainForDocument(header.url()); |
| 1850 | QVERIFY(headerCtx); |
| 1851 | QCOMPARE(headerCtx->localDeclarations().size(), 1); |
| 1852 | Declaration* foo = headerCtx->localDeclarations().first(); |
| 1853 | QCOMPARE(foo->uses().size(), 1); |
| 1854 | QCOMPARE(foo->uses().begin().key(), impl.url()); |
| 1855 | QCOMPARE(foo->uses().begin()->size(), 1); |
| 1856 | QCOMPARE(foo->uses().begin()->first(), RangeInRevision(4, 28, 4, 31)); |
| 1857 | } |
| 1858 | |
| 1859 | void TestDUChain::testReparseUnchanged_data() |
| 1860 | { |
nothing calls this directly
no test coverage detected