| 2726 | } |
| 2727 | |
| 2728 | void TestDUChain::testBitWidthUpdate() |
| 2729 | { |
| 2730 | #if CINDEX_VERSION_MINOR >= 16 |
| 2731 | TestFile file(QStringLiteral(R"( |
| 2732 | struct foo { int i:7; }; |
| 2733 | )"), |
| 2734 | QStringLiteral("cpp")); |
| 2735 | file.parse(TopDUContext::AllDeclarationsContextsAndUses); |
| 2736 | QVERIFY(file.waitForParsed(1000)); |
| 2737 | |
| 2738 | { |
| 2739 | DUChainReadLocker lock; |
| 2740 | const auto top = file.topContext(); |
| 2741 | QVERIFY(top); |
| 2742 | QVERIFY(top->problems().isEmpty()); |
| 2743 | QCOMPARE(top->localDeclarations().size(), 1); |
| 2744 | QCOMPARE(top->childContexts().size(), 1); |
| 2745 | |
| 2746 | const auto fooContext = top->childContexts().first(); |
| 2747 | QVERIFY(fooContext); |
| 2748 | QCOMPARE(fooContext->type(), DUContext::Class); |
| 2749 | QCOMPARE(fooContext->localDeclarations().size(), 1); |
| 2750 | QCOMPARE(fooContext->childContexts().size(), 0); |
| 2751 | |
| 2752 | const auto varI = dynamic_cast<ClassMemberDeclaration *>(fooContext->localDeclarations().at(0)); |
| 2753 | QCOMPARE(varI->bitWidth(), 7); |
| 2754 | } |
| 2755 | |
| 2756 | file.setFileContents(QStringLiteral(R"( |
| 2757 | struct foo { int i; }; |
| 2758 | )")); |
| 2759 | file.parse(TopDUContext::AllDeclarationsContextsAndUses | TopDUContext::ForceUpdate); |
| 2760 | QVERIFY(file.waitForParsed(1000)); |
| 2761 | |
| 2762 | { |
| 2763 | DUChainReadLocker lock; |
| 2764 | const auto top = file.topContext(); |
| 2765 | QVERIFY(top); |
| 2766 | QVERIFY(top->problems().isEmpty()); |
| 2767 | QCOMPARE(top->localDeclarations().size(), 1); |
| 2768 | QCOMPARE(top->childContexts().size(), 1); |
| 2769 | |
| 2770 | const auto fooContext = top->childContexts().first(); |
| 2771 | QVERIFY(fooContext); |
| 2772 | QCOMPARE(fooContext->type(), DUContext::Class); |
| 2773 | QCOMPARE(fooContext->localDeclarations().size(), 1); |
| 2774 | QCOMPARE(fooContext->childContexts().size(), 0); |
| 2775 | |
| 2776 | const auto varI = dynamic_cast<ClassMemberDeclaration *>(fooContext->localDeclarations().at(0)); |
| 2777 | QCOMPARE(varI->bitWidth(), ClassMemberDeclaration::NotABitField); |
| 2778 | } |
| 2779 | #endif |
| 2780 | } |
| 2781 | |
| 2782 | #include "moc_test_duchain.cpp" |
nothing calls this directly
no test coverage detected